babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990
  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. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. /**
  409. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1199. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1200. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1201. /** @hidden */
  1202. export class ShaderCodeTestNode extends ShaderCodeNode {
  1203. testExpression: ShaderDefineExpression;
  1204. isValid(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1210. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1211. /** @hidden */
  1212. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1213. define: string;
  1214. not: boolean;
  1215. constructor(define: string, not?: boolean);
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1236. leftOperand: ShaderDefineExpression;
  1237. rightOperand: ShaderDefineExpression;
  1238. isTrue(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module "babylonjs/Offline/IOfflineProvider" {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module "babylonjs/Misc/filesInputStore" {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module "babylonjs/Misc/retryStrategy" {
  1308. import { WebRequest } from "babylonjs/Misc/webRequest";
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module "babylonjs/Misc/baseError" {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/fileTools" {
  1332. import { WebRequest } from "babylonjs/Misc/webRequest";
  1333. import { Nullable } from "babylonjs/types";
  1334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1335. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1336. import { BaseError } from "babylonjs/Misc/baseError";
  1337. /** @ignore */
  1338. export class LoadFileError extends BaseError {
  1339. request?: WebRequest;
  1340. file?: File;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. * @param file defines the optional file
  1346. */
  1347. constructor(message: string, object?: WebRequest | File);
  1348. }
  1349. /** @ignore */
  1350. export class RequestFileError extends BaseError {
  1351. request: WebRequest;
  1352. /**
  1353. * Creates a new LoadFileError
  1354. * @param message defines the message of the error
  1355. * @param request defines the optional web request
  1356. */
  1357. constructor(message: string, request: WebRequest);
  1358. }
  1359. /** @ignore */
  1360. export class ReadFileError extends BaseError {
  1361. file: File;
  1362. /**
  1363. * Creates a new ReadFileError
  1364. * @param message defines the message of the error
  1365. * @param file defines the optional file
  1366. */
  1367. constructor(message: string, file: File);
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export class FileTools {
  1373. /**
  1374. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1375. */
  1376. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1377. /**
  1378. * Gets or sets the base URL to use to load assets
  1379. */
  1380. static BaseUrl: string;
  1381. /**
  1382. * Default behaviour for cors in the application.
  1383. * It can be a string if the expected behavior is identical in the entire app.
  1384. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1385. */
  1386. static CorsBehavior: string | ((url: string | string[]) => string);
  1387. /**
  1388. * Gets or sets a function used to pre-process url before using them to load assets
  1389. */
  1390. static PreprocessUrl: (url: string) => string;
  1391. /**
  1392. * Removes unwanted characters from an url
  1393. * @param url defines the url to clean
  1394. * @returns the cleaned url
  1395. */
  1396. private static _CleanUrl;
  1397. /**
  1398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1399. * @param url define the url we are trying
  1400. * @param element define the dom element where to configure the cors policy
  1401. */
  1402. static SetCorsBehavior(url: string | string[], element: {
  1403. crossOrigin: string | null;
  1404. }): void;
  1405. /**
  1406. * Loads an image as an HTMLImageElement.
  1407. * @param input url string, ArrayBuffer, or Blob to load
  1408. * @param onLoad callback called when the image successfully loads
  1409. * @param onError callback called when the image fails to load
  1410. * @param offlineProvider offline provider for caching
  1411. * @param mimeType optional mime type
  1412. * @returns the HTMLImageElement of the loaded image
  1413. */
  1414. 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>;
  1415. /**
  1416. * Reads a file from a File object
  1417. * @param file defines the file to load
  1418. * @param onSuccess defines the callback to call when data is loaded
  1419. * @param onProgress defines the callback to call during loading process
  1420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1421. * @param onError defines the callback to call when an error occurs
  1422. * @returns a file request object
  1423. */
  1424. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file from a url
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param offlineProvider defines the offline provider for caching
  1431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1432. * @param onError callback called when the file fails to load
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Loads a file
  1438. * @param url url to load
  1439. * @param onSuccess callback called when the file successfully loads
  1440. * @param onProgress callback called while file is loading (if the server supports this mode)
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @param onOpened callback called when the web request is opened
  1444. * @returns a file request object
  1445. */
  1446. 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;
  1447. /**
  1448. * Checks if the loaded document was accessed via `file:`-Protocol.
  1449. * @returns boolean
  1450. */
  1451. static IsFileURL(): boolean;
  1452. }
  1453. }
  1454. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1455. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1456. import { WebRequest } from "babylonjs/Misc/webRequest";
  1457. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1459. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1460. /** @hidden */
  1461. export class ShaderProcessor {
  1462. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1463. private static _ProcessPrecision;
  1464. private static _ExtractOperation;
  1465. private static _BuildSubExpression;
  1466. private static _BuildExpression;
  1467. private static _MoveCursorWithinIf;
  1468. private static _MoveCursor;
  1469. private static _EvaluatePreProcessors;
  1470. private static _PreparePreProcessors;
  1471. private static _ProcessShaderConversion;
  1472. private static _ProcessIncludes;
  1473. /**
  1474. * Loads a file from a url
  1475. * @param url url to load
  1476. * @param onSuccess callback called when the file successfully loads
  1477. * @param onProgress callback called while file is loading (if the server supports this mode)
  1478. * @param offlineProvider defines the offline provider for caching
  1479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1480. * @param onError callback called when the file fails to load
  1481. * @returns a file request object
  1482. * @hidden
  1483. */
  1484. 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;
  1485. }
  1486. }
  1487. declare module "babylonjs/Maths/math.like" {
  1488. import { float, int, DeepImmutable } from "babylonjs/types";
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IColor4Like {
  1493. r: float;
  1494. g: float;
  1495. b: float;
  1496. a: float;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor3Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IVector4Like {
  1510. x: float;
  1511. y: float;
  1512. z: float;
  1513. w: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector3Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector2Like {
  1527. x: float;
  1528. y: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IMatrixLike {
  1534. toArray(): DeepImmutable<Float32Array>;
  1535. updateFlag: int;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IViewportLike {
  1541. x: float;
  1542. y: float;
  1543. width: float;
  1544. height: float;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IPlaneLike {
  1550. normal: IVector3Like;
  1551. d: float;
  1552. normalize(): void;
  1553. }
  1554. }
  1555. declare module "babylonjs/Materials/iEffectFallbacks" {
  1556. import { Effect } from "babylonjs/Materials/effect";
  1557. /**
  1558. * Interface used to define common properties for effect fallbacks
  1559. */
  1560. export interface IEffectFallbacks {
  1561. /**
  1562. * Removes the defines that should be removed when falling back.
  1563. * @param currentDefines defines the current define statements for the shader.
  1564. * @param effect defines the current effect we try to compile
  1565. * @returns The resulting defines with defines of the current rank removed.
  1566. */
  1567. reduce(currentDefines: string, effect: Effect): string;
  1568. /**
  1569. * Removes the fallback from the bound mesh.
  1570. */
  1571. unBindMesh(): void;
  1572. /**
  1573. * Checks to see if more fallbacks are still availible.
  1574. */
  1575. hasMoreFallbacks: boolean;
  1576. }
  1577. }
  1578. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1579. /**
  1580. * Class used to evalaute queries containing `and` and `or` operators
  1581. */
  1582. export class AndOrNotEvaluator {
  1583. /**
  1584. * Evaluate a query
  1585. * @param query defines the query to evaluate
  1586. * @param evaluateCallback defines the callback used to filter result
  1587. * @returns true if the query matches
  1588. */
  1589. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1590. private static _HandleParenthesisContent;
  1591. private static _SimplifyNegation;
  1592. }
  1593. }
  1594. declare module "babylonjs/Misc/tags" {
  1595. /**
  1596. * Class used to store custom tags
  1597. */
  1598. export class Tags {
  1599. /**
  1600. * Adds support for tags on the given object
  1601. * @param obj defines the object to use
  1602. */
  1603. static EnableFor(obj: any): void;
  1604. /**
  1605. * Removes tags support
  1606. * @param obj defines the object to use
  1607. */
  1608. static DisableFor(obj: any): void;
  1609. /**
  1610. * Gets a boolean indicating if the given object has tags
  1611. * @param obj defines the object to use
  1612. * @returns a boolean
  1613. */
  1614. static HasTags(obj: any): boolean;
  1615. /**
  1616. * Gets the tags available on a given object
  1617. * @param obj defines the object to use
  1618. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1619. * @returns the tags
  1620. */
  1621. static GetTags(obj: any, asString?: boolean): any;
  1622. /**
  1623. * Adds tags to an object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1626. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1627. */
  1628. static AddTagsTo(obj: any, tagsString: string): void;
  1629. /**
  1630. * @hidden
  1631. */
  1632. static _AddTagTo(obj: any, tag: string): void;
  1633. /**
  1634. * Removes specific tags from a specific object
  1635. * @param obj defines the object to use
  1636. * @param tagsString defines the tags to remove
  1637. */
  1638. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1639. /**
  1640. * @hidden
  1641. */
  1642. static _RemoveTagFrom(obj: any, tag: string): void;
  1643. /**
  1644. * Defines if tags hosted on an object match a given query
  1645. * @param obj defines the object to use
  1646. * @param tagsQuery defines the tag query
  1647. * @returns a boolean
  1648. */
  1649. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1650. }
  1651. }
  1652. declare module "babylonjs/Maths/math.scalar" {
  1653. /**
  1654. * Scalar computation library
  1655. */
  1656. export class Scalar {
  1657. /**
  1658. * Two pi constants convenient for computation.
  1659. */
  1660. static TwoPi: number;
  1661. /**
  1662. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. * @param a number
  1664. * @param b number
  1665. * @param epsilon (default = 1.401298E-45)
  1666. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. */
  1668. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1669. /**
  1670. * Returns a string : the upper case translation of the number i to hexadecimal.
  1671. * @param i number
  1672. * @returns the upper case translation of the number i to hexadecimal.
  1673. */
  1674. static ToHex(i: number): string;
  1675. /**
  1676. * Returns -1 if value is negative and +1 is value is positive.
  1677. * @param value the value
  1678. * @returns the value itself if it's equal to zero.
  1679. */
  1680. static Sign(value: number): number;
  1681. /**
  1682. * Returns the value itself if it's between min and max.
  1683. * Returns min if the value is lower than min.
  1684. * Returns max if the value is greater than max.
  1685. * @param value the value to clmap
  1686. * @param min the min value to clamp to (default: 0)
  1687. * @param max the max value to clamp to (default: 1)
  1688. * @returns the clamped value
  1689. */
  1690. static Clamp(value: number, min?: number, max?: number): number;
  1691. /**
  1692. * the log2 of value.
  1693. * @param value the value to compute log2 of
  1694. * @returns the log2 of value.
  1695. */
  1696. static Log2(value: number): number;
  1697. /**
  1698. * Loops the value, so that it is never larger than length and never smaller than 0.
  1699. *
  1700. * This is similar to the modulo operator but it works with floating point numbers.
  1701. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1702. * With t = 5 and length = 2.5, the result would be 0.0.
  1703. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1704. * @param value the value
  1705. * @param length the length
  1706. * @returns the looped value
  1707. */
  1708. static Repeat(value: number, length: number): number;
  1709. /**
  1710. * Normalize the value between 0.0 and 1.0 using min and max values
  1711. * @param value value to normalize
  1712. * @param min max to normalize between
  1713. * @param max min to normalize between
  1714. * @returns the normalized value
  1715. */
  1716. static Normalize(value: number, min: number, max: number): number;
  1717. /**
  1718. * Denormalize the value from 0.0 and 1.0 using min and max values
  1719. * @param normalized value to denormalize
  1720. * @param min max to denormalize between
  1721. * @param max min to denormalize between
  1722. * @returns the denormalized value
  1723. */
  1724. static Denormalize(normalized: number, min: number, max: number): number;
  1725. /**
  1726. * Calculates the shortest difference between two given angles given in degrees.
  1727. * @param current current angle in degrees
  1728. * @param target target angle in degrees
  1729. * @returns the delta
  1730. */
  1731. static DeltaAngle(current: number, target: number): number;
  1732. /**
  1733. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1734. * @param tx value
  1735. * @param length length
  1736. * @returns The returned value will move back and forth between 0 and length
  1737. */
  1738. static PingPong(tx: number, length: number): number;
  1739. /**
  1740. * Interpolates between min and max with smoothing at the limits.
  1741. *
  1742. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1743. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1744. * @param from from
  1745. * @param to to
  1746. * @param tx value
  1747. * @returns the smooth stepped value
  1748. */
  1749. static SmoothStep(from: number, to: number, tx: number): number;
  1750. /**
  1751. * Moves a value current towards target.
  1752. *
  1753. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1754. * Negative values of maxDelta pushes the value away from target.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting value
  1759. */
  1760. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1763. *
  1764. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1765. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1766. * @param current current value
  1767. * @param target target value
  1768. * @param maxDelta max distance to move
  1769. * @returns resulting angle
  1770. */
  1771. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1772. /**
  1773. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1774. * @param start start value
  1775. * @param end target value
  1776. * @param amount amount to lerp between
  1777. * @returns the lerped value
  1778. */
  1779. static Lerp(start: number, end: number, amount: number): number;
  1780. /**
  1781. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  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 LerpAngle(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1791. * @param a start value
  1792. * @param b target value
  1793. * @param value value between a and b
  1794. * @returns the inverseLerp value
  1795. */
  1796. static InverseLerp(a: number, b: number, value: number): number;
  1797. /**
  1798. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1799. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1800. * @param value1 spline value
  1801. * @param tangent1 spline value
  1802. * @param value2 spline value
  1803. * @param tangent2 spline value
  1804. * @param amount input value
  1805. * @returns hermite result
  1806. */
  1807. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1808. /**
  1809. * Returns a random float number between and min and max values
  1810. * @param min min value of random
  1811. * @param max max value of random
  1812. * @returns random value
  1813. */
  1814. static RandomRange(min: number, max: number): number;
  1815. /**
  1816. * This function returns percentage of a number in a given range.
  1817. *
  1818. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1819. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1820. * @param number to convert to percentage
  1821. * @param min min range
  1822. * @param max max range
  1823. * @returns the percentage
  1824. */
  1825. static RangeToPercent(number: number, min: number, max: number): number;
  1826. /**
  1827. * This function returns number that corresponds to the percentage in a given range.
  1828. *
  1829. * PercentToRange(0.34,0,100) will return 34.
  1830. * @param percent to convert to number
  1831. * @param min min range
  1832. * @param max max range
  1833. * @returns the number
  1834. */
  1835. static PercentToRange(percent: number, min: number, max: number): number;
  1836. /**
  1837. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1838. * @param angle The angle to normalize in radian.
  1839. * @return The converted angle.
  1840. */
  1841. static NormalizeRadians(angle: number): number;
  1842. }
  1843. }
  1844. declare module "babylonjs/Maths/math.constants" {
  1845. /**
  1846. * Constant used to convert a value to gamma space
  1847. * @ignorenaming
  1848. */
  1849. export const ToGammaSpace: number;
  1850. /**
  1851. * Constant used to convert a value to linear space
  1852. * @ignorenaming
  1853. */
  1854. export const ToLinearSpace = 2.2;
  1855. /**
  1856. * Constant used to define the minimal number value in Babylon.js
  1857. * @ignorenaming
  1858. */
  1859. let Epsilon: number;
  1860. export { Epsilon };
  1861. }
  1862. declare module "babylonjs/Maths/math.viewport" {
  1863. /**
  1864. * Class used to represent a viewport on screen
  1865. */
  1866. export class Viewport {
  1867. /** viewport left coordinate */
  1868. x: number;
  1869. /** viewport top coordinate */
  1870. y: number;
  1871. /**viewport width */
  1872. width: number;
  1873. /** viewport height */
  1874. height: number;
  1875. /**
  1876. * Creates a Viewport object located at (x, y) and sized (width, height)
  1877. * @param x defines viewport left coordinate
  1878. * @param y defines viewport top coordinate
  1879. * @param width defines the viewport width
  1880. * @param height defines the viewport height
  1881. */
  1882. constructor(
  1883. /** viewport left coordinate */
  1884. x: number,
  1885. /** viewport top coordinate */
  1886. y: number,
  1887. /**viewport width */
  1888. width: number,
  1889. /** viewport height */
  1890. height: number);
  1891. /**
  1892. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @returns a new Viewport
  1896. */
  1897. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1898. /**
  1899. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @param ref defines the target viewport
  1903. * @returns the current viewport
  1904. */
  1905. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1906. /**
  1907. * Returns a new Viewport copied from the current one
  1908. * @returns a new Viewport
  1909. */
  1910. clone(): Viewport;
  1911. }
  1912. }
  1913. declare module "babylonjs/Misc/arrayTools" {
  1914. /**
  1915. * Class containing a set of static utilities functions for arrays.
  1916. */
  1917. export class ArrayTools {
  1918. /**
  1919. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1920. * @param size the number of element to construct and put in the array
  1921. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1922. * @returns a new array filled with new objects
  1923. */
  1924. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1925. }
  1926. }
  1927. declare module "babylonjs/Maths/math.vector" {
  1928. import { Viewport } from "babylonjs/Maths/math.viewport";
  1929. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1930. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1931. /**
  1932. * Class representing a vector containing 2 coordinates
  1933. */
  1934. export class Vector2 {
  1935. /** defines the first coordinate */
  1936. x: number;
  1937. /** defines the second coordinate */
  1938. y: number;
  1939. /**
  1940. * Creates a new Vector2 from the given x and y coordinates
  1941. * @param x defines the first coordinate
  1942. * @param y defines the second coordinate
  1943. */
  1944. constructor(
  1945. /** defines the first coordinate */
  1946. x?: number,
  1947. /** defines the second coordinate */
  1948. y?: number);
  1949. /**
  1950. * Gets a string with the Vector2 coordinates
  1951. * @returns a string with the Vector2 coordinates
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Gets class name
  1956. * @returns the string "Vector2"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Gets current vector hash code
  1961. * @returns the Vector2 hash code as a number
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1966. * @param array defines the source array
  1967. * @param index defines the offset in source array
  1968. * @returns the current Vector2
  1969. */
  1970. toArray(array: FloatArray, index?: number): Vector2;
  1971. /**
  1972. * Copy the current vector to an array
  1973. * @returns a new array with 2 elements: the Vector2 coordinates.
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1978. * @param source defines the source Vector2
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFromFloats(x: number, y: number): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. set(x: number, y: number): Vector2;
  1996. /**
  1997. * Add another vector with the current one
  1998. * @param otherVector defines the other vector
  1999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2000. */
  2001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @param result defines the target vector
  2006. * @returns the unmodified current Vector2
  2007. */
  2008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2009. /**
  2010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2011. * @param otherVector defines the other vector
  2012. * @returns the current updated Vector2
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2015. /**
  2016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2
  2019. */
  2020. addVector3(otherVector: Vector3): Vector2;
  2021. /**
  2022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2023. * @param otherVector defines the other vector
  2024. * @returns a new Vector2
  2025. */
  2026. subtract(otherVector: Vector2): Vector2;
  2027. /**
  2028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2029. * @param otherVector defines the other vector
  2030. * @param result defines the target vector
  2031. * @returns the unmodified current Vector2
  2032. */
  2033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2034. /**
  2035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns the current updated Vector2
  2038. */
  2039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2040. /**
  2041. * Multiplies in place the current Vector2 coordinates by the given ones
  2042. * @param otherVector defines the other vector
  2043. * @returns the current updated Vector2
  2044. */
  2045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2046. /**
  2047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @returns a new Vector2
  2050. */
  2051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2054. * @param otherVector defines the other vector
  2055. * @param result defines the target vector
  2056. * @returns the unmodified current Vector2
  2057. */
  2058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2059. /**
  2060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. * @returns a new Vector2
  2064. */
  2065. multiplyByFloats(x: number, y: number): Vector2;
  2066. /**
  2067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2068. * @param otherVector defines the other vector
  2069. * @returns a new Vector2
  2070. */
  2071. divide(otherVector: Vector2): Vector2;
  2072. /**
  2073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2074. * @param otherVector defines the other vector
  2075. * @param result defines the target vector
  2076. * @returns the unmodified current Vector2
  2077. */
  2078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2079. /**
  2080. * Divides the current Vector2 coordinates by the given ones
  2081. * @param otherVector defines the other vector
  2082. * @returns the current updated Vector2
  2083. */
  2084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2085. /**
  2086. * Gets a new Vector2 with current Vector2 negated coordinates
  2087. * @returns a new Vector2
  2088. */
  2089. negate(): Vector2;
  2090. /**
  2091. * Negate this vector in place
  2092. * @returns this
  2093. */
  2094. negateInPlace(): Vector2;
  2095. /**
  2096. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2097. * @param result defines the Vector3 object where to store the result
  2098. * @returns the current Vector2
  2099. */
  2100. negateToRef(result: Vector2): Vector2;
  2101. /**
  2102. * Multiply the Vector2 coordinates by scale
  2103. * @param scale defines the scaling factor
  2104. * @returns the current updated Vector2
  2105. */
  2106. scaleInPlace(scale: number): Vector2;
  2107. /**
  2108. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2109. * @param scale defines the scaling factor
  2110. * @returns a new Vector2
  2111. */
  2112. scale(scale: number): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Gets a boolean if two vectors are equals
  2129. * @param otherVector defines the other vector
  2130. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2131. */
  2132. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2133. /**
  2134. * Gets a boolean if two vectors are equals (using an epsilon value)
  2135. * @param otherVector defines the other vector
  2136. * @param epsilon defines the minimal distance to consider equality
  2137. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2138. */
  2139. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2140. /**
  2141. * Gets a new Vector2 from current Vector2 floored values
  2142. * @returns a new Vector2
  2143. */
  2144. floor(): Vector2;
  2145. /**
  2146. * Gets a new Vector2 from current Vector2 floored values
  2147. * @returns a new Vector2
  2148. */
  2149. fract(): Vector2;
  2150. /**
  2151. * Gets the length of the vector
  2152. * @returns the vector length (float)
  2153. */
  2154. length(): number;
  2155. /**
  2156. * Gets the vector squared length
  2157. * @returns the vector squared length (float)
  2158. */
  2159. lengthSquared(): number;
  2160. /**
  2161. * Normalize the vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. normalize(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 copied from the Vector2
  2167. * @returns a new Vector2
  2168. */
  2169. clone(): Vector2;
  2170. /**
  2171. * Gets a new Vector2(0, 0)
  2172. * @returns a new Vector2
  2173. */
  2174. static Zero(): Vector2;
  2175. /**
  2176. * Gets a new Vector2(1, 1)
  2177. * @returns a new Vector2
  2178. */
  2179. static One(): Vector2;
  2180. /**
  2181. * Gets a new Vector2 set from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @returns a new Vector2
  2185. */
  2186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2187. /**
  2188. * Sets "result" from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @param result defines the target vector
  2192. */
  2193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2194. /**
  2195. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2196. * @param value1 defines 1st point of control
  2197. * @param value2 defines 2nd point of control
  2198. * @param value3 defines 3rd point of control
  2199. * @param value4 defines 4th point of control
  2200. * @param amount defines the interpolation factor
  2201. * @returns a new Vector2
  2202. */
  2203. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2204. /**
  2205. * 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".
  2206. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2207. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2208. * @param value defines the value to clamp
  2209. * @param min defines the lower limit
  2210. * @param max defines the upper limit
  2211. * @returns a new Vector2
  2212. */
  2213. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2216. * @param value1 defines the 1st control point
  2217. * @param tangent1 defines the outgoing tangent
  2218. * @param value2 defines the 2nd control point
  2219. * @param tangent2 defines the incoming tangent
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2226. * @param start defines the start vector
  2227. * @param end defines the end vector
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Gets the dot product of the vector "left" and the vector "right"
  2234. * @param left defines first vector
  2235. * @param right defines second vector
  2236. * @returns the dot product (float)
  2237. */
  2238. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2239. /**
  2240. * Returns a new Vector2 equal to the normalized given vector
  2241. * @param vector defines the vector to normalize
  2242. * @returns a new Vector2
  2243. */
  2244. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @returns a new Vector2
  2264. */
  2265. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2266. /**
  2267. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @param result defines the target vector
  2271. */
  2272. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2273. /**
  2274. * Determines if a given vector is included in a triangle
  2275. * @param p defines the vector to test
  2276. * @param p0 defines 1st triangle point
  2277. * @param p1 defines 2nd triangle point
  2278. * @param p2 defines 3rd triangle point
  2279. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2280. */
  2281. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2282. /**
  2283. * Gets the distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the distance between vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Returns the squared distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the squared distance between vectors
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns a new Vector2
  2301. */
  2302. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2303. /**
  2304. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2305. * @param p defines the middle point
  2306. * @param segA defines one point of the segment
  2307. * @param segB defines the other point of the segment
  2308. * @returns the shortest distance
  2309. */
  2310. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2311. }
  2312. /**
  2313. * Class used to store (x,y,z) vector representation
  2314. * A Vector3 is the main object used in 3D geometry
  2315. * It can represent etiher the coordinates of a point the space, either a direction
  2316. * Reminder: js uses a left handed forward facing system
  2317. */
  2318. export class Vector3 {
  2319. /**
  2320. * Defines the first coordinates (on X axis)
  2321. */
  2322. x: number;
  2323. /**
  2324. * Defines the second coordinates (on Y axis)
  2325. */
  2326. y: number;
  2327. /**
  2328. * Defines the third coordinates (on Z axis)
  2329. */
  2330. z: number;
  2331. private static _UpReadOnly;
  2332. private static _ZeroReadOnly;
  2333. /**
  2334. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2335. * @param x defines the first coordinates (on X axis)
  2336. * @param y defines the second coordinates (on Y axis)
  2337. * @param z defines the third coordinates (on Z axis)
  2338. */
  2339. constructor(
  2340. /**
  2341. * Defines the first coordinates (on X axis)
  2342. */
  2343. x?: number,
  2344. /**
  2345. * Defines the second coordinates (on Y axis)
  2346. */
  2347. y?: number,
  2348. /**
  2349. * Defines the third coordinates (on Z axis)
  2350. */
  2351. z?: number);
  2352. /**
  2353. * Creates a string representation of the Vector3
  2354. * @returns a string with the Vector3 coordinates.
  2355. */
  2356. toString(): string;
  2357. /**
  2358. * Gets the class name
  2359. * @returns the string "Vector3"
  2360. */
  2361. getClassName(): string;
  2362. /**
  2363. * Creates the Vector3 hash code
  2364. * @returns a number which tends to be unique between Vector3 instances
  2365. */
  2366. getHashCode(): number;
  2367. /**
  2368. * Creates an array containing three elements : the coordinates of the Vector3
  2369. * @returns a new array of numbers
  2370. */
  2371. asArray(): number[];
  2372. /**
  2373. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2374. * @param array defines the destination array
  2375. * @param index defines the offset in the destination array
  2376. * @returns the current Vector3
  2377. */
  2378. toArray(array: FloatArray, index?: number): Vector3;
  2379. /**
  2380. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2381. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2382. */
  2383. toQuaternion(): Quaternion;
  2384. /**
  2385. * Adds the given vector to the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Adds the given coordinates to the current Vector3
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2400. * @param otherVector defines the second operand
  2401. * @returns the resulting Vector3
  2402. */
  2403. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2404. /**
  2405. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2406. * @param otherVector defines the second operand
  2407. * @param result defines the Vector3 object where to store the result
  2408. * @returns the current Vector3
  2409. */
  2410. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2411. /**
  2412. * Subtract the given vector from the current Vector3
  2413. * @param otherVector defines the second operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2417. /**
  2418. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2425. * @param otherVector defines the second operand
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @returns the resulting Vector3
  2436. */
  2437. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2438. /**
  2439. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2447. /**
  2448. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2449. * @returns a new Vector3
  2450. */
  2451. negate(): Vector3;
  2452. /**
  2453. * Negate this vector in place
  2454. * @returns this
  2455. */
  2456. negateInPlace(): Vector3;
  2457. /**
  2458. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. negateToRef(result: Vector3): Vector3;
  2463. /**
  2464. * Multiplies the Vector3 coordinates by the float "scale"
  2465. * @param scale defines the multiplier factor
  2466. * @returns the current updated Vector3
  2467. */
  2468. scaleInPlace(scale: number): Vector3;
  2469. /**
  2470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2471. * @param scale defines the multiplier factor
  2472. * @returns a new Vector3
  2473. */
  2474. scale(scale: number): Vector3;
  2475. /**
  2476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2477. * @param scale defines the multiplier factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. scaleToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the unmodified current Vector3
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2491. * @param otherVector defines the second operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2497. * @param otherVector defines the second operand
  2498. * @param epsilon defines the minimal distance to define values as equals
  2499. * @returns true if both vectors are distant less than epsilon
  2500. */
  2501. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 coordinates equals the given floats
  2504. * @param x defines the x coordinate of the operand
  2505. * @param y defines the y coordinate of the operand
  2506. * @param z defines the z coordinate of the operand
  2507. * @returns true if both vectors are equals
  2508. */
  2509. equalsToFloats(x: number, y: number, z: number): boolean;
  2510. /**
  2511. * Multiplies the current Vector3 coordinates by the given ones
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2516. /**
  2517. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2531. * @param x defines the x coordinate of the operand
  2532. * @param y defines the y coordinate of the operand
  2533. * @param z defines the z coordinate of the operand
  2534. * @returns the new Vector3
  2535. */
  2536. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2537. /**
  2538. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2539. * @param otherVector defines the second operand
  2540. * @returns the new Vector3
  2541. */
  2542. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones and stores the result in the given 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. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones.
  2552. * @param otherVector defines the second operand
  2553. * @returns the current updated Vector3
  2554. */
  2555. divideInPlace(otherVector: Vector3): Vector3;
  2556. /**
  2557. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2558. * @param other defines the second operand
  2559. * @returns the current updated Vector3
  2560. */
  2561. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2564. * @param other defines the second operand
  2565. * @returns the current updated Vector3
  2566. */
  2567. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2568. /**
  2569. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2570. * @param x defines the x coordinate of the operand
  2571. * @param y defines the y coordinate of the operand
  2572. * @param z defines the z coordinate of the operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2576. /**
  2577. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2586. * Check if is non uniform within a certain amount of decimal places to account for this
  2587. * @param epsilon the amount the values can differ
  2588. * @returns if the the vector is non uniform to a certain number of decimal places
  2589. */
  2590. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2591. /**
  2592. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2593. */
  2594. get isNonUniform(): boolean;
  2595. /**
  2596. * Gets a new Vector3 from current Vector3 floored values
  2597. * @returns a new Vector3
  2598. */
  2599. floor(): Vector3;
  2600. /**
  2601. * Gets a new Vector3 from current Vector3 floored values
  2602. * @returns a new Vector3
  2603. */
  2604. fract(): Vector3;
  2605. /**
  2606. * Gets the length of the Vector3
  2607. * @returns the length of the Vector3
  2608. */
  2609. length(): number;
  2610. /**
  2611. * Gets the squared length of the Vector3
  2612. * @returns squared length of the Vector3
  2613. */
  2614. lengthSquared(): number;
  2615. /**
  2616. * Normalize the current Vector3.
  2617. * Please note that this is an in place operation.
  2618. * @returns the current updated Vector3
  2619. */
  2620. normalize(): Vector3;
  2621. /**
  2622. * Reorders the x y z properties of the vector in place
  2623. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2624. * @returns the current updated vector
  2625. */
  2626. reorderInPlace(order: string): this;
  2627. /**
  2628. * Rotates the vector around 0,0,0 by a quaternion
  2629. * @param quaternion the rotation quaternion
  2630. * @param result vector to store the result
  2631. * @returns the resulting vector
  2632. */
  2633. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2634. /**
  2635. * Rotates a vector around a given point
  2636. * @param quaternion the rotation quaternion
  2637. * @param point the point to rotate around
  2638. * @param result vector to store the result
  2639. * @returns the resulting vector
  2640. */
  2641. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2642. /**
  2643. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2644. * The cross product is then orthogonal to both current and "other"
  2645. * @param other defines the right operand
  2646. * @returns the cross product
  2647. */
  2648. cross(other: Vector3): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 with the given input length.
  2651. * Please note that this is an in place operation.
  2652. * @param len the length of the vector
  2653. * @returns the current updated Vector3
  2654. */
  2655. normalizeFromLength(len: number): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 to a new vector
  2658. * @returns the new Vector3
  2659. */
  2660. normalizeToNew(): Vector3;
  2661. /**
  2662. * Normalize the current Vector3 to the reference
  2663. * @param reference define the Vector3 to update
  2664. * @returns the updated Vector3
  2665. */
  2666. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Creates a new Vector3 copied from the current Vector3
  2669. * @returns the new Vector3
  2670. */
  2671. clone(): Vector3;
  2672. /**
  2673. * Copies the given vector coordinates to the current Vector3 ones
  2674. * @param source defines the source Vector3
  2675. * @returns the current updated Vector3
  2676. */
  2677. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Copies the given floats to the current Vector3 coordinates
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns the current updated Vector3
  2684. */
  2685. copyFromFloats(x: number, y: number, z: number): Vector3;
  2686. /**
  2687. * Copies the given floats to the current Vector3 coordinates
  2688. * @param x defines the x coordinate of the operand
  2689. * @param y defines the y coordinate of the operand
  2690. * @param z defines the z coordinate of the operand
  2691. * @returns the current updated Vector3
  2692. */
  2693. set(x: number, y: number, z: number): Vector3;
  2694. /**
  2695. * Copies the given float to the current Vector3 coordinates
  2696. * @param v defines the x, y and z coordinates of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. setAll(v: number): Vector3;
  2700. /**
  2701. * Get the clip factor between two vectors
  2702. * @param vector0 defines the first operand
  2703. * @param vector1 defines the second operand
  2704. * @param axis defines the axis to use
  2705. * @param size defines the size along the axis
  2706. * @returns the clip factor
  2707. */
  2708. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2709. /**
  2710. * Get angle between two vectors
  2711. * @param vector0 angle between vector0 and vector1
  2712. * @param vector1 angle between vector0 and vector1
  2713. * @param normal direction of the normal
  2714. * @return the angle between vector0 and vector1
  2715. */
  2716. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. * @deprecated Please use FromArray instead.
  2730. */
  2731. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. * @deprecated Please use FromArrayToRef instead.
  2745. */
  2746. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2747. /**
  2748. * Sets the given vector "result" with the given floats.
  2749. * @param x defines the x coordinate of the source
  2750. * @param y defines the y coordinate of the source
  2751. * @param z defines the z coordinate of the source
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2757. * @returns a new empty Vector3
  2758. */
  2759. static Zero(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2762. * @returns a new unit Vector3
  2763. */
  2764. static One(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2767. * @returns a new up Vector3
  2768. */
  2769. static Up(): Vector3;
  2770. /**
  2771. * Gets a up Vector3 that must not be updated
  2772. */
  2773. static get UpReadOnly(): DeepImmutable<Vector3>;
  2774. /**
  2775. * Gets a zero Vector3 that must not be updated
  2776. */
  2777. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2780. * @returns a new down Vector3
  2781. */
  2782. static Down(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2785. * @returns a new forward Vector3
  2786. */
  2787. static Forward(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2790. * @returns a new forward Vector3
  2791. */
  2792. static Backward(): Vector3;
  2793. /**
  2794. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2795. * @returns a new right Vector3
  2796. */
  2797. static Right(): Vector3;
  2798. /**
  2799. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2800. * @returns a new left Vector3
  2801. */
  2802. static Left(): Vector3;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2805. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the transformed Vector3
  2809. */
  2810. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2813. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2821. * This method computes tranformed coordinates only, not transformed direction vectors
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2831. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2832. * @param vector defines the Vector3 to transform
  2833. * @param transformation defines the transformation matrix
  2834. * @returns the new Vector3
  2835. */
  2836. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2837. /**
  2838. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2839. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2840. * @param vector defines the Vector3 to transform
  2841. * @param transformation defines the transformation matrix
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2848. * @param x define the x coordinate of the source vector
  2849. * @param y define the y coordinate of the source vector
  2850. * @param z define the z coordinate of the source vector
  2851. * @param transformation defines the transformation matrix
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2857. * @param value1 defines the first control point
  2858. * @param value2 defines the second control point
  2859. * @param value3 defines the third control point
  2860. * @param value4 defines the fourth control point
  2861. * @param amount defines the amount on the spline to use
  2862. * @returns the new Vector3
  2863. */
  2864. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2865. /**
  2866. * 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"
  2867. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2868. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2869. * @param value defines the current value
  2870. * @param min defines the lower range value
  2871. * @param max defines the upper range value
  2872. * @returns the new Vector3
  2873. */
  2874. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2875. /**
  2876. * 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"
  2877. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2878. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2879. * @param value defines the current value
  2880. * @param min defines the lower range value
  2881. * @param max defines the upper range value
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2885. /**
  2886. * Checks if a given vector is inside a specific range
  2887. * @param v defines the vector to test
  2888. * @param min defines the minimum range
  2889. * @param max defines the maximum range
  2890. */
  2891. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2894. * @param value1 defines the first control point
  2895. * @param tangent1 defines the first tangent vector
  2896. * @param value2 defines the second control point
  2897. * @param tangent2 defines the second tangent vector
  2898. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2899. * @returns the new Vector3
  2900. */
  2901. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2902. /**
  2903. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2904. * @param start defines the start value
  2905. * @param end defines the end value
  2906. * @param amount max defines amount between both (between 0 and 1)
  2907. * @returns the new Vector3
  2908. */
  2909. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2910. /**
  2911. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2912. * @param start defines the start value
  2913. * @param end defines the end value
  2914. * @param amount max defines amount between both (between 0 and 1)
  2915. * @param result defines the Vector3 where to store the result
  2916. */
  2917. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2918. /**
  2919. * Returns the dot product (float) between the vectors "left" and "right"
  2920. * @param left defines the left operand
  2921. * @param right defines the right operand
  2922. * @returns the dot product
  2923. */
  2924. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2925. /**
  2926. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2927. * The cross product is then orthogonal to both "left" and "right"
  2928. * @param left defines the left operand
  2929. * @param right defines the right operand
  2930. * @returns the cross product
  2931. */
  2932. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2933. /**
  2934. * Sets the given vector "result" with the cross product of "left" and "right"
  2935. * The cross product is then orthogonal to both "left" and "right"
  2936. * @param left defines the left operand
  2937. * @param right defines the right operand
  2938. * @param result defines the Vector3 where to store the result
  2939. */
  2940. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2941. /**
  2942. * Returns a new Vector3 as the normalization of the given vector
  2943. * @param vector defines the Vector3 to normalize
  2944. * @returns the new Vector3
  2945. */
  2946. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" with the normalization of the given first vector
  2949. * @param vector defines the Vector3 to normalize
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2953. /**
  2954. * Project a Vector3 onto screen space
  2955. * @param vector defines the Vector3 to project
  2956. * @param world defines the world matrix to use
  2957. * @param transform defines the transform (view x projection) matrix to use
  2958. * @param viewport defines the screen viewport to use
  2959. * @returns the new Vector3
  2960. */
  2961. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2962. /** @hidden */
  2963. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param transform defines the transform (view x projection) matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @returns the new Vector3
  2983. */
  2984. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param source defines the screen space Vector3 to use
  2988. * @param viewportWidth defines the current width of the viewport
  2989. * @param viewportHeight defines the current height of the viewport
  2990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2991. * @param view defines the view matrix to use
  2992. * @param projection defines the projection matrix to use
  2993. * @param result defines the Vector3 where to store the result
  2994. */
  2995. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2996. /**
  2997. * Unproject from screen space to object space
  2998. * @param sourceX defines the screen space x coordinate to use
  2999. * @param sourceY defines the screen space y coordinate to use
  3000. * @param sourceZ defines the screen space z coordinate to use
  3001. * @param viewportWidth defines the current width of the viewport
  3002. * @param viewportHeight defines the current height of the viewport
  3003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3004. * @param view defines the view matrix to use
  3005. * @param projection defines the projection matrix to use
  3006. * @param result defines the Vector3 where to store the result
  3007. */
  3008. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3009. /**
  3010. * Gets the minimal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Gets the maximal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Returns the distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the distance
  3028. */
  3029. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns the squared distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the squared distance
  3035. */
  3036. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns a new Vector3 located at the center between "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the new Vector3
  3042. */
  3043. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3046. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3047. * to something in order to rotate it from its local system to the given target system
  3048. * Note: axis1, axis2 and axis3 are normalized during this operation
  3049. * @param axis1 defines the first axis
  3050. * @param axis2 defines the second axis
  3051. * @param axis3 defines the third axis
  3052. * @returns a new Vector3
  3053. */
  3054. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3057. * @param axis1 defines the first axis
  3058. * @param axis2 defines the second axis
  3059. * @param axis3 defines the third axis
  3060. * @param ref defines the Vector3 where to store the result
  3061. */
  3062. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3063. }
  3064. /**
  3065. * Vector4 class created for EulerAngle class conversion to Quaternion
  3066. */
  3067. export class Vector4 {
  3068. /** x value of the vector */
  3069. x: number;
  3070. /** y value of the vector */
  3071. y: number;
  3072. /** z value of the vector */
  3073. z: number;
  3074. /** w value of the vector */
  3075. w: number;
  3076. /**
  3077. * Creates a Vector4 object from the given floats.
  3078. * @param x x value of the vector
  3079. * @param y y value of the vector
  3080. * @param z z value of the vector
  3081. * @param w w value of the vector
  3082. */
  3083. constructor(
  3084. /** x value of the vector */
  3085. x: number,
  3086. /** y value of the vector */
  3087. y: number,
  3088. /** z value of the vector */
  3089. z: number,
  3090. /** w value of the vector */
  3091. w: number);
  3092. /**
  3093. * Returns the string with the Vector4 coordinates.
  3094. * @returns a string containing all the vector values
  3095. */
  3096. toString(): string;
  3097. /**
  3098. * Returns the string "Vector4".
  3099. * @returns "Vector4"
  3100. */
  3101. getClassName(): string;
  3102. /**
  3103. * Returns the Vector4 hash code.
  3104. * @returns a unique hash code
  3105. */
  3106. getHashCode(): number;
  3107. /**
  3108. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3109. * @returns the resulting array
  3110. */
  3111. asArray(): number[];
  3112. /**
  3113. * Populates the given array from the given index with the Vector4 coordinates.
  3114. * @param array array to populate
  3115. * @param index index of the array to start at (default: 0)
  3116. * @returns the Vector4.
  3117. */
  3118. toArray(array: FloatArray, index?: number): Vector4;
  3119. /**
  3120. * Adds the given vector to the current Vector4.
  3121. * @param otherVector the vector to add
  3122. * @returns the updated Vector4.
  3123. */
  3124. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3127. * @param otherVector the vector to add
  3128. * @returns the resulting vector
  3129. */
  3130. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3133. * @param otherVector the vector to add
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Subtract in place the given vector from the current Vector4.
  3140. * @param otherVector the vector to subtract
  3141. * @returns the updated Vector4.
  3142. */
  3143. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3146. * @param otherVector the vector to add
  3147. * @returns the new vector with the result
  3148. */
  3149. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3152. * @param otherVector the vector to subtract
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3159. */
  3160. /**
  3161. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3162. * @param x value to subtract
  3163. * @param y value to subtract
  3164. * @param z value to subtract
  3165. * @param w value to subtract
  3166. * @returns new vector containing the result
  3167. */
  3168. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3169. /**
  3170. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @param result the vector to store the result in
  3176. * @returns the current Vector4.
  3177. */
  3178. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3181. * @returns a new vector with the negated values
  3182. */
  3183. negate(): Vector4;
  3184. /**
  3185. * Negate this vector in place
  3186. * @returns this
  3187. */
  3188. negateInPlace(): Vector4;
  3189. /**
  3190. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3191. * @param result defines the Vector3 object where to store the result
  3192. * @returns the current Vector4
  3193. */
  3194. negateToRef(result: Vector4): Vector4;
  3195. /**
  3196. * Multiplies the current Vector4 coordinates by scale (float).
  3197. * @param scale the number to scale with
  3198. * @returns the updated Vector4.
  3199. */
  3200. scaleInPlace(scale: number): Vector4;
  3201. /**
  3202. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3203. * @param scale the number to scale with
  3204. * @returns a new vector with the result
  3205. */
  3206. scale(scale: number): Vector4;
  3207. /**
  3208. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3209. * @param scale the number to scale with
  3210. * @param result a vector to store the result in
  3211. * @returns the current Vector4.
  3212. */
  3213. scaleToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3216. * @param scale defines the scale factor
  3217. * @param result defines the Vector4 object where to store the result
  3218. * @returns the unmodified current Vector4
  3219. */
  3220. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3223. * @param otherVector the vector to compare against
  3224. * @returns true if they are equal
  3225. */
  3226. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3227. /**
  3228. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3229. * @param otherVector vector to compare against
  3230. * @param epsilon (Default: very small number)
  3231. * @returns true if they are equal
  3232. */
  3233. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3234. /**
  3235. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3236. * @param x x value to compare against
  3237. * @param y y value to compare against
  3238. * @param z z value to compare against
  3239. * @param w w value to compare against
  3240. * @returns true if equal
  3241. */
  3242. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3243. /**
  3244. * Multiplies in place the current Vector4 by the given one.
  3245. * @param otherVector vector to multiple with
  3246. * @returns the updated Vector4.
  3247. */
  3248. multiplyInPlace(otherVector: Vector4): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3251. * @param otherVector vector to multiple with
  3252. * @returns resulting new vector
  3253. */
  3254. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3257. * @param otherVector vector to multiple with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3264. * @param x x value multiply with
  3265. * @param y y value multiply with
  3266. * @param z z value multiply with
  3267. * @param w w value multiply with
  3268. * @returns resulting new vector
  3269. */
  3270. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3273. * @param otherVector vector to devide with
  3274. * @returns resulting new vector
  3275. */
  3276. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3279. * @param otherVector vector to devide with
  3280. * @param result vector to store the result
  3281. * @returns the current Vector4.
  3282. */
  3283. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3284. /**
  3285. * Divides the current Vector3 coordinates by the given ones.
  3286. * @param otherVector vector to devide with
  3287. * @returns the updated Vector3.
  3288. */
  3289. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3290. /**
  3291. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3292. * @param other defines the second operand
  3293. * @returns the current updated Vector4
  3294. */
  3295. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3298. * @param other defines the second operand
  3299. * @returns the current updated Vector4
  3300. */
  3301. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Gets a new Vector4 from current Vector4 floored values
  3304. * @returns a new Vector4
  3305. */
  3306. floor(): Vector4;
  3307. /**
  3308. * Gets a new Vector4 from current Vector3 floored values
  3309. * @returns a new Vector4
  3310. */
  3311. fract(): Vector4;
  3312. /**
  3313. * Returns the Vector4 length (float).
  3314. * @returns the length
  3315. */
  3316. length(): number;
  3317. /**
  3318. * Returns the Vector4 squared length (float).
  3319. * @returns the length squared
  3320. */
  3321. lengthSquared(): number;
  3322. /**
  3323. * Normalizes in place the Vector4.
  3324. * @returns the updated Vector4.
  3325. */
  3326. normalize(): Vector4;
  3327. /**
  3328. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3329. * @returns this converted to a new vector3
  3330. */
  3331. toVector3(): Vector3;
  3332. /**
  3333. * Returns a new Vector4 copied from the current one.
  3334. * @returns the new cloned vector
  3335. */
  3336. clone(): Vector4;
  3337. /**
  3338. * Updates the current Vector4 with the given one coordinates.
  3339. * @param source the source vector to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to copy from
  3346. * @param y float to copy from
  3347. * @param z float to copy from
  3348. * @param w float to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to set from
  3355. * @param y float to set from
  3356. * @param z float to set from
  3357. * @param w float to set from
  3358. * @returns the updated Vector4.
  3359. */
  3360. set(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Copies the given float to the current Vector3 coordinates
  3363. * @param v defines the x, y, z and w coordinates of the operand
  3364. * @returns the current updated Vector3
  3365. */
  3366. setAll(v: number): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @returns the new vector
  3372. */
  3373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3374. /**
  3375. * Updates the given vector "result" from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @param result the vector to store the result in
  3379. */
  3380. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given Float32Array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" coordinates from the given floats.
  3390. * @param x float to set from
  3391. * @param y float to set from
  3392. * @param z float to set from
  3393. * @param w float to set from
  3394. * @param result the vector to the floats in
  3395. */
  3396. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3397. /**
  3398. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3399. * @returns the new vector
  3400. */
  3401. static Zero(): Vector4;
  3402. /**
  3403. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3404. * @returns the new vector
  3405. */
  3406. static One(): Vector4;
  3407. /**
  3408. * Returns a new normalized Vector4 from the given one.
  3409. * @param vector the vector to normalize
  3410. * @returns the vector
  3411. */
  3412. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" from the normalization of the given one.
  3415. * @param vector the vector to normalize
  3416. * @param result the vector to store the result in
  3417. */
  3418. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3419. /**
  3420. * Returns a vector with the minimum values from the left and right vectors
  3421. * @param left left vector to minimize
  3422. * @param right right vector to minimize
  3423. * @returns a new vector with the minimum of the left and right vector values
  3424. */
  3425. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns a vector with the maximum values from the left and right vectors
  3428. * @param left left vector to maximize
  3429. * @param right right vector to maximize
  3430. * @returns a new vector with the maximum of the left and right vector values
  3431. */
  3432. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns the distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors
  3438. */
  3439. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors squared
  3445. */
  3446. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the center between
  3450. * @param value2 value to calulate the center between
  3451. * @return the center between the two vectors
  3452. */
  3453. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3456. * This methods computes transformed normalized direction vectors only.
  3457. * @param vector the vector to transform
  3458. * @param transformation the transformation matrix to apply
  3459. * @returns the new vector
  3460. */
  3461. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3462. /**
  3463. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3464. * This methods computes transformed normalized direction vectors only.
  3465. * @param vector the vector to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the result in
  3468. */
  3469. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3472. * This methods computes transformed normalized direction vectors only.
  3473. * @param x value to transform
  3474. * @param y value to transform
  3475. * @param z value to transform
  3476. * @param w value to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @param result the vector to store the results in
  3479. */
  3480. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3481. /**
  3482. * Creates a new Vector4 from a Vector3
  3483. * @param source defines the source data
  3484. * @param w defines the 4th component (default is 0)
  3485. * @returns a new Vector4
  3486. */
  3487. static FromVector3(source: Vector3, w?: number): Vector4;
  3488. }
  3489. /**
  3490. * Class used to store quaternion data
  3491. * @see https://en.wikipedia.org/wiki/Quaternion
  3492. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3493. */
  3494. export class Quaternion {
  3495. /** defines the first component (0 by default) */
  3496. x: number;
  3497. /** defines the second component (0 by default) */
  3498. y: number;
  3499. /** defines the third component (0 by default) */
  3500. z: number;
  3501. /** defines the fourth component (1.0 by default) */
  3502. w: number;
  3503. /**
  3504. * Creates a new Quaternion from the given floats
  3505. * @param x defines the first component (0 by default)
  3506. * @param y defines the second component (0 by default)
  3507. * @param z defines the third component (0 by default)
  3508. * @param w defines the fourth component (1.0 by default)
  3509. */
  3510. constructor(
  3511. /** defines the first component (0 by default) */
  3512. x?: number,
  3513. /** defines the second component (0 by default) */
  3514. y?: number,
  3515. /** defines the third component (0 by default) */
  3516. z?: number,
  3517. /** defines the fourth component (1.0 by default) */
  3518. w?: number);
  3519. /**
  3520. * Gets a string representation for the current quaternion
  3521. * @returns a string with the Quaternion coordinates
  3522. */
  3523. toString(): string;
  3524. /**
  3525. * Gets the class name of the quaternion
  3526. * @returns the string "Quaternion"
  3527. */
  3528. getClassName(): string;
  3529. /**
  3530. * Gets a hash code for this quaternion
  3531. * @returns the quaternion hash code
  3532. */
  3533. getHashCode(): number;
  3534. /**
  3535. * Copy the quaternion to an array
  3536. * @returns a new array populated with 4 elements from the quaternion coordinates
  3537. */
  3538. asArray(): number[];
  3539. /**
  3540. * Check if two quaternions are equals
  3541. * @param otherQuaternion defines the second operand
  3542. * @return true if the current quaternion and the given one coordinates are strictly equals
  3543. */
  3544. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3545. /**
  3546. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3547. * @param otherQuaternion defines the other quaternion
  3548. * @param epsilon defines the minimal distance to consider equality
  3549. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3550. */
  3551. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3552. /**
  3553. * Clone the current quaternion
  3554. * @returns a new quaternion copied from the current one
  3555. */
  3556. clone(): Quaternion;
  3557. /**
  3558. * Copy a quaternion to the current one
  3559. * @param other defines the other quaternion
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Updates the current quaternion with the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Updates the current quaternion from the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. set(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Adds two quaternions
  3583. * @param other defines the second operand
  3584. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3585. */
  3586. add(other: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Add a quaternion to the current one
  3589. * @param other defines the quaternion to add
  3590. * @returns the current quaternion
  3591. */
  3592. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3593. /**
  3594. * Subtract two quaternions
  3595. * @param other defines the second operand
  3596. * @returns a new quaternion as the subtraction result of the given one from the current one
  3597. */
  3598. subtract(other: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies the current quaternion by a scale factor
  3601. * @param value defines the scale factor
  3602. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3603. */
  3604. scale(value: number): Quaternion;
  3605. /**
  3606. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3607. * @param scale defines the scale factor
  3608. * @param result defines the Quaternion object where to store the result
  3609. * @returns the unmodified current quaternion
  3610. */
  3611. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3612. /**
  3613. * Multiplies in place the current quaternion by a scale factor
  3614. * @param value defines the scale factor
  3615. * @returns the current modified quaternion
  3616. */
  3617. scaleInPlace(value: number): Quaternion;
  3618. /**
  3619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3620. * @param scale defines the scale factor
  3621. * @param result defines the Quaternion object where to store the result
  3622. * @returns the unmodified current quaternion
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3625. /**
  3626. * Multiplies two quaternions
  3627. * @param q1 defines the second operand
  3628. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3629. */
  3630. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3631. /**
  3632. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @param result defines the target quaternion
  3635. * @returns the current quaternion
  3636. */
  3637. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3638. /**
  3639. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @returns the currentupdated quaternion
  3642. */
  3643. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3644. /**
  3645. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3646. * @param ref defines the target quaternion
  3647. * @returns the current quaternion
  3648. */
  3649. conjugateToRef(ref: Quaternion): Quaternion;
  3650. /**
  3651. * Conjugates in place (1-q) the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. conjugateInPlace(): Quaternion;
  3655. /**
  3656. * Conjugates in place (1-q) the current quaternion
  3657. * @returns a new quaternion
  3658. */
  3659. conjugate(): Quaternion;
  3660. /**
  3661. * Gets length of current quaternion
  3662. * @returns the quaternion length (float)
  3663. */
  3664. length(): number;
  3665. /**
  3666. * Normalize in place the current quaternion
  3667. * @returns the current updated quaternion
  3668. */
  3669. normalize(): Quaternion;
  3670. /**
  3671. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns a new Vector3 containing the Euler angles
  3674. */
  3675. toEulerAngles(order?: string): Vector3;
  3676. /**
  3677. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3678. * @param result defines the vector which will be filled with the Euler angles
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns the current unchanged quaternion
  3681. */
  3682. toEulerAnglesToRef(result: Vector3): Quaternion;
  3683. /**
  3684. * Updates the given rotation matrix with the current quaternion values
  3685. * @param result defines the target matrix
  3686. * @returns the current unchanged quaternion
  3687. */
  3688. toRotationMatrix(result: Matrix): Quaternion;
  3689. /**
  3690. * Updates the current quaternion from the given rotation matrix values
  3691. * @param matrix defines the source matrix
  3692. * @returns the current updated quaternion
  3693. */
  3694. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3695. /**
  3696. * Creates a new quaternion from a rotation matrix
  3697. * @param matrix defines the source matrix
  3698. * @returns a new quaternion created from the given rotation matrix values
  3699. */
  3700. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3701. /**
  3702. * Updates the given quaternion with the given rotation matrix values
  3703. * @param matrix defines the source matrix
  3704. * @param result defines the target quaternion
  3705. */
  3706. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3707. /**
  3708. * Returns the dot product (float) between the quaternions "left" and "right"
  3709. * @param left defines the left operand
  3710. * @param right defines the right operand
  3711. * @returns the dot product
  3712. */
  3713. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3714. /**
  3715. * Checks if the two quaternions are close to each other
  3716. * @param quat0 defines the first quaternion to check
  3717. * @param quat1 defines the second quaternion to check
  3718. * @returns true if the two quaternions are close to each other
  3719. */
  3720. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates an empty quaternion
  3723. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3724. */
  3725. static Zero(): Quaternion;
  3726. /**
  3727. * Inverse a given quaternion
  3728. * @param q defines the source quaternion
  3729. * @returns a new quaternion as the inverted current quaternion
  3730. */
  3731. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Inverse a given quaternion
  3734. * @param q defines the source quaternion
  3735. * @param result the quaternion the result will be stored in
  3736. * @returns the result quaternion
  3737. */
  3738. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates an identity quaternion
  3741. * @returns the identity quaternion
  3742. */
  3743. static Identity(): Quaternion;
  3744. /**
  3745. * Gets a boolean indicating if the given quaternion is identity
  3746. * @param quaternion defines the quaternion to check
  3747. * @returns true if the quaternion is identity
  3748. */
  3749. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3750. /**
  3751. * Creates a quaternion from a rotation around an axis
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3755. */
  3756. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3757. /**
  3758. * Creates a rotation around an axis and stores it into the given quaternion
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @param result defines the target quaternion
  3762. * @returns the target quaternion
  3763. */
  3764. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from data stored into an array
  3767. * @param array defines the data source
  3768. * @param offset defines the offset in the source array where the data starts
  3769. * @returns a new quaternion
  3770. */
  3771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3772. /**
  3773. * Updates the given quaternion "result" from the starting index of the given array.
  3774. * @param array the array to pull values from
  3775. * @param offset the offset into the array to start at
  3776. * @param result the quaternion to store the result in
  3777. */
  3778. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * 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)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * 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
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. 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;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. 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;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4415. /**
  4416. * 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"
  4417. * This function works in left handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * 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".
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * 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"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * 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".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * 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.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * 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)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @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
  4958. * @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
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. 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);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. _getVertexShaderCode(): string | null;
  7245. _getFragmentShaderCode(): string | null;
  7246. }
  7247. }
  7248. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7249. import { FloatArray, Nullable } from "babylonjs/types";
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. module "babylonjs/Engines/thinEngine" {
  7253. interface ThinEngine {
  7254. /**
  7255. * Create an uniform buffer
  7256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7257. * @param elements defines the content of the uniform buffer
  7258. * @returns the webGL uniform buffer
  7259. */
  7260. createUniformBuffer(elements: FloatArray): DataBuffer;
  7261. /**
  7262. * Create a dynamic uniform buffer
  7263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7264. * @param elements defines the content of the uniform buffer
  7265. * @returns the webGL uniform buffer
  7266. */
  7267. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7268. /**
  7269. * Update an existing uniform buffer
  7270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7271. * @param uniformBuffer defines the target uniform buffer
  7272. * @param elements defines the content to update
  7273. * @param offset defines the offset in the uniform buffer where update should start
  7274. * @param count defines the size of the data to update
  7275. */
  7276. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7277. /**
  7278. * Bind an uniform buffer to the current webGL context
  7279. * @param buffer defines the buffer to bind
  7280. */
  7281. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7282. /**
  7283. * Bind a buffer to the current webGL context at a given location
  7284. * @param buffer defines the buffer to bind
  7285. * @param location defines the index where to bind the buffer
  7286. */
  7287. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7288. /**
  7289. * Bind a specific block at a given index in a specific shader program
  7290. * @param pipelineContext defines the pipeline context to use
  7291. * @param blockName defines the block name
  7292. * @param index defines the index where to bind the block
  7293. */
  7294. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7295. }
  7296. }
  7297. }
  7298. declare module "babylonjs/Materials/uniformBuffer" {
  7299. import { Nullable, FloatArray } from "babylonjs/types";
  7300. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7301. import { Engine } from "babylonjs/Engines/engine";
  7302. import { Effect } from "babylonjs/Materials/effect";
  7303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7304. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7305. import { Color3 } from "babylonjs/Maths/math.color";
  7306. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7307. /**
  7308. * Uniform buffer objects.
  7309. *
  7310. * Handles blocks of uniform on the GPU.
  7311. *
  7312. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7313. *
  7314. * For more information, please refer to :
  7315. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7316. */
  7317. export class UniformBuffer {
  7318. private _engine;
  7319. private _buffer;
  7320. private _data;
  7321. private _bufferData;
  7322. private _dynamic?;
  7323. private _uniformLocations;
  7324. private _uniformSizes;
  7325. private _uniformLocationPointer;
  7326. private _needSync;
  7327. private _noUBO;
  7328. private _currentEffect;
  7329. /** @hidden */
  7330. _alreadyBound: boolean;
  7331. private static _MAX_UNIFORM_SIZE;
  7332. private static _tempBuffer;
  7333. /**
  7334. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7339. /**
  7340. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7345. /**
  7346. * Lambda to Update a single float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat: (name: string, x: number) => void;
  7351. /**
  7352. * Lambda to Update a vec2 of float in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7357. /**
  7358. * Lambda to Update a vec3 of float in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7363. /**
  7364. * Lambda to Update a vec4 of float in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7369. /**
  7370. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateMatrix: (name: string, mat: Matrix) => void;
  7375. /**
  7376. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateVector3: (name: string, vector: Vector3) => void;
  7381. /**
  7382. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateVector4: (name: string, vector: Vector4) => void;
  7387. /**
  7388. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7389. * This is dynamic to allow compat with webgl 1 and 2.
  7390. * You will need to pass the name of the uniform as well as the value.
  7391. */
  7392. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7393. /**
  7394. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7395. * This is dynamic to allow compat with webgl 1 and 2.
  7396. * You will need to pass the name of the uniform as well as the value.
  7397. */
  7398. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7399. /**
  7400. * Instantiates a new Uniform buffer objects.
  7401. *
  7402. * Handles blocks of uniform on the GPU.
  7403. *
  7404. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7405. *
  7406. * For more information, please refer to :
  7407. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7408. * @param engine Define the engine the buffer is associated with
  7409. * @param data Define the data contained in the buffer
  7410. * @param dynamic Define if the buffer is updatable
  7411. */
  7412. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7413. /**
  7414. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7415. * or just falling back on setUniformXXX calls.
  7416. */
  7417. get useUbo(): boolean;
  7418. /**
  7419. * Indicates if the WebGL underlying uniform buffer is in sync
  7420. * with the javascript cache data.
  7421. */
  7422. get isSync(): boolean;
  7423. /**
  7424. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7425. * Also, a dynamic UniformBuffer will disable cache verification and always
  7426. * update the underlying WebGL uniform buffer to the GPU.
  7427. * @returns if Dynamic, otherwise false
  7428. */
  7429. isDynamic(): boolean;
  7430. /**
  7431. * The data cache on JS side.
  7432. * @returns the underlying data as a float array
  7433. */
  7434. getData(): Float32Array;
  7435. /**
  7436. * The underlying WebGL Uniform buffer.
  7437. * @returns the webgl buffer
  7438. */
  7439. getBuffer(): Nullable<DataBuffer>;
  7440. /**
  7441. * std140 layout specifies how to align data within an UBO structure.
  7442. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7443. * for specs.
  7444. */
  7445. private _fillAlignment;
  7446. /**
  7447. * Adds an uniform in the buffer.
  7448. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7449. * for the layout to be correct !
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. * @param size Data size, or data directly.
  7452. */
  7453. addUniform(name: string, size: number | number[]): void;
  7454. /**
  7455. * Adds a Matrix 4x4 to the uniform buffer.
  7456. * @param name Name of the uniform, as used in the uniform block in the shader.
  7457. * @param mat A 4x4 matrix.
  7458. */
  7459. addMatrix(name: string, mat: Matrix): void;
  7460. /**
  7461. * Adds a vec2 to the uniform buffer.
  7462. * @param name Name of the uniform, as used in the uniform block in the shader.
  7463. * @param x Define the x component value of the vec2
  7464. * @param y Define the y component value of the vec2
  7465. */
  7466. addFloat2(name: string, x: number, y: number): void;
  7467. /**
  7468. * Adds a vec3 to the uniform buffer.
  7469. * @param name Name of the uniform, as used in the uniform block in the shader.
  7470. * @param x Define the x component value of the vec3
  7471. * @param y Define the y component value of the vec3
  7472. * @param z Define the z component value of the vec3
  7473. */
  7474. addFloat3(name: string, x: number, y: number, z: number): void;
  7475. /**
  7476. * Adds a vec3 to the uniform buffer.
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param color Define the vec3 from a Color
  7479. */
  7480. addColor3(name: string, color: Color3): void;
  7481. /**
  7482. * Adds a vec4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param color Define the rgb components from a Color
  7485. * @param alpha Define the a component of the vec4
  7486. */
  7487. addColor4(name: string, color: Color3, alpha: number): void;
  7488. /**
  7489. * Adds a vec3 to the uniform buffer.
  7490. * @param name Name of the uniform, as used in the uniform block in the shader.
  7491. * @param vector Define the vec3 components from a Vector
  7492. */
  7493. addVector3(name: string, vector: Vector3): void;
  7494. /**
  7495. * Adds a Matrix 3x3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. */
  7498. addMatrix3x3(name: string): void;
  7499. /**
  7500. * Adds a Matrix 2x2 to the uniform buffer.
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. */
  7503. addMatrix2x2(name: string): void;
  7504. /**
  7505. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7506. */
  7507. create(): void;
  7508. /** @hidden */
  7509. _rebuild(): void;
  7510. /**
  7511. * Updates the WebGL Uniform Buffer on the GPU.
  7512. * If the `dynamic` flag is set to true, no cache comparison is done.
  7513. * Otherwise, the buffer will be updated only if the cache differs.
  7514. */
  7515. update(): void;
  7516. /**
  7517. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7518. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7519. * @param data Define the flattened data
  7520. * @param size Define the size of the data.
  7521. */
  7522. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7523. private _valueCache;
  7524. private _cacheMatrix;
  7525. private _updateMatrix3x3ForUniform;
  7526. private _updateMatrix3x3ForEffect;
  7527. private _updateMatrix2x2ForEffect;
  7528. private _updateMatrix2x2ForUniform;
  7529. private _updateFloatForEffect;
  7530. private _updateFloatForUniform;
  7531. private _updateFloat2ForEffect;
  7532. private _updateFloat2ForUniform;
  7533. private _updateFloat3ForEffect;
  7534. private _updateFloat3ForUniform;
  7535. private _updateFloat4ForEffect;
  7536. private _updateFloat4ForUniform;
  7537. private _updateMatrixForEffect;
  7538. private _updateMatrixForUniform;
  7539. private _updateVector3ForEffect;
  7540. private _updateVector3ForUniform;
  7541. private _updateVector4ForEffect;
  7542. private _updateVector4ForUniform;
  7543. private _updateColor3ForEffect;
  7544. private _updateColor3ForUniform;
  7545. private _updateColor4ForEffect;
  7546. private _updateColor4ForUniform;
  7547. /**
  7548. * Sets a sampler uniform on the effect.
  7549. * @param name Define the name of the sampler.
  7550. * @param texture Define the texture to set in the sampler
  7551. */
  7552. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7553. /**
  7554. * Directly updates the value of the uniform in the cache AND on the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. */
  7558. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7559. /**
  7560. * Binds this uniform buffer to an effect.
  7561. * @param effect Define the effect to bind the buffer to
  7562. * @param name Name of the uniform block in the shader.
  7563. */
  7564. bindToEffect(effect: Effect, name: string): void;
  7565. /**
  7566. * Disposes the uniform buffer.
  7567. */
  7568. dispose(): void;
  7569. }
  7570. }
  7571. declare module "babylonjs/Misc/iInspectable" {
  7572. /**
  7573. * Enum that determines the text-wrapping mode to use.
  7574. */
  7575. export enum InspectableType {
  7576. /**
  7577. * Checkbox for booleans
  7578. */
  7579. Checkbox = 0,
  7580. /**
  7581. * Sliders for numbers
  7582. */
  7583. Slider = 1,
  7584. /**
  7585. * Vector3
  7586. */
  7587. Vector3 = 2,
  7588. /**
  7589. * Quaternions
  7590. */
  7591. Quaternion = 3,
  7592. /**
  7593. * Color3
  7594. */
  7595. Color3 = 4,
  7596. /**
  7597. * String
  7598. */
  7599. String = 5
  7600. }
  7601. /**
  7602. * Interface used to define custom inspectable properties.
  7603. * This interface is used by the inspector to display custom property grids
  7604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7605. */
  7606. export interface IInspectable {
  7607. /**
  7608. * Gets the label to display
  7609. */
  7610. label: string;
  7611. /**
  7612. * Gets the name of the property to edit
  7613. */
  7614. propertyName: string;
  7615. /**
  7616. * Gets the type of the editor to use
  7617. */
  7618. type: InspectableType;
  7619. /**
  7620. * Gets the minimum value of the property when using in "slider" mode
  7621. */
  7622. min?: number;
  7623. /**
  7624. * Gets the maximum value of the property when using in "slider" mode
  7625. */
  7626. max?: number;
  7627. /**
  7628. * Gets the setp to use when using in "slider" mode
  7629. */
  7630. step?: number;
  7631. }
  7632. }
  7633. declare module "babylonjs/Misc/timingTools" {
  7634. /**
  7635. * Class used to provide helper for timing
  7636. */
  7637. export class TimingTools {
  7638. /**
  7639. * Polyfill for setImmediate
  7640. * @param action defines the action to execute after the current execution block
  7641. */
  7642. static SetImmediate(action: () => void): void;
  7643. }
  7644. }
  7645. declare module "babylonjs/Misc/instantiationTools" {
  7646. /**
  7647. * Class used to enable instatition of objects by class name
  7648. */
  7649. export class InstantiationTools {
  7650. /**
  7651. * Use this object to register external classes like custom textures or material
  7652. * to allow the laoders to instantiate them
  7653. */
  7654. static RegisteredExternalClasses: {
  7655. [key: string]: Object;
  7656. };
  7657. /**
  7658. * Tries to instantiate a new object from a given class name
  7659. * @param className defines the class name to instantiate
  7660. * @returns the new object or null if the system was not able to do the instantiation
  7661. */
  7662. static Instantiate(className: string): any;
  7663. }
  7664. }
  7665. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7666. /**
  7667. * Define options used to create a depth texture
  7668. */
  7669. export class DepthTextureCreationOptions {
  7670. /** Specifies whether or not a stencil should be allocated in the texture */
  7671. generateStencil?: boolean;
  7672. /** Specifies whether or not bilinear filtering is enable on the texture */
  7673. bilinearFiltering?: boolean;
  7674. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7675. comparisonFunction?: number;
  7676. /** Specifies if the created texture is a cube texture */
  7677. isCube?: boolean;
  7678. }
  7679. }
  7680. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7681. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7682. import { Nullable } from "babylonjs/types";
  7683. import { Scene } from "babylonjs/scene";
  7684. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7685. module "babylonjs/Engines/thinEngine" {
  7686. interface ThinEngine {
  7687. /**
  7688. * Creates a depth stencil cube texture.
  7689. * This is only available in WebGL 2.
  7690. * @param size The size of face edge in the cube texture.
  7691. * @param options The options defining the cube texture.
  7692. * @returns The cube texture
  7693. */
  7694. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7695. /**
  7696. * Creates a cube texture
  7697. * @param rootUrl defines the url where the files to load is located
  7698. * @param scene defines the current scene
  7699. * @param files defines the list of files to load (1 per face)
  7700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7701. * @param onLoad defines an optional callback raised when the texture is loaded
  7702. * @param onError defines an optional callback raised if there is an issue to load the texture
  7703. * @param format defines the format of the data
  7704. * @param forcedExtension defines the extension to use to pick the right loader
  7705. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7706. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7707. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7708. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. 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;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. 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;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. 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;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. 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);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * 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;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets the global Hue value.
  8023. * 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).
  8024. */
  8025. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * 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).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * 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.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * 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.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets the global Saturation value.
  8045. * 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.
  8046. */
  8047. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation value.
  8050. * 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.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets the global Exposure value.
  8055. * 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.
  8056. */
  8057. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * 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.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets the highlights Hue value.
  8069. * 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).
  8070. */
  8071. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * 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).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * 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.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * 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.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets the highlights Saturation value.
  8091. * 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.
  8092. */
  8093. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation value.
  8096. * 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.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets the highlights Exposure value.
  8101. * 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.
  8102. */
  8103. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * 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.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets the midtones Hue value.
  8115. * 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).
  8116. */
  8117. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * 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).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets the midtones Saturation value.
  8137. * 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.
  8138. */
  8139. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation value.
  8142. * 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.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets the midtones Exposure value.
  8147. * 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.
  8148. */
  8149. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * 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.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets the shadows Hue value.
  8161. * 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).
  8162. */
  8163. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * 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).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets the shadows Saturation value.
  8183. * 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.
  8184. */
  8185. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation value.
  8188. * 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.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets the shadows Exposure value.
  8193. * 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.
  8194. */
  8195. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * 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.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8662. * panning
  8663. */
  8664. invertRotation: boolean;
  8665. /**
  8666. * Speed multiplier for inverse camera panning
  8667. */
  8668. inverseRotationSpeed: number;
  8669. /**
  8670. * Define the current target of the camera as an object or a position.
  8671. */
  8672. lockedTarget: any;
  8673. /** @hidden */
  8674. _currentTarget: Vector3;
  8675. /** @hidden */
  8676. _initialFocalDistance: number;
  8677. /** @hidden */
  8678. _viewMatrix: Matrix;
  8679. /** @hidden */
  8680. _camMatrix: Matrix;
  8681. /** @hidden */
  8682. _cameraTransformMatrix: Matrix;
  8683. /** @hidden */
  8684. _cameraRotationMatrix: Matrix;
  8685. /** @hidden */
  8686. _referencePoint: Vector3;
  8687. /** @hidden */
  8688. _transformedReferencePoint: Vector3;
  8689. protected _globalCurrentTarget: Vector3;
  8690. protected _globalCurrentUpVector: Vector3;
  8691. /** @hidden */
  8692. _reset: () => void;
  8693. private _defaultUp;
  8694. /**
  8695. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8696. * This is the base of the follow, arc rotate cameras and Free camera
  8697. * @see http://doc.babylonjs.com/features/cameras
  8698. * @param name Defines the name of the camera in the scene
  8699. * @param position Defines the start position of the camera in the scene
  8700. * @param scene Defines the scene the camera belongs to
  8701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8702. */
  8703. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8704. /**
  8705. * Gets the position in front of the camera at a given distance.
  8706. * @param distance The distance from the camera we want the position to be
  8707. * @returns the position
  8708. */
  8709. getFrontPosition(distance: number): Vector3;
  8710. /** @hidden */
  8711. _getLockedTargetPosition(): Nullable<Vector3>;
  8712. private _storedPosition;
  8713. private _storedRotation;
  8714. private _storedRotationQuaternion;
  8715. /**
  8716. * Store current camera state of the camera (fov, position, rotation, etc..)
  8717. * @returns the camera
  8718. */
  8719. storeState(): Camera;
  8720. /**
  8721. * Restored camera state. You must call storeState() first
  8722. * @returns whether it was successful or not
  8723. * @hidden
  8724. */
  8725. _restoreStateValues(): boolean;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _updateCache(ignoreParentClass?: boolean): void;
  8730. /** @hidden */
  8731. _isSynchronizedViewMatrix(): boolean;
  8732. /** @hidden */
  8733. _computeLocalCameraSpeed(): number;
  8734. /**
  8735. * Defines the target the camera should look at.
  8736. * @param target Defines the new target as a Vector or a mesh
  8737. */
  8738. setTarget(target: Vector3): void;
  8739. /**
  8740. * Return the current target position of the camera. This value is expressed in local space.
  8741. * @returns the target position
  8742. */
  8743. getTarget(): Vector3;
  8744. /** @hidden */
  8745. _decideIfNeedsToMove(): boolean;
  8746. /** @hidden */
  8747. _updatePosition(): void;
  8748. /** @hidden */
  8749. _checkInputs(): void;
  8750. protected _updateCameraRotationMatrix(): void;
  8751. /**
  8752. * 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)
  8753. * @returns the current camera
  8754. */
  8755. private _rotateUpVectorWithCameraRotationMatrix;
  8756. private _cachedRotationZ;
  8757. private _cachedQuaternionRotationZ;
  8758. /** @hidden */
  8759. _getViewMatrix(): Matrix;
  8760. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8761. /**
  8762. * @hidden
  8763. */
  8764. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8765. /**
  8766. * @hidden
  8767. */
  8768. _updateRigCameras(): void;
  8769. private _getRigCamPositionAndTarget;
  8770. /**
  8771. * Gets the current object class name.
  8772. * @return the class name
  8773. */
  8774. getClassName(): string;
  8775. }
  8776. }
  8777. declare module "babylonjs/Events/keyboardEvents" {
  8778. /**
  8779. * Gather the list of keyboard event types as constants.
  8780. */
  8781. export class KeyboardEventTypes {
  8782. /**
  8783. * The keydown event is fired when a key becomes active (pressed).
  8784. */
  8785. static readonly KEYDOWN: number;
  8786. /**
  8787. * The keyup event is fired when a key has been released.
  8788. */
  8789. static readonly KEYUP: number;
  8790. }
  8791. /**
  8792. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8793. */
  8794. export class KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Instantiates a new keyboard info.
  8805. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8806. * @param type Defines the type of event (KeyboardEventTypes)
  8807. * @param event Defines the related dom event
  8808. */
  8809. constructor(
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number,
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent);
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8821. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8822. */
  8823. export class KeyboardInfoPre extends KeyboardInfo {
  8824. /**
  8825. * Defines the type of event (KeyboardEventTypes)
  8826. */
  8827. type: number;
  8828. /**
  8829. * Defines the related dom event
  8830. */
  8831. event: KeyboardEvent;
  8832. /**
  8833. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8834. */
  8835. skipOnPointerObservable: boolean;
  8836. /**
  8837. * Instantiates a new keyboard pre info.
  8838. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8839. * @param type Defines the type of event (KeyboardEventTypes)
  8840. * @param event Defines the related dom event
  8841. */
  8842. constructor(
  8843. /**
  8844. * Defines the type of event (KeyboardEventTypes)
  8845. */
  8846. type: number,
  8847. /**
  8848. * Defines the related dom event
  8849. */
  8850. event: KeyboardEvent);
  8851. }
  8852. }
  8853. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8854. import { Nullable } from "babylonjs/types";
  8855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8857. /**
  8858. * Manage the keyboard inputs to control the movement of a free camera.
  8859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8860. */
  8861. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8862. /**
  8863. * Defines the camera the input is attached to.
  8864. */
  8865. camera: FreeCamera;
  8866. /**
  8867. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8868. */
  8869. keysUp: number[];
  8870. /**
  8871. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8872. */
  8873. keysUpward: number[];
  8874. /**
  8875. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8876. */
  8877. keysDown: number[];
  8878. /**
  8879. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8880. */
  8881. keysDownward: number[];
  8882. /**
  8883. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8884. */
  8885. keysLeft: number[];
  8886. /**
  8887. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8888. */
  8889. keysRight: number[];
  8890. private _keys;
  8891. private _onCanvasBlurObserver;
  8892. private _onKeyboardObserver;
  8893. private _engine;
  8894. private _scene;
  8895. /**
  8896. * Attach the input controls to a specific dom element to get the input from.
  8897. * @param element Defines the element the controls should be listened from
  8898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8899. */
  8900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8901. /**
  8902. * Detach the current controls from the specified dom element.
  8903. * @param element Defines the element to stop listening the inputs from
  8904. */
  8905. detachControl(element: Nullable<HTMLElement>): void;
  8906. /**
  8907. * Update the current camera state depending on the inputs that have been used this frame.
  8908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8909. */
  8910. checkInputs(): void;
  8911. /**
  8912. * Gets the class name of the current intput.
  8913. * @returns the class name
  8914. */
  8915. getClassName(): string;
  8916. /** @hidden */
  8917. _onLostFocus(): void;
  8918. /**
  8919. * Get the friendly name associated with the input class.
  8920. * @returns the input friendly name
  8921. */
  8922. getSimpleName(): string;
  8923. }
  8924. }
  8925. declare module "babylonjs/Lights/shadowLight" {
  8926. import { Camera } from "babylonjs/Cameras/camera";
  8927. import { Scene } from "babylonjs/scene";
  8928. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8930. import { Light } from "babylonjs/Lights/light";
  8931. /**
  8932. * Interface describing all the common properties and methods a shadow light needs to implement.
  8933. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8934. * as well as binding the different shadow properties to the effects.
  8935. */
  8936. export interface IShadowLight extends Light {
  8937. /**
  8938. * The light id in the scene (used in scene.findLighById for instance)
  8939. */
  8940. id: string;
  8941. /**
  8942. * The position the shdow will be casted from.
  8943. */
  8944. position: Vector3;
  8945. /**
  8946. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8947. */
  8948. direction: Vector3;
  8949. /**
  8950. * The transformed position. Position of the light in world space taking parenting in account.
  8951. */
  8952. transformedPosition: Vector3;
  8953. /**
  8954. * The transformed direction. Direction of the light in world space taking parenting in account.
  8955. */
  8956. transformedDirection: Vector3;
  8957. /**
  8958. * The friendly name of the light in the scene.
  8959. */
  8960. name: string;
  8961. /**
  8962. * Defines the shadow projection clipping minimum z value.
  8963. */
  8964. shadowMinZ: number;
  8965. /**
  8966. * Defines the shadow projection clipping maximum z value.
  8967. */
  8968. shadowMaxZ: number;
  8969. /**
  8970. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8971. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8972. */
  8973. computeTransformedInformation(): boolean;
  8974. /**
  8975. * Gets the scene the light belongs to.
  8976. * @returns The scene
  8977. */
  8978. getScene(): Scene;
  8979. /**
  8980. * Callback defining a custom Projection Matrix Builder.
  8981. * This can be used to override the default projection matrix computation.
  8982. */
  8983. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8984. /**
  8985. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8986. * @param matrix The materix to updated with the projection information
  8987. * @param viewMatrix The transform matrix of the light
  8988. * @param renderList The list of mesh to render in the map
  8989. * @returns The current light
  8990. */
  8991. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8992. /**
  8993. * Gets the current depth scale used in ESM.
  8994. * @returns The scale
  8995. */
  8996. getDepthScale(): number;
  8997. /**
  8998. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8999. * @returns true if a cube texture needs to be use
  9000. */
  9001. needCube(): boolean;
  9002. /**
  9003. * Detects if the projection matrix requires to be recomputed this frame.
  9004. * @returns true if it requires to be recomputed otherwise, false.
  9005. */
  9006. needProjectionMatrixCompute(): boolean;
  9007. /**
  9008. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9009. */
  9010. forceProjectionMatrixCompute(): void;
  9011. /**
  9012. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9015. */
  9016. getShadowDirection(faceIndex?: number): Vector3;
  9017. /**
  9018. * Gets the minZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the min for
  9020. * @returns the depth min z
  9021. */
  9022. getDepthMinZ(activeCamera: Camera): number;
  9023. /**
  9024. * Gets the maxZ used for shadow according to both the scene and the light.
  9025. * @param activeCamera The camera we are returning the max for
  9026. * @returns the depth max z
  9027. */
  9028. getDepthMaxZ(activeCamera: Camera): number;
  9029. }
  9030. /**
  9031. * Base implementation IShadowLight
  9032. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9033. */
  9034. export abstract class ShadowLight extends Light implements IShadowLight {
  9035. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9036. protected _position: Vector3;
  9037. protected _setPosition(value: Vector3): void;
  9038. /**
  9039. * Sets the position the shadow will be casted from. Also use as the light position for both
  9040. * point and spot lights.
  9041. */
  9042. get position(): Vector3;
  9043. /**
  9044. * Sets the position the shadow will be casted from. Also use as the light position for both
  9045. * point and spot lights.
  9046. */
  9047. set position(value: Vector3);
  9048. protected _direction: Vector3;
  9049. protected _setDirection(value: Vector3): void;
  9050. /**
  9051. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9052. * Also use as the light direction on spot and directional lights.
  9053. */
  9054. get direction(): Vector3;
  9055. /**
  9056. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9057. * Also use as the light direction on spot and directional lights.
  9058. */
  9059. set direction(value: Vector3);
  9060. protected _shadowMinZ: number;
  9061. /**
  9062. * Gets the shadow projection clipping minimum z value.
  9063. */
  9064. get shadowMinZ(): number;
  9065. /**
  9066. * Sets the shadow projection clipping minimum z value.
  9067. */
  9068. set shadowMinZ(value: number);
  9069. protected _shadowMaxZ: number;
  9070. /**
  9071. * Sets the shadow projection clipping maximum z value.
  9072. */
  9073. get shadowMaxZ(): number;
  9074. /**
  9075. * Gets the shadow projection clipping maximum z value.
  9076. */
  9077. set shadowMaxZ(value: number);
  9078. /**
  9079. * Callback defining a custom Projection Matrix Builder.
  9080. * This can be used to override the default projection matrix computation.
  9081. */
  9082. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9083. /**
  9084. * The transformed position. Position of the light in world space taking parenting in account.
  9085. */
  9086. transformedPosition: Vector3;
  9087. /**
  9088. * The transformed direction. Direction of the light in world space taking parenting in account.
  9089. */
  9090. transformedDirection: Vector3;
  9091. private _needProjectionMatrixCompute;
  9092. /**
  9093. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9094. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9095. */
  9096. computeTransformedInformation(): boolean;
  9097. /**
  9098. * Return the depth scale used for the shadow map.
  9099. * @returns the depth scale.
  9100. */
  9101. getDepthScale(): number;
  9102. /**
  9103. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9106. */
  9107. getShadowDirection(faceIndex?: number): Vector3;
  9108. /**
  9109. * Returns the ShadowLight absolute position in the World.
  9110. * @returns the position vector in world space
  9111. */
  9112. getAbsolutePosition(): Vector3;
  9113. /**
  9114. * Sets the ShadowLight direction toward the passed target.
  9115. * @param target The point to target in local space
  9116. * @returns the updated ShadowLight direction
  9117. */
  9118. setDirectionToTarget(target: Vector3): Vector3;
  9119. /**
  9120. * Returns the light rotation in euler definition.
  9121. * @returns the x y z rotation in local space.
  9122. */
  9123. getRotation(): Vector3;
  9124. /**
  9125. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9126. * @returns true if a cube texture needs to be use
  9127. */
  9128. needCube(): boolean;
  9129. /**
  9130. * Detects if the projection matrix requires to be recomputed this frame.
  9131. * @returns true if it requires to be recomputed otherwise, false.
  9132. */
  9133. needProjectionMatrixCompute(): boolean;
  9134. /**
  9135. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9136. */
  9137. forceProjectionMatrixCompute(): void;
  9138. /** @hidden */
  9139. _initCache(): void;
  9140. /** @hidden */
  9141. _isSynchronized(): boolean;
  9142. /**
  9143. * Computes the world matrix of the node
  9144. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9145. * @returns the world matrix
  9146. */
  9147. computeWorldMatrix(force?: boolean): Matrix;
  9148. /**
  9149. * Gets the minZ used for shadow according to both the scene and the light.
  9150. * @param activeCamera The camera we are returning the min for
  9151. * @returns the depth min z
  9152. */
  9153. getDepthMinZ(activeCamera: Camera): number;
  9154. /**
  9155. * Gets the maxZ used for shadow according to both the scene and the light.
  9156. * @param activeCamera The camera we are returning the max for
  9157. * @returns the depth max z
  9158. */
  9159. getDepthMaxZ(activeCamera: Camera): number;
  9160. /**
  9161. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9162. * @param matrix The materix to updated with the projection information
  9163. * @param viewMatrix The transform matrix of the light
  9164. * @param renderList The list of mesh to render in the map
  9165. * @returns The current light
  9166. */
  9167. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9168. }
  9169. }
  9170. declare module "babylonjs/Materials/effectFallbacks" {
  9171. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9172. import { Effect } from "babylonjs/Materials/effect";
  9173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9174. /**
  9175. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9176. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9177. */
  9178. export class EffectFallbacks implements IEffectFallbacks {
  9179. private _defines;
  9180. private _currentRank;
  9181. private _maxRank;
  9182. private _mesh;
  9183. /**
  9184. * Removes the fallback from the bound mesh.
  9185. */
  9186. unBindMesh(): void;
  9187. /**
  9188. * Adds a fallback on the specified property.
  9189. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9190. * @param define The name of the define in the shader
  9191. */
  9192. addFallback(rank: number, define: string): void;
  9193. /**
  9194. * Sets the mesh to use CPU skinning when needing to fallback.
  9195. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9196. * @param mesh The mesh to use the fallbacks.
  9197. */
  9198. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9199. /**
  9200. * Checks to see if more fallbacks are still availible.
  9201. */
  9202. get hasMoreFallbacks(): boolean;
  9203. /**
  9204. * Removes the defines that should be removed when falling back.
  9205. * @param currentDefines defines the current define statements for the shader.
  9206. * @param effect defines the current effect we try to compile
  9207. * @returns The resulting defines with defines of the current rank removed.
  9208. */
  9209. reduce(currentDefines: string, effect: Effect): string;
  9210. }
  9211. }
  9212. declare module "babylonjs/Materials/materialHelper" {
  9213. import { Nullable } from "babylonjs/types";
  9214. import { Scene } from "babylonjs/scene";
  9215. import { Engine } from "babylonjs/Engines/engine";
  9216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9217. import { Light } from "babylonjs/Lights/light";
  9218. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9219. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9222. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9223. /**
  9224. * "Static Class" containing the most commonly used helper while dealing with material for
  9225. * rendering purpose.
  9226. *
  9227. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9228. *
  9229. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9230. */
  9231. export class MaterialHelper {
  9232. /**
  9233. * Bind the current view position to an effect.
  9234. * @param effect The effect to be bound
  9235. * @param scene The scene the eyes position is used from
  9236. */
  9237. static BindEyePosition(effect: Effect, scene: Scene): void;
  9238. /**
  9239. * Helps preparing the defines values about the UVs in used in the effect.
  9240. * UVs are shared as much as we can accross channels in the shaders.
  9241. * @param texture The texture we are preparing the UVs for
  9242. * @param defines The defines to update
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9246. /**
  9247. * Binds a texture matrix value to its corrsponding uniform
  9248. * @param texture The texture to bind the matrix for
  9249. * @param uniformBuffer The uniform buffer receivin the data
  9250. * @param key The channel key "diffuse", "specular"... used in the shader
  9251. */
  9252. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9253. /**
  9254. * Gets the current status of the fog (should it be enabled?)
  9255. * @param mesh defines the mesh to evaluate for fog support
  9256. * @param scene defines the hosting scene
  9257. * @returns true if fog must be enabled
  9258. */
  9259. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9260. /**
  9261. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9262. * @param mesh defines the current mesh
  9263. * @param scene defines the current scene
  9264. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9265. * @param pointsCloud defines if point cloud rendering has to be turned on
  9266. * @param fogEnabled defines if fog has to be turned on
  9267. * @param alphaTest defines if alpha testing has to be turned on
  9268. * @param defines defines the current list of defines
  9269. */
  9270. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9271. /**
  9272. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9273. * @param scene defines the current scene
  9274. * @param engine defines the current engine
  9275. * @param defines specifies the list of active defines
  9276. * @param useInstances defines if instances have to be turned on
  9277. * @param useClipPlane defines if clip plane have to be turned on
  9278. */
  9279. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9280. /**
  9281. * Prepares the defines for bones
  9282. * @param mesh The mesh containing the geometry data we will draw
  9283. * @param defines The defines to update
  9284. */
  9285. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9286. /**
  9287. * Prepares the defines for morph targets
  9288. * @param mesh The mesh containing the geometry data we will draw
  9289. * @param defines The defines to update
  9290. */
  9291. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9292. /**
  9293. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9294. * @param mesh The mesh containing the geometry data we will draw
  9295. * @param defines The defines to update
  9296. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9297. * @param useBones Precise whether bones should be used or not (override mesh info)
  9298. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9299. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9300. * @returns false if defines are considered not dirty and have not been checked
  9301. */
  9302. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9303. /**
  9304. * Prepares the defines related to multiview
  9305. * @param scene The scene we are intending to draw
  9306. * @param defines The defines to update
  9307. */
  9308. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9309. /**
  9310. * Prepares the defines related to the light information passed in parameter
  9311. * @param scene The scene we are intending to draw
  9312. * @param mesh The mesh the effect is compiling for
  9313. * @param light The light the effect is compiling for
  9314. * @param lightIndex The index of the light
  9315. * @param defines The defines to update
  9316. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9317. * @param state Defines the current state regarding what is needed (normals, etc...)
  9318. */
  9319. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9320. needNormals: boolean;
  9321. needRebuild: boolean;
  9322. shadowEnabled: boolean;
  9323. specularEnabled: boolean;
  9324. lightmapMode: boolean;
  9325. }): void;
  9326. /**
  9327. * Prepares the defines related to the light information passed in parameter
  9328. * @param scene The scene we are intending to draw
  9329. * @param mesh The mesh the effect is compiling for
  9330. * @param defines The defines to update
  9331. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9332. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9333. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9334. * @returns true if normals will be required for the rest of the effect
  9335. */
  9336. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9337. /**
  9338. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9339. * @param lightIndex defines the light index
  9340. * @param uniformsList The uniform list
  9341. * @param samplersList The sampler list
  9342. * @param projectedLightTexture defines if projected texture must be used
  9343. * @param uniformBuffersList defines an optional list of uniform buffers
  9344. */
  9345. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9346. /**
  9347. * Prepares the uniforms and samplers list to be used in the effect
  9348. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9349. * @param samplersList The sampler list
  9350. * @param defines The defines helping in the list generation
  9351. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9352. */
  9353. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9354. /**
  9355. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9356. * @param defines The defines to update while falling back
  9357. * @param fallbacks The authorized effect fallbacks
  9358. * @param maxSimultaneousLights The maximum number of lights allowed
  9359. * @param rank the current rank of the Effect
  9360. * @returns The newly affected rank
  9361. */
  9362. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9363. private static _TmpMorphInfluencers;
  9364. /**
  9365. * Prepares the list of attributes required for morph targets according to the effect defines.
  9366. * @param attribs The current list of supported attribs
  9367. * @param mesh The mesh to prepare the morph targets attributes for
  9368. * @param influencers The number of influencers
  9369. */
  9370. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9371. /**
  9372. * Prepares the list of attributes required for morph targets according to the effect defines.
  9373. * @param attribs The current list of supported attribs
  9374. * @param mesh The mesh to prepare the morph targets attributes for
  9375. * @param defines The current Defines of the effect
  9376. */
  9377. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9378. /**
  9379. * Prepares the list of attributes required for bones according to the effect defines.
  9380. * @param attribs The current list of supported attribs
  9381. * @param mesh The mesh to prepare the bones attributes for
  9382. * @param defines The current Defines of the effect
  9383. * @param fallbacks The current efffect fallback strategy
  9384. */
  9385. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9386. /**
  9387. * Check and prepare the list of attributes required for instances according to the effect defines.
  9388. * @param attribs The current list of supported attribs
  9389. * @param defines The current MaterialDefines of the effect
  9390. */
  9391. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9392. /**
  9393. * Add the list of attributes required for instances to the attribs array.
  9394. * @param attribs The current list of supported attribs
  9395. */
  9396. static PushAttributesForInstances(attribs: string[]): void;
  9397. /**
  9398. * Binds the light information to the effect.
  9399. * @param light The light containing the generator
  9400. * @param effect The effect we are binding the data to
  9401. * @param lightIndex The light index in the effect used to render
  9402. */
  9403. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9404. /**
  9405. * Binds the lights information from the scene to the effect for the given mesh.
  9406. * @param light Light to bind
  9407. * @param lightIndex Light index
  9408. * @param scene The scene where the light belongs to
  9409. * @param effect The effect we are binding the data to
  9410. * @param useSpecular Defines if specular is supported
  9411. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9412. */
  9413. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9414. /**
  9415. * Binds the lights information from the scene to the effect for the given mesh.
  9416. * @param scene The scene the lights belongs to
  9417. * @param mesh The mesh we are binding the information to render
  9418. * @param effect The effect we are binding the data to
  9419. * @param defines The generated defines for the effect
  9420. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9421. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9422. */
  9423. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9424. private static _tempFogColor;
  9425. /**
  9426. * Binds the fog information from the scene to the effect for the given mesh.
  9427. * @param scene The scene the lights belongs to
  9428. * @param mesh The mesh we are binding the information to render
  9429. * @param effect The effect we are binding the data to
  9430. * @param linearSpace Defines if the fog effect is applied in linear space
  9431. */
  9432. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9433. /**
  9434. * Binds the bones information from the mesh to the effect.
  9435. * @param mesh The mesh we are binding the information to render
  9436. * @param effect The effect we are binding the data to
  9437. */
  9438. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9439. /**
  9440. * Binds the morph targets information from the mesh to the effect.
  9441. * @param abstractMesh The mesh we are binding the information to render
  9442. * @param effect The effect we are binding the data to
  9443. */
  9444. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9445. /**
  9446. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9447. * @param defines The generated defines used in the effect
  9448. * @param effect The effect we are binding the data to
  9449. * @param scene The scene we are willing to render with logarithmic scale for
  9450. */
  9451. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9452. /**
  9453. * Binds the clip plane information from the scene to the effect.
  9454. * @param scene The scene the clip plane information are extracted from
  9455. * @param effect The effect we are binding the data to
  9456. */
  9457. static BindClipPlane(effect: Effect, scene: Scene): void;
  9458. }
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9461. /** @hidden */
  9462. export var packingFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9468. /** @hidden */
  9469. export var clipPlaneFragmentDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9475. /** @hidden */
  9476. export var clipPlaneFragment: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9482. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9484. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9485. /** @hidden */
  9486. export var shadowMapPixelShader: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9492. /** @hidden */
  9493. export var bonesDeclaration: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9499. /** @hidden */
  9500. export var morphTargetsVertexGlobalDeclaration: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9506. /** @hidden */
  9507. export var morphTargetsVertexDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9513. /** @hidden */
  9514. export var instancesDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9520. /** @hidden */
  9521. export var helperFunctions: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9527. /** @hidden */
  9528. export var clipPlaneVertexDeclaration: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9534. /** @hidden */
  9535. export var morphTargetsVertex: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9541. /** @hidden */
  9542. export var instancesVertex: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9548. /** @hidden */
  9549. export var bonesVertex: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9555. /** @hidden */
  9556. export var clipPlaneVertex: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9562. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9563. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9564. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9565. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9567. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9569. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9570. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9572. /** @hidden */
  9573. export var shadowMapVertexShader: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9579. /** @hidden */
  9580. export var depthBoxBlurPixelShader: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Culling/ray" {
  9586. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9587. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9589. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9590. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9591. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9592. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9593. import { Plane } from "babylonjs/Maths/math.plane";
  9594. /**
  9595. * Class representing a ray with position and direction
  9596. */
  9597. export class Ray {
  9598. /** origin point */
  9599. origin: Vector3;
  9600. /** direction */
  9601. direction: Vector3;
  9602. /** length of the ray */
  9603. length: number;
  9604. private static readonly TmpVector3;
  9605. private _tmpRay;
  9606. /**
  9607. * Creates a new ray
  9608. * @param origin origin point
  9609. * @param direction direction
  9610. * @param length length of the ray
  9611. */
  9612. constructor(
  9613. /** origin point */
  9614. origin: Vector3,
  9615. /** direction */
  9616. direction: Vector3,
  9617. /** length of the ray */
  9618. length?: number);
  9619. /**
  9620. * Checks if the ray intersects a box
  9621. * @param minimum bound of the box
  9622. * @param maximum bound of the box
  9623. * @param intersectionTreshold extra extend to be added to the box in all direction
  9624. * @returns if the box was hit
  9625. */
  9626. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9627. /**
  9628. * Checks if the ray intersects a box
  9629. * @param box the bounding box to check
  9630. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9631. * @returns if the box was hit
  9632. */
  9633. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9634. /**
  9635. * If the ray hits a sphere
  9636. * @param sphere the bounding sphere to check
  9637. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9638. * @returns true if it hits the sphere
  9639. */
  9640. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9641. /**
  9642. * If the ray hits a triange
  9643. * @param vertex0 triangle vertex
  9644. * @param vertex1 triangle vertex
  9645. * @param vertex2 triangle vertex
  9646. * @returns intersection information if hit
  9647. */
  9648. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9649. /**
  9650. * Checks if ray intersects a plane
  9651. * @param plane the plane to check
  9652. * @returns the distance away it was hit
  9653. */
  9654. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9655. /**
  9656. * Calculate the intercept of a ray on a given axis
  9657. * @param axis to check 'x' | 'y' | 'z'
  9658. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9659. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9660. */
  9661. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9662. /**
  9663. * Checks if ray intersects a mesh
  9664. * @param mesh the mesh to check
  9665. * @param fastCheck if only the bounding box should checked
  9666. * @returns picking info of the intersecton
  9667. */
  9668. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9669. /**
  9670. * Checks if ray intersects a mesh
  9671. * @param meshes the meshes to check
  9672. * @param fastCheck if only the bounding box should checked
  9673. * @param results array to store result in
  9674. * @returns Array of picking infos
  9675. */
  9676. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9677. private _comparePickingInfo;
  9678. private static smallnum;
  9679. private static rayl;
  9680. /**
  9681. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9682. * @param sega the first point of the segment to test the intersection against
  9683. * @param segb the second point of the segment to test the intersection against
  9684. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9685. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9686. */
  9687. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9688. /**
  9689. * Update the ray from viewport position
  9690. * @param x position
  9691. * @param y y position
  9692. * @param viewportWidth viewport width
  9693. * @param viewportHeight viewport height
  9694. * @param world world matrix
  9695. * @param view view matrix
  9696. * @param projection projection matrix
  9697. * @returns this ray updated
  9698. */
  9699. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9700. /**
  9701. * Creates a ray with origin and direction of 0,0,0
  9702. * @returns the new ray
  9703. */
  9704. static Zero(): Ray;
  9705. /**
  9706. * Creates a new ray from screen space and viewport
  9707. * @param x position
  9708. * @param y y position
  9709. * @param viewportWidth viewport width
  9710. * @param viewportHeight viewport height
  9711. * @param world world matrix
  9712. * @param view view matrix
  9713. * @param projection projection matrix
  9714. * @returns new ray
  9715. */
  9716. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9717. /**
  9718. * 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
  9719. * transformed to the given world matrix.
  9720. * @param origin The origin point
  9721. * @param end The end point
  9722. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9723. * @returns the new ray
  9724. */
  9725. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9726. /**
  9727. * Transforms a ray by a matrix
  9728. * @param ray ray to transform
  9729. * @param matrix matrix to apply
  9730. * @returns the resulting new ray
  9731. */
  9732. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9733. /**
  9734. * Transforms a ray by a matrix
  9735. * @param ray ray to transform
  9736. * @param matrix matrix to apply
  9737. * @param result ray to store result in
  9738. */
  9739. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9740. /**
  9741. * Unproject a ray from screen space to object space
  9742. * @param sourceX defines the screen space x coordinate to use
  9743. * @param sourceY defines the screen space y coordinate to use
  9744. * @param viewportWidth defines the current width of the viewport
  9745. * @param viewportHeight defines the current height of the viewport
  9746. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9747. * @param view defines the view matrix to use
  9748. * @param projection defines the projection matrix to use
  9749. */
  9750. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9751. }
  9752. /**
  9753. * Type used to define predicate used to select faces when a mesh intersection is detected
  9754. */
  9755. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9756. module "babylonjs/scene" {
  9757. interface Scene {
  9758. /** @hidden */
  9759. _tempPickingRay: Nullable<Ray>;
  9760. /** @hidden */
  9761. _cachedRayForTransform: Ray;
  9762. /** @hidden */
  9763. _pickWithRayInverseMatrix: Matrix;
  9764. /** @hidden */
  9765. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9766. /** @hidden */
  9767. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9768. }
  9769. }
  9770. }
  9771. declare module "babylonjs/sceneComponent" {
  9772. import { Scene } from "babylonjs/scene";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9775. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9776. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9777. import { Nullable } from "babylonjs/types";
  9778. import { Camera } from "babylonjs/Cameras/camera";
  9779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9780. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9781. import { AbstractScene } from "babylonjs/abstractScene";
  9782. import { Mesh } from "babylonjs/Meshes/mesh";
  9783. /**
  9784. * Groups all the scene component constants in one place to ease maintenance.
  9785. * @hidden
  9786. */
  9787. export class SceneComponentConstants {
  9788. static readonly NAME_EFFECTLAYER: string;
  9789. static readonly NAME_LAYER: string;
  9790. static readonly NAME_LENSFLARESYSTEM: string;
  9791. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9792. static readonly NAME_PARTICLESYSTEM: string;
  9793. static readonly NAME_GAMEPAD: string;
  9794. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9795. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9796. static readonly NAME_DEPTHRENDERER: string;
  9797. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9798. static readonly NAME_SPRITE: string;
  9799. static readonly NAME_OUTLINERENDERER: string;
  9800. static readonly NAME_PROCEDURALTEXTURE: string;
  9801. static readonly NAME_SHADOWGENERATOR: string;
  9802. static readonly NAME_OCTREE: string;
  9803. static readonly NAME_PHYSICSENGINE: string;
  9804. static readonly NAME_AUDIO: string;
  9805. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9806. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9807. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9808. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9809. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9810. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9811. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9812. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9813. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9814. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9815. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9816. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9817. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9818. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9819. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9820. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9821. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9822. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9823. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9824. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9825. static readonly STEP_AFTERRENDER_AUDIO: number;
  9826. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9827. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9828. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9829. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9830. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9831. static readonly STEP_POINTERMOVE_SPRITE: number;
  9832. static readonly STEP_POINTERDOWN_SPRITE: number;
  9833. static readonly STEP_POINTERUP_SPRITE: number;
  9834. }
  9835. /**
  9836. * This represents a scene component.
  9837. *
  9838. * This is used to decouple the dependency the scene is having on the different workloads like
  9839. * layers, post processes...
  9840. */
  9841. export interface ISceneComponent {
  9842. /**
  9843. * The name of the component. Each component must have a unique name.
  9844. */
  9845. name: string;
  9846. /**
  9847. * The scene the component belongs to.
  9848. */
  9849. scene: Scene;
  9850. /**
  9851. * Register the component to one instance of a scene.
  9852. */
  9853. register(): void;
  9854. /**
  9855. * Rebuilds the elements related to this component in case of
  9856. * context lost for instance.
  9857. */
  9858. rebuild(): void;
  9859. /**
  9860. * Disposes the component and the associated ressources.
  9861. */
  9862. dispose(): void;
  9863. }
  9864. /**
  9865. * This represents a SERIALIZABLE scene component.
  9866. *
  9867. * This extends Scene Component to add Serialization methods on top.
  9868. */
  9869. export interface ISceneSerializableComponent extends ISceneComponent {
  9870. /**
  9871. * Adds all the elements from the container to the scene
  9872. * @param container the container holding the elements
  9873. */
  9874. addFromContainer(container: AbstractScene): void;
  9875. /**
  9876. * Removes all the elements in the container from the scene
  9877. * @param container contains the elements to remove
  9878. * @param dispose if the removed element should be disposed (default: false)
  9879. */
  9880. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9881. /**
  9882. * Serializes the component data to the specified json object
  9883. * @param serializationObject The object to serialize to
  9884. */
  9885. serialize(serializationObject: any): void;
  9886. }
  9887. /**
  9888. * Strong typing of a Mesh related stage step action
  9889. */
  9890. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9891. /**
  9892. * Strong typing of a Evaluate Sub Mesh related stage step action
  9893. */
  9894. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9895. /**
  9896. * Strong typing of a Active Mesh related stage step action
  9897. */
  9898. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9899. /**
  9900. * Strong typing of a Camera related stage step action
  9901. */
  9902. export type CameraStageAction = (camera: Camera) => void;
  9903. /**
  9904. * Strong typing of a Camera Frame buffer related stage step action
  9905. */
  9906. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9907. /**
  9908. * Strong typing of a Render Target related stage step action
  9909. */
  9910. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9911. /**
  9912. * Strong typing of a RenderingGroup related stage step action
  9913. */
  9914. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9915. /**
  9916. * Strong typing of a Mesh Render related stage step action
  9917. */
  9918. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9919. /**
  9920. * Strong typing of a simple stage step action
  9921. */
  9922. export type SimpleStageAction = () => void;
  9923. /**
  9924. * Strong typing of a render target action.
  9925. */
  9926. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9927. /**
  9928. * Strong typing of a pointer move action.
  9929. */
  9930. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9931. /**
  9932. * Strong typing of a pointer up/down action.
  9933. */
  9934. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9935. /**
  9936. * Representation of a stage in the scene (Basically a list of ordered steps)
  9937. * @hidden
  9938. */
  9939. export class Stage<T extends Function> extends Array<{
  9940. index: number;
  9941. component: ISceneComponent;
  9942. action: T;
  9943. }> {
  9944. /**
  9945. * Hide ctor from the rest of the world.
  9946. * @param items The items to add.
  9947. */
  9948. private constructor();
  9949. /**
  9950. * Creates a new Stage.
  9951. * @returns A new instance of a Stage
  9952. */
  9953. static Create<T extends Function>(): Stage<T>;
  9954. /**
  9955. * Registers a step in an ordered way in the targeted stage.
  9956. * @param index Defines the position to register the step in
  9957. * @param component Defines the component attached to the step
  9958. * @param action Defines the action to launch during the step
  9959. */
  9960. registerStep(index: number, component: ISceneComponent, action: T): void;
  9961. /**
  9962. * Clears all the steps from the stage.
  9963. */
  9964. clear(): void;
  9965. }
  9966. }
  9967. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9968. import { Nullable } from "babylonjs/types";
  9969. import { Observable } from "babylonjs/Misc/observable";
  9970. import { Scene } from "babylonjs/scene";
  9971. import { Sprite } from "babylonjs/Sprites/sprite";
  9972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9973. import { Ray } from "babylonjs/Culling/ray";
  9974. import { Camera } from "babylonjs/Cameras/camera";
  9975. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9976. import { ISceneComponent } from "babylonjs/sceneComponent";
  9977. module "babylonjs/scene" {
  9978. interface Scene {
  9979. /** @hidden */
  9980. _pointerOverSprite: Nullable<Sprite>;
  9981. /** @hidden */
  9982. _pickedDownSprite: Nullable<Sprite>;
  9983. /** @hidden */
  9984. _tempSpritePickingRay: Nullable<Ray>;
  9985. /**
  9986. * All of the sprite managers added to this scene
  9987. * @see http://doc.babylonjs.com/babylon101/sprites
  9988. */
  9989. spriteManagers: Array<ISpriteManager>;
  9990. /**
  9991. * An event triggered when sprites rendering is about to start
  9992. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9993. */
  9994. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9995. /**
  9996. * An event triggered when sprites rendering is done
  9997. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9998. */
  9999. onAfterSpritesRenderingObservable: Observable<Scene>;
  10000. /** @hidden */
  10001. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10002. /** Launch a ray to try to pick a sprite in the scene
  10003. * @param x position on screen
  10004. * @param y position on screen
  10005. * @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
  10006. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10007. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10008. * @returns a PickingInfo
  10009. */
  10010. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10011. /** Use the given ray to pick a sprite in the scene
  10012. * @param ray The ray (in world space) to use to pick meshes
  10013. * @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
  10014. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10015. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10016. * @returns a PickingInfo
  10017. */
  10018. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10019. /** @hidden */
  10020. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10021. /** Launch a ray to try to pick sprites in the scene
  10022. * @param x position on screen
  10023. * @param y position on screen
  10024. * @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
  10025. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10026. * @returns a PickingInfo array
  10027. */
  10028. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10029. /** Use the given ray to pick sprites in the scene
  10030. * @param ray The ray (in world space) to use to pick meshes
  10031. * @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
  10032. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10033. * @returns a PickingInfo array
  10034. */
  10035. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10036. /**
  10037. * Force the sprite under the pointer
  10038. * @param sprite defines the sprite to use
  10039. */
  10040. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10041. /**
  10042. * Gets the sprite under the pointer
  10043. * @returns a Sprite or null if no sprite is under the pointer
  10044. */
  10045. getPointerOverSprite(): Nullable<Sprite>;
  10046. }
  10047. }
  10048. /**
  10049. * Defines the sprite scene component responsible to manage sprites
  10050. * in a given scene.
  10051. */
  10052. export class SpriteSceneComponent implements ISceneComponent {
  10053. /**
  10054. * The component name helpfull to identify the component in the list of scene components.
  10055. */
  10056. readonly name: string;
  10057. /**
  10058. * The scene the component belongs to.
  10059. */
  10060. scene: Scene;
  10061. /** @hidden */
  10062. private _spritePredicate;
  10063. /**
  10064. * Creates a new instance of the component for the given scene
  10065. * @param scene Defines the scene to register the component in
  10066. */
  10067. constructor(scene: Scene);
  10068. /**
  10069. * Registers the component in a given scene
  10070. */
  10071. register(): void;
  10072. /**
  10073. * Rebuilds the elements related to this component in case of
  10074. * context lost for instance.
  10075. */
  10076. rebuild(): void;
  10077. /**
  10078. * Disposes the component and the associated ressources.
  10079. */
  10080. dispose(): void;
  10081. private _pickSpriteButKeepRay;
  10082. private _pointerMove;
  10083. private _pointerDown;
  10084. private _pointerUp;
  10085. }
  10086. }
  10087. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10088. /** @hidden */
  10089. export var fogFragmentDeclaration: {
  10090. name: string;
  10091. shader: string;
  10092. };
  10093. }
  10094. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10095. /** @hidden */
  10096. export var fogFragment: {
  10097. name: string;
  10098. shader: string;
  10099. };
  10100. }
  10101. declare module "babylonjs/Shaders/sprites.fragment" {
  10102. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10103. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10104. /** @hidden */
  10105. export var spritesPixelShader: {
  10106. name: string;
  10107. shader: string;
  10108. };
  10109. }
  10110. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10111. /** @hidden */
  10112. export var fogVertexDeclaration: {
  10113. name: string;
  10114. shader: string;
  10115. };
  10116. }
  10117. declare module "babylonjs/Shaders/sprites.vertex" {
  10118. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10119. /** @hidden */
  10120. export var spritesVertexShader: {
  10121. name: string;
  10122. shader: string;
  10123. };
  10124. }
  10125. declare module "babylonjs/Sprites/spriteManager" {
  10126. import { IDisposable, Scene } from "babylonjs/scene";
  10127. import { Nullable } from "babylonjs/types";
  10128. import { Observable } from "babylonjs/Misc/observable";
  10129. import { Sprite } from "babylonjs/Sprites/sprite";
  10130. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10131. import { Camera } from "babylonjs/Cameras/camera";
  10132. import { Texture } from "babylonjs/Materials/Textures/texture";
  10133. import "babylonjs/Shaders/sprites.fragment";
  10134. import "babylonjs/Shaders/sprites.vertex";
  10135. import { Ray } from "babylonjs/Culling/ray";
  10136. /**
  10137. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10138. */
  10139. export interface ISpriteManager extends IDisposable {
  10140. /**
  10141. * Restricts the camera to viewing objects with the same layerMask.
  10142. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10143. */
  10144. layerMask: number;
  10145. /**
  10146. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10147. */
  10148. isPickable: boolean;
  10149. /**
  10150. * Specifies the rendering group id for this mesh (0 by default)
  10151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10152. */
  10153. renderingGroupId: number;
  10154. /**
  10155. * Defines the list of sprites managed by the manager.
  10156. */
  10157. sprites: Array<Sprite>;
  10158. /**
  10159. * Tests the intersection of a sprite with a specific ray.
  10160. * @param ray The ray we are sending to test the collision
  10161. * @param camera The camera space we are sending rays in
  10162. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10163. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10164. * @returns picking info or null.
  10165. */
  10166. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10167. /**
  10168. * Intersects the sprites with a ray
  10169. * @param ray defines the ray to intersect with
  10170. * @param camera defines the current active camera
  10171. * @param predicate defines a predicate used to select candidate sprites
  10172. * @returns null if no hit or a PickingInfo array
  10173. */
  10174. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10175. /**
  10176. * Renders the list of sprites on screen.
  10177. */
  10178. render(): void;
  10179. }
  10180. /**
  10181. * Class used to manage multiple sprites on the same spritesheet
  10182. * @see http://doc.babylonjs.com/babylon101/sprites
  10183. */
  10184. export class SpriteManager implements ISpriteManager {
  10185. /** defines the manager's name */
  10186. name: string;
  10187. /** Gets the list of sprites */
  10188. sprites: Sprite[];
  10189. /** Gets or sets the rendering group id (0 by default) */
  10190. renderingGroupId: number;
  10191. /** Gets or sets camera layer mask */
  10192. layerMask: number;
  10193. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10194. fogEnabled: boolean;
  10195. /** Gets or sets a boolean indicating if the sprites are pickable */
  10196. isPickable: boolean;
  10197. /** Defines the default width of a cell in the spritesheet */
  10198. cellWidth: number;
  10199. /** Defines the default height of a cell in the spritesheet */
  10200. cellHeight: number;
  10201. /** Associative array from JSON sprite data file */
  10202. private _cellData;
  10203. /** Array of sprite names from JSON sprite data file */
  10204. private _spriteMap;
  10205. /** True when packed cell data from JSON file is ready*/
  10206. private _packedAndReady;
  10207. /**
  10208. * An event triggered when the manager is disposed.
  10209. */
  10210. onDisposeObservable: Observable<SpriteManager>;
  10211. private _onDisposeObserver;
  10212. /**
  10213. * Callback called when the manager is disposed
  10214. */
  10215. set onDispose(callback: () => void);
  10216. private _capacity;
  10217. private _fromPacked;
  10218. private _spriteTexture;
  10219. private _epsilon;
  10220. private _scene;
  10221. private _vertexData;
  10222. private _buffer;
  10223. private _vertexBuffers;
  10224. private _indexBuffer;
  10225. private _effectBase;
  10226. private _effectFog;
  10227. /**
  10228. * Gets or sets the spritesheet texture
  10229. */
  10230. get texture(): Texture;
  10231. set texture(value: Texture);
  10232. private _blendMode;
  10233. /**
  10234. * Blend mode use to render the particle, it can be any of
  10235. * the static Constants.ALPHA_x properties provided in this class.
  10236. * Default value is Constants.ALPHA_COMBINE
  10237. */
  10238. get blendMode(): number;
  10239. set blendMode(blendMode: number);
  10240. /** Disables writing to the depth buffer when rendering the sprites.
  10241. * It can be handy to disable depth writing when using textures without alpha channel
  10242. * and setting some specific blend modes.
  10243. */
  10244. disableDepthWrite: boolean;
  10245. /**
  10246. * Creates a new sprite manager
  10247. * @param name defines the manager's name
  10248. * @param imgUrl defines the sprite sheet url
  10249. * @param capacity defines the maximum allowed number of sprites
  10250. * @param cellSize defines the size of a sprite cell
  10251. * @param scene defines the hosting scene
  10252. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10253. * @param samplingMode defines the smapling mode to use with spritesheet
  10254. * @param fromPacked set to false; do not alter
  10255. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10256. */
  10257. constructor(
  10258. /** defines the manager's name */
  10259. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10260. private _makePacked;
  10261. private _appendSpriteVertex;
  10262. /**
  10263. * Intersects the sprites with a ray
  10264. * @param ray defines the ray to intersect with
  10265. * @param camera defines the current active camera
  10266. * @param predicate defines a predicate used to select candidate sprites
  10267. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10268. * @returns null if no hit or a PickingInfo
  10269. */
  10270. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10271. /**
  10272. * Intersects the sprites with a ray
  10273. * @param ray defines the ray to intersect with
  10274. * @param camera defines the current active camera
  10275. * @param predicate defines a predicate used to select candidate sprites
  10276. * @returns null if no hit or a PickingInfo array
  10277. */
  10278. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10279. /**
  10280. * Render all child sprites
  10281. */
  10282. render(): void;
  10283. /**
  10284. * Release associated resources
  10285. */
  10286. dispose(): void;
  10287. }
  10288. }
  10289. declare module "babylonjs/Misc/gradients" {
  10290. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10291. /** Interface used by value gradients (color, factor, ...) */
  10292. export interface IValueGradient {
  10293. /**
  10294. * Gets or sets the gradient value (between 0 and 1)
  10295. */
  10296. gradient: number;
  10297. }
  10298. /** Class used to store color4 gradient */
  10299. export class ColorGradient implements IValueGradient {
  10300. /**
  10301. * Gets or sets the gradient value (between 0 and 1)
  10302. */
  10303. gradient: number;
  10304. /**
  10305. * Gets or sets first associated color
  10306. */
  10307. color1: Color4;
  10308. /**
  10309. * Gets or sets second associated color
  10310. */
  10311. color2?: Color4;
  10312. /**
  10313. * Will get a color picked randomly between color1 and color2.
  10314. * If color2 is undefined then color1 will be used
  10315. * @param result defines the target Color4 to store the result in
  10316. */
  10317. getColorToRef(result: Color4): void;
  10318. }
  10319. /** Class used to store color 3 gradient */
  10320. export class Color3Gradient implements IValueGradient {
  10321. /**
  10322. * Gets or sets the gradient value (between 0 and 1)
  10323. */
  10324. gradient: number;
  10325. /**
  10326. * Gets or sets the associated color
  10327. */
  10328. color: Color3;
  10329. }
  10330. /** Class used to store factor gradient */
  10331. export class FactorGradient implements IValueGradient {
  10332. /**
  10333. * Gets or sets the gradient value (between 0 and 1)
  10334. */
  10335. gradient: number;
  10336. /**
  10337. * Gets or sets first associated factor
  10338. */
  10339. factor1: number;
  10340. /**
  10341. * Gets or sets second associated factor
  10342. */
  10343. factor2?: number;
  10344. /**
  10345. * Will get a number picked randomly between factor1 and factor2.
  10346. * If factor2 is undefined then factor1 will be used
  10347. * @returns the picked number
  10348. */
  10349. getFactor(): number;
  10350. }
  10351. /**
  10352. * Helper used to simplify some generic gradient tasks
  10353. */
  10354. export class GradientHelper {
  10355. /**
  10356. * Gets the current gradient from an array of IValueGradient
  10357. * @param ratio defines the current ratio to get
  10358. * @param gradients defines the array of IValueGradient
  10359. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10360. */
  10361. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10362. }
  10363. }
  10364. declare module "babylonjs/Maths/math.size" {
  10365. /**
  10366. * Interface for the size containing width and height
  10367. */
  10368. export interface ISize {
  10369. /**
  10370. * Width
  10371. */
  10372. width: number;
  10373. /**
  10374. * Heighht
  10375. */
  10376. height: number;
  10377. }
  10378. /**
  10379. * Size containing widht and height
  10380. */
  10381. export class Size implements ISize {
  10382. /**
  10383. * Width
  10384. */
  10385. width: number;
  10386. /**
  10387. * Height
  10388. */
  10389. height: number;
  10390. /**
  10391. * Creates a Size object from the given width and height (floats).
  10392. * @param width width of the new size
  10393. * @param height height of the new size
  10394. */
  10395. constructor(width: number, height: number);
  10396. /**
  10397. * Returns a string with the Size width and height
  10398. * @returns a string with the Size width and height
  10399. */
  10400. toString(): string;
  10401. /**
  10402. * "Size"
  10403. * @returns the string "Size"
  10404. */
  10405. getClassName(): string;
  10406. /**
  10407. * Returns the Size hash code.
  10408. * @returns a hash code for a unique width and height
  10409. */
  10410. getHashCode(): number;
  10411. /**
  10412. * Updates the current size from the given one.
  10413. * @param src the given size
  10414. */
  10415. copyFrom(src: Size): void;
  10416. /**
  10417. * Updates in place the current Size from the given floats.
  10418. * @param width width of the new size
  10419. * @param height height of the new size
  10420. * @returns the updated Size.
  10421. */
  10422. copyFromFloats(width: number, height: number): Size;
  10423. /**
  10424. * Updates in place the current Size from the given floats.
  10425. * @param width width to set
  10426. * @param height height to set
  10427. * @returns the updated Size.
  10428. */
  10429. set(width: number, height: number): Size;
  10430. /**
  10431. * Multiplies the width and height by numbers
  10432. * @param w factor to multiple the width by
  10433. * @param h factor to multiple the height by
  10434. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10435. */
  10436. multiplyByFloats(w: number, h: number): Size;
  10437. /**
  10438. * Clones the size
  10439. * @returns a new Size copied from the given one.
  10440. */
  10441. clone(): Size;
  10442. /**
  10443. * True if the current Size and the given one width and height are strictly equal.
  10444. * @param other the other size to compare against
  10445. * @returns True if the current Size and the given one width and height are strictly equal.
  10446. */
  10447. equals(other: Size): boolean;
  10448. /**
  10449. * The surface of the Size : width * height (float).
  10450. */
  10451. get surface(): number;
  10452. /**
  10453. * Create a new size of zero
  10454. * @returns a new Size set to (0.0, 0.0)
  10455. */
  10456. static Zero(): Size;
  10457. /**
  10458. * Sums the width and height of two sizes
  10459. * @param otherSize size to add to this size
  10460. * @returns a new Size set as the addition result of the current Size and the given one.
  10461. */
  10462. add(otherSize: Size): Size;
  10463. /**
  10464. * Subtracts the width and height of two
  10465. * @param otherSize size to subtract to this size
  10466. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10467. */
  10468. subtract(otherSize: Size): Size;
  10469. /**
  10470. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10471. * @param start starting size to lerp between
  10472. * @param end end size to lerp between
  10473. * @param amount amount to lerp between the start and end values
  10474. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10475. */
  10476. static Lerp(start: Size, end: Size, amount: number): Size;
  10477. }
  10478. }
  10479. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10481. import { Nullable } from "babylonjs/types";
  10482. module "babylonjs/Engines/thinEngine" {
  10483. interface ThinEngine {
  10484. /**
  10485. * Creates a dynamic texture
  10486. * @param width defines the width of the texture
  10487. * @param height defines the height of the texture
  10488. * @param generateMipMaps defines if the engine should generate the mip levels
  10489. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10490. * @returns the dynamic texture inside an InternalTexture
  10491. */
  10492. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10493. /**
  10494. * Update the content of a dynamic texture
  10495. * @param texture defines the texture to update
  10496. * @param canvas defines the canvas containing the source
  10497. * @param invertY defines if data must be stored with Y axis inverted
  10498. * @param premulAlpha defines if alpha is stored as premultiplied
  10499. * @param format defines the format of the data
  10500. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10501. */
  10502. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10503. }
  10504. }
  10505. }
  10506. declare module "babylonjs/Misc/canvasGenerator" {
  10507. /**
  10508. * Helper class used to generate a canvas to manipulate images
  10509. */
  10510. export class CanvasGenerator {
  10511. /**
  10512. * Create a new canvas (or offscreen canvas depending on the context)
  10513. * @param width defines the expected width
  10514. * @param height defines the expected height
  10515. * @return a new canvas or offscreen canvas
  10516. */
  10517. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10518. }
  10519. }
  10520. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10521. import { Scene } from "babylonjs/scene";
  10522. import { Texture } from "babylonjs/Materials/Textures/texture";
  10523. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10524. /**
  10525. * A class extending Texture allowing drawing on a texture
  10526. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10527. */
  10528. export class DynamicTexture extends Texture {
  10529. private _generateMipMaps;
  10530. private _canvas;
  10531. private _context;
  10532. private _engine;
  10533. /**
  10534. * Creates a DynamicTexture
  10535. * @param name defines the name of the texture
  10536. * @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
  10537. * @param scene defines the scene where you want the texture
  10538. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10539. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10540. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10541. */
  10542. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10543. /**
  10544. * Get the current class name of the texture useful for serialization or dynamic coding.
  10545. * @returns "DynamicTexture"
  10546. */
  10547. getClassName(): string;
  10548. /**
  10549. * Gets the current state of canRescale
  10550. */
  10551. get canRescale(): boolean;
  10552. private _recreate;
  10553. /**
  10554. * Scales the texture
  10555. * @param ratio the scale factor to apply to both width and height
  10556. */
  10557. scale(ratio: number): void;
  10558. /**
  10559. * Resizes the texture
  10560. * @param width the new width
  10561. * @param height the new height
  10562. */
  10563. scaleTo(width: number, height: number): void;
  10564. /**
  10565. * Gets the context of the canvas used by the texture
  10566. * @returns the canvas context of the dynamic texture
  10567. */
  10568. getContext(): CanvasRenderingContext2D;
  10569. /**
  10570. * Clears the texture
  10571. */
  10572. clear(): void;
  10573. /**
  10574. * Updates the texture
  10575. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10576. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10577. */
  10578. update(invertY?: boolean, premulAlpha?: boolean): void;
  10579. /**
  10580. * Draws text onto the texture
  10581. * @param text defines the text to be drawn
  10582. * @param x defines the placement of the text from the left
  10583. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10584. * @param font defines the font to be used with font-style, font-size, font-name
  10585. * @param color defines the color used for the text
  10586. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10587. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10588. * @param update defines whether texture is immediately update (default is true)
  10589. */
  10590. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10591. /**
  10592. * Clones the texture
  10593. * @returns the clone of the texture.
  10594. */
  10595. clone(): DynamicTexture;
  10596. /**
  10597. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10598. * @returns a serialized dynamic texture object
  10599. */
  10600. serialize(): any;
  10601. /** @hidden */
  10602. _rebuild(): void;
  10603. }
  10604. }
  10605. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10606. import { Nullable } from "babylonjs/types";
  10607. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10608. import { Scene } from "babylonjs/scene";
  10609. module "babylonjs/Engines/engine" {
  10610. interface Engine {
  10611. /**
  10612. * Creates a raw texture
  10613. * @param data defines the data to store in the texture
  10614. * @param width defines the width of the texture
  10615. * @param height defines the height of the texture
  10616. * @param format defines the format of the data
  10617. * @param generateMipMaps defines if the engine should generate the mip levels
  10618. * @param invertY defines if data must be stored with Y axis inverted
  10619. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10620. * @param compression defines the compression used (null by default)
  10621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10622. * @returns the raw texture inside an InternalTexture
  10623. */
  10624. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10625. /**
  10626. * Update a raw texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store in the texture
  10629. * @param format defines the format of the data
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. */
  10632. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10633. /**
  10634. * Update a raw texture
  10635. * @param texture defines the texture to update
  10636. * @param data defines the data to store in the texture
  10637. * @param format defines the format of the data
  10638. * @param invertY defines if data must be stored with Y axis inverted
  10639. * @param compression defines the compression used (null by default)
  10640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10641. */
  10642. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10643. /**
  10644. * Creates a new raw cube texture
  10645. * @param data defines the array of data to use to create each face
  10646. * @param size defines the size of the textures
  10647. * @param format defines the format of the data
  10648. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10649. * @param generateMipMaps defines if the engine should generate the mip levels
  10650. * @param invertY defines if data must be stored with Y axis inverted
  10651. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10652. * @param compression defines the compression used (null by default)
  10653. * @returns the cube texture as an InternalTexture
  10654. */
  10655. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10656. /**
  10657. * Update a raw cube texture
  10658. * @param texture defines the texture to udpdate
  10659. * @param data defines the data to store
  10660. * @param format defines the data format
  10661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10662. * @param invertY defines if data must be stored with Y axis inverted
  10663. */
  10664. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10665. /**
  10666. * Update a raw cube texture
  10667. * @param texture defines the texture to udpdate
  10668. * @param data defines the data to store
  10669. * @param format defines the data format
  10670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10671. * @param invertY defines if data must be stored with Y axis inverted
  10672. * @param compression defines the compression used (null by default)
  10673. */
  10674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10675. /**
  10676. * Update a raw cube texture
  10677. * @param texture defines the texture to udpdate
  10678. * @param data defines the data to store
  10679. * @param format defines the data format
  10680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10681. * @param invertY defines if data must be stored with Y axis inverted
  10682. * @param compression defines the compression used (null by default)
  10683. * @param level defines which level of the texture to update
  10684. */
  10685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10686. /**
  10687. * Creates a new raw cube texture from a specified url
  10688. * @param url defines the url where the data is located
  10689. * @param scene defines the current scene
  10690. * @param size defines the size of the textures
  10691. * @param format defines the format of the data
  10692. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10693. * @param noMipmap defines if the engine should avoid generating the mip levels
  10694. * @param callback defines a callback used to extract texture data from loaded data
  10695. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10696. * @param onLoad defines a callback called when texture is loaded
  10697. * @param onError defines a callback called if there is an error
  10698. * @returns the cube texture as an InternalTexture
  10699. */
  10700. 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;
  10701. /**
  10702. * Creates a new raw cube texture from a specified url
  10703. * @param url defines the url where the data is located
  10704. * @param scene defines the current scene
  10705. * @param size defines the size of the textures
  10706. * @param format defines the format of the data
  10707. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10708. * @param noMipmap defines if the engine should avoid generating the mip levels
  10709. * @param callback defines a callback used to extract texture data from loaded data
  10710. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10711. * @param onLoad defines a callback called when texture is loaded
  10712. * @param onError defines a callback called if there is an error
  10713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10714. * @param invertY defines if data must be stored with Y axis inverted
  10715. * @returns the cube texture as an InternalTexture
  10716. */
  10717. 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;
  10718. /**
  10719. * Creates a new raw 3D texture
  10720. * @param data defines the data used to create the texture
  10721. * @param width defines the width of the texture
  10722. * @param height defines the height of the texture
  10723. * @param depth defines the depth of the texture
  10724. * @param format defines the format of the texture
  10725. * @param generateMipMaps defines if the engine must generate mip levels
  10726. * @param invertY defines if data must be stored with Y axis inverted
  10727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10728. * @param compression defines the compressed used (can be null)
  10729. * @param textureType defines the compressed used (can be null)
  10730. * @returns a new raw 3D texture (stored in an InternalTexture)
  10731. */
  10732. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10733. /**
  10734. * Update a raw 3D texture
  10735. * @param texture defines the texture to update
  10736. * @param data defines the data to store
  10737. * @param format defines the data format
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. */
  10740. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10741. /**
  10742. * Update a raw 3D texture
  10743. * @param texture defines the texture to update
  10744. * @param data defines the data to store
  10745. * @param format defines the data format
  10746. * @param invertY defines if data must be stored with Y axis inverted
  10747. * @param compression defines the used compression (can be null)
  10748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10749. */
  10750. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10751. /**
  10752. * Creates a new raw 2D array texture
  10753. * @param data defines the data used to create the texture
  10754. * @param width defines the width of the texture
  10755. * @param height defines the height of the texture
  10756. * @param depth defines the number of layers of the texture
  10757. * @param format defines the format of the texture
  10758. * @param generateMipMaps defines if the engine must generate mip levels
  10759. * @param invertY defines if data must be stored with Y axis inverted
  10760. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10761. * @param compression defines the compressed used (can be null)
  10762. * @param textureType defines the compressed used (can be null)
  10763. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10764. */
  10765. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10766. /**
  10767. * Update a raw 2D array texture
  10768. * @param texture defines the texture to update
  10769. * @param data defines the data to store
  10770. * @param format defines the data format
  10771. * @param invertY defines if data must be stored with Y axis inverted
  10772. */
  10773. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10774. /**
  10775. * Update a raw 2D array texture
  10776. * @param texture defines the texture to update
  10777. * @param data defines the data to store
  10778. * @param format defines the data format
  10779. * @param invertY defines if data must be stored with Y axis inverted
  10780. * @param compression defines the used compression (can be null)
  10781. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10782. */
  10783. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10784. }
  10785. }
  10786. }
  10787. declare module "babylonjs/Materials/Textures/rawTexture" {
  10788. import { Scene } from "babylonjs/scene";
  10789. import { Texture } from "babylonjs/Materials/Textures/texture";
  10790. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10791. /**
  10792. * Raw texture can help creating a texture directly from an array of data.
  10793. * This can be super useful if you either get the data from an uncompressed source or
  10794. * if you wish to create your texture pixel by pixel.
  10795. */
  10796. export class RawTexture extends Texture {
  10797. /**
  10798. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10799. */
  10800. format: number;
  10801. private _engine;
  10802. /**
  10803. * Instantiates a new RawTexture.
  10804. * Raw texture can help creating a texture directly from an array of data.
  10805. * This can be super useful if you either get the data from an uncompressed source or
  10806. * if you wish to create your texture pixel by pixel.
  10807. * @param data define the array of data to use to create the texture
  10808. * @param width define the width of the texture
  10809. * @param height define the height of the texture
  10810. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10811. * @param scene define the scene the texture belongs to
  10812. * @param generateMipMaps define whether mip maps should be generated or not
  10813. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10814. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10815. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10816. */
  10817. constructor(data: ArrayBufferView, width: number, height: number,
  10818. /**
  10819. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10820. */
  10821. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10822. /**
  10823. * Updates the texture underlying data.
  10824. * @param data Define the new data of the texture
  10825. */
  10826. update(data: ArrayBufferView): void;
  10827. /**
  10828. * Creates a luminance texture from some data.
  10829. * @param data Define the texture data
  10830. * @param width Define the width of the texture
  10831. * @param height Define the height of the texture
  10832. * @param scene Define the scene the texture belongs to
  10833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10836. * @returns the luminance texture
  10837. */
  10838. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10839. /**
  10840. * Creates a luminance alpha texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @returns the luminance alpha texture
  10849. */
  10850. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10851. /**
  10852. * Creates an alpha texture from some data.
  10853. * @param data Define the texture data
  10854. * @param width Define the width of the texture
  10855. * @param height Define the height of the texture
  10856. * @param scene Define the scene the texture belongs to
  10857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10860. * @returns the alpha texture
  10861. */
  10862. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10863. /**
  10864. * Creates a RGB texture from some data.
  10865. * @param data Define the texture data
  10866. * @param width Define the width of the texture
  10867. * @param height Define the height of the texture
  10868. * @param scene Define the scene the texture belongs to
  10869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10872. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10873. * @returns the RGB alpha texture
  10874. */
  10875. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10876. /**
  10877. * Creates a RGBA texture from some data.
  10878. * @param data Define the texture data
  10879. * @param width Define the width of the texture
  10880. * @param height Define the height of the texture
  10881. * @param scene Define the scene the texture belongs to
  10882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10885. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10886. * @returns the RGBA texture
  10887. */
  10888. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10889. /**
  10890. * Creates a R texture from some data.
  10891. * @param data Define the texture data
  10892. * @param width Define the width of the texture
  10893. * @param height Define the height of the texture
  10894. * @param scene Define the scene the texture belongs to
  10895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10898. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10899. * @returns the R texture
  10900. */
  10901. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10902. }
  10903. }
  10904. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10905. import { Scene } from "babylonjs/scene";
  10906. import { ISceneComponent } from "babylonjs/sceneComponent";
  10907. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10908. module "babylonjs/abstractScene" {
  10909. interface AbstractScene {
  10910. /**
  10911. * The list of procedural textures added to the scene
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10913. */
  10914. proceduralTextures: Array<ProceduralTexture>;
  10915. }
  10916. }
  10917. /**
  10918. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10919. * in a given scene.
  10920. */
  10921. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10922. /**
  10923. * The component name helpfull to identify the component in the list of scene components.
  10924. */
  10925. readonly name: string;
  10926. /**
  10927. * The scene the component belongs to.
  10928. */
  10929. scene: Scene;
  10930. /**
  10931. * Creates a new instance of the component for the given scene
  10932. * @param scene Defines the scene to register the component in
  10933. */
  10934. constructor(scene: Scene);
  10935. /**
  10936. * Registers the component in a given scene
  10937. */
  10938. register(): void;
  10939. /**
  10940. * Rebuilds the elements related to this component in case of
  10941. * context lost for instance.
  10942. */
  10943. rebuild(): void;
  10944. /**
  10945. * Disposes the component and the associated ressources.
  10946. */
  10947. dispose(): void;
  10948. private _beforeClear;
  10949. }
  10950. }
  10951. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10953. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10954. module "babylonjs/Engines/thinEngine" {
  10955. interface ThinEngine {
  10956. /**
  10957. * Creates a new render target cube texture
  10958. * @param size defines the size of the texture
  10959. * @param options defines the options used to create the texture
  10960. * @returns a new render target cube texture stored in an InternalTexture
  10961. */
  10962. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10963. }
  10964. }
  10965. }
  10966. declare module "babylonjs/Shaders/procedural.vertex" {
  10967. /** @hidden */
  10968. export var proceduralVertexShader: {
  10969. name: string;
  10970. shader: string;
  10971. };
  10972. }
  10973. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10974. import { Observable } from "babylonjs/Misc/observable";
  10975. import { Nullable } from "babylonjs/types";
  10976. import { Scene } from "babylonjs/scene";
  10977. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10978. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10979. import { Effect } from "babylonjs/Materials/effect";
  10980. import { Texture } from "babylonjs/Materials/Textures/texture";
  10981. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10982. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10983. import "babylonjs/Shaders/procedural.vertex";
  10984. /**
  10985. * 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.
  10986. * This is the base class of any Procedural texture and contains most of the shareable code.
  10987. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10988. */
  10989. export class ProceduralTexture extends Texture {
  10990. isCube: boolean;
  10991. /**
  10992. * Define if the texture is enabled or not (disabled texture will not render)
  10993. */
  10994. isEnabled: boolean;
  10995. /**
  10996. * Define if the texture must be cleared before rendering (default is true)
  10997. */
  10998. autoClear: boolean;
  10999. /**
  11000. * Callback called when the texture is generated
  11001. */
  11002. onGenerated: () => void;
  11003. /**
  11004. * Event raised when the texture is generated
  11005. */
  11006. onGeneratedObservable: Observable<ProceduralTexture>;
  11007. /** @hidden */
  11008. _generateMipMaps: boolean;
  11009. /** @hidden **/
  11010. _effect: Effect;
  11011. /** @hidden */
  11012. _textures: {
  11013. [key: string]: Texture;
  11014. };
  11015. private _size;
  11016. private _currentRefreshId;
  11017. private _frameId;
  11018. private _refreshRate;
  11019. private _vertexBuffers;
  11020. private _indexBuffer;
  11021. private _uniforms;
  11022. private _samplers;
  11023. private _fragment;
  11024. private _floats;
  11025. private _ints;
  11026. private _floatsArrays;
  11027. private _colors3;
  11028. private _colors4;
  11029. private _vectors2;
  11030. private _vectors3;
  11031. private _matrices;
  11032. private _fallbackTexture;
  11033. private _fallbackTextureUsed;
  11034. private _engine;
  11035. private _cachedDefines;
  11036. private _contentUpdateId;
  11037. private _contentData;
  11038. /**
  11039. * Instantiates a new procedural texture.
  11040. * 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.
  11041. * This is the base class of any Procedural texture and contains most of the shareable code.
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11043. * @param name Define the name of the texture
  11044. * @param size Define the size of the texture to create
  11045. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11046. * @param scene Define the scene the texture belongs to
  11047. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11048. * @param generateMipMaps Define if the texture should creates mip maps or not
  11049. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11050. */
  11051. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11052. /**
  11053. * The effect that is created when initializing the post process.
  11054. * @returns The created effect corresponding the the postprocess.
  11055. */
  11056. getEffect(): Effect;
  11057. /**
  11058. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11059. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11060. */
  11061. getContent(): Nullable<ArrayBufferView>;
  11062. private _createIndexBuffer;
  11063. /** @hidden */
  11064. _rebuild(): void;
  11065. /**
  11066. * Resets the texture in order to recreate its associated resources.
  11067. * This can be called in case of context loss
  11068. */
  11069. reset(): void;
  11070. protected _getDefines(): string;
  11071. /**
  11072. * Is the texture ready to be used ? (rendered at least once)
  11073. * @returns true if ready, otherwise, false.
  11074. */
  11075. isReady(): boolean;
  11076. /**
  11077. * Resets the refresh counter of the texture and start bak from scratch.
  11078. * Could be useful to regenerate the texture if it is setup to render only once.
  11079. */
  11080. resetRefreshCounter(): void;
  11081. /**
  11082. * Set the fragment shader to use in order to render the texture.
  11083. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11084. */
  11085. setFragment(fragment: any): void;
  11086. /**
  11087. * Define the refresh rate of the texture or the rendering frequency.
  11088. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11089. */
  11090. get refreshRate(): number;
  11091. set refreshRate(value: number);
  11092. /** @hidden */
  11093. _shouldRender(): boolean;
  11094. /**
  11095. * Get the size the texture is rendering at.
  11096. * @returns the size (texture is always squared)
  11097. */
  11098. getRenderSize(): number;
  11099. /**
  11100. * Resize the texture to new value.
  11101. * @param size Define the new size the texture should have
  11102. * @param generateMipMaps Define whether the new texture should create mip maps
  11103. */
  11104. resize(size: number, generateMipMaps: boolean): void;
  11105. private _checkUniform;
  11106. /**
  11107. * Set a texture in the shader program used to render.
  11108. * @param name Define the name of the uniform samplers as defined in the shader
  11109. * @param texture Define the texture to bind to this sampler
  11110. * @return the texture itself allowing "fluent" like uniform updates
  11111. */
  11112. setTexture(name: string, texture: Texture): ProceduralTexture;
  11113. /**
  11114. * Set a float in the shader.
  11115. * @param name Define the name of the uniform as defined in the shader
  11116. * @param value Define the value to give to the uniform
  11117. * @return the texture itself allowing "fluent" like uniform updates
  11118. */
  11119. setFloat(name: string, value: number): ProceduralTexture;
  11120. /**
  11121. * Set a int in the shader.
  11122. * @param name Define the name of the uniform as defined in the shader
  11123. * @param value Define the value to give to the uniform
  11124. * @return the texture itself allowing "fluent" like uniform updates
  11125. */
  11126. setInt(name: string, value: number): ProceduralTexture;
  11127. /**
  11128. * Set an array of floats in the shader.
  11129. * @param name Define the name of the uniform as defined in the shader
  11130. * @param value Define the value to give to the uniform
  11131. * @return the texture itself allowing "fluent" like uniform updates
  11132. */
  11133. setFloats(name: string, value: number[]): ProceduralTexture;
  11134. /**
  11135. * Set a vec3 in the shader from a Color3.
  11136. * @param name Define the name of the uniform as defined in the shader
  11137. * @param value Define the value to give to the uniform
  11138. * @return the texture itself allowing "fluent" like uniform updates
  11139. */
  11140. setColor3(name: string, value: Color3): ProceduralTexture;
  11141. /**
  11142. * Set a vec4 in the shader from a Color4.
  11143. * @param name Define the name of the uniform as defined in the shader
  11144. * @param value Define the value to give to the uniform
  11145. * @return the texture itself allowing "fluent" like uniform updates
  11146. */
  11147. setColor4(name: string, value: Color4): ProceduralTexture;
  11148. /**
  11149. * Set a vec2 in the shader from a Vector2.
  11150. * @param name Define the name of the uniform as defined in the shader
  11151. * @param value Define the value to give to the uniform
  11152. * @return the texture itself allowing "fluent" like uniform updates
  11153. */
  11154. setVector2(name: string, value: Vector2): ProceduralTexture;
  11155. /**
  11156. * Set a vec3 in the shader from a Vector3.
  11157. * @param name Define the name of the uniform as defined in the shader
  11158. * @param value Define the value to give to the uniform
  11159. * @return the texture itself allowing "fluent" like uniform updates
  11160. */
  11161. setVector3(name: string, value: Vector3): ProceduralTexture;
  11162. /**
  11163. * Set a mat4 in the shader from a MAtrix.
  11164. * @param name Define the name of the uniform as defined in the shader
  11165. * @param value Define the value to give to the uniform
  11166. * @return the texture itself allowing "fluent" like uniform updates
  11167. */
  11168. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11169. /**
  11170. * Render the texture to its associated render target.
  11171. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11172. */
  11173. render(useCameraPostProcess?: boolean): void;
  11174. /**
  11175. * Clone the texture.
  11176. * @returns the cloned texture
  11177. */
  11178. clone(): ProceduralTexture;
  11179. /**
  11180. * Dispose the texture and release its asoociated resources.
  11181. */
  11182. dispose(): void;
  11183. }
  11184. }
  11185. declare module "babylonjs/Particles/baseParticleSystem" {
  11186. import { Nullable } from "babylonjs/types";
  11187. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11189. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11190. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11191. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11192. import { Scene } from "babylonjs/scene";
  11193. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11194. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11195. import { Texture } from "babylonjs/Materials/Textures/texture";
  11196. import { Color4 } from "babylonjs/Maths/math.color";
  11197. import { Animation } from "babylonjs/Animations/animation";
  11198. /**
  11199. * This represents the base class for particle system in Babylon.
  11200. * 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.
  11201. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11202. * @example https://doc.babylonjs.com/babylon101/particles
  11203. */
  11204. export class BaseParticleSystem {
  11205. /**
  11206. * Source color is added to the destination color without alpha affecting the result
  11207. */
  11208. static BLENDMODE_ONEONE: number;
  11209. /**
  11210. * Blend current color and particle color using particle’s alpha
  11211. */
  11212. static BLENDMODE_STANDARD: number;
  11213. /**
  11214. * Add current color and particle color multiplied by particle’s alpha
  11215. */
  11216. static BLENDMODE_ADD: number;
  11217. /**
  11218. * Multiply current color with particle color
  11219. */
  11220. static BLENDMODE_MULTIPLY: number;
  11221. /**
  11222. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11223. */
  11224. static BLENDMODE_MULTIPLYADD: number;
  11225. /**
  11226. * List of animations used by the particle system.
  11227. */
  11228. animations: Animation[];
  11229. /**
  11230. * The id of the Particle system.
  11231. */
  11232. id: string;
  11233. /**
  11234. * The friendly name of the Particle system.
  11235. */
  11236. name: string;
  11237. /**
  11238. * The rendering group used by the Particle system to chose when to render.
  11239. */
  11240. renderingGroupId: number;
  11241. /**
  11242. * The emitter represents the Mesh or position we are attaching the particle system to.
  11243. */
  11244. emitter: Nullable<AbstractMesh | Vector3>;
  11245. /**
  11246. * The maximum number of particles to emit per frame
  11247. */
  11248. emitRate: number;
  11249. /**
  11250. * If you want to launch only a few particles at once, that can be done, as well.
  11251. */
  11252. manualEmitCount: number;
  11253. /**
  11254. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11255. */
  11256. updateSpeed: number;
  11257. /**
  11258. * The amount of time the particle system is running (depends of the overall update speed).
  11259. */
  11260. targetStopDuration: number;
  11261. /**
  11262. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11263. */
  11264. disposeOnStop: boolean;
  11265. /**
  11266. * Minimum power of emitting particles.
  11267. */
  11268. minEmitPower: number;
  11269. /**
  11270. * Maximum power of emitting particles.
  11271. */
  11272. maxEmitPower: number;
  11273. /**
  11274. * Minimum life time of emitting particles.
  11275. */
  11276. minLifeTime: number;
  11277. /**
  11278. * Maximum life time of emitting particles.
  11279. */
  11280. maxLifeTime: number;
  11281. /**
  11282. * Minimum Size of emitting particles.
  11283. */
  11284. minSize: number;
  11285. /**
  11286. * Maximum Size of emitting particles.
  11287. */
  11288. maxSize: number;
  11289. /**
  11290. * Minimum scale of emitting particles on X axis.
  11291. */
  11292. minScaleX: number;
  11293. /**
  11294. * Maximum scale of emitting particles on X axis.
  11295. */
  11296. maxScaleX: number;
  11297. /**
  11298. * Minimum scale of emitting particles on Y axis.
  11299. */
  11300. minScaleY: number;
  11301. /**
  11302. * Maximum scale of emitting particles on Y axis.
  11303. */
  11304. maxScaleY: number;
  11305. /**
  11306. * Gets or sets the minimal initial rotation in radians.
  11307. */
  11308. minInitialRotation: number;
  11309. /**
  11310. * Gets or sets the maximal initial rotation in radians.
  11311. */
  11312. maxInitialRotation: number;
  11313. /**
  11314. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11315. */
  11316. minAngularSpeed: number;
  11317. /**
  11318. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11319. */
  11320. maxAngularSpeed: number;
  11321. /**
  11322. * The texture used to render each particle. (this can be a spritesheet)
  11323. */
  11324. particleTexture: Nullable<Texture>;
  11325. /**
  11326. * The layer mask we are rendering the particles through.
  11327. */
  11328. layerMask: number;
  11329. /**
  11330. * This can help using your own shader to render the particle system.
  11331. * The according effect will be created
  11332. */
  11333. customShader: any;
  11334. /**
  11335. * By default particle system starts as soon as they are created. This prevents the
  11336. * automatic start to happen and let you decide when to start emitting particles.
  11337. */
  11338. preventAutoStart: boolean;
  11339. private _noiseTexture;
  11340. /**
  11341. * Gets or sets a texture used to add random noise to particle positions
  11342. */
  11343. get noiseTexture(): Nullable<ProceduralTexture>;
  11344. set noiseTexture(value: Nullable<ProceduralTexture>);
  11345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11346. noiseStrength: Vector3;
  11347. /**
  11348. * Callback triggered when the particle animation is ending.
  11349. */
  11350. onAnimationEnd: Nullable<() => void>;
  11351. /**
  11352. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11353. */
  11354. blendMode: number;
  11355. /**
  11356. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11357. * to override the particles.
  11358. */
  11359. forceDepthWrite: boolean;
  11360. /** 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 */
  11361. preWarmCycles: number;
  11362. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11363. preWarmStepOffset: number;
  11364. /**
  11365. * 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)
  11366. */
  11367. spriteCellChangeSpeed: number;
  11368. /**
  11369. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11370. */
  11371. startSpriteCellID: number;
  11372. /**
  11373. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11374. */
  11375. endSpriteCellID: number;
  11376. /**
  11377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11378. */
  11379. spriteCellWidth: number;
  11380. /**
  11381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11382. */
  11383. spriteCellHeight: number;
  11384. /**
  11385. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11386. */
  11387. spriteRandomStartCell: boolean;
  11388. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11389. translationPivot: Vector2;
  11390. /** @hidden */
  11391. protected _isAnimationSheetEnabled: boolean;
  11392. /**
  11393. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11394. */
  11395. beginAnimationOnStart: boolean;
  11396. /**
  11397. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11398. */
  11399. beginAnimationFrom: number;
  11400. /**
  11401. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11402. */
  11403. beginAnimationTo: number;
  11404. /**
  11405. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11406. */
  11407. beginAnimationLoop: boolean;
  11408. /**
  11409. * Gets or sets a world offset applied to all particles
  11410. */
  11411. worldOffset: Vector3;
  11412. /**
  11413. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11414. */
  11415. get isAnimationSheetEnabled(): boolean;
  11416. set isAnimationSheetEnabled(value: boolean);
  11417. /**
  11418. * Get hosting scene
  11419. * @returns the scene
  11420. */
  11421. getScene(): Scene;
  11422. /**
  11423. * You can use gravity if you want to give an orientation to your particles.
  11424. */
  11425. gravity: Vector3;
  11426. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11427. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11428. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11429. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11430. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11431. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11432. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11433. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11434. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11435. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11436. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11437. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11438. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11439. /**
  11440. * Defines the delay in milliseconds before starting the system (0 by default)
  11441. */
  11442. startDelay: number;
  11443. /**
  11444. * Gets the current list of drag gradients.
  11445. * You must use addDragGradient and removeDragGradient to udpate this list
  11446. * @returns the list of drag gradients
  11447. */
  11448. getDragGradients(): Nullable<Array<FactorGradient>>;
  11449. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11450. limitVelocityDamping: number;
  11451. /**
  11452. * Gets the current list of limit velocity gradients.
  11453. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11454. * @returns the list of limit velocity gradients
  11455. */
  11456. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11457. /**
  11458. * Gets the current list of color gradients.
  11459. * You must use addColorGradient and removeColorGradient to udpate this list
  11460. * @returns the list of color gradients
  11461. */
  11462. getColorGradients(): Nullable<Array<ColorGradient>>;
  11463. /**
  11464. * Gets the current list of size gradients.
  11465. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11466. * @returns the list of size gradients
  11467. */
  11468. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11469. /**
  11470. * Gets the current list of color remap gradients.
  11471. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11472. * @returns the list of color remap gradients
  11473. */
  11474. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11475. /**
  11476. * Gets the current list of alpha remap gradients.
  11477. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11478. * @returns the list of alpha remap gradients
  11479. */
  11480. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11481. /**
  11482. * Gets the current list of life time gradients.
  11483. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11484. * @returns the list of life time gradients
  11485. */
  11486. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11487. /**
  11488. * Gets the current list of angular speed gradients.
  11489. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11490. * @returns the list of angular speed gradients
  11491. */
  11492. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11493. /**
  11494. * Gets the current list of velocity gradients.
  11495. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11496. * @returns the list of velocity gradients
  11497. */
  11498. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11499. /**
  11500. * Gets the current list of start size gradients.
  11501. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11502. * @returns the list of start size gradients
  11503. */
  11504. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11505. /**
  11506. * Gets the current list of emit rate gradients.
  11507. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11508. * @returns the list of emit rate gradients
  11509. */
  11510. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11511. /**
  11512. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11513. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11514. */
  11515. get direction1(): Vector3;
  11516. set direction1(value: Vector3);
  11517. /**
  11518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11520. */
  11521. get direction2(): Vector3;
  11522. set direction2(value: Vector3);
  11523. /**
  11524. * 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.
  11525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11526. */
  11527. get minEmitBox(): Vector3;
  11528. set minEmitBox(value: Vector3);
  11529. /**
  11530. * 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.
  11531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11532. */
  11533. get maxEmitBox(): Vector3;
  11534. set maxEmitBox(value: Vector3);
  11535. /**
  11536. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11537. */
  11538. color1: Color4;
  11539. /**
  11540. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11541. */
  11542. color2: Color4;
  11543. /**
  11544. * Color the particle will have at the end of its lifetime
  11545. */
  11546. colorDead: Color4;
  11547. /**
  11548. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11549. */
  11550. textureMask: Color4;
  11551. /**
  11552. * The particle emitter type defines the emitter used by the particle system.
  11553. * It can be for example box, sphere, or cone...
  11554. */
  11555. particleEmitterType: IParticleEmitterType;
  11556. /** @hidden */
  11557. _isSubEmitter: boolean;
  11558. /**
  11559. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11560. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11561. */
  11562. billboardMode: number;
  11563. protected _isBillboardBased: boolean;
  11564. /**
  11565. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11566. */
  11567. get isBillboardBased(): boolean;
  11568. set isBillboardBased(value: boolean);
  11569. /**
  11570. * The scene the particle system belongs to.
  11571. */
  11572. protected _scene: Scene;
  11573. /**
  11574. * Local cache of defines for image processing.
  11575. */
  11576. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11577. /**
  11578. * Default configuration related to image processing available in the standard Material.
  11579. */
  11580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11581. /**
  11582. * Gets the image processing configuration used either in this material.
  11583. */
  11584. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11585. /**
  11586. * Sets the Default image processing configuration used either in the this material.
  11587. *
  11588. * If sets to null, the scene one is in use.
  11589. */
  11590. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11591. /**
  11592. * Attaches a new image processing configuration to the Standard Material.
  11593. * @param configuration
  11594. */
  11595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11596. /** @hidden */
  11597. protected _reset(): void;
  11598. /** @hidden */
  11599. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11600. /**
  11601. * Instantiates a particle system.
  11602. * 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.
  11603. * @param name The name of the particle system
  11604. */
  11605. constructor(name: string);
  11606. /**
  11607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11610. * @returns the emitter
  11611. */
  11612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11613. /**
  11614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11615. * @param radius The radius of the hemisphere to emit from
  11616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11617. * @returns the emitter
  11618. */
  11619. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11620. /**
  11621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11622. * @param radius The radius of the sphere to emit from
  11623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11624. * @returns the emitter
  11625. */
  11626. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11627. /**
  11628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11629. * @param radius The radius of the sphere to emit from
  11630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11632. * @returns the emitter
  11633. */
  11634. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11635. /**
  11636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11637. * @param radius The radius of the emission cylinder
  11638. * @param height The height of the emission cylinder
  11639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11641. * @returns the emitter
  11642. */
  11643. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11644. /**
  11645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11646. * @param radius The radius of the cylinder to emit from
  11647. * @param height The height of the emission cylinder
  11648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11651. * @returns the emitter
  11652. */
  11653. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11654. /**
  11655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11656. * @param radius The radius of the cone to emit from
  11657. * @param angle The base angle of the cone
  11658. * @returns the emitter
  11659. */
  11660. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11661. /**
  11662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11667. * @returns the emitter
  11668. */
  11669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11670. }
  11671. }
  11672. declare module "babylonjs/Particles/subEmitter" {
  11673. import { Scene } from "babylonjs/scene";
  11674. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11675. /**
  11676. * Type of sub emitter
  11677. */
  11678. export enum SubEmitterType {
  11679. /**
  11680. * Attached to the particle over it's lifetime
  11681. */
  11682. ATTACHED = 0,
  11683. /**
  11684. * Created when the particle dies
  11685. */
  11686. END = 1
  11687. }
  11688. /**
  11689. * Sub emitter class used to emit particles from an existing particle
  11690. */
  11691. export class SubEmitter {
  11692. /**
  11693. * the particle system to be used by the sub emitter
  11694. */
  11695. particleSystem: ParticleSystem;
  11696. /**
  11697. * Type of the submitter (Default: END)
  11698. */
  11699. type: SubEmitterType;
  11700. /**
  11701. * 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)
  11702. * Note: This only is supported when using an emitter of type Mesh
  11703. */
  11704. inheritDirection: boolean;
  11705. /**
  11706. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11707. */
  11708. inheritedVelocityAmount: number;
  11709. /**
  11710. * Creates a sub emitter
  11711. * @param particleSystem the particle system to be used by the sub emitter
  11712. */
  11713. constructor(
  11714. /**
  11715. * the particle system to be used by the sub emitter
  11716. */
  11717. particleSystem: ParticleSystem);
  11718. /**
  11719. * Clones the sub emitter
  11720. * @returns the cloned sub emitter
  11721. */
  11722. clone(): SubEmitter;
  11723. /**
  11724. * Serialize current object to a JSON object
  11725. * @returns the serialized object
  11726. */
  11727. serialize(): any;
  11728. /** @hidden */
  11729. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11730. /**
  11731. * Creates a new SubEmitter from a serialized JSON version
  11732. * @param serializationObject defines the JSON object to read from
  11733. * @param scene defines the hosting scene
  11734. * @param rootUrl defines the rootUrl for data loading
  11735. * @returns a new SubEmitter
  11736. */
  11737. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11738. /** Release associated resources */
  11739. dispose(): void;
  11740. }
  11741. }
  11742. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11743. /** @hidden */
  11744. export var imageProcessingDeclaration: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11750. /** @hidden */
  11751. export var imageProcessingFunctions: {
  11752. name: string;
  11753. shader: string;
  11754. };
  11755. }
  11756. declare module "babylonjs/Shaders/particles.fragment" {
  11757. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11758. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11759. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11760. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11761. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11762. /** @hidden */
  11763. export var particlesPixelShader: {
  11764. name: string;
  11765. shader: string;
  11766. };
  11767. }
  11768. declare module "babylonjs/Shaders/particles.vertex" {
  11769. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11770. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11771. /** @hidden */
  11772. export var particlesVertexShader: {
  11773. name: string;
  11774. shader: string;
  11775. };
  11776. }
  11777. declare module "babylonjs/Particles/particleSystem" {
  11778. import { Nullable } from "babylonjs/types";
  11779. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11780. import { Observable } from "babylonjs/Misc/observable";
  11781. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11782. import { Effect } from "babylonjs/Materials/effect";
  11783. import { Scene, IDisposable } from "babylonjs/scene";
  11784. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11785. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11786. import { Particle } from "babylonjs/Particles/particle";
  11787. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11788. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11789. import "babylonjs/Shaders/particles.fragment";
  11790. import "babylonjs/Shaders/particles.vertex";
  11791. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11792. /**
  11793. * This represents a particle system in Babylon.
  11794. * 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.
  11795. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11796. * @example https://doc.babylonjs.com/babylon101/particles
  11797. */
  11798. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11799. /**
  11800. * Billboard mode will only apply to Y axis
  11801. */
  11802. static readonly BILLBOARDMODE_Y: number;
  11803. /**
  11804. * Billboard mode will apply to all axes
  11805. */
  11806. static readonly BILLBOARDMODE_ALL: number;
  11807. /**
  11808. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11809. */
  11810. static readonly BILLBOARDMODE_STRETCHED: number;
  11811. /**
  11812. * This function can be defined to provide custom update for active particles.
  11813. * This function will be called instead of regular update (age, position, color, etc.).
  11814. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11815. */
  11816. updateFunction: (particles: Particle[]) => void;
  11817. private _emitterWorldMatrix;
  11818. /**
  11819. * This function can be defined to specify initial direction for every new particle.
  11820. * It by default use the emitterType defined function
  11821. */
  11822. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11823. /**
  11824. * This function can be defined to specify initial position for every new particle.
  11825. * It by default use the emitterType defined function
  11826. */
  11827. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11828. /**
  11829. * @hidden
  11830. */
  11831. _inheritedVelocityOffset: Vector3;
  11832. /**
  11833. * An event triggered when the system is disposed
  11834. */
  11835. onDisposeObservable: Observable<ParticleSystem>;
  11836. private _onDisposeObserver;
  11837. /**
  11838. * Sets a callback that will be triggered when the system is disposed
  11839. */
  11840. set onDispose(callback: () => void);
  11841. private _particles;
  11842. private _epsilon;
  11843. private _capacity;
  11844. private _stockParticles;
  11845. private _newPartsExcess;
  11846. private _vertexData;
  11847. private _vertexBuffer;
  11848. private _vertexBuffers;
  11849. private _spriteBuffer;
  11850. private _indexBuffer;
  11851. private _effect;
  11852. private _customEffect;
  11853. private _cachedDefines;
  11854. private _scaledColorStep;
  11855. private _colorDiff;
  11856. private _scaledDirection;
  11857. private _scaledGravity;
  11858. private _currentRenderId;
  11859. private _alive;
  11860. private _useInstancing;
  11861. private _started;
  11862. private _stopped;
  11863. private _actualFrame;
  11864. private _scaledUpdateSpeed;
  11865. private _vertexBufferSize;
  11866. /** @hidden */
  11867. _currentEmitRateGradient: Nullable<FactorGradient>;
  11868. /** @hidden */
  11869. _currentEmitRate1: number;
  11870. /** @hidden */
  11871. _currentEmitRate2: number;
  11872. /** @hidden */
  11873. _currentStartSizeGradient: Nullable<FactorGradient>;
  11874. /** @hidden */
  11875. _currentStartSize1: number;
  11876. /** @hidden */
  11877. _currentStartSize2: number;
  11878. private readonly _rawTextureWidth;
  11879. private _rampGradientsTexture;
  11880. private _useRampGradients;
  11881. /** Gets or sets a boolean indicating that ramp gradients must be used
  11882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11883. */
  11884. get useRampGradients(): boolean;
  11885. set useRampGradients(value: boolean);
  11886. /**
  11887. * 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.
  11888. * 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: [])
  11889. */
  11890. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11891. private _subEmitters;
  11892. /**
  11893. * @hidden
  11894. * If the particle systems emitter should be disposed when the particle system is disposed
  11895. */
  11896. _disposeEmitterOnDispose: boolean;
  11897. /**
  11898. * The current active Sub-systems, this property is used by the root particle system only.
  11899. */
  11900. activeSubSystems: Array<ParticleSystem>;
  11901. /**
  11902. * Specifies if the particles are updated in emitter local space or world space
  11903. */
  11904. isLocal: boolean;
  11905. private _rootParticleSystem;
  11906. /**
  11907. * Gets the current list of active particles
  11908. */
  11909. get particles(): Particle[];
  11910. /**
  11911. * Returns the string "ParticleSystem"
  11912. * @returns a string containing the class name
  11913. */
  11914. getClassName(): string;
  11915. /**
  11916. * Instantiates a particle system.
  11917. * 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.
  11918. * @param name The name of the particle system
  11919. * @param capacity The max number of particles alive at the same time
  11920. * @param scene The scene the particle system belongs to
  11921. * @param customEffect a custom effect used to change the way particles are rendered by default
  11922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11923. * @param epsilon Offset used to render the particles
  11924. */
  11925. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11926. private _addFactorGradient;
  11927. private _removeFactorGradient;
  11928. /**
  11929. * Adds a new life time gradient
  11930. * @param gradient defines the gradient to use (between 0 and 1)
  11931. * @param factor defines the life time factor to affect to the specified gradient
  11932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11933. * @returns the current particle system
  11934. */
  11935. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11936. /**
  11937. * Remove a specific life time gradient
  11938. * @param gradient defines the gradient to remove
  11939. * @returns the current particle system
  11940. */
  11941. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11942. /**
  11943. * Adds a new size gradient
  11944. * @param gradient defines the gradient to use (between 0 and 1)
  11945. * @param factor defines the size factor to affect to the specified gradient
  11946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11947. * @returns the current particle system
  11948. */
  11949. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11950. /**
  11951. * Remove a specific size gradient
  11952. * @param gradient defines the gradient to remove
  11953. * @returns the current particle system
  11954. */
  11955. removeSizeGradient(gradient: number): IParticleSystem;
  11956. /**
  11957. * Adds a new color remap gradient
  11958. * @param gradient defines the gradient to use (between 0 and 1)
  11959. * @param min defines the color remap minimal range
  11960. * @param max defines the color remap maximal range
  11961. * @returns the current particle system
  11962. */
  11963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11964. /**
  11965. * Remove a specific color remap gradient
  11966. * @param gradient defines the gradient to remove
  11967. * @returns the current particle system
  11968. */
  11969. removeColorRemapGradient(gradient: number): IParticleSystem;
  11970. /**
  11971. * Adds a new alpha remap gradient
  11972. * @param gradient defines the gradient to use (between 0 and 1)
  11973. * @param min defines the alpha remap minimal range
  11974. * @param max defines the alpha remap maximal range
  11975. * @returns the current particle system
  11976. */
  11977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11978. /**
  11979. * Remove a specific alpha remap gradient
  11980. * @param gradient defines the gradient to remove
  11981. * @returns the current particle system
  11982. */
  11983. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11984. /**
  11985. * Adds a new angular speed gradient
  11986. * @param gradient defines the gradient to use (between 0 and 1)
  11987. * @param factor defines the angular speed to affect to the specified gradient
  11988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11989. * @returns the current particle system
  11990. */
  11991. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11992. /**
  11993. * Remove a specific angular speed gradient
  11994. * @param gradient defines the gradient to remove
  11995. * @returns the current particle system
  11996. */
  11997. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11998. /**
  11999. * Adds a new velocity gradient
  12000. * @param gradient defines the gradient to use (between 0 and 1)
  12001. * @param factor defines the velocity to affect to the specified gradient
  12002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12003. * @returns the current particle system
  12004. */
  12005. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12006. /**
  12007. * Remove a specific velocity gradient
  12008. * @param gradient defines the gradient to remove
  12009. * @returns the current particle system
  12010. */
  12011. removeVelocityGradient(gradient: number): IParticleSystem;
  12012. /**
  12013. * Adds a new limit velocity gradient
  12014. * @param gradient defines the gradient to use (between 0 and 1)
  12015. * @param factor defines the limit velocity value to affect to the specified gradient
  12016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12017. * @returns the current particle system
  12018. */
  12019. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12020. /**
  12021. * Remove a specific limit velocity gradient
  12022. * @param gradient defines the gradient to remove
  12023. * @returns the current particle system
  12024. */
  12025. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12026. /**
  12027. * Adds a new drag gradient
  12028. * @param gradient defines the gradient to use (between 0 and 1)
  12029. * @param factor defines the drag value to affect to the specified gradient
  12030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12031. * @returns the current particle system
  12032. */
  12033. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12034. /**
  12035. * Remove a specific drag gradient
  12036. * @param gradient defines the gradient to remove
  12037. * @returns the current particle system
  12038. */
  12039. removeDragGradient(gradient: number): IParticleSystem;
  12040. /**
  12041. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12042. * @param gradient defines the gradient to use (between 0 and 1)
  12043. * @param factor defines the emit rate value to affect to the specified gradient
  12044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12045. * @returns the current particle system
  12046. */
  12047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12048. /**
  12049. * Remove a specific emit rate gradient
  12050. * @param gradient defines the gradient to remove
  12051. * @returns the current particle system
  12052. */
  12053. removeEmitRateGradient(gradient: number): IParticleSystem;
  12054. /**
  12055. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12056. * @param gradient defines the gradient to use (between 0 and 1)
  12057. * @param factor defines the start size value to affect to the specified gradient
  12058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12059. * @returns the current particle system
  12060. */
  12061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12062. /**
  12063. * Remove a specific start size gradient
  12064. * @param gradient defines the gradient to remove
  12065. * @returns the current particle system
  12066. */
  12067. removeStartSizeGradient(gradient: number): IParticleSystem;
  12068. private _createRampGradientTexture;
  12069. /**
  12070. * Gets the current list of ramp gradients.
  12071. * You must use addRampGradient and removeRampGradient to udpate this list
  12072. * @returns the list of ramp gradients
  12073. */
  12074. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12075. /**
  12076. * Adds a new ramp gradient used to remap particle colors
  12077. * @param gradient defines the gradient to use (between 0 and 1)
  12078. * @param color defines the color to affect to the specified gradient
  12079. * @returns the current particle system
  12080. */
  12081. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12082. /**
  12083. * Remove a specific ramp gradient
  12084. * @param gradient defines the gradient to remove
  12085. * @returns the current particle system
  12086. */
  12087. removeRampGradient(gradient: number): ParticleSystem;
  12088. /**
  12089. * Adds a new color gradient
  12090. * @param gradient defines the gradient to use (between 0 and 1)
  12091. * @param color1 defines the color to affect to the specified gradient
  12092. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12093. * @returns this particle system
  12094. */
  12095. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12096. /**
  12097. * Remove a specific color gradient
  12098. * @param gradient defines the gradient to remove
  12099. * @returns this particle system
  12100. */
  12101. removeColorGradient(gradient: number): IParticleSystem;
  12102. private _fetchR;
  12103. protected _reset(): void;
  12104. private _resetEffect;
  12105. private _createVertexBuffers;
  12106. private _createIndexBuffer;
  12107. /**
  12108. * Gets the maximum number of particles active at the same time.
  12109. * @returns The max number of active particles.
  12110. */
  12111. getCapacity(): number;
  12112. /**
  12113. * Gets whether there are still active particles in the system.
  12114. * @returns True if it is alive, otherwise false.
  12115. */
  12116. isAlive(): boolean;
  12117. /**
  12118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12119. * @returns True if it has been started, otherwise false.
  12120. */
  12121. isStarted(): boolean;
  12122. private _prepareSubEmitterInternalArray;
  12123. /**
  12124. * Starts the particle system and begins to emit
  12125. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12126. */
  12127. start(delay?: number): void;
  12128. /**
  12129. * Stops the particle system.
  12130. * @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.
  12131. */
  12132. stop(stopSubEmitters?: boolean): void;
  12133. /**
  12134. * Remove all active particles
  12135. */
  12136. reset(): void;
  12137. /**
  12138. * @hidden (for internal use only)
  12139. */
  12140. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12141. /**
  12142. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12143. * Its lifetime will start back at 0.
  12144. */
  12145. recycleParticle: (particle: Particle) => void;
  12146. private _stopSubEmitters;
  12147. private _createParticle;
  12148. private _removeFromRoot;
  12149. private _emitFromParticle;
  12150. private _update;
  12151. /** @hidden */
  12152. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12153. /** @hidden */
  12154. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12155. /** @hidden */
  12156. private _getEffect;
  12157. /**
  12158. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12159. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12160. */
  12161. animate(preWarmOnly?: boolean): void;
  12162. private _appendParticleVertices;
  12163. /**
  12164. * Rebuilds the particle system.
  12165. */
  12166. rebuild(): void;
  12167. /**
  12168. * Is this system ready to be used/rendered
  12169. * @return true if the system is ready
  12170. */
  12171. isReady(): boolean;
  12172. private _render;
  12173. /**
  12174. * Renders the particle system in its current state.
  12175. * @returns the current number of particles
  12176. */
  12177. render(): number;
  12178. /**
  12179. * Disposes the particle system and free the associated resources
  12180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12181. */
  12182. dispose(disposeTexture?: boolean): void;
  12183. /**
  12184. * Clones the particle system.
  12185. * @param name The name of the cloned object
  12186. * @param newEmitter The new emitter to use
  12187. * @returns the cloned particle system
  12188. */
  12189. clone(name: string, newEmitter: any): ParticleSystem;
  12190. /**
  12191. * Serializes the particle system to a JSON object.
  12192. * @returns the JSON object
  12193. */
  12194. serialize(): any;
  12195. /** @hidden */
  12196. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12197. /** @hidden */
  12198. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12199. /**
  12200. * Parses a JSON object to create a particle system.
  12201. * @param parsedParticleSystem The JSON object to parse
  12202. * @param scene The scene to create the particle system in
  12203. * @param rootUrl The root url to use to load external dependencies like texture
  12204. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12205. * @returns the Parsed particle system
  12206. */
  12207. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12208. }
  12209. }
  12210. declare module "babylonjs/Particles/particle" {
  12211. import { Nullable } from "babylonjs/types";
  12212. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12213. import { Color4 } from "babylonjs/Maths/math.color";
  12214. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12215. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12216. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12217. /**
  12218. * A particle represents one of the element emitted by a particle system.
  12219. * This is mainly define by its coordinates, direction, velocity and age.
  12220. */
  12221. export class Particle {
  12222. /**
  12223. * The particle system the particle belongs to.
  12224. */
  12225. particleSystem: ParticleSystem;
  12226. private static _Count;
  12227. /**
  12228. * Unique ID of the particle
  12229. */
  12230. id: number;
  12231. /**
  12232. * The world position of the particle in the scene.
  12233. */
  12234. position: Vector3;
  12235. /**
  12236. * The world direction of the particle in the scene.
  12237. */
  12238. direction: Vector3;
  12239. /**
  12240. * The color of the particle.
  12241. */
  12242. color: Color4;
  12243. /**
  12244. * The color change of the particle per step.
  12245. */
  12246. colorStep: Color4;
  12247. /**
  12248. * Defines how long will the life of the particle be.
  12249. */
  12250. lifeTime: number;
  12251. /**
  12252. * The current age of the particle.
  12253. */
  12254. age: number;
  12255. /**
  12256. * The current size of the particle.
  12257. */
  12258. size: number;
  12259. /**
  12260. * The current scale of the particle.
  12261. */
  12262. scale: Vector2;
  12263. /**
  12264. * The current angle of the particle.
  12265. */
  12266. angle: number;
  12267. /**
  12268. * Defines how fast is the angle changing.
  12269. */
  12270. angularSpeed: number;
  12271. /**
  12272. * Defines the cell index used by the particle to be rendered from a sprite.
  12273. */
  12274. cellIndex: number;
  12275. /**
  12276. * The information required to support color remapping
  12277. */
  12278. remapData: Vector4;
  12279. /** @hidden */
  12280. _randomCellOffset?: number;
  12281. /** @hidden */
  12282. _initialDirection: Nullable<Vector3>;
  12283. /** @hidden */
  12284. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12285. /** @hidden */
  12286. _initialStartSpriteCellID: number;
  12287. /** @hidden */
  12288. _initialEndSpriteCellID: number;
  12289. /** @hidden */
  12290. _currentColorGradient: Nullable<ColorGradient>;
  12291. /** @hidden */
  12292. _currentColor1: Color4;
  12293. /** @hidden */
  12294. _currentColor2: Color4;
  12295. /** @hidden */
  12296. _currentSizeGradient: Nullable<FactorGradient>;
  12297. /** @hidden */
  12298. _currentSize1: number;
  12299. /** @hidden */
  12300. _currentSize2: number;
  12301. /** @hidden */
  12302. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12303. /** @hidden */
  12304. _currentAngularSpeed1: number;
  12305. /** @hidden */
  12306. _currentAngularSpeed2: number;
  12307. /** @hidden */
  12308. _currentVelocityGradient: Nullable<FactorGradient>;
  12309. /** @hidden */
  12310. _currentVelocity1: number;
  12311. /** @hidden */
  12312. _currentVelocity2: number;
  12313. /** @hidden */
  12314. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12315. /** @hidden */
  12316. _currentLimitVelocity1: number;
  12317. /** @hidden */
  12318. _currentLimitVelocity2: number;
  12319. /** @hidden */
  12320. _currentDragGradient: Nullable<FactorGradient>;
  12321. /** @hidden */
  12322. _currentDrag1: number;
  12323. /** @hidden */
  12324. _currentDrag2: number;
  12325. /** @hidden */
  12326. _randomNoiseCoordinates1: Vector3;
  12327. /** @hidden */
  12328. _randomNoiseCoordinates2: Vector3;
  12329. /** @hidden */
  12330. _localPosition?: Vector3;
  12331. /**
  12332. * Creates a new instance Particle
  12333. * @param particleSystem the particle system the particle belongs to
  12334. */
  12335. constructor(
  12336. /**
  12337. * The particle system the particle belongs to.
  12338. */
  12339. particleSystem: ParticleSystem);
  12340. private updateCellInfoFromSystem;
  12341. /**
  12342. * Defines how the sprite cell index is updated for the particle
  12343. */
  12344. updateCellIndex(): void;
  12345. /** @hidden */
  12346. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12347. /** @hidden */
  12348. _inheritParticleInfoToSubEmitters(): void;
  12349. /** @hidden */
  12350. _reset(): void;
  12351. /**
  12352. * Copy the properties of particle to another one.
  12353. * @param other the particle to copy the information to.
  12354. */
  12355. copyTo(other: Particle): void;
  12356. }
  12357. }
  12358. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12359. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12360. import { Effect } from "babylonjs/Materials/effect";
  12361. import { Particle } from "babylonjs/Particles/particle";
  12362. import { Scene } from "babylonjs/scene";
  12363. /**
  12364. * Particle emitter represents a volume emitting particles.
  12365. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12366. */
  12367. export interface IParticleEmitterType {
  12368. /**
  12369. * Called by the particle System when the direction is computed for the created particle.
  12370. * @param worldMatrix is the world matrix of the particle system
  12371. * @param directionToUpdate is the direction vector to update with the result
  12372. * @param particle is the particle we are computed the direction for
  12373. * @param isLocal defines if the direction should be set in local space
  12374. */
  12375. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12376. /**
  12377. * Called by the particle System when the position is computed for the created particle.
  12378. * @param worldMatrix is the world matrix of the particle system
  12379. * @param positionToUpdate is the position vector to update with the result
  12380. * @param particle is the particle we are computed the position for
  12381. * @param isLocal defines if the position should be set in local space
  12382. */
  12383. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12384. /**
  12385. * Clones the current emitter and returns a copy of it
  12386. * @returns the new emitter
  12387. */
  12388. clone(): IParticleEmitterType;
  12389. /**
  12390. * Called by the GPUParticleSystem to setup the update shader
  12391. * @param effect defines the update shader
  12392. */
  12393. applyToShader(effect: Effect): void;
  12394. /**
  12395. * Returns a string to use to update the GPU particles update shader
  12396. * @returns the effect defines string
  12397. */
  12398. getEffectDefines(): string;
  12399. /**
  12400. * Returns a string representing the class name
  12401. * @returns a string containing the class name
  12402. */
  12403. getClassName(): string;
  12404. /**
  12405. * Serializes the particle system to a JSON object.
  12406. * @returns the JSON object
  12407. */
  12408. serialize(): any;
  12409. /**
  12410. * Parse properties from a JSON object
  12411. * @param serializationObject defines the JSON object
  12412. * @param scene defines the hosting scene
  12413. */
  12414. parse(serializationObject: any, scene: Scene): void;
  12415. }
  12416. }
  12417. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12418. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12419. import { Effect } from "babylonjs/Materials/effect";
  12420. import { Particle } from "babylonjs/Particles/particle";
  12421. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12422. /**
  12423. * Particle emitter emitting particles from the inside of a box.
  12424. * It emits the particles randomly between 2 given directions.
  12425. */
  12426. export class BoxParticleEmitter implements IParticleEmitterType {
  12427. /**
  12428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12429. */
  12430. direction1: Vector3;
  12431. /**
  12432. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12433. */
  12434. direction2: Vector3;
  12435. /**
  12436. * 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.
  12437. */
  12438. minEmitBox: Vector3;
  12439. /**
  12440. * 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.
  12441. */
  12442. maxEmitBox: Vector3;
  12443. /**
  12444. * Creates a new instance BoxParticleEmitter
  12445. */
  12446. constructor();
  12447. /**
  12448. * Called by the particle System when the direction is computed for the created particle.
  12449. * @param worldMatrix is the world matrix of the particle system
  12450. * @param directionToUpdate is the direction vector to update with the result
  12451. * @param particle is the particle we are computed the direction for
  12452. * @param isLocal defines if the direction should be set in local space
  12453. */
  12454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12455. /**
  12456. * Called by the particle System when the position is computed for the created particle.
  12457. * @param worldMatrix is the world matrix of the particle system
  12458. * @param positionToUpdate is the position vector to update with the result
  12459. * @param particle is the particle we are computed the position for
  12460. * @param isLocal defines if the position should be set in local space
  12461. */
  12462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12463. /**
  12464. * Clones the current emitter and returns a copy of it
  12465. * @returns the new emitter
  12466. */
  12467. clone(): BoxParticleEmitter;
  12468. /**
  12469. * Called by the GPUParticleSystem to setup the update shader
  12470. * @param effect defines the update shader
  12471. */
  12472. applyToShader(effect: Effect): void;
  12473. /**
  12474. * Returns a string to use to update the GPU particles update shader
  12475. * @returns a string containng the defines string
  12476. */
  12477. getEffectDefines(): string;
  12478. /**
  12479. * Returns the string "BoxParticleEmitter"
  12480. * @returns a string containing the class name
  12481. */
  12482. getClassName(): string;
  12483. /**
  12484. * Serializes the particle system to a JSON object.
  12485. * @returns the JSON object
  12486. */
  12487. serialize(): any;
  12488. /**
  12489. * Parse properties from a JSON object
  12490. * @param serializationObject defines the JSON object
  12491. */
  12492. parse(serializationObject: any): void;
  12493. }
  12494. }
  12495. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12496. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12497. import { Effect } from "babylonjs/Materials/effect";
  12498. import { Particle } from "babylonjs/Particles/particle";
  12499. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12500. /**
  12501. * Particle emitter emitting particles from the inside of a cone.
  12502. * It emits the particles alongside the cone volume from the base to the particle.
  12503. * The emission direction might be randomized.
  12504. */
  12505. export class ConeParticleEmitter implements IParticleEmitterType {
  12506. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12507. directionRandomizer: number;
  12508. private _radius;
  12509. private _angle;
  12510. private _height;
  12511. /**
  12512. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12513. */
  12514. radiusRange: number;
  12515. /**
  12516. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12517. */
  12518. heightRange: number;
  12519. /**
  12520. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12521. */
  12522. emitFromSpawnPointOnly: boolean;
  12523. /**
  12524. * Gets or sets the radius of the emission cone
  12525. */
  12526. get radius(): number;
  12527. set radius(value: number);
  12528. /**
  12529. * Gets or sets the angle of the emission cone
  12530. */
  12531. get angle(): number;
  12532. set angle(value: number);
  12533. private _buildHeight;
  12534. /**
  12535. * Creates a new instance ConeParticleEmitter
  12536. * @param radius the radius of the emission cone (1 by default)
  12537. * @param angle the cone base angle (PI by default)
  12538. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12539. */
  12540. constructor(radius?: number, angle?: number,
  12541. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12542. directionRandomizer?: number);
  12543. /**
  12544. * Called by the particle System when the direction is computed for the created particle.
  12545. * @param worldMatrix is the world matrix of the particle system
  12546. * @param directionToUpdate is the direction vector to update with the result
  12547. * @param particle is the particle we are computed the direction for
  12548. * @param isLocal defines if the direction should be set in local space
  12549. */
  12550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12551. /**
  12552. * Called by the particle System when the position is computed for the created particle.
  12553. * @param worldMatrix is the world matrix of the particle system
  12554. * @param positionToUpdate is the position vector to update with the result
  12555. * @param particle is the particle we are computed the position for
  12556. * @param isLocal defines if the position should be set in local space
  12557. */
  12558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12559. /**
  12560. * Clones the current emitter and returns a copy of it
  12561. * @returns the new emitter
  12562. */
  12563. clone(): ConeParticleEmitter;
  12564. /**
  12565. * Called by the GPUParticleSystem to setup the update shader
  12566. * @param effect defines the update shader
  12567. */
  12568. applyToShader(effect: Effect): void;
  12569. /**
  12570. * Returns a string to use to update the GPU particles update shader
  12571. * @returns a string containng the defines string
  12572. */
  12573. getEffectDefines(): string;
  12574. /**
  12575. * Returns the string "ConeParticleEmitter"
  12576. * @returns a string containing the class name
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Serializes the particle system to a JSON object.
  12581. * @returns the JSON object
  12582. */
  12583. serialize(): any;
  12584. /**
  12585. * Parse properties from a JSON object
  12586. * @param serializationObject defines the JSON object
  12587. */
  12588. parse(serializationObject: any): void;
  12589. }
  12590. }
  12591. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12592. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12593. import { Effect } from "babylonjs/Materials/effect";
  12594. import { Particle } from "babylonjs/Particles/particle";
  12595. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12596. /**
  12597. * Particle emitter emitting particles from the inside of a cylinder.
  12598. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12599. */
  12600. export class CylinderParticleEmitter implements IParticleEmitterType {
  12601. /**
  12602. * The radius of the emission cylinder.
  12603. */
  12604. radius: number;
  12605. /**
  12606. * The height of the emission cylinder.
  12607. */
  12608. height: number;
  12609. /**
  12610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12611. */
  12612. radiusRange: number;
  12613. /**
  12614. * How much to randomize the particle direction [0-1].
  12615. */
  12616. directionRandomizer: number;
  12617. /**
  12618. * Creates a new instance CylinderParticleEmitter
  12619. * @param radius the radius of the emission cylinder (1 by default)
  12620. * @param height the height of the emission cylinder (1 by default)
  12621. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12622. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12623. */
  12624. constructor(
  12625. /**
  12626. * The radius of the emission cylinder.
  12627. */
  12628. radius?: number,
  12629. /**
  12630. * The height of the emission cylinder.
  12631. */
  12632. height?: number,
  12633. /**
  12634. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12635. */
  12636. radiusRange?: number,
  12637. /**
  12638. * How much to randomize the particle direction [0-1].
  12639. */
  12640. directionRandomizer?: number);
  12641. /**
  12642. * Called by the particle System when the direction is computed for the created particle.
  12643. * @param worldMatrix is the world matrix of the particle system
  12644. * @param directionToUpdate is the direction vector to update with the result
  12645. * @param particle is the particle we are computed the direction for
  12646. * @param isLocal defines if the direction should be set in local space
  12647. */
  12648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12649. /**
  12650. * Called by the particle System when the position is computed for the created particle.
  12651. * @param worldMatrix is the world matrix of the particle system
  12652. * @param positionToUpdate is the position vector to update with the result
  12653. * @param particle is the particle we are computed the position for
  12654. * @param isLocal defines if the position should be set in local space
  12655. */
  12656. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12657. /**
  12658. * Clones the current emitter and returns a copy of it
  12659. * @returns the new emitter
  12660. */
  12661. clone(): CylinderParticleEmitter;
  12662. /**
  12663. * Called by the GPUParticleSystem to setup the update shader
  12664. * @param effect defines the update shader
  12665. */
  12666. applyToShader(effect: Effect): void;
  12667. /**
  12668. * Returns a string to use to update the GPU particles update shader
  12669. * @returns a string containng the defines string
  12670. */
  12671. getEffectDefines(): string;
  12672. /**
  12673. * Returns the string "CylinderParticleEmitter"
  12674. * @returns a string containing the class name
  12675. */
  12676. getClassName(): string;
  12677. /**
  12678. * Serializes the particle system to a JSON object.
  12679. * @returns the JSON object
  12680. */
  12681. serialize(): any;
  12682. /**
  12683. * Parse properties from a JSON object
  12684. * @param serializationObject defines the JSON object
  12685. */
  12686. parse(serializationObject: any): void;
  12687. }
  12688. /**
  12689. * Particle emitter emitting particles from the inside of a cylinder.
  12690. * It emits the particles randomly between two vectors.
  12691. */
  12692. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12693. /**
  12694. * The min limit of the emission direction.
  12695. */
  12696. direction1: Vector3;
  12697. /**
  12698. * The max limit of the emission direction.
  12699. */
  12700. direction2: Vector3;
  12701. /**
  12702. * Creates a new instance CylinderDirectedParticleEmitter
  12703. * @param radius the radius of the emission cylinder (1 by default)
  12704. * @param height the height of the emission cylinder (1 by default)
  12705. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12706. * @param direction1 the min limit of the emission direction (up vector by default)
  12707. * @param direction2 the max limit of the emission direction (up vector by default)
  12708. */
  12709. constructor(radius?: number, height?: number, radiusRange?: number,
  12710. /**
  12711. * The min limit of the emission direction.
  12712. */
  12713. direction1?: Vector3,
  12714. /**
  12715. * The max limit of the emission direction.
  12716. */
  12717. direction2?: Vector3);
  12718. /**
  12719. * Called by the particle System when the direction is computed for the created particle.
  12720. * @param worldMatrix is the world matrix of the particle system
  12721. * @param directionToUpdate is the direction vector to update with the result
  12722. * @param particle is the particle we are computed the direction for
  12723. */
  12724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12725. /**
  12726. * Clones the current emitter and returns a copy of it
  12727. * @returns the new emitter
  12728. */
  12729. clone(): CylinderDirectedParticleEmitter;
  12730. /**
  12731. * Called by the GPUParticleSystem to setup the update shader
  12732. * @param effect defines the update shader
  12733. */
  12734. applyToShader(effect: Effect): void;
  12735. /**
  12736. * Returns a string to use to update the GPU particles update shader
  12737. * @returns a string containng the defines string
  12738. */
  12739. getEffectDefines(): string;
  12740. /**
  12741. * Returns the string "CylinderDirectedParticleEmitter"
  12742. * @returns a string containing the class name
  12743. */
  12744. getClassName(): string;
  12745. /**
  12746. * Serializes the particle system to a JSON object.
  12747. * @returns the JSON object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Parse properties from a JSON object
  12752. * @param serializationObject defines the JSON object
  12753. */
  12754. parse(serializationObject: any): void;
  12755. }
  12756. }
  12757. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12759. import { Effect } from "babylonjs/Materials/effect";
  12760. import { Particle } from "babylonjs/Particles/particle";
  12761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12762. /**
  12763. * Particle emitter emitting particles from the inside of a hemisphere.
  12764. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12765. */
  12766. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12767. /**
  12768. * The radius of the emission hemisphere.
  12769. */
  12770. radius: number;
  12771. /**
  12772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12773. */
  12774. radiusRange: number;
  12775. /**
  12776. * How much to randomize the particle direction [0-1].
  12777. */
  12778. directionRandomizer: number;
  12779. /**
  12780. * Creates a new instance HemisphericParticleEmitter
  12781. * @param radius the radius of the emission hemisphere (1 by default)
  12782. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12783. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12784. */
  12785. constructor(
  12786. /**
  12787. * The radius of the emission hemisphere.
  12788. */
  12789. radius?: number,
  12790. /**
  12791. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12792. */
  12793. radiusRange?: number,
  12794. /**
  12795. * How much to randomize the particle direction [0-1].
  12796. */
  12797. directionRandomizer?: number);
  12798. /**
  12799. * Called by the particle System when the direction is computed for the created particle.
  12800. * @param worldMatrix is the world matrix of the particle system
  12801. * @param directionToUpdate is the direction vector to update with the result
  12802. * @param particle is the particle we are computed the direction for
  12803. * @param isLocal defines if the direction should be set in local space
  12804. */
  12805. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12806. /**
  12807. * Called by the particle System when the position is computed for the created particle.
  12808. * @param worldMatrix is the world matrix of the particle system
  12809. * @param positionToUpdate is the position vector to update with the result
  12810. * @param particle is the particle we are computed the position for
  12811. * @param isLocal defines if the position should be set in local space
  12812. */
  12813. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12814. /**
  12815. * Clones the current emitter and returns a copy of it
  12816. * @returns the new emitter
  12817. */
  12818. clone(): HemisphericParticleEmitter;
  12819. /**
  12820. * Called by the GPUParticleSystem to setup the update shader
  12821. * @param effect defines the update shader
  12822. */
  12823. applyToShader(effect: Effect): void;
  12824. /**
  12825. * Returns a string to use to update the GPU particles update shader
  12826. * @returns a string containng the defines string
  12827. */
  12828. getEffectDefines(): string;
  12829. /**
  12830. * Returns the string "HemisphericParticleEmitter"
  12831. * @returns a string containing the class name
  12832. */
  12833. getClassName(): string;
  12834. /**
  12835. * Serializes the particle system to a JSON object.
  12836. * @returns the JSON object
  12837. */
  12838. serialize(): any;
  12839. /**
  12840. * Parse properties from a JSON object
  12841. * @param serializationObject defines the JSON object
  12842. */
  12843. parse(serializationObject: any): void;
  12844. }
  12845. }
  12846. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12847. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12848. import { Effect } from "babylonjs/Materials/effect";
  12849. import { Particle } from "babylonjs/Particles/particle";
  12850. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12851. /**
  12852. * Particle emitter emitting particles from a point.
  12853. * It emits the particles randomly between 2 given directions.
  12854. */
  12855. export class PointParticleEmitter implements IParticleEmitterType {
  12856. /**
  12857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12858. */
  12859. direction1: Vector3;
  12860. /**
  12861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12862. */
  12863. direction2: Vector3;
  12864. /**
  12865. * Creates a new instance PointParticleEmitter
  12866. */
  12867. constructor();
  12868. /**
  12869. * Called by the particle System when the direction is computed for the created particle.
  12870. * @param worldMatrix is the world matrix of the particle system
  12871. * @param directionToUpdate is the direction vector to update with the result
  12872. * @param particle is the particle we are computed the direction for
  12873. * @param isLocal defines if the direction should be set in local space
  12874. */
  12875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12876. /**
  12877. * Called by the particle System when the position is computed for the created particle.
  12878. * @param worldMatrix is the world matrix of the particle system
  12879. * @param positionToUpdate is the position vector to update with the result
  12880. * @param particle is the particle we are computed the position for
  12881. * @param isLocal defines if the position should be set in local space
  12882. */
  12883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12884. /**
  12885. * Clones the current emitter and returns a copy of it
  12886. * @returns the new emitter
  12887. */
  12888. clone(): PointParticleEmitter;
  12889. /**
  12890. * Called by the GPUParticleSystem to setup the update shader
  12891. * @param effect defines the update shader
  12892. */
  12893. applyToShader(effect: Effect): void;
  12894. /**
  12895. * Returns a string to use to update the GPU particles update shader
  12896. * @returns a string containng the defines string
  12897. */
  12898. getEffectDefines(): string;
  12899. /**
  12900. * Returns the string "PointParticleEmitter"
  12901. * @returns a string containing the class name
  12902. */
  12903. getClassName(): string;
  12904. /**
  12905. * Serializes the particle system to a JSON object.
  12906. * @returns the JSON object
  12907. */
  12908. serialize(): any;
  12909. /**
  12910. * Parse properties from a JSON object
  12911. * @param serializationObject defines the JSON object
  12912. */
  12913. parse(serializationObject: any): void;
  12914. }
  12915. }
  12916. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12917. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12918. import { Effect } from "babylonjs/Materials/effect";
  12919. import { Particle } from "babylonjs/Particles/particle";
  12920. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12921. /**
  12922. * Particle emitter emitting particles from the inside of a sphere.
  12923. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12924. */
  12925. export class SphereParticleEmitter implements IParticleEmitterType {
  12926. /**
  12927. * The radius of the emission sphere.
  12928. */
  12929. radius: number;
  12930. /**
  12931. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12932. */
  12933. radiusRange: number;
  12934. /**
  12935. * How much to randomize the particle direction [0-1].
  12936. */
  12937. directionRandomizer: number;
  12938. /**
  12939. * Creates a new instance SphereParticleEmitter
  12940. * @param radius the radius of the emission sphere (1 by default)
  12941. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12942. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12943. */
  12944. constructor(
  12945. /**
  12946. * The radius of the emission sphere.
  12947. */
  12948. radius?: number,
  12949. /**
  12950. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12951. */
  12952. radiusRange?: number,
  12953. /**
  12954. * How much to randomize the particle direction [0-1].
  12955. */
  12956. directionRandomizer?: number);
  12957. /**
  12958. * Called by the particle System when the direction is computed for the created particle.
  12959. * @param worldMatrix is the world matrix of the particle system
  12960. * @param directionToUpdate is the direction vector to update with the result
  12961. * @param particle is the particle we are computed the direction for
  12962. * @param isLocal defines if the direction should be set in local space
  12963. */
  12964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12965. /**
  12966. * Called by the particle System when the position is computed for the created particle.
  12967. * @param worldMatrix is the world matrix of the particle system
  12968. * @param positionToUpdate is the position vector to update with the result
  12969. * @param particle is the particle we are computed the position for
  12970. * @param isLocal defines if the position should be set in local space
  12971. */
  12972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12973. /**
  12974. * Clones the current emitter and returns a copy of it
  12975. * @returns the new emitter
  12976. */
  12977. clone(): SphereParticleEmitter;
  12978. /**
  12979. * Called by the GPUParticleSystem to setup the update shader
  12980. * @param effect defines the update shader
  12981. */
  12982. applyToShader(effect: Effect): void;
  12983. /**
  12984. * Returns a string to use to update the GPU particles update shader
  12985. * @returns a string containng the defines string
  12986. */
  12987. getEffectDefines(): string;
  12988. /**
  12989. * Returns the string "SphereParticleEmitter"
  12990. * @returns a string containing the class name
  12991. */
  12992. getClassName(): string;
  12993. /**
  12994. * Serializes the particle system to a JSON object.
  12995. * @returns the JSON object
  12996. */
  12997. serialize(): any;
  12998. /**
  12999. * Parse properties from a JSON object
  13000. * @param serializationObject defines the JSON object
  13001. */
  13002. parse(serializationObject: any): void;
  13003. }
  13004. /**
  13005. * Particle emitter emitting particles from the inside of a sphere.
  13006. * It emits the particles randomly between two vectors.
  13007. */
  13008. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13009. /**
  13010. * The min limit of the emission direction.
  13011. */
  13012. direction1: Vector3;
  13013. /**
  13014. * The max limit of the emission direction.
  13015. */
  13016. direction2: Vector3;
  13017. /**
  13018. * Creates a new instance SphereDirectedParticleEmitter
  13019. * @param radius the radius of the emission sphere (1 by default)
  13020. * @param direction1 the min limit of the emission direction (up vector by default)
  13021. * @param direction2 the max limit of the emission direction (up vector by default)
  13022. */
  13023. constructor(radius?: number,
  13024. /**
  13025. * The min limit of the emission direction.
  13026. */
  13027. direction1?: Vector3,
  13028. /**
  13029. * The max limit of the emission direction.
  13030. */
  13031. direction2?: Vector3);
  13032. /**
  13033. * Called by the particle System when the direction is computed for the created particle.
  13034. * @param worldMatrix is the world matrix of the particle system
  13035. * @param directionToUpdate is the direction vector to update with the result
  13036. * @param particle is the particle we are computed the direction for
  13037. */
  13038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13039. /**
  13040. * Clones the current emitter and returns a copy of it
  13041. * @returns the new emitter
  13042. */
  13043. clone(): SphereDirectedParticleEmitter;
  13044. /**
  13045. * Called by the GPUParticleSystem to setup the update shader
  13046. * @param effect defines the update shader
  13047. */
  13048. applyToShader(effect: Effect): void;
  13049. /**
  13050. * Returns a string to use to update the GPU particles update shader
  13051. * @returns a string containng the defines string
  13052. */
  13053. getEffectDefines(): string;
  13054. /**
  13055. * Returns the string "SphereDirectedParticleEmitter"
  13056. * @returns a string containing the class name
  13057. */
  13058. getClassName(): string;
  13059. /**
  13060. * Serializes the particle system to a JSON object.
  13061. * @returns the JSON object
  13062. */
  13063. serialize(): any;
  13064. /**
  13065. * Parse properties from a JSON object
  13066. * @param serializationObject defines the JSON object
  13067. */
  13068. parse(serializationObject: any): void;
  13069. }
  13070. }
  13071. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13072. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13073. import { Effect } from "babylonjs/Materials/effect";
  13074. import { Particle } from "babylonjs/Particles/particle";
  13075. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13076. import { Nullable } from "babylonjs/types";
  13077. /**
  13078. * Particle emitter emitting particles from a custom list of positions.
  13079. */
  13080. export class CustomParticleEmitter implements IParticleEmitterType {
  13081. /**
  13082. * Gets or sets the position generator that will create the inital position of each particle.
  13083. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13084. */
  13085. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13086. /**
  13087. * Gets or sets the destination generator that will create the final destination of each particle.
  13088. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13089. */
  13090. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13091. /**
  13092. * Creates a new instance CustomParticleEmitter
  13093. */
  13094. constructor();
  13095. /**
  13096. * Called by the particle System when the direction is computed for the created particle.
  13097. * @param worldMatrix is the world matrix of the particle system
  13098. * @param directionToUpdate is the direction vector to update with the result
  13099. * @param particle is the particle we are computed the direction for
  13100. * @param isLocal defines if the direction should be set in local space
  13101. */
  13102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13103. /**
  13104. * Called by the particle System when the position is computed for the created particle.
  13105. * @param worldMatrix is the world matrix of the particle system
  13106. * @param positionToUpdate is the position vector to update with the result
  13107. * @param particle is the particle we are computed the position for
  13108. * @param isLocal defines if the position should be set in local space
  13109. */
  13110. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13111. /**
  13112. * Clones the current emitter and returns a copy of it
  13113. * @returns the new emitter
  13114. */
  13115. clone(): CustomParticleEmitter;
  13116. /**
  13117. * Called by the GPUParticleSystem to setup the update shader
  13118. * @param effect defines the update shader
  13119. */
  13120. applyToShader(effect: Effect): void;
  13121. /**
  13122. * Returns a string to use to update the GPU particles update shader
  13123. * @returns a string containng the defines string
  13124. */
  13125. getEffectDefines(): string;
  13126. /**
  13127. * Returns the string "PointParticleEmitter"
  13128. * @returns a string containing the class name
  13129. */
  13130. getClassName(): string;
  13131. /**
  13132. * Serializes the particle system to a JSON object.
  13133. * @returns the JSON object
  13134. */
  13135. serialize(): any;
  13136. /**
  13137. * Parse properties from a JSON object
  13138. * @param serializationObject defines the JSON object
  13139. */
  13140. parse(serializationObject: any): void;
  13141. }
  13142. }
  13143. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13144. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13145. import { Effect } from "babylonjs/Materials/effect";
  13146. import { Particle } from "babylonjs/Particles/particle";
  13147. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13148. import { Nullable } from "babylonjs/types";
  13149. import { Scene } from "babylonjs/scene";
  13150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13151. /**
  13152. * Particle emitter emitting particles from the inside of a box.
  13153. * It emits the particles randomly between 2 given directions.
  13154. */
  13155. export class MeshParticleEmitter implements IParticleEmitterType {
  13156. private _indices;
  13157. private _positions;
  13158. private _normals;
  13159. private _storedNormal;
  13160. private _mesh;
  13161. /**
  13162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13163. */
  13164. direction1: Vector3;
  13165. /**
  13166. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13167. */
  13168. direction2: Vector3;
  13169. /**
  13170. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13171. */
  13172. useMeshNormalsForDirection: boolean;
  13173. /** Defines the mesh to use as source */
  13174. get mesh(): Nullable<AbstractMesh>;
  13175. set mesh(value: Nullable<AbstractMesh>);
  13176. /**
  13177. * Creates a new instance MeshParticleEmitter
  13178. * @param mesh defines the mesh to use as source
  13179. */
  13180. constructor(mesh?: Nullable<AbstractMesh>);
  13181. /**
  13182. * Called by the particle System when the direction is computed for the created particle.
  13183. * @param worldMatrix is the world matrix of the particle system
  13184. * @param directionToUpdate is the direction vector to update with the result
  13185. * @param particle is the particle we are computed the direction for
  13186. * @param isLocal defines if the direction should be set in local space
  13187. */
  13188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13189. /**
  13190. * Called by the particle System when the position is computed for the created particle.
  13191. * @param worldMatrix is the world matrix of the particle system
  13192. * @param positionToUpdate is the position vector to update with the result
  13193. * @param particle is the particle we are computed the position for
  13194. * @param isLocal defines if the position should be set in local space
  13195. */
  13196. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13197. /**
  13198. * Clones the current emitter and returns a copy of it
  13199. * @returns the new emitter
  13200. */
  13201. clone(): MeshParticleEmitter;
  13202. /**
  13203. * Called by the GPUParticleSystem to setup the update shader
  13204. * @param effect defines the update shader
  13205. */
  13206. applyToShader(effect: Effect): void;
  13207. /**
  13208. * Returns a string to use to update the GPU particles update shader
  13209. * @returns a string containng the defines string
  13210. */
  13211. getEffectDefines(): string;
  13212. /**
  13213. * Returns the string "BoxParticleEmitter"
  13214. * @returns a string containing the class name
  13215. */
  13216. getClassName(): string;
  13217. /**
  13218. * Serializes the particle system to a JSON object.
  13219. * @returns the JSON object
  13220. */
  13221. serialize(): any;
  13222. /**
  13223. * Parse properties from a JSON object
  13224. * @param serializationObject defines the JSON object
  13225. * @param scene defines the hosting scene
  13226. */
  13227. parse(serializationObject: any, scene: Scene): void;
  13228. }
  13229. }
  13230. declare module "babylonjs/Particles/EmitterTypes/index" {
  13231. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13232. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13233. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13234. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13235. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13236. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13237. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13238. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13239. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13240. }
  13241. declare module "babylonjs/Particles/IParticleSystem" {
  13242. import { Nullable } from "babylonjs/types";
  13243. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13244. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13247. import { Texture } from "babylonjs/Materials/Textures/texture";
  13248. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13249. import { Scene } from "babylonjs/scene";
  13250. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13251. import { Animation } from "babylonjs/Animations/animation";
  13252. /**
  13253. * Interface representing a particle system in Babylon.js.
  13254. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13255. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13256. */
  13257. export interface IParticleSystem {
  13258. /**
  13259. * List of animations used by the particle system.
  13260. */
  13261. animations: Animation[];
  13262. /**
  13263. * The id of the Particle system.
  13264. */
  13265. id: string;
  13266. /**
  13267. * The name of the Particle system.
  13268. */
  13269. name: string;
  13270. /**
  13271. * The emitter represents the Mesh or position we are attaching the particle system to.
  13272. */
  13273. emitter: Nullable<AbstractMesh | Vector3>;
  13274. /**
  13275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13276. */
  13277. isBillboardBased: boolean;
  13278. /**
  13279. * The rendering group used by the Particle system to chose when to render.
  13280. */
  13281. renderingGroupId: number;
  13282. /**
  13283. * The layer mask we are rendering the particles through.
  13284. */
  13285. layerMask: number;
  13286. /**
  13287. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13288. */
  13289. updateSpeed: number;
  13290. /**
  13291. * The amount of time the particle system is running (depends of the overall update speed).
  13292. */
  13293. targetStopDuration: number;
  13294. /**
  13295. * The texture used to render each particle. (this can be a spritesheet)
  13296. */
  13297. particleTexture: Nullable<Texture>;
  13298. /**
  13299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13300. */
  13301. blendMode: number;
  13302. /**
  13303. * Minimum life time of emitting particles.
  13304. */
  13305. minLifeTime: number;
  13306. /**
  13307. * Maximum life time of emitting particles.
  13308. */
  13309. maxLifeTime: number;
  13310. /**
  13311. * Minimum Size of emitting particles.
  13312. */
  13313. minSize: number;
  13314. /**
  13315. * Maximum Size of emitting particles.
  13316. */
  13317. maxSize: number;
  13318. /**
  13319. * Minimum scale of emitting particles on X axis.
  13320. */
  13321. minScaleX: number;
  13322. /**
  13323. * Maximum scale of emitting particles on X axis.
  13324. */
  13325. maxScaleX: number;
  13326. /**
  13327. * Minimum scale of emitting particles on Y axis.
  13328. */
  13329. minScaleY: number;
  13330. /**
  13331. * Maximum scale of emitting particles on Y axis.
  13332. */
  13333. maxScaleY: number;
  13334. /**
  13335. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13336. */
  13337. color1: Color4;
  13338. /**
  13339. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13340. */
  13341. color2: Color4;
  13342. /**
  13343. * Color the particle will have at the end of its lifetime.
  13344. */
  13345. colorDead: Color4;
  13346. /**
  13347. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13348. */
  13349. emitRate: number;
  13350. /**
  13351. * You can use gravity if you want to give an orientation to your particles.
  13352. */
  13353. gravity: Vector3;
  13354. /**
  13355. * Minimum power of emitting particles.
  13356. */
  13357. minEmitPower: number;
  13358. /**
  13359. * Maximum power of emitting particles.
  13360. */
  13361. maxEmitPower: number;
  13362. /**
  13363. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13364. */
  13365. minAngularSpeed: number;
  13366. /**
  13367. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13368. */
  13369. maxAngularSpeed: number;
  13370. /**
  13371. * Gets or sets the minimal initial rotation in radians.
  13372. */
  13373. minInitialRotation: number;
  13374. /**
  13375. * Gets or sets the maximal initial rotation in radians.
  13376. */
  13377. maxInitialRotation: number;
  13378. /**
  13379. * The particle emitter type defines the emitter used by the particle system.
  13380. * It can be for example box, sphere, or cone...
  13381. */
  13382. particleEmitterType: Nullable<IParticleEmitterType>;
  13383. /**
  13384. * Defines the delay in milliseconds before starting the system (0 by default)
  13385. */
  13386. startDelay: number;
  13387. /**
  13388. * 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
  13389. */
  13390. preWarmCycles: number;
  13391. /**
  13392. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13393. */
  13394. preWarmStepOffset: number;
  13395. /**
  13396. * 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)
  13397. */
  13398. spriteCellChangeSpeed: number;
  13399. /**
  13400. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13401. */
  13402. startSpriteCellID: number;
  13403. /**
  13404. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13405. */
  13406. endSpriteCellID: number;
  13407. /**
  13408. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13409. */
  13410. spriteCellWidth: number;
  13411. /**
  13412. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13413. */
  13414. spriteCellHeight: number;
  13415. /**
  13416. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13417. */
  13418. spriteRandomStartCell: boolean;
  13419. /**
  13420. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13421. */
  13422. isAnimationSheetEnabled: boolean;
  13423. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13424. translationPivot: Vector2;
  13425. /**
  13426. * Gets or sets a texture used to add random noise to particle positions
  13427. */
  13428. noiseTexture: Nullable<BaseTexture>;
  13429. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13430. noiseStrength: Vector3;
  13431. /**
  13432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13434. */
  13435. billboardMode: number;
  13436. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13437. limitVelocityDamping: number;
  13438. /**
  13439. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13440. */
  13441. beginAnimationOnStart: boolean;
  13442. /**
  13443. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13444. */
  13445. beginAnimationFrom: number;
  13446. /**
  13447. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13448. */
  13449. beginAnimationTo: number;
  13450. /**
  13451. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13452. */
  13453. beginAnimationLoop: boolean;
  13454. /**
  13455. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13456. */
  13457. disposeOnStop: boolean;
  13458. /**
  13459. * Specifies if the particles are updated in emitter local space or world space
  13460. */
  13461. isLocal: boolean;
  13462. /**
  13463. * Gets the maximum number of particles active at the same time.
  13464. * @returns The max number of active particles.
  13465. */
  13466. getCapacity(): number;
  13467. /**
  13468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13469. * @returns True if it has been started, otherwise false.
  13470. */
  13471. isStarted(): boolean;
  13472. /**
  13473. * Animates the particle system for this frame.
  13474. */
  13475. animate(): void;
  13476. /**
  13477. * Renders the particle system in its current state.
  13478. * @returns the current number of particles
  13479. */
  13480. render(): number;
  13481. /**
  13482. * Dispose the particle system and frees its associated resources.
  13483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13484. */
  13485. dispose(disposeTexture?: boolean): void;
  13486. /**
  13487. * Clones the particle system.
  13488. * @param name The name of the cloned object
  13489. * @param newEmitter The new emitter to use
  13490. * @returns the cloned particle system
  13491. */
  13492. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13493. /**
  13494. * Serializes the particle system to a JSON object.
  13495. * @returns the JSON object
  13496. */
  13497. serialize(): any;
  13498. /**
  13499. * Rebuild the particle system
  13500. */
  13501. rebuild(): void;
  13502. /**
  13503. * Starts the particle system and begins to emit
  13504. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13505. */
  13506. start(delay?: number): void;
  13507. /**
  13508. * Stops the particle system.
  13509. */
  13510. stop(): void;
  13511. /**
  13512. * Remove all active particles
  13513. */
  13514. reset(): void;
  13515. /**
  13516. * Is this system ready to be used/rendered
  13517. * @return true if the system is ready
  13518. */
  13519. isReady(): boolean;
  13520. /**
  13521. * Returns the string "ParticleSystem"
  13522. * @returns a string containing the class name
  13523. */
  13524. getClassName(): string;
  13525. /**
  13526. * Adds a new color gradient
  13527. * @param gradient defines the gradient to use (between 0 and 1)
  13528. * @param color1 defines the color to affect to the specified gradient
  13529. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13530. * @returns the current particle system
  13531. */
  13532. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13533. /**
  13534. * Remove a specific color gradient
  13535. * @param gradient defines the gradient to remove
  13536. * @returns the current particle system
  13537. */
  13538. removeColorGradient(gradient: number): IParticleSystem;
  13539. /**
  13540. * Adds a new size gradient
  13541. * @param gradient defines the gradient to use (between 0 and 1)
  13542. * @param factor defines the size factor to affect to the specified gradient
  13543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13544. * @returns the current particle system
  13545. */
  13546. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13547. /**
  13548. * Remove a specific size gradient
  13549. * @param gradient defines the gradient to remove
  13550. * @returns the current particle system
  13551. */
  13552. removeSizeGradient(gradient: number): IParticleSystem;
  13553. /**
  13554. * Gets the current list of color gradients.
  13555. * You must use addColorGradient and removeColorGradient to udpate this list
  13556. * @returns the list of color gradients
  13557. */
  13558. getColorGradients(): Nullable<Array<ColorGradient>>;
  13559. /**
  13560. * Gets the current list of size gradients.
  13561. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13562. * @returns the list of size gradients
  13563. */
  13564. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13565. /**
  13566. * Gets the current list of angular speed gradients.
  13567. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13568. * @returns the list of angular speed gradients
  13569. */
  13570. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13571. /**
  13572. * Adds a new angular speed gradient
  13573. * @param gradient defines the gradient to use (between 0 and 1)
  13574. * @param factor defines the angular speed to affect to the specified gradient
  13575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13576. * @returns the current particle system
  13577. */
  13578. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13579. /**
  13580. * Remove a specific angular speed gradient
  13581. * @param gradient defines the gradient to remove
  13582. * @returns the current particle system
  13583. */
  13584. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13585. /**
  13586. * Gets the current list of velocity gradients.
  13587. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13588. * @returns the list of velocity gradients
  13589. */
  13590. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13591. /**
  13592. * Adds a new velocity gradient
  13593. * @param gradient defines the gradient to use (between 0 and 1)
  13594. * @param factor defines the velocity to affect to the specified gradient
  13595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13596. * @returns the current particle system
  13597. */
  13598. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13599. /**
  13600. * Remove a specific velocity gradient
  13601. * @param gradient defines the gradient to remove
  13602. * @returns the current particle system
  13603. */
  13604. removeVelocityGradient(gradient: number): IParticleSystem;
  13605. /**
  13606. * Gets the current list of limit velocity gradients.
  13607. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13608. * @returns the list of limit velocity gradients
  13609. */
  13610. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13611. /**
  13612. * Adds a new limit velocity gradient
  13613. * @param gradient defines the gradient to use (between 0 and 1)
  13614. * @param factor defines the limit velocity to affect to the specified gradient
  13615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13616. * @returns the current particle system
  13617. */
  13618. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13619. /**
  13620. * Remove a specific limit velocity gradient
  13621. * @param gradient defines the gradient to remove
  13622. * @returns the current particle system
  13623. */
  13624. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13625. /**
  13626. * Adds a new drag gradient
  13627. * @param gradient defines the gradient to use (between 0 and 1)
  13628. * @param factor defines the drag to affect to the specified gradient
  13629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13630. * @returns the current particle system
  13631. */
  13632. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13633. /**
  13634. * Remove a specific drag gradient
  13635. * @param gradient defines the gradient to remove
  13636. * @returns the current particle system
  13637. */
  13638. removeDragGradient(gradient: number): IParticleSystem;
  13639. /**
  13640. * Gets the current list of drag gradients.
  13641. * You must use addDragGradient and removeDragGradient to udpate this list
  13642. * @returns the list of drag gradients
  13643. */
  13644. getDragGradients(): Nullable<Array<FactorGradient>>;
  13645. /**
  13646. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13647. * @param gradient defines the gradient to use (between 0 and 1)
  13648. * @param factor defines the emit rate to affect to the specified gradient
  13649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13650. * @returns the current particle system
  13651. */
  13652. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13653. /**
  13654. * Remove a specific emit rate gradient
  13655. * @param gradient defines the gradient to remove
  13656. * @returns the current particle system
  13657. */
  13658. removeEmitRateGradient(gradient: number): IParticleSystem;
  13659. /**
  13660. * Gets the current list of emit rate gradients.
  13661. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13662. * @returns the list of emit rate gradients
  13663. */
  13664. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13665. /**
  13666. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13667. * @param gradient defines the gradient to use (between 0 and 1)
  13668. * @param factor defines the start size to affect to the specified gradient
  13669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13670. * @returns the current particle system
  13671. */
  13672. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13673. /**
  13674. * Remove a specific start size gradient
  13675. * @param gradient defines the gradient to remove
  13676. * @returns the current particle system
  13677. */
  13678. removeStartSizeGradient(gradient: number): IParticleSystem;
  13679. /**
  13680. * Gets the current list of start size gradients.
  13681. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13682. * @returns the list of start size gradients
  13683. */
  13684. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13685. /**
  13686. * Adds a new life time gradient
  13687. * @param gradient defines the gradient to use (between 0 and 1)
  13688. * @param factor defines the life time factor to affect to the specified gradient
  13689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13690. * @returns the current particle system
  13691. */
  13692. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13693. /**
  13694. * Remove a specific life time gradient
  13695. * @param gradient defines the gradient to remove
  13696. * @returns the current particle system
  13697. */
  13698. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13699. /**
  13700. * Gets the current list of life time gradients.
  13701. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13702. * @returns the list of life time gradients
  13703. */
  13704. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13705. /**
  13706. * Gets the current list of color gradients.
  13707. * You must use addColorGradient and removeColorGradient to udpate this list
  13708. * @returns the list of color gradients
  13709. */
  13710. getColorGradients(): Nullable<Array<ColorGradient>>;
  13711. /**
  13712. * Adds a new ramp gradient used to remap particle colors
  13713. * @param gradient defines the gradient to use (between 0 and 1)
  13714. * @param color defines the color to affect to the specified gradient
  13715. * @returns the current particle system
  13716. */
  13717. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13718. /**
  13719. * Gets the current list of ramp gradients.
  13720. * You must use addRampGradient and removeRampGradient to udpate this list
  13721. * @returns the list of ramp gradients
  13722. */
  13723. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13724. /** Gets or sets a boolean indicating that ramp gradients must be used
  13725. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13726. */
  13727. useRampGradients: boolean;
  13728. /**
  13729. * Adds a new color remap gradient
  13730. * @param gradient defines the gradient to use (between 0 and 1)
  13731. * @param min defines the color remap minimal range
  13732. * @param max defines the color remap maximal range
  13733. * @returns the current particle system
  13734. */
  13735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13736. /**
  13737. * Gets the current list of color remap gradients.
  13738. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13739. * @returns the list of color remap gradients
  13740. */
  13741. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13742. /**
  13743. * Adds a new alpha remap gradient
  13744. * @param gradient defines the gradient to use (between 0 and 1)
  13745. * @param min defines the alpha remap minimal range
  13746. * @param max defines the alpha remap maximal range
  13747. * @returns the current particle system
  13748. */
  13749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13750. /**
  13751. * Gets the current list of alpha remap gradients.
  13752. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13753. * @returns the list of alpha remap gradients
  13754. */
  13755. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13756. /**
  13757. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13758. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13759. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13760. * @returns the emitter
  13761. */
  13762. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13763. /**
  13764. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13765. * @param radius The radius of the hemisphere to emit from
  13766. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13767. * @returns the emitter
  13768. */
  13769. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13770. /**
  13771. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13772. * @param radius The radius of the sphere to emit from
  13773. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13774. * @returns the emitter
  13775. */
  13776. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13777. /**
  13778. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13779. * @param radius The radius of the sphere to emit from
  13780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13782. * @returns the emitter
  13783. */
  13784. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13785. /**
  13786. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13787. * @param radius The radius of the emission cylinder
  13788. * @param height The height of the emission cylinder
  13789. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13790. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13791. * @returns the emitter
  13792. */
  13793. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13794. /**
  13795. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13796. * @param radius The radius of the cylinder to emit from
  13797. * @param height The height of the emission cylinder
  13798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13801. * @returns the emitter
  13802. */
  13803. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13804. /**
  13805. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13806. * @param radius The radius of the cone to emit from
  13807. * @param angle The base angle of the cone
  13808. * @returns the emitter
  13809. */
  13810. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13811. /**
  13812. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13815. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13816. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13817. * @returns the emitter
  13818. */
  13819. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13820. /**
  13821. * Get hosting scene
  13822. * @returns the scene
  13823. */
  13824. getScene(): Scene;
  13825. }
  13826. }
  13827. declare module "babylonjs/Meshes/transformNode" {
  13828. import { DeepImmutable } from "babylonjs/types";
  13829. import { Observable } from "babylonjs/Misc/observable";
  13830. import { Nullable } from "babylonjs/types";
  13831. import { Camera } from "babylonjs/Cameras/camera";
  13832. import { Scene } from "babylonjs/scene";
  13833. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13834. import { Node } from "babylonjs/node";
  13835. import { Bone } from "babylonjs/Bones/bone";
  13836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13837. import { Space } from "babylonjs/Maths/math.axis";
  13838. /**
  13839. * 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.
  13840. * @see https://doc.babylonjs.com/how_to/transformnode
  13841. */
  13842. export class TransformNode extends Node {
  13843. /**
  13844. * Object will not rotate to face the camera
  13845. */
  13846. static BILLBOARDMODE_NONE: number;
  13847. /**
  13848. * Object will rotate to face the camera but only on the x axis
  13849. */
  13850. static BILLBOARDMODE_X: number;
  13851. /**
  13852. * Object will rotate to face the camera but only on the y axis
  13853. */
  13854. static BILLBOARDMODE_Y: number;
  13855. /**
  13856. * Object will rotate to face the camera but only on the z axis
  13857. */
  13858. static BILLBOARDMODE_Z: number;
  13859. /**
  13860. * Object will rotate to face the camera
  13861. */
  13862. static BILLBOARDMODE_ALL: number;
  13863. /**
  13864. * Object will rotate to face the camera's position instead of orientation
  13865. */
  13866. static BILLBOARDMODE_USE_POSITION: number;
  13867. private _forward;
  13868. private _forwardInverted;
  13869. private _up;
  13870. private _right;
  13871. private _rightInverted;
  13872. private _position;
  13873. private _rotation;
  13874. private _rotationQuaternion;
  13875. protected _scaling: Vector3;
  13876. protected _isDirty: boolean;
  13877. private _transformToBoneReferal;
  13878. private _isAbsoluteSynced;
  13879. private _billboardMode;
  13880. /**
  13881. * Gets or sets the billboard mode. Default is 0.
  13882. *
  13883. * | Value | Type | Description |
  13884. * | --- | --- | --- |
  13885. * | 0 | BILLBOARDMODE_NONE | |
  13886. * | 1 | BILLBOARDMODE_X | |
  13887. * | 2 | BILLBOARDMODE_Y | |
  13888. * | 4 | BILLBOARDMODE_Z | |
  13889. * | 7 | BILLBOARDMODE_ALL | |
  13890. *
  13891. */
  13892. get billboardMode(): number;
  13893. set billboardMode(value: number);
  13894. private _preserveParentRotationForBillboard;
  13895. /**
  13896. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13897. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13898. */
  13899. get preserveParentRotationForBillboard(): boolean;
  13900. set preserveParentRotationForBillboard(value: boolean);
  13901. /**
  13902. * 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
  13903. */
  13904. scalingDeterminant: number;
  13905. private _infiniteDistance;
  13906. /**
  13907. * Gets or sets the distance of the object to max, often used by skybox
  13908. */
  13909. get infiniteDistance(): boolean;
  13910. set infiniteDistance(value: boolean);
  13911. /**
  13912. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13913. * By default the system will update normals to compensate
  13914. */
  13915. ignoreNonUniformScaling: boolean;
  13916. /**
  13917. * 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
  13918. */
  13919. reIntegrateRotationIntoRotationQuaternion: boolean;
  13920. /** @hidden */
  13921. _poseMatrix: Nullable<Matrix>;
  13922. /** @hidden */
  13923. _localMatrix: Matrix;
  13924. private _usePivotMatrix;
  13925. private _absolutePosition;
  13926. private _absoluteScaling;
  13927. private _absoluteRotationQuaternion;
  13928. private _pivotMatrix;
  13929. private _pivotMatrixInverse;
  13930. protected _postMultiplyPivotMatrix: boolean;
  13931. protected _isWorldMatrixFrozen: boolean;
  13932. /** @hidden */
  13933. _indexInSceneTransformNodesArray: number;
  13934. /**
  13935. * An event triggered after the world matrix is updated
  13936. */
  13937. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13938. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13939. /**
  13940. * Gets a string identifying the name of the class
  13941. * @returns "TransformNode" string
  13942. */
  13943. getClassName(): string;
  13944. /**
  13945. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13946. */
  13947. get position(): Vector3;
  13948. set position(newPosition: Vector3);
  13949. /**
  13950. * 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)).
  13951. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13952. */
  13953. get rotation(): Vector3;
  13954. set rotation(newRotation: Vector3);
  13955. /**
  13956. * 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)).
  13957. */
  13958. get scaling(): Vector3;
  13959. set scaling(newScaling: Vector3);
  13960. /**
  13961. * 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).
  13962. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13963. */
  13964. get rotationQuaternion(): Nullable<Quaternion>;
  13965. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13966. /**
  13967. * The forward direction of that transform in world space.
  13968. */
  13969. get forward(): Vector3;
  13970. /**
  13971. * The up direction of that transform in world space.
  13972. */
  13973. get up(): Vector3;
  13974. /**
  13975. * The right direction of that transform in world space.
  13976. */
  13977. get right(): Vector3;
  13978. /**
  13979. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13980. * @param matrix the matrix to copy the pose from
  13981. * @returns this TransformNode.
  13982. */
  13983. updatePoseMatrix(matrix: Matrix): TransformNode;
  13984. /**
  13985. * Returns the mesh Pose matrix.
  13986. * @returns the pose matrix
  13987. */
  13988. getPoseMatrix(): Matrix;
  13989. /** @hidden */
  13990. _isSynchronized(): boolean;
  13991. /** @hidden */
  13992. _initCache(): void;
  13993. /**
  13994. * Flag the transform node as dirty (Forcing it to update everything)
  13995. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13996. * @returns this transform node
  13997. */
  13998. markAsDirty(property: string): TransformNode;
  13999. /**
  14000. * Returns the current mesh absolute position.
  14001. * Returns a Vector3.
  14002. */
  14003. get absolutePosition(): Vector3;
  14004. /**
  14005. * Returns the current mesh absolute scaling.
  14006. * Returns a Vector3.
  14007. */
  14008. get absoluteScaling(): Vector3;
  14009. /**
  14010. * Returns the current mesh absolute rotation.
  14011. * Returns a Quaternion.
  14012. */
  14013. get absoluteRotationQuaternion(): Quaternion;
  14014. /**
  14015. * Sets a new matrix to apply before all other transformation
  14016. * @param matrix defines the transform matrix
  14017. * @returns the current TransformNode
  14018. */
  14019. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14020. /**
  14021. * Sets a new pivot matrix to the current node
  14022. * @param matrix defines the new pivot matrix to use
  14023. * @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
  14024. * @returns the current TransformNode
  14025. */
  14026. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14027. /**
  14028. * Returns the mesh pivot matrix.
  14029. * Default : Identity.
  14030. * @returns the matrix
  14031. */
  14032. getPivotMatrix(): Matrix;
  14033. /**
  14034. * Instantiate (when possible) or clone that node with its hierarchy
  14035. * @param newParent defines the new parent to use for the instance (or clone)
  14036. * @param options defines options to configure how copy is done
  14037. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14038. * @returns an instance (or a clone) of the current node with its hiearchy
  14039. */
  14040. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14041. doNotInstantiate: boolean;
  14042. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14043. /**
  14044. * Prevents the World matrix to be computed any longer
  14045. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14046. * @returns the TransformNode.
  14047. */
  14048. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14049. /**
  14050. * Allows back the World matrix computation.
  14051. * @returns the TransformNode.
  14052. */
  14053. unfreezeWorldMatrix(): this;
  14054. /**
  14055. * True if the World matrix has been frozen.
  14056. */
  14057. get isWorldMatrixFrozen(): boolean;
  14058. /**
  14059. * Retuns the mesh absolute position in the World.
  14060. * @returns a Vector3.
  14061. */
  14062. getAbsolutePosition(): Vector3;
  14063. /**
  14064. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14065. * @param absolutePosition the absolute position to set
  14066. * @returns the TransformNode.
  14067. */
  14068. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14069. /**
  14070. * Sets the mesh position in its local space.
  14071. * @param vector3 the position to set in localspace
  14072. * @returns the TransformNode.
  14073. */
  14074. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14075. /**
  14076. * Returns the mesh position in the local space from the current World matrix values.
  14077. * @returns a new Vector3.
  14078. */
  14079. getPositionExpressedInLocalSpace(): Vector3;
  14080. /**
  14081. * Translates the mesh along the passed Vector3 in its local space.
  14082. * @param vector3 the distance to translate in localspace
  14083. * @returns the TransformNode.
  14084. */
  14085. locallyTranslate(vector3: Vector3): TransformNode;
  14086. private static _lookAtVectorCache;
  14087. /**
  14088. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14089. * @param targetPoint the position (must be in same space as current mesh) to look at
  14090. * @param yawCor optional yaw (y-axis) correction in radians
  14091. * @param pitchCor optional pitch (x-axis) correction in radians
  14092. * @param rollCor optional roll (z-axis) correction in radians
  14093. * @param space the choosen space of the target
  14094. * @returns the TransformNode.
  14095. */
  14096. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14097. /**
  14098. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14099. * This Vector3 is expressed in the World space.
  14100. * @param localAxis axis to rotate
  14101. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14102. */
  14103. getDirection(localAxis: Vector3): Vector3;
  14104. /**
  14105. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14106. * localAxis is expressed in the mesh local space.
  14107. * result is computed in the Wordl space from the mesh World matrix.
  14108. * @param localAxis axis to rotate
  14109. * @param result the resulting transformnode
  14110. * @returns this TransformNode.
  14111. */
  14112. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14113. /**
  14114. * Sets this transform node rotation to the given local axis.
  14115. * @param localAxis the axis in local space
  14116. * @param yawCor optional yaw (y-axis) correction in radians
  14117. * @param pitchCor optional pitch (x-axis) correction in radians
  14118. * @param rollCor optional roll (z-axis) correction in radians
  14119. * @returns this TransformNode
  14120. */
  14121. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14122. /**
  14123. * Sets a new pivot point to the current node
  14124. * @param point defines the new pivot point to use
  14125. * @param space defines if the point is in world or local space (local by default)
  14126. * @returns the current TransformNode
  14127. */
  14128. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14129. /**
  14130. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14131. * @returns the pivot point
  14132. */
  14133. getPivotPoint(): Vector3;
  14134. /**
  14135. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14136. * @param result the vector3 to store the result
  14137. * @returns this TransformNode.
  14138. */
  14139. getPivotPointToRef(result: Vector3): TransformNode;
  14140. /**
  14141. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14142. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14143. */
  14144. getAbsolutePivotPoint(): Vector3;
  14145. /**
  14146. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14147. * @param result vector3 to store the result
  14148. * @returns this TransformNode.
  14149. */
  14150. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14151. /**
  14152. * Defines the passed node as the parent of the current node.
  14153. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14154. * @see https://doc.babylonjs.com/how_to/parenting
  14155. * @param node the node ot set as the parent
  14156. * @returns this TransformNode.
  14157. */
  14158. setParent(node: Nullable<Node>): TransformNode;
  14159. private _nonUniformScaling;
  14160. /**
  14161. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14162. */
  14163. get nonUniformScaling(): boolean;
  14164. /** @hidden */
  14165. _updateNonUniformScalingState(value: boolean): boolean;
  14166. /**
  14167. * Attach the current TransformNode to another TransformNode associated with a bone
  14168. * @param bone Bone affecting the TransformNode
  14169. * @param affectedTransformNode TransformNode associated with the bone
  14170. * @returns this object
  14171. */
  14172. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14173. /**
  14174. * Detach the transform node if its associated with a bone
  14175. * @returns this object
  14176. */
  14177. detachFromBone(): TransformNode;
  14178. private static _rotationAxisCache;
  14179. /**
  14180. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14181. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14182. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14183. * The passed axis is also normalized.
  14184. * @param axis the axis to rotate around
  14185. * @param amount the amount to rotate in radians
  14186. * @param space Space to rotate in (Default: local)
  14187. * @returns the TransformNode.
  14188. */
  14189. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14190. /**
  14191. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14192. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14193. * The passed axis is also normalized. .
  14194. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14195. * @param point the point to rotate around
  14196. * @param axis the axis to rotate around
  14197. * @param amount the amount to rotate in radians
  14198. * @returns the TransformNode
  14199. */
  14200. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14201. /**
  14202. * Translates the mesh along the axis vector for the passed distance in the given space.
  14203. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14204. * @param axis the axis to translate in
  14205. * @param distance the distance to translate
  14206. * @param space Space to rotate in (Default: local)
  14207. * @returns the TransformNode.
  14208. */
  14209. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14210. /**
  14211. * Adds a rotation step to the mesh current rotation.
  14212. * x, y, z are Euler angles expressed in radians.
  14213. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14214. * This means this rotation is made in the mesh local space only.
  14215. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14216. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14217. * ```javascript
  14218. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14219. * ```
  14220. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14221. * 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.
  14222. * @param x Rotation to add
  14223. * @param y Rotation to add
  14224. * @param z Rotation to add
  14225. * @returns the TransformNode.
  14226. */
  14227. addRotation(x: number, y: number, z: number): TransformNode;
  14228. /**
  14229. * @hidden
  14230. */
  14231. protected _getEffectiveParent(): Nullable<Node>;
  14232. /**
  14233. * Computes the world matrix of the node
  14234. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14235. * @returns the world matrix
  14236. */
  14237. computeWorldMatrix(force?: boolean): Matrix;
  14238. /**
  14239. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14240. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14241. */
  14242. resetLocalMatrix(independentOfChildren?: boolean): void;
  14243. protected _afterComputeWorldMatrix(): void;
  14244. /**
  14245. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14246. * @param func callback function to add
  14247. *
  14248. * @returns the TransformNode.
  14249. */
  14250. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14251. /**
  14252. * Removes a registered callback function.
  14253. * @param func callback function to remove
  14254. * @returns the TransformNode.
  14255. */
  14256. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14257. /**
  14258. * Gets the position of the current mesh in camera space
  14259. * @param camera defines the camera to use
  14260. * @returns a position
  14261. */
  14262. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14263. /**
  14264. * Returns the distance from the mesh to the active camera
  14265. * @param camera defines the camera to use
  14266. * @returns the distance
  14267. */
  14268. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14269. /**
  14270. * Clone the current transform node
  14271. * @param name Name of the new clone
  14272. * @param newParent New parent for the clone
  14273. * @param doNotCloneChildren Do not clone children hierarchy
  14274. * @returns the new transform node
  14275. */
  14276. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14277. /**
  14278. * Serializes the objects information.
  14279. * @param currentSerializationObject defines the object to serialize in
  14280. * @returns the serialized object
  14281. */
  14282. serialize(currentSerializationObject?: any): any;
  14283. /**
  14284. * Returns a new TransformNode object parsed from the source provided.
  14285. * @param parsedTransformNode is the source.
  14286. * @param scene the scne the object belongs to
  14287. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14288. * @returns a new TransformNode object parsed from the source provided.
  14289. */
  14290. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14291. /**
  14292. * Get all child-transformNodes of this node
  14293. * @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
  14294. * @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
  14295. * @returns an array of TransformNode
  14296. */
  14297. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14298. /**
  14299. * Releases resources associated with this transform node.
  14300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14302. */
  14303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14304. /**
  14305. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14306. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14307. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14308. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14309. * @returns the current mesh
  14310. */
  14311. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14312. private _syncAbsoluteScalingAndRotation;
  14313. }
  14314. }
  14315. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14316. /**
  14317. * Class used to override all child animations of a given target
  14318. */
  14319. export class AnimationPropertiesOverride {
  14320. /**
  14321. * Gets or sets a value indicating if animation blending must be used
  14322. */
  14323. enableBlending: boolean;
  14324. /**
  14325. * Gets or sets the blending speed to use when enableBlending is true
  14326. */
  14327. blendingSpeed: number;
  14328. /**
  14329. * Gets or sets the default loop mode to use
  14330. */
  14331. loopMode: number;
  14332. }
  14333. }
  14334. declare module "babylonjs/Bones/bone" {
  14335. import { Skeleton } from "babylonjs/Bones/skeleton";
  14336. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14337. import { Nullable } from "babylonjs/types";
  14338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14340. import { Node } from "babylonjs/node";
  14341. import { Space } from "babylonjs/Maths/math.axis";
  14342. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14343. /**
  14344. * Class used to store bone information
  14345. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14346. */
  14347. export class Bone extends Node {
  14348. /**
  14349. * defines the bone name
  14350. */
  14351. name: string;
  14352. private static _tmpVecs;
  14353. private static _tmpQuat;
  14354. private static _tmpMats;
  14355. /**
  14356. * Gets the list of child bones
  14357. */
  14358. children: Bone[];
  14359. /** Gets the animations associated with this bone */
  14360. animations: import("babylonjs/Animations/animation").Animation[];
  14361. /**
  14362. * Gets or sets bone length
  14363. */
  14364. length: number;
  14365. /**
  14366. * @hidden Internal only
  14367. * Set this value to map this bone to a different index in the transform matrices
  14368. * Set this value to -1 to exclude the bone from the transform matrices
  14369. */
  14370. _index: Nullable<number>;
  14371. private _skeleton;
  14372. private _localMatrix;
  14373. private _restPose;
  14374. private _baseMatrix;
  14375. private _absoluteTransform;
  14376. private _invertedAbsoluteTransform;
  14377. private _parent;
  14378. private _scalingDeterminant;
  14379. private _worldTransform;
  14380. private _localScaling;
  14381. private _localRotation;
  14382. private _localPosition;
  14383. private _needToDecompose;
  14384. private _needToCompose;
  14385. /** @hidden */
  14386. _linkedTransformNode: Nullable<TransformNode>;
  14387. /** @hidden */
  14388. _waitingTransformNodeId: Nullable<string>;
  14389. /** @hidden */
  14390. get _matrix(): Matrix;
  14391. /** @hidden */
  14392. set _matrix(value: Matrix);
  14393. /**
  14394. * Create a new bone
  14395. * @param name defines the bone name
  14396. * @param skeleton defines the parent skeleton
  14397. * @param parentBone defines the parent (can be null if the bone is the root)
  14398. * @param localMatrix defines the local matrix
  14399. * @param restPose defines the rest pose matrix
  14400. * @param baseMatrix defines the base matrix
  14401. * @param index defines index of the bone in the hiearchy
  14402. */
  14403. constructor(
  14404. /**
  14405. * defines the bone name
  14406. */
  14407. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14408. /**
  14409. * Gets the current object class name.
  14410. * @return the class name
  14411. */
  14412. getClassName(): string;
  14413. /**
  14414. * Gets the parent skeleton
  14415. * @returns a skeleton
  14416. */
  14417. getSkeleton(): Skeleton;
  14418. /**
  14419. * Gets parent bone
  14420. * @returns a bone or null if the bone is the root of the bone hierarchy
  14421. */
  14422. getParent(): Nullable<Bone>;
  14423. /**
  14424. * Returns an array containing the root bones
  14425. * @returns an array containing the root bones
  14426. */
  14427. getChildren(): Array<Bone>;
  14428. /**
  14429. * Gets the node index in matrix array generated for rendering
  14430. * @returns the node index
  14431. */
  14432. getIndex(): number;
  14433. /**
  14434. * Sets the parent bone
  14435. * @param parent defines the parent (can be null if the bone is the root)
  14436. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14437. */
  14438. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14439. /**
  14440. * Gets the local matrix
  14441. * @returns a matrix
  14442. */
  14443. getLocalMatrix(): Matrix;
  14444. /**
  14445. * Gets the base matrix (initial matrix which remains unchanged)
  14446. * @returns a matrix
  14447. */
  14448. getBaseMatrix(): Matrix;
  14449. /**
  14450. * Gets the rest pose matrix
  14451. * @returns a matrix
  14452. */
  14453. getRestPose(): Matrix;
  14454. /**
  14455. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14456. */
  14457. getWorldMatrix(): Matrix;
  14458. /**
  14459. * Sets the local matrix to rest pose matrix
  14460. */
  14461. returnToRest(): void;
  14462. /**
  14463. * Gets the inverse of the absolute transform matrix.
  14464. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14465. * @returns a matrix
  14466. */
  14467. getInvertedAbsoluteTransform(): Matrix;
  14468. /**
  14469. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14470. * @returns a matrix
  14471. */
  14472. getAbsoluteTransform(): Matrix;
  14473. /**
  14474. * Links with the given transform node.
  14475. * The local matrix of this bone is copied from the transform node every frame.
  14476. * @param transformNode defines the transform node to link to
  14477. */
  14478. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14479. /**
  14480. * Gets the node used to drive the bone's transformation
  14481. * @returns a transform node or null
  14482. */
  14483. getTransformNode(): Nullable<TransformNode>;
  14484. /** Gets or sets current position (in local space) */
  14485. get position(): Vector3;
  14486. set position(newPosition: Vector3);
  14487. /** Gets or sets current rotation (in local space) */
  14488. get rotation(): Vector3;
  14489. set rotation(newRotation: Vector3);
  14490. /** Gets or sets current rotation quaternion (in local space) */
  14491. get rotationQuaternion(): Quaternion;
  14492. set rotationQuaternion(newRotation: Quaternion);
  14493. /** Gets or sets current scaling (in local space) */
  14494. get scaling(): Vector3;
  14495. set scaling(newScaling: Vector3);
  14496. /**
  14497. * Gets the animation properties override
  14498. */
  14499. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14500. private _decompose;
  14501. private _compose;
  14502. /**
  14503. * Update the base and local matrices
  14504. * @param matrix defines the new base or local matrix
  14505. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14506. * @param updateLocalMatrix defines if the local matrix should be updated
  14507. */
  14508. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14509. /** @hidden */
  14510. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14511. /**
  14512. * Flag the bone as dirty (Forcing it to update everything)
  14513. */
  14514. markAsDirty(): void;
  14515. /** @hidden */
  14516. _markAsDirtyAndCompose(): void;
  14517. private _markAsDirtyAndDecompose;
  14518. /**
  14519. * Translate the bone in local or world space
  14520. * @param vec The amount to translate the bone
  14521. * @param space The space that the translation is in
  14522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14523. */
  14524. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14525. /**
  14526. * Set the postion of the bone in local or world space
  14527. * @param position The position to set the bone
  14528. * @param space The space that the position is in
  14529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14530. */
  14531. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14532. /**
  14533. * Set the absolute position of the bone (world space)
  14534. * @param position The position to set the bone
  14535. * @param mesh The mesh that this bone is attached to
  14536. */
  14537. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14538. /**
  14539. * Scale the bone on the x, y and z axes (in local space)
  14540. * @param x The amount to scale the bone on the x axis
  14541. * @param y The amount to scale the bone on the y axis
  14542. * @param z The amount to scale the bone on the z axis
  14543. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14544. */
  14545. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14546. /**
  14547. * Set the bone scaling in local space
  14548. * @param scale defines the scaling vector
  14549. */
  14550. setScale(scale: Vector3): void;
  14551. /**
  14552. * Gets the current scaling in local space
  14553. * @returns the current scaling vector
  14554. */
  14555. getScale(): Vector3;
  14556. /**
  14557. * Gets the current scaling in local space and stores it in a target vector
  14558. * @param result defines the target vector
  14559. */
  14560. getScaleToRef(result: Vector3): void;
  14561. /**
  14562. * Set the yaw, pitch, and roll of the bone in local or world space
  14563. * @param yaw The rotation of the bone on the y axis
  14564. * @param pitch The rotation of the bone on the x axis
  14565. * @param roll The rotation of the bone on the z axis
  14566. * @param space The space that the axes of rotation are in
  14567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14568. */
  14569. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14570. /**
  14571. * Add a rotation to the bone on an axis in local or world space
  14572. * @param axis The axis to rotate the bone on
  14573. * @param amount The amount to rotate the bone
  14574. * @param space The space that the axis is in
  14575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14576. */
  14577. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14578. /**
  14579. * Set the rotation of the bone to a particular axis angle in local or world space
  14580. * @param axis The axis to rotate the bone on
  14581. * @param angle The angle that the bone should be rotated to
  14582. * @param space The space that the axis is in
  14583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14584. */
  14585. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14586. /**
  14587. * Set the euler rotation of the bone in local of world space
  14588. * @param rotation The euler rotation that the bone should be set to
  14589. * @param space The space that the rotation is in
  14590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14591. */
  14592. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14593. /**
  14594. * Set the quaternion rotation of the bone in local of world space
  14595. * @param quat The quaternion rotation that the bone should be set to
  14596. * @param space The space that the rotation is in
  14597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14598. */
  14599. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14600. /**
  14601. * Set the rotation matrix of the bone in local of world space
  14602. * @param rotMat The rotation matrix that the bone should be set to
  14603. * @param space The space that the rotation is in
  14604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14605. */
  14606. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14607. private _rotateWithMatrix;
  14608. private _getNegativeRotationToRef;
  14609. /**
  14610. * Get the position of the bone in local or world space
  14611. * @param space The space that the returned position is in
  14612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14613. * @returns The position of the bone
  14614. */
  14615. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14616. /**
  14617. * Copy the position of the bone to a vector3 in local or world space
  14618. * @param space The space that the returned position is in
  14619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14620. * @param result The vector3 to copy the position to
  14621. */
  14622. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14623. /**
  14624. * Get the absolute position of the bone (world space)
  14625. * @param mesh The mesh that this bone is attached to
  14626. * @returns The absolute position of the bone
  14627. */
  14628. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14629. /**
  14630. * Copy the absolute position of the bone (world space) to the result param
  14631. * @param mesh The mesh that this bone is attached to
  14632. * @param result The vector3 to copy the absolute position to
  14633. */
  14634. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14635. /**
  14636. * Compute the absolute transforms of this bone and its children
  14637. */
  14638. computeAbsoluteTransforms(): void;
  14639. /**
  14640. * Get the world direction from an axis that is in the local space of the bone
  14641. * @param localAxis The local direction that is used to compute the world direction
  14642. * @param mesh The mesh that this bone is attached to
  14643. * @returns The world direction
  14644. */
  14645. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14646. /**
  14647. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14648. * @param localAxis The local direction that is used to compute the world direction
  14649. * @param mesh The mesh that this bone is attached to
  14650. * @param result The vector3 that the world direction will be copied to
  14651. */
  14652. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14653. /**
  14654. * Get the euler rotation of the bone in local or world space
  14655. * @param space The space that the rotation should be in
  14656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14657. * @returns The euler rotation
  14658. */
  14659. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14660. /**
  14661. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14662. * @param space The space that the rotation should be in
  14663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14664. * @param result The vector3 that the rotation should be copied to
  14665. */
  14666. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14667. /**
  14668. * Get the quaternion rotation of the bone in either local or world space
  14669. * @param space The space that the rotation should be in
  14670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14671. * @returns The quaternion rotation
  14672. */
  14673. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14674. /**
  14675. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14676. * @param space The space that the rotation should be in
  14677. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14678. * @param result The quaternion that the rotation should be copied to
  14679. */
  14680. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14681. /**
  14682. * Get the rotation matrix of the bone in local or world space
  14683. * @param space The space that the rotation should be in
  14684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14685. * @returns The rotation matrix
  14686. */
  14687. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14688. /**
  14689. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14690. * @param space The space that the rotation should be in
  14691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14692. * @param result The quaternion that the rotation should be copied to
  14693. */
  14694. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14695. /**
  14696. * Get the world position of a point that is in the local space of the bone
  14697. * @param position The local position
  14698. * @param mesh The mesh that this bone is attached to
  14699. * @returns The world position
  14700. */
  14701. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14702. /**
  14703. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14704. * @param position The local position
  14705. * @param mesh The mesh that this bone is attached to
  14706. * @param result The vector3 that the world position should be copied to
  14707. */
  14708. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14709. /**
  14710. * Get the local position of a point that is in world space
  14711. * @param position The world position
  14712. * @param mesh The mesh that this bone is attached to
  14713. * @returns The local position
  14714. */
  14715. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14716. /**
  14717. * Get the local position of a point that is in world space and copy it to the result param
  14718. * @param position The world position
  14719. * @param mesh The mesh that this bone is attached to
  14720. * @param result The vector3 that the local position should be copied to
  14721. */
  14722. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14723. }
  14724. }
  14725. declare module "babylonjs/Animations/runtimeAnimation" {
  14726. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14727. import { Animatable } from "babylonjs/Animations/animatable";
  14728. import { Scene } from "babylonjs/scene";
  14729. /**
  14730. * Defines a runtime animation
  14731. */
  14732. export class RuntimeAnimation {
  14733. private _events;
  14734. /**
  14735. * The current frame of the runtime animation
  14736. */
  14737. private _currentFrame;
  14738. /**
  14739. * The animation used by the runtime animation
  14740. */
  14741. private _animation;
  14742. /**
  14743. * The target of the runtime animation
  14744. */
  14745. private _target;
  14746. /**
  14747. * The initiating animatable
  14748. */
  14749. private _host;
  14750. /**
  14751. * The original value of the runtime animation
  14752. */
  14753. private _originalValue;
  14754. /**
  14755. * The original blend value of the runtime animation
  14756. */
  14757. private _originalBlendValue;
  14758. /**
  14759. * The offsets cache of the runtime animation
  14760. */
  14761. private _offsetsCache;
  14762. /**
  14763. * The high limits cache of the runtime animation
  14764. */
  14765. private _highLimitsCache;
  14766. /**
  14767. * Specifies if the runtime animation has been stopped
  14768. */
  14769. private _stopped;
  14770. /**
  14771. * The blending factor of the runtime animation
  14772. */
  14773. private _blendingFactor;
  14774. /**
  14775. * The BabylonJS scene
  14776. */
  14777. private _scene;
  14778. /**
  14779. * The current value of the runtime animation
  14780. */
  14781. private _currentValue;
  14782. /** @hidden */
  14783. _animationState: _IAnimationState;
  14784. /**
  14785. * The active target of the runtime animation
  14786. */
  14787. private _activeTargets;
  14788. private _currentActiveTarget;
  14789. private _directTarget;
  14790. /**
  14791. * The target path of the runtime animation
  14792. */
  14793. private _targetPath;
  14794. /**
  14795. * The weight of the runtime animation
  14796. */
  14797. private _weight;
  14798. /**
  14799. * The ratio offset of the runtime animation
  14800. */
  14801. private _ratioOffset;
  14802. /**
  14803. * The previous delay of the runtime animation
  14804. */
  14805. private _previousDelay;
  14806. /**
  14807. * The previous ratio of the runtime animation
  14808. */
  14809. private _previousRatio;
  14810. private _enableBlending;
  14811. private _keys;
  14812. private _minFrame;
  14813. private _maxFrame;
  14814. private _minValue;
  14815. private _maxValue;
  14816. private _targetIsArray;
  14817. /**
  14818. * Gets the current frame of the runtime animation
  14819. */
  14820. get currentFrame(): number;
  14821. /**
  14822. * Gets the weight of the runtime animation
  14823. */
  14824. get weight(): number;
  14825. /**
  14826. * Gets the current value of the runtime animation
  14827. */
  14828. get currentValue(): any;
  14829. /**
  14830. * Gets the target path of the runtime animation
  14831. */
  14832. get targetPath(): string;
  14833. /**
  14834. * Gets the actual target of the runtime animation
  14835. */
  14836. get target(): any;
  14837. /** @hidden */
  14838. _onLoop: () => void;
  14839. /**
  14840. * Create a new RuntimeAnimation object
  14841. * @param target defines the target of the animation
  14842. * @param animation defines the source animation object
  14843. * @param scene defines the hosting scene
  14844. * @param host defines the initiating Animatable
  14845. */
  14846. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14847. private _preparePath;
  14848. /**
  14849. * Gets the animation from the runtime animation
  14850. */
  14851. get animation(): Animation;
  14852. /**
  14853. * Resets the runtime animation to the beginning
  14854. * @param restoreOriginal defines whether to restore the target property to the original value
  14855. */
  14856. reset(restoreOriginal?: boolean): void;
  14857. /**
  14858. * Specifies if the runtime animation is stopped
  14859. * @returns Boolean specifying if the runtime animation is stopped
  14860. */
  14861. isStopped(): boolean;
  14862. /**
  14863. * Disposes of the runtime animation
  14864. */
  14865. dispose(): void;
  14866. /**
  14867. * Apply the interpolated value to the target
  14868. * @param currentValue defines the value computed by the animation
  14869. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14870. */
  14871. setValue(currentValue: any, weight: number): void;
  14872. private _getOriginalValues;
  14873. private _setValue;
  14874. /**
  14875. * Gets the loop pmode of the runtime animation
  14876. * @returns Loop Mode
  14877. */
  14878. private _getCorrectLoopMode;
  14879. /**
  14880. * Move the current animation to a given frame
  14881. * @param frame defines the frame to move to
  14882. */
  14883. goToFrame(frame: number): void;
  14884. /**
  14885. * @hidden Internal use only
  14886. */
  14887. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14888. /**
  14889. * Execute the current animation
  14890. * @param delay defines the delay to add to the current frame
  14891. * @param from defines the lower bound of the animation range
  14892. * @param to defines the upper bound of the animation range
  14893. * @param loop defines if the current animation must loop
  14894. * @param speedRatio defines the current speed ratio
  14895. * @param weight defines the weight of the animation (default is -1 so no weight)
  14896. * @param onLoop optional callback called when animation loops
  14897. * @returns a boolean indicating if the animation is running
  14898. */
  14899. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14900. }
  14901. }
  14902. declare module "babylonjs/Animations/animatable" {
  14903. import { Animation } from "babylonjs/Animations/animation";
  14904. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14905. import { Nullable } from "babylonjs/types";
  14906. import { Observable } from "babylonjs/Misc/observable";
  14907. import { Scene } from "babylonjs/scene";
  14908. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14909. import { Node } from "babylonjs/node";
  14910. /**
  14911. * Class used to store an actual running animation
  14912. */
  14913. export class Animatable {
  14914. /** defines the target object */
  14915. target: any;
  14916. /** defines the starting frame number (default is 0) */
  14917. fromFrame: number;
  14918. /** defines the ending frame number (default is 100) */
  14919. toFrame: number;
  14920. /** defines if the animation must loop (default is false) */
  14921. loopAnimation: boolean;
  14922. /** defines a callback to call when animation ends if it is not looping */
  14923. onAnimationEnd?: (() => void) | null | undefined;
  14924. /** defines a callback to call when animation loops */
  14925. onAnimationLoop?: (() => void) | null | undefined;
  14926. private _localDelayOffset;
  14927. private _pausedDelay;
  14928. private _runtimeAnimations;
  14929. private _paused;
  14930. private _scene;
  14931. private _speedRatio;
  14932. private _weight;
  14933. private _syncRoot;
  14934. /**
  14935. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14936. * This will only apply for non looping animation (default is true)
  14937. */
  14938. disposeOnEnd: boolean;
  14939. /**
  14940. * Gets a boolean indicating if the animation has started
  14941. */
  14942. animationStarted: boolean;
  14943. /**
  14944. * Observer raised when the animation ends
  14945. */
  14946. onAnimationEndObservable: Observable<Animatable>;
  14947. /**
  14948. * Observer raised when the animation loops
  14949. */
  14950. onAnimationLoopObservable: Observable<Animatable>;
  14951. /**
  14952. * Gets the root Animatable used to synchronize and normalize animations
  14953. */
  14954. get syncRoot(): Nullable<Animatable>;
  14955. /**
  14956. * Gets the current frame of the first RuntimeAnimation
  14957. * Used to synchronize Animatables
  14958. */
  14959. get masterFrame(): number;
  14960. /**
  14961. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14962. */
  14963. get weight(): number;
  14964. set weight(value: number);
  14965. /**
  14966. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14967. */
  14968. get speedRatio(): number;
  14969. set speedRatio(value: number);
  14970. /**
  14971. * Creates a new Animatable
  14972. * @param scene defines the hosting scene
  14973. * @param target defines the target object
  14974. * @param fromFrame defines the starting frame number (default is 0)
  14975. * @param toFrame defines the ending frame number (default is 100)
  14976. * @param loopAnimation defines if the animation must loop (default is false)
  14977. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14978. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14979. * @param animations defines a group of animation to add to the new Animatable
  14980. * @param onAnimationLoop defines a callback to call when animation loops
  14981. */
  14982. constructor(scene: Scene,
  14983. /** defines the target object */
  14984. target: any,
  14985. /** defines the starting frame number (default is 0) */
  14986. fromFrame?: number,
  14987. /** defines the ending frame number (default is 100) */
  14988. toFrame?: number,
  14989. /** defines if the animation must loop (default is false) */
  14990. loopAnimation?: boolean, speedRatio?: number,
  14991. /** defines a callback to call when animation ends if it is not looping */
  14992. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14993. /** defines a callback to call when animation loops */
  14994. onAnimationLoop?: (() => void) | null | undefined);
  14995. /**
  14996. * Synchronize and normalize current Animatable with a source Animatable
  14997. * This is useful when using animation weights and when animations are not of the same length
  14998. * @param root defines the root Animatable to synchronize with
  14999. * @returns the current Animatable
  15000. */
  15001. syncWith(root: Animatable): Animatable;
  15002. /**
  15003. * Gets the list of runtime animations
  15004. * @returns an array of RuntimeAnimation
  15005. */
  15006. getAnimations(): RuntimeAnimation[];
  15007. /**
  15008. * Adds more animations to the current animatable
  15009. * @param target defines the target of the animations
  15010. * @param animations defines the new animations to add
  15011. */
  15012. appendAnimations(target: any, animations: Animation[]): void;
  15013. /**
  15014. * Gets the source animation for a specific property
  15015. * @param property defines the propertyu to look for
  15016. * @returns null or the source animation for the given property
  15017. */
  15018. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15019. /**
  15020. * Gets the runtime animation for a specific property
  15021. * @param property defines the propertyu to look for
  15022. * @returns null or the runtime animation for the given property
  15023. */
  15024. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15025. /**
  15026. * Resets the animatable to its original state
  15027. */
  15028. reset(): void;
  15029. /**
  15030. * Allows the animatable to blend with current running animations
  15031. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15032. * @param blendingSpeed defines the blending speed to use
  15033. */
  15034. enableBlending(blendingSpeed: number): void;
  15035. /**
  15036. * Disable animation blending
  15037. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15038. */
  15039. disableBlending(): void;
  15040. /**
  15041. * Jump directly to a given frame
  15042. * @param frame defines the frame to jump to
  15043. */
  15044. goToFrame(frame: number): void;
  15045. /**
  15046. * Pause the animation
  15047. */
  15048. pause(): void;
  15049. /**
  15050. * Restart the animation
  15051. */
  15052. restart(): void;
  15053. private _raiseOnAnimationEnd;
  15054. /**
  15055. * Stop and delete the current animation
  15056. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15057. * @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)
  15058. */
  15059. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15060. /**
  15061. * Wait asynchronously for the animation to end
  15062. * @returns a promise which will be fullfilled when the animation ends
  15063. */
  15064. waitAsync(): Promise<Animatable>;
  15065. /** @hidden */
  15066. _animate(delay: number): boolean;
  15067. }
  15068. module "babylonjs/scene" {
  15069. interface Scene {
  15070. /** @hidden */
  15071. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15072. /** @hidden */
  15073. _processLateAnimationBindingsForMatrices(holder: {
  15074. totalWeight: number;
  15075. animations: RuntimeAnimation[];
  15076. originalValue: Matrix;
  15077. }): any;
  15078. /** @hidden */
  15079. _processLateAnimationBindingsForQuaternions(holder: {
  15080. totalWeight: number;
  15081. animations: RuntimeAnimation[];
  15082. originalValue: Quaternion;
  15083. }, refQuaternion: Quaternion): Quaternion;
  15084. /** @hidden */
  15085. _processLateAnimationBindings(): void;
  15086. /**
  15087. * Will start the animation sequence of a given target
  15088. * @param target defines the target
  15089. * @param from defines from which frame should animation start
  15090. * @param to defines until which frame should animation run.
  15091. * @param weight defines the weight to apply to the animation (1.0 by default)
  15092. * @param loop defines if the animation loops
  15093. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15094. * @param onAnimationEnd defines the function to be executed when the animation ends
  15095. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15096. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15097. * @param onAnimationLoop defines the callback to call when an animation loops
  15098. * @returns the animatable object created for this animation
  15099. */
  15100. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15101. /**
  15102. * Will start the animation sequence of a given target
  15103. * @param target defines the target
  15104. * @param from defines from which frame should animation start
  15105. * @param to defines until which frame should animation run.
  15106. * @param loop defines if the animation loops
  15107. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15108. * @param onAnimationEnd defines the function to be executed when the animation ends
  15109. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15110. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15111. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15112. * @param onAnimationLoop defines the callback to call when an animation loops
  15113. * @returns the animatable object created for this animation
  15114. */
  15115. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15116. /**
  15117. * Will start the animation sequence of a given target and its hierarchy
  15118. * @param target defines the target
  15119. * @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.
  15120. * @param from defines from which frame should animation start
  15121. * @param to defines until which frame should animation run.
  15122. * @param loop defines if the animation loops
  15123. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15124. * @param onAnimationEnd defines the function to be executed when the animation ends
  15125. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15126. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15127. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15128. * @param onAnimationLoop defines the callback to call when an animation loops
  15129. * @returns the list of created animatables
  15130. */
  15131. 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): Animatable[];
  15132. /**
  15133. * Begin a new animation on a given node
  15134. * @param target defines the target where the animation will take place
  15135. * @param animations defines the list of animations to start
  15136. * @param from defines the initial value
  15137. * @param to defines the final value
  15138. * @param loop defines if you want animation to loop (off by default)
  15139. * @param speedRatio defines the speed ratio to apply to all animations
  15140. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15141. * @param onAnimationLoop defines the callback to call when an animation loops
  15142. * @returns the list of created animatables
  15143. */
  15144. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15145. /**
  15146. * Begin a new animation on a given node and its hierarchy
  15147. * @param target defines the root node where the animation will take place
  15148. * @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.
  15149. * @param animations defines the list of animations to start
  15150. * @param from defines the initial value
  15151. * @param to defines the final value
  15152. * @param loop defines if you want animation to loop (off by default)
  15153. * @param speedRatio defines the speed ratio to apply to all animations
  15154. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15155. * @param onAnimationLoop defines the callback to call when an animation loops
  15156. * @returns the list of animatables created for all nodes
  15157. */
  15158. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15159. /**
  15160. * Gets the animatable associated with a specific target
  15161. * @param target defines the target of the animatable
  15162. * @returns the required animatable if found
  15163. */
  15164. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15165. /**
  15166. * Gets all animatables associated with a given target
  15167. * @param target defines the target to look animatables for
  15168. * @returns an array of Animatables
  15169. */
  15170. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15171. /**
  15172. * Stops and removes all animations that have been applied to the scene
  15173. */
  15174. stopAllAnimations(): void;
  15175. /**
  15176. * Gets the current delta time used by animation engine
  15177. */
  15178. deltaTime: number;
  15179. }
  15180. }
  15181. module "babylonjs/Bones/bone" {
  15182. interface Bone {
  15183. /**
  15184. * Copy an animation range from another bone
  15185. * @param source defines the source bone
  15186. * @param rangeName defines the range name to copy
  15187. * @param frameOffset defines the frame offset
  15188. * @param rescaleAsRequired defines if rescaling must be applied if required
  15189. * @param skelDimensionsRatio defines the scaling ratio
  15190. * @returns true if operation was successful
  15191. */
  15192. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15193. }
  15194. }
  15195. }
  15196. declare module "babylonjs/Bones/skeleton" {
  15197. import { Bone } from "babylonjs/Bones/bone";
  15198. import { Observable } from "babylonjs/Misc/observable";
  15199. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15200. import { Scene } from "babylonjs/scene";
  15201. import { Nullable } from "babylonjs/types";
  15202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15203. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15204. import { Animatable } from "babylonjs/Animations/animatable";
  15205. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15206. import { Animation } from "babylonjs/Animations/animation";
  15207. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15208. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15209. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15210. /**
  15211. * Class used to handle skinning animations
  15212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15213. */
  15214. export class Skeleton implements IAnimatable {
  15215. /** defines the skeleton name */
  15216. name: string;
  15217. /** defines the skeleton Id */
  15218. id: string;
  15219. /**
  15220. * Defines the list of child bones
  15221. */
  15222. bones: Bone[];
  15223. /**
  15224. * Defines an estimate of the dimension of the skeleton at rest
  15225. */
  15226. dimensionsAtRest: Vector3;
  15227. /**
  15228. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15229. */
  15230. needInitialSkinMatrix: boolean;
  15231. /**
  15232. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15233. */
  15234. overrideMesh: Nullable<AbstractMesh>;
  15235. /**
  15236. * Gets the list of animations attached to this skeleton
  15237. */
  15238. animations: Array<Animation>;
  15239. private _scene;
  15240. private _isDirty;
  15241. private _transformMatrices;
  15242. private _transformMatrixTexture;
  15243. private _meshesWithPoseMatrix;
  15244. private _animatables;
  15245. private _identity;
  15246. private _synchronizedWithMesh;
  15247. private _ranges;
  15248. private _lastAbsoluteTransformsUpdateId;
  15249. private _canUseTextureForBones;
  15250. private _uniqueId;
  15251. /** @hidden */
  15252. _numBonesWithLinkedTransformNode: number;
  15253. /** @hidden */
  15254. _hasWaitingData: Nullable<boolean>;
  15255. /**
  15256. * Specifies if the skeleton should be serialized
  15257. */
  15258. doNotSerialize: boolean;
  15259. private _useTextureToStoreBoneMatrices;
  15260. /**
  15261. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15262. * Please note that this option is not available if the hardware does not support it
  15263. */
  15264. get useTextureToStoreBoneMatrices(): boolean;
  15265. set useTextureToStoreBoneMatrices(value: boolean);
  15266. private _animationPropertiesOverride;
  15267. /**
  15268. * Gets or sets the animation properties override
  15269. */
  15270. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15271. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15272. /**
  15273. * List of inspectable custom properties (used by the Inspector)
  15274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15275. */
  15276. inspectableCustomProperties: IInspectable[];
  15277. /**
  15278. * An observable triggered before computing the skeleton's matrices
  15279. */
  15280. onBeforeComputeObservable: Observable<Skeleton>;
  15281. /**
  15282. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15283. */
  15284. get isUsingTextureForMatrices(): boolean;
  15285. /**
  15286. * Gets the unique ID of this skeleton
  15287. */
  15288. get uniqueId(): number;
  15289. /**
  15290. * Creates a new skeleton
  15291. * @param name defines the skeleton name
  15292. * @param id defines the skeleton Id
  15293. * @param scene defines the hosting scene
  15294. */
  15295. constructor(
  15296. /** defines the skeleton name */
  15297. name: string,
  15298. /** defines the skeleton Id */
  15299. id: string, scene: Scene);
  15300. /**
  15301. * Gets the current object class name.
  15302. * @return the class name
  15303. */
  15304. getClassName(): string;
  15305. /**
  15306. * Returns an array containing the root bones
  15307. * @returns an array containing the root bones
  15308. */
  15309. getChildren(): Array<Bone>;
  15310. /**
  15311. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15312. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15313. * @returns a Float32Array containing matrices data
  15314. */
  15315. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15316. /**
  15317. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15318. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15319. * @returns a raw texture containing the data
  15320. */
  15321. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15322. /**
  15323. * Gets the current hosting scene
  15324. * @returns a scene object
  15325. */
  15326. getScene(): Scene;
  15327. /**
  15328. * Gets a string representing the current skeleton data
  15329. * @param fullDetails defines a boolean indicating if we want a verbose version
  15330. * @returns a string representing the current skeleton data
  15331. */
  15332. toString(fullDetails?: boolean): string;
  15333. /**
  15334. * Get bone's index searching by name
  15335. * @param name defines bone's name to search for
  15336. * @return the indice of the bone. Returns -1 if not found
  15337. */
  15338. getBoneIndexByName(name: string): number;
  15339. /**
  15340. * Creater a new animation range
  15341. * @param name defines the name of the range
  15342. * @param from defines the start key
  15343. * @param to defines the end key
  15344. */
  15345. createAnimationRange(name: string, from: number, to: number): void;
  15346. /**
  15347. * Delete a specific animation range
  15348. * @param name defines the name of the range
  15349. * @param deleteFrames defines if frames must be removed as well
  15350. */
  15351. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15352. /**
  15353. * Gets a specific animation range
  15354. * @param name defines the name of the range to look for
  15355. * @returns the requested animation range or null if not found
  15356. */
  15357. getAnimationRange(name: string): Nullable<AnimationRange>;
  15358. /**
  15359. * Gets the list of all animation ranges defined on this skeleton
  15360. * @returns an array
  15361. */
  15362. getAnimationRanges(): Nullable<AnimationRange>[];
  15363. /**
  15364. * Copy animation range from a source skeleton.
  15365. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15366. * @param source defines the source skeleton
  15367. * @param name defines the name of the range to copy
  15368. * @param rescaleAsRequired defines if rescaling must be applied if required
  15369. * @returns true if operation was successful
  15370. */
  15371. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15372. /**
  15373. * Forces the skeleton to go to rest pose
  15374. */
  15375. returnToRest(): void;
  15376. private _getHighestAnimationFrame;
  15377. /**
  15378. * Begin a specific animation range
  15379. * @param name defines the name of the range to start
  15380. * @param loop defines if looping must be turned on (false by default)
  15381. * @param speedRatio defines the speed ratio to apply (1 by default)
  15382. * @param onAnimationEnd defines a callback which will be called when animation will end
  15383. * @returns a new animatable
  15384. */
  15385. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15386. /** @hidden */
  15387. _markAsDirty(): void;
  15388. /** @hidden */
  15389. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15390. /** @hidden */
  15391. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15392. private _computeTransformMatrices;
  15393. /**
  15394. * Build all resources required to render a skeleton
  15395. */
  15396. prepare(): void;
  15397. /**
  15398. * Gets the list of animatables currently running for this skeleton
  15399. * @returns an array of animatables
  15400. */
  15401. getAnimatables(): IAnimatable[];
  15402. /**
  15403. * Clone the current skeleton
  15404. * @param name defines the name of the new skeleton
  15405. * @param id defines the id of the new skeleton
  15406. * @returns the new skeleton
  15407. */
  15408. clone(name: string, id?: string): Skeleton;
  15409. /**
  15410. * Enable animation blending for this skeleton
  15411. * @param blendingSpeed defines the blending speed to apply
  15412. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15413. */
  15414. enableBlending(blendingSpeed?: number): void;
  15415. /**
  15416. * Releases all resources associated with the current skeleton
  15417. */
  15418. dispose(): void;
  15419. /**
  15420. * Serialize the skeleton in a JSON object
  15421. * @returns a JSON object
  15422. */
  15423. serialize(): any;
  15424. /**
  15425. * Creates a new skeleton from serialized data
  15426. * @param parsedSkeleton defines the serialized data
  15427. * @param scene defines the hosting scene
  15428. * @returns a new skeleton
  15429. */
  15430. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15431. /**
  15432. * Compute all node absolute transforms
  15433. * @param forceUpdate defines if computation must be done even if cache is up to date
  15434. */
  15435. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15436. /**
  15437. * Gets the root pose matrix
  15438. * @returns a matrix
  15439. */
  15440. getPoseMatrix(): Nullable<Matrix>;
  15441. /**
  15442. * Sorts bones per internal index
  15443. */
  15444. sortBones(): void;
  15445. private _sortBones;
  15446. }
  15447. }
  15448. declare module "babylonjs/Meshes/instancedMesh" {
  15449. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15450. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15451. import { Camera } from "babylonjs/Cameras/camera";
  15452. import { Node } from "babylonjs/node";
  15453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15454. import { Mesh } from "babylonjs/Meshes/mesh";
  15455. import { Material } from "babylonjs/Materials/material";
  15456. import { Skeleton } from "babylonjs/Bones/skeleton";
  15457. import { Light } from "babylonjs/Lights/light";
  15458. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15459. /**
  15460. * Creates an instance based on a source mesh.
  15461. */
  15462. export class InstancedMesh extends AbstractMesh {
  15463. private _sourceMesh;
  15464. private _currentLOD;
  15465. /** @hidden */
  15466. _indexInSourceMeshInstanceArray: number;
  15467. constructor(name: string, source: Mesh);
  15468. /**
  15469. * Returns the string "InstancedMesh".
  15470. */
  15471. getClassName(): string;
  15472. /** Gets the list of lights affecting that mesh */
  15473. get lightSources(): Light[];
  15474. _resyncLightSources(): void;
  15475. _resyncLightSource(light: Light): void;
  15476. _removeLightSource(light: Light, dispose: boolean): void;
  15477. /**
  15478. * If the source mesh receives shadows
  15479. */
  15480. get receiveShadows(): boolean;
  15481. /**
  15482. * The material of the source mesh
  15483. */
  15484. get material(): Nullable<Material>;
  15485. /**
  15486. * Visibility of the source mesh
  15487. */
  15488. get visibility(): number;
  15489. /**
  15490. * Skeleton of the source mesh
  15491. */
  15492. get skeleton(): Nullable<Skeleton>;
  15493. /**
  15494. * Rendering ground id of the source mesh
  15495. */
  15496. get renderingGroupId(): number;
  15497. set renderingGroupId(value: number);
  15498. /**
  15499. * Returns the total number of vertices (integer).
  15500. */
  15501. getTotalVertices(): number;
  15502. /**
  15503. * Returns a positive integer : the total number of indices in this mesh geometry.
  15504. * @returns the numner of indices or zero if the mesh has no geometry.
  15505. */
  15506. getTotalIndices(): number;
  15507. /**
  15508. * The source mesh of the instance
  15509. */
  15510. get sourceMesh(): Mesh;
  15511. /**
  15512. * Is this node ready to be used/rendered
  15513. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15514. * @return {boolean} is it ready
  15515. */
  15516. isReady(completeCheck?: boolean): boolean;
  15517. /**
  15518. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15519. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15520. * @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.
  15521. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15522. */
  15523. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15524. /**
  15525. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15526. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15527. * The `data` are either a numeric array either a Float32Array.
  15528. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15529. * 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).
  15530. * Note that a new underlying VertexBuffer object is created each call.
  15531. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15532. *
  15533. * Possible `kind` values :
  15534. * - VertexBuffer.PositionKind
  15535. * - VertexBuffer.UVKind
  15536. * - VertexBuffer.UV2Kind
  15537. * - VertexBuffer.UV3Kind
  15538. * - VertexBuffer.UV4Kind
  15539. * - VertexBuffer.UV5Kind
  15540. * - VertexBuffer.UV6Kind
  15541. * - VertexBuffer.ColorKind
  15542. * - VertexBuffer.MatricesIndicesKind
  15543. * - VertexBuffer.MatricesIndicesExtraKind
  15544. * - VertexBuffer.MatricesWeightsKind
  15545. * - VertexBuffer.MatricesWeightsExtraKind
  15546. *
  15547. * Returns the Mesh.
  15548. */
  15549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15550. /**
  15551. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15552. * If the mesh has no geometry, it is simply returned as it is.
  15553. * The `data` are either a numeric array either a Float32Array.
  15554. * No new underlying VertexBuffer object is created.
  15555. * 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.
  15556. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15557. *
  15558. * Possible `kind` values :
  15559. * - VertexBuffer.PositionKind
  15560. * - VertexBuffer.UVKind
  15561. * - VertexBuffer.UV2Kind
  15562. * - VertexBuffer.UV3Kind
  15563. * - VertexBuffer.UV4Kind
  15564. * - VertexBuffer.UV5Kind
  15565. * - VertexBuffer.UV6Kind
  15566. * - VertexBuffer.ColorKind
  15567. * - VertexBuffer.MatricesIndicesKind
  15568. * - VertexBuffer.MatricesIndicesExtraKind
  15569. * - VertexBuffer.MatricesWeightsKind
  15570. * - VertexBuffer.MatricesWeightsExtraKind
  15571. *
  15572. * Returns the Mesh.
  15573. */
  15574. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15575. /**
  15576. * Sets the mesh indices.
  15577. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15578. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15579. * This method creates a new index buffer each call.
  15580. * Returns the Mesh.
  15581. */
  15582. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15583. /**
  15584. * Boolean : True if the mesh owns the requested kind of data.
  15585. */
  15586. isVerticesDataPresent(kind: string): boolean;
  15587. /**
  15588. * Returns an array of indices (IndicesArray).
  15589. */
  15590. getIndices(): Nullable<IndicesArray>;
  15591. get _positions(): Nullable<Vector3[]>;
  15592. /**
  15593. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15594. * This means the mesh underlying bounding box and sphere are recomputed.
  15595. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15596. * @returns the current mesh
  15597. */
  15598. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15599. /** @hidden */
  15600. _preActivate(): InstancedMesh;
  15601. /** @hidden */
  15602. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15603. /** @hidden */
  15604. _postActivate(): void;
  15605. getWorldMatrix(): Matrix;
  15606. get isAnInstance(): boolean;
  15607. /**
  15608. * Returns the current associated LOD AbstractMesh.
  15609. */
  15610. getLOD(camera: Camera): AbstractMesh;
  15611. /** @hidden */
  15612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15613. /** @hidden */
  15614. _syncSubMeshes(): InstancedMesh;
  15615. /** @hidden */
  15616. _generatePointsArray(): boolean;
  15617. /**
  15618. * Creates a new InstancedMesh from the current mesh.
  15619. * - name (string) : the cloned mesh name
  15620. * - newParent (optional Node) : the optional Node to parent the clone to.
  15621. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15622. *
  15623. * Returns the clone.
  15624. */
  15625. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15626. /**
  15627. * Disposes the InstancedMesh.
  15628. * Returns nothing.
  15629. */
  15630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15631. }
  15632. module "babylonjs/Meshes/mesh" {
  15633. interface Mesh {
  15634. /**
  15635. * Register a custom buffer that will be instanced
  15636. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15637. * @param kind defines the buffer kind
  15638. * @param stride defines the stride in floats
  15639. */
  15640. registerInstancedBuffer(kind: string, stride: number): void;
  15641. /** @hidden */
  15642. _userInstancedBuffersStorage: {
  15643. data: {
  15644. [key: string]: Float32Array;
  15645. };
  15646. sizes: {
  15647. [key: string]: number;
  15648. };
  15649. vertexBuffers: {
  15650. [key: string]: Nullable<VertexBuffer>;
  15651. };
  15652. strides: {
  15653. [key: string]: number;
  15654. };
  15655. };
  15656. }
  15657. }
  15658. module "babylonjs/Meshes/abstractMesh" {
  15659. interface AbstractMesh {
  15660. /**
  15661. * Object used to store instanced buffers defined by user
  15662. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15663. */
  15664. instancedBuffers: {
  15665. [key: string]: any;
  15666. };
  15667. }
  15668. }
  15669. }
  15670. declare module "babylonjs/Materials/shaderMaterial" {
  15671. import { Scene } from "babylonjs/scene";
  15672. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15674. import { Mesh } from "babylonjs/Meshes/mesh";
  15675. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15676. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15677. import { Texture } from "babylonjs/Materials/Textures/texture";
  15678. import { Material } from "babylonjs/Materials/material";
  15679. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15680. /**
  15681. * Defines the options associated with the creation of a shader material.
  15682. */
  15683. export interface IShaderMaterialOptions {
  15684. /**
  15685. * Does the material work in alpha blend mode
  15686. */
  15687. needAlphaBlending: boolean;
  15688. /**
  15689. * Does the material work in alpha test mode
  15690. */
  15691. needAlphaTesting: boolean;
  15692. /**
  15693. * The list of attribute names used in the shader
  15694. */
  15695. attributes: string[];
  15696. /**
  15697. * The list of unifrom names used in the shader
  15698. */
  15699. uniforms: string[];
  15700. /**
  15701. * The list of UBO names used in the shader
  15702. */
  15703. uniformBuffers: string[];
  15704. /**
  15705. * The list of sampler names used in the shader
  15706. */
  15707. samplers: string[];
  15708. /**
  15709. * The list of defines used in the shader
  15710. */
  15711. defines: string[];
  15712. }
  15713. /**
  15714. * 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.
  15715. *
  15716. * This returned material effects how the mesh will look based on the code in the shaders.
  15717. *
  15718. * @see http://doc.babylonjs.com/how_to/shader_material
  15719. */
  15720. export class ShaderMaterial extends Material {
  15721. private _shaderPath;
  15722. private _options;
  15723. private _textures;
  15724. private _textureArrays;
  15725. private _floats;
  15726. private _ints;
  15727. private _floatsArrays;
  15728. private _colors3;
  15729. private _colors3Arrays;
  15730. private _colors4;
  15731. private _colors4Arrays;
  15732. private _vectors2;
  15733. private _vectors3;
  15734. private _vectors4;
  15735. private _matrices;
  15736. private _matrixArrays;
  15737. private _matrices3x3;
  15738. private _matrices2x2;
  15739. private _vectors2Arrays;
  15740. private _vectors3Arrays;
  15741. private _vectors4Arrays;
  15742. private _cachedWorldViewMatrix;
  15743. private _cachedWorldViewProjectionMatrix;
  15744. private _renderId;
  15745. private _multiview;
  15746. /**
  15747. * Instantiate a new shader material.
  15748. * 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.
  15749. * This returned material effects how the mesh will look based on the code in the shaders.
  15750. * @see http://doc.babylonjs.com/how_to/shader_material
  15751. * @param name Define the name of the material in the scene
  15752. * @param scene Define the scene the material belongs to
  15753. * @param shaderPath Defines the route to the shader code in one of three ways:
  15754. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15755. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15756. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15757. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15758. * @param options Define the options used to create the shader
  15759. */
  15760. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15761. /**
  15762. * Gets the shader path used to define the shader code
  15763. * It can be modified to trigger a new compilation
  15764. */
  15765. get shaderPath(): any;
  15766. /**
  15767. * Sets the shader path used to define the shader code
  15768. * It can be modified to trigger a new compilation
  15769. */
  15770. set shaderPath(shaderPath: any);
  15771. /**
  15772. * Gets the options used to compile the shader.
  15773. * They can be modified to trigger a new compilation
  15774. */
  15775. get options(): IShaderMaterialOptions;
  15776. /**
  15777. * Gets the current class name of the material e.g. "ShaderMaterial"
  15778. * Mainly use in serialization.
  15779. * @returns the class name
  15780. */
  15781. getClassName(): string;
  15782. /**
  15783. * Specifies if the material will require alpha blending
  15784. * @returns a boolean specifying if alpha blending is needed
  15785. */
  15786. needAlphaBlending(): boolean;
  15787. /**
  15788. * Specifies if this material should be rendered in alpha test mode
  15789. * @returns a boolean specifying if an alpha test is needed.
  15790. */
  15791. needAlphaTesting(): boolean;
  15792. private _checkUniform;
  15793. /**
  15794. * Set a texture in the shader.
  15795. * @param name Define the name of the uniform samplers as defined in the shader
  15796. * @param texture Define the texture to bind to this sampler
  15797. * @return the material itself allowing "fluent" like uniform updates
  15798. */
  15799. setTexture(name: string, texture: Texture): ShaderMaterial;
  15800. /**
  15801. * Set a texture array in the shader.
  15802. * @param name Define the name of the uniform sampler array as defined in the shader
  15803. * @param textures Define the list of textures to bind to this sampler
  15804. * @return the material itself allowing "fluent" like uniform updates
  15805. */
  15806. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15807. /**
  15808. * Set a float in the shader.
  15809. * @param name Define the name of the uniform as defined in the shader
  15810. * @param value Define the value to give to the uniform
  15811. * @return the material itself allowing "fluent" like uniform updates
  15812. */
  15813. setFloat(name: string, value: number): ShaderMaterial;
  15814. /**
  15815. * Set a int in the shader.
  15816. * @param name Define the name of the uniform as defined in the shader
  15817. * @param value Define the value to give to the uniform
  15818. * @return the material itself allowing "fluent" like uniform updates
  15819. */
  15820. setInt(name: string, value: number): ShaderMaterial;
  15821. /**
  15822. * Set an array of floats in the shader.
  15823. * @param name Define the name of the uniform as defined in the shader
  15824. * @param value Define the value to give to the uniform
  15825. * @return the material itself allowing "fluent" like uniform updates
  15826. */
  15827. setFloats(name: string, value: number[]): ShaderMaterial;
  15828. /**
  15829. * Set a vec3 in the shader from a Color3.
  15830. * @param name Define the name of the uniform as defined in the shader
  15831. * @param value Define the value to give to the uniform
  15832. * @return the material itself allowing "fluent" like uniform updates
  15833. */
  15834. setColor3(name: string, value: Color3): ShaderMaterial;
  15835. /**
  15836. * Set a vec3 array in the shader from a Color3 array.
  15837. * @param name Define the name of the uniform as defined in the shader
  15838. * @param value Define the value to give to the uniform
  15839. * @return the material itself allowing "fluent" like uniform updates
  15840. */
  15841. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15842. /**
  15843. * Set a vec4 in the shader from a Color4.
  15844. * @param name Define the name of the uniform as defined in the shader
  15845. * @param value Define the value to give to the uniform
  15846. * @return the material itself allowing "fluent" like uniform updates
  15847. */
  15848. setColor4(name: string, value: Color4): ShaderMaterial;
  15849. /**
  15850. * Set a vec4 array in the shader from a Color4 array.
  15851. * @param name Define the name of the uniform as defined in the shader
  15852. * @param value Define the value to give to the uniform
  15853. * @return the material itself allowing "fluent" like uniform updates
  15854. */
  15855. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15856. /**
  15857. * Set a vec2 in the shader from a Vector2.
  15858. * @param name Define the name of the uniform as defined in the shader
  15859. * @param value Define the value to give to the uniform
  15860. * @return the material itself allowing "fluent" like uniform updates
  15861. */
  15862. setVector2(name: string, value: Vector2): ShaderMaterial;
  15863. /**
  15864. * Set a vec3 in the shader from a Vector3.
  15865. * @param name Define the name of the uniform as defined in the shader
  15866. * @param value Define the value to give to the uniform
  15867. * @return the material itself allowing "fluent" like uniform updates
  15868. */
  15869. setVector3(name: string, value: Vector3): ShaderMaterial;
  15870. /**
  15871. * Set a vec4 in the shader from a Vector4.
  15872. * @param name Define the name of the uniform as defined in the shader
  15873. * @param value Define the value to give to the uniform
  15874. * @return the material itself allowing "fluent" like uniform updates
  15875. */
  15876. setVector4(name: string, value: Vector4): ShaderMaterial;
  15877. /**
  15878. * Set a mat4 in the shader from a Matrix.
  15879. * @param name Define the name of the uniform as defined in the shader
  15880. * @param value Define the value to give to the uniform
  15881. * @return the material itself allowing "fluent" like uniform updates
  15882. */
  15883. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15884. /**
  15885. * Set a float32Array in the shader from a matrix array.
  15886. * @param name Define the name of the uniform as defined in the shader
  15887. * @param value Define the value to give to the uniform
  15888. * @return the material itself allowing "fluent" like uniform updates
  15889. */
  15890. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15891. /**
  15892. * Set a mat3 in the shader from a Float32Array.
  15893. * @param name Define the name of the uniform as defined in the shader
  15894. * @param value Define the value to give to the uniform
  15895. * @return the material itself allowing "fluent" like uniform updates
  15896. */
  15897. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15898. /**
  15899. * Set a mat2 in the shader from a Float32Array.
  15900. * @param name Define the name of the uniform as defined in the shader
  15901. * @param value Define the value to give to the uniform
  15902. * @return the material itself allowing "fluent" like uniform updates
  15903. */
  15904. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15905. /**
  15906. * Set a vec2 array in the shader from a number array.
  15907. * @param name Define the name of the uniform as defined in the shader
  15908. * @param value Define the value to give to the uniform
  15909. * @return the material itself allowing "fluent" like uniform updates
  15910. */
  15911. setArray2(name: string, value: number[]): ShaderMaterial;
  15912. /**
  15913. * Set a vec3 array in the shader from a number array.
  15914. * @param name Define the name of the uniform as defined in the shader
  15915. * @param value Define the value to give to the uniform
  15916. * @return the material itself allowing "fluent" like uniform updates
  15917. */
  15918. setArray3(name: string, value: number[]): ShaderMaterial;
  15919. /**
  15920. * Set a vec4 array in the shader from a number array.
  15921. * @param name Define the name of the uniform as defined in the shader
  15922. * @param value Define the value to give to the uniform
  15923. * @return the material itself allowing "fluent" like uniform updates
  15924. */
  15925. setArray4(name: string, value: number[]): ShaderMaterial;
  15926. private _checkCache;
  15927. /**
  15928. * Specifies that the submesh is ready to be used
  15929. * @param mesh defines the mesh to check
  15930. * @param subMesh defines which submesh to check
  15931. * @param useInstances specifies that instances should be used
  15932. * @returns a boolean indicating that the submesh is ready or not
  15933. */
  15934. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15935. /**
  15936. * Checks if the material is ready to render the requested mesh
  15937. * @param mesh Define the mesh to render
  15938. * @param useInstances Define whether or not the material is used with instances
  15939. * @returns true if ready, otherwise false
  15940. */
  15941. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15942. /**
  15943. * Binds the world matrix to the material
  15944. * @param world defines the world transformation matrix
  15945. */
  15946. bindOnlyWorldMatrix(world: Matrix): void;
  15947. /**
  15948. * Binds the material to the mesh
  15949. * @param world defines the world transformation matrix
  15950. * @param mesh defines the mesh to bind the material to
  15951. */
  15952. bind(world: Matrix, mesh?: Mesh): void;
  15953. /**
  15954. * Gets the active textures from the material
  15955. * @returns an array of textures
  15956. */
  15957. getActiveTextures(): BaseTexture[];
  15958. /**
  15959. * Specifies if the material uses a texture
  15960. * @param texture defines the texture to check against the material
  15961. * @returns a boolean specifying if the material uses the texture
  15962. */
  15963. hasTexture(texture: BaseTexture): boolean;
  15964. /**
  15965. * Makes a duplicate of the material, and gives it a new name
  15966. * @param name defines the new name for the duplicated material
  15967. * @returns the cloned material
  15968. */
  15969. clone(name: string): ShaderMaterial;
  15970. /**
  15971. * Disposes the material
  15972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15974. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15975. */
  15976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15977. /**
  15978. * Serializes this material in a JSON representation
  15979. * @returns the serialized material object
  15980. */
  15981. serialize(): any;
  15982. /**
  15983. * Creates a shader material from parsed shader material data
  15984. * @param source defines the JSON represnetation of the material
  15985. * @param scene defines the hosting scene
  15986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15987. * @returns a new material
  15988. */
  15989. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15990. }
  15991. }
  15992. declare module "babylonjs/Shaders/color.fragment" {
  15993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15995. /** @hidden */
  15996. export var colorPixelShader: {
  15997. name: string;
  15998. shader: string;
  15999. };
  16000. }
  16001. declare module "babylonjs/Shaders/color.vertex" {
  16002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16008. /** @hidden */
  16009. export var colorVertexShader: {
  16010. name: string;
  16011. shader: string;
  16012. };
  16013. }
  16014. declare module "babylonjs/Meshes/linesMesh" {
  16015. import { Nullable } from "babylonjs/types";
  16016. import { Scene } from "babylonjs/scene";
  16017. import { Color3 } from "babylonjs/Maths/math.color";
  16018. import { Node } from "babylonjs/node";
  16019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16020. import { Mesh } from "babylonjs/Meshes/mesh";
  16021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16022. import { Effect } from "babylonjs/Materials/effect";
  16023. import { Material } from "babylonjs/Materials/material";
  16024. import "babylonjs/Shaders/color.fragment";
  16025. import "babylonjs/Shaders/color.vertex";
  16026. /**
  16027. * Line mesh
  16028. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16029. */
  16030. export class LinesMesh extends Mesh {
  16031. /**
  16032. * If vertex color should be applied to the mesh
  16033. */
  16034. readonly useVertexColor?: boolean | undefined;
  16035. /**
  16036. * If vertex alpha should be applied to the mesh
  16037. */
  16038. readonly useVertexAlpha?: boolean | undefined;
  16039. /**
  16040. * Color of the line (Default: White)
  16041. */
  16042. color: Color3;
  16043. /**
  16044. * Alpha of the line (Default: 1)
  16045. */
  16046. alpha: number;
  16047. /**
  16048. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16049. * This margin is expressed in world space coordinates, so its value may vary.
  16050. * Default value is 0.1
  16051. */
  16052. intersectionThreshold: number;
  16053. private _colorShader;
  16054. private color4;
  16055. /**
  16056. * Creates a new LinesMesh
  16057. * @param name defines the name
  16058. * @param scene defines the hosting scene
  16059. * @param parent defines the parent mesh if any
  16060. * @param source defines the optional source LinesMesh used to clone data from
  16061. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16062. * When false, achieved by calling a clone(), also passing False.
  16063. * This will make creation of children, recursive.
  16064. * @param useVertexColor defines if this LinesMesh supports vertex color
  16065. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16066. */
  16067. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16068. /**
  16069. * If vertex color should be applied to the mesh
  16070. */
  16071. useVertexColor?: boolean | undefined,
  16072. /**
  16073. * If vertex alpha should be applied to the mesh
  16074. */
  16075. useVertexAlpha?: boolean | undefined);
  16076. private _addClipPlaneDefine;
  16077. private _removeClipPlaneDefine;
  16078. isReady(): boolean;
  16079. /**
  16080. * Returns the string "LineMesh"
  16081. */
  16082. getClassName(): string;
  16083. /**
  16084. * @hidden
  16085. */
  16086. get material(): Material;
  16087. /**
  16088. * @hidden
  16089. */
  16090. set material(value: Material);
  16091. /**
  16092. * @hidden
  16093. */
  16094. get checkCollisions(): boolean;
  16095. /** @hidden */
  16096. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16097. /** @hidden */
  16098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16099. /**
  16100. * Disposes of the line mesh
  16101. * @param doNotRecurse If children should be disposed
  16102. */
  16103. dispose(doNotRecurse?: boolean): void;
  16104. /**
  16105. * Returns a new LineMesh object cloned from the current one.
  16106. */
  16107. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16108. /**
  16109. * Creates a new InstancedLinesMesh object from the mesh model.
  16110. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16111. * @param name defines the name of the new instance
  16112. * @returns a new InstancedLinesMesh
  16113. */
  16114. createInstance(name: string): InstancedLinesMesh;
  16115. }
  16116. /**
  16117. * Creates an instance based on a source LinesMesh
  16118. */
  16119. export class InstancedLinesMesh extends InstancedMesh {
  16120. /**
  16121. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16122. * This margin is expressed in world space coordinates, so its value may vary.
  16123. * Initilized with the intersectionThreshold value of the source LinesMesh
  16124. */
  16125. intersectionThreshold: number;
  16126. constructor(name: string, source: LinesMesh);
  16127. /**
  16128. * Returns the string "InstancedLinesMesh".
  16129. */
  16130. getClassName(): string;
  16131. }
  16132. }
  16133. declare module "babylonjs/Shaders/line.fragment" {
  16134. /** @hidden */
  16135. export var linePixelShader: {
  16136. name: string;
  16137. shader: string;
  16138. };
  16139. }
  16140. declare module "babylonjs/Shaders/line.vertex" {
  16141. /** @hidden */
  16142. export var lineVertexShader: {
  16143. name: string;
  16144. shader: string;
  16145. };
  16146. }
  16147. declare module "babylonjs/Rendering/edgesRenderer" {
  16148. import { Nullable } from "babylonjs/types";
  16149. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16151. import { Vector3 } from "babylonjs/Maths/math.vector";
  16152. import { IDisposable } from "babylonjs/scene";
  16153. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16154. import "babylonjs/Shaders/line.fragment";
  16155. import "babylonjs/Shaders/line.vertex";
  16156. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16157. module "babylonjs/Meshes/abstractMesh" {
  16158. interface AbstractMesh {
  16159. /**
  16160. * Gets the edgesRenderer associated with the mesh
  16161. */
  16162. edgesRenderer: Nullable<EdgesRenderer>;
  16163. }
  16164. }
  16165. module "babylonjs/Meshes/linesMesh" {
  16166. interface LinesMesh {
  16167. /**
  16168. * Enables the edge rendering mode on the mesh.
  16169. * This mode makes the mesh edges visible
  16170. * @param epsilon defines the maximal distance between two angles to detect a face
  16171. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16172. * @returns the currentAbstractMesh
  16173. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16174. */
  16175. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16176. }
  16177. }
  16178. module "babylonjs/Meshes/linesMesh" {
  16179. interface InstancedLinesMesh {
  16180. /**
  16181. * Enables the edge rendering mode on the mesh.
  16182. * This mode makes the mesh edges visible
  16183. * @param epsilon defines the maximal distance between two angles to detect a face
  16184. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16185. * @returns the current InstancedLinesMesh
  16186. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16187. */
  16188. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16189. }
  16190. }
  16191. /**
  16192. * Defines the minimum contract an Edges renderer should follow.
  16193. */
  16194. export interface IEdgesRenderer extends IDisposable {
  16195. /**
  16196. * Gets or sets a boolean indicating if the edgesRenderer is active
  16197. */
  16198. isEnabled: boolean;
  16199. /**
  16200. * Renders the edges of the attached mesh,
  16201. */
  16202. render(): void;
  16203. /**
  16204. * Checks wether or not the edges renderer is ready to render.
  16205. * @return true if ready, otherwise false.
  16206. */
  16207. isReady(): boolean;
  16208. }
  16209. /**
  16210. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16211. */
  16212. export class EdgesRenderer implements IEdgesRenderer {
  16213. /**
  16214. * Define the size of the edges with an orthographic camera
  16215. */
  16216. edgesWidthScalerForOrthographic: number;
  16217. /**
  16218. * Define the size of the edges with a perspective camera
  16219. */
  16220. edgesWidthScalerForPerspective: number;
  16221. protected _source: AbstractMesh;
  16222. protected _linesPositions: number[];
  16223. protected _linesNormals: number[];
  16224. protected _linesIndices: number[];
  16225. protected _epsilon: number;
  16226. protected _indicesCount: number;
  16227. protected _lineShader: ShaderMaterial;
  16228. protected _ib: DataBuffer;
  16229. protected _buffers: {
  16230. [key: string]: Nullable<VertexBuffer>;
  16231. };
  16232. protected _checkVerticesInsteadOfIndices: boolean;
  16233. private _meshRebuildObserver;
  16234. private _meshDisposeObserver;
  16235. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16236. isEnabled: boolean;
  16237. /**
  16238. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16239. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16240. * @param source Mesh used to create edges
  16241. * @param epsilon sum of angles in adjacency to check for edge
  16242. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16243. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16244. */
  16245. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16246. protected _prepareRessources(): void;
  16247. /** @hidden */
  16248. _rebuild(): void;
  16249. /**
  16250. * Releases the required resources for the edges renderer
  16251. */
  16252. dispose(): void;
  16253. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16254. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16255. /**
  16256. * Checks if the pair of p0 and p1 is en edge
  16257. * @param faceIndex
  16258. * @param edge
  16259. * @param faceNormals
  16260. * @param p0
  16261. * @param p1
  16262. * @private
  16263. */
  16264. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16265. /**
  16266. * push line into the position, normal and index buffer
  16267. * @protected
  16268. */
  16269. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16270. /**
  16271. * Generates lines edges from adjacencjes
  16272. * @private
  16273. */
  16274. _generateEdgesLines(): void;
  16275. /**
  16276. * Checks wether or not the edges renderer is ready to render.
  16277. * @return true if ready, otherwise false.
  16278. */
  16279. isReady(): boolean;
  16280. /**
  16281. * Renders the edges of the attached mesh,
  16282. */
  16283. render(): void;
  16284. }
  16285. /**
  16286. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16287. */
  16288. export class LineEdgesRenderer extends EdgesRenderer {
  16289. /**
  16290. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16291. * @param source LineMesh used to generate edges
  16292. * @param epsilon not important (specified angle for edge detection)
  16293. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16294. */
  16295. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16296. /**
  16297. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16298. */
  16299. _generateEdgesLines(): void;
  16300. }
  16301. }
  16302. declare module "babylonjs/Rendering/renderingGroup" {
  16303. import { SmartArray } from "babylonjs/Misc/smartArray";
  16304. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16306. import { Nullable } from "babylonjs/types";
  16307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16308. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16309. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16310. import { Material } from "babylonjs/Materials/material";
  16311. import { Scene } from "babylonjs/scene";
  16312. /**
  16313. * This represents the object necessary to create a rendering group.
  16314. * This is exclusively used and created by the rendering manager.
  16315. * To modify the behavior, you use the available helpers in your scene or meshes.
  16316. * @hidden
  16317. */
  16318. export class RenderingGroup {
  16319. index: number;
  16320. private static _zeroVector;
  16321. private _scene;
  16322. private _opaqueSubMeshes;
  16323. private _transparentSubMeshes;
  16324. private _alphaTestSubMeshes;
  16325. private _depthOnlySubMeshes;
  16326. private _particleSystems;
  16327. private _spriteManagers;
  16328. private _opaqueSortCompareFn;
  16329. private _alphaTestSortCompareFn;
  16330. private _transparentSortCompareFn;
  16331. private _renderOpaque;
  16332. private _renderAlphaTest;
  16333. private _renderTransparent;
  16334. /** @hidden */
  16335. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16336. onBeforeTransparentRendering: () => void;
  16337. /**
  16338. * Set the opaque sort comparison function.
  16339. * If null the sub meshes will be render in the order they were created
  16340. */
  16341. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16342. /**
  16343. * Set the alpha test sort comparison function.
  16344. * If null the sub meshes will be render in the order they were created
  16345. */
  16346. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16347. /**
  16348. * Set the transparent sort comparison function.
  16349. * If null the sub meshes will be render in the order they were created
  16350. */
  16351. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16352. /**
  16353. * Creates a new rendering group.
  16354. * @param index The rendering group index
  16355. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16356. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16357. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16358. */
  16359. 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>);
  16360. /**
  16361. * Render all the sub meshes contained in the group.
  16362. * @param customRenderFunction Used to override the default render behaviour of the group.
  16363. * @returns true if rendered some submeshes.
  16364. */
  16365. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16366. /**
  16367. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16368. * @param subMeshes The submeshes to render
  16369. */
  16370. private renderOpaqueSorted;
  16371. /**
  16372. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16373. * @param subMeshes The submeshes to render
  16374. */
  16375. private renderAlphaTestSorted;
  16376. /**
  16377. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16378. * @param subMeshes The submeshes to render
  16379. */
  16380. private renderTransparentSorted;
  16381. /**
  16382. * Renders the submeshes in a specified order.
  16383. * @param subMeshes The submeshes to sort before render
  16384. * @param sortCompareFn The comparison function use to sort
  16385. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16386. * @param transparent Specifies to activate blending if true
  16387. */
  16388. private static renderSorted;
  16389. /**
  16390. * Renders the submeshes in the order they were dispatched (no sort applied).
  16391. * @param subMeshes The submeshes to render
  16392. */
  16393. private static renderUnsorted;
  16394. /**
  16395. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16396. * are rendered back to front if in the same alpha index.
  16397. *
  16398. * @param a The first submesh
  16399. * @param b The second submesh
  16400. * @returns The result of the comparison
  16401. */
  16402. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16403. /**
  16404. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16405. * are rendered back to front.
  16406. *
  16407. * @param a The first submesh
  16408. * @param b The second submesh
  16409. * @returns The result of the comparison
  16410. */
  16411. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16412. /**
  16413. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16414. * are rendered front to back (prevent overdraw).
  16415. *
  16416. * @param a The first submesh
  16417. * @param b The second submesh
  16418. * @returns The result of the comparison
  16419. */
  16420. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16421. /**
  16422. * Resets the different lists of submeshes to prepare a new frame.
  16423. */
  16424. prepare(): void;
  16425. dispose(): void;
  16426. /**
  16427. * Inserts the submesh in its correct queue depending on its material.
  16428. * @param subMesh The submesh to dispatch
  16429. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16430. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16431. */
  16432. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16433. dispatchSprites(spriteManager: ISpriteManager): void;
  16434. dispatchParticles(particleSystem: IParticleSystem): void;
  16435. private _renderParticles;
  16436. private _renderSprites;
  16437. }
  16438. }
  16439. declare module "babylonjs/Rendering/renderingManager" {
  16440. import { Nullable } from "babylonjs/types";
  16441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16443. import { SmartArray } from "babylonjs/Misc/smartArray";
  16444. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16445. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16446. import { Material } from "babylonjs/Materials/material";
  16447. import { Scene } from "babylonjs/scene";
  16448. import { Camera } from "babylonjs/Cameras/camera";
  16449. /**
  16450. * Interface describing the different options available in the rendering manager
  16451. * regarding Auto Clear between groups.
  16452. */
  16453. export interface IRenderingManagerAutoClearSetup {
  16454. /**
  16455. * Defines whether or not autoclear is enable.
  16456. */
  16457. autoClear: boolean;
  16458. /**
  16459. * Defines whether or not to autoclear the depth buffer.
  16460. */
  16461. depth: boolean;
  16462. /**
  16463. * Defines whether or not to autoclear the stencil buffer.
  16464. */
  16465. stencil: boolean;
  16466. }
  16467. /**
  16468. * This class is used by the onRenderingGroupObservable
  16469. */
  16470. export class RenderingGroupInfo {
  16471. /**
  16472. * The Scene that being rendered
  16473. */
  16474. scene: Scene;
  16475. /**
  16476. * The camera currently used for the rendering pass
  16477. */
  16478. camera: Nullable<Camera>;
  16479. /**
  16480. * The ID of the renderingGroup being processed
  16481. */
  16482. renderingGroupId: number;
  16483. }
  16484. /**
  16485. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16486. * It is enable to manage the different groups as well as the different necessary sort functions.
  16487. * This should not be used directly aside of the few static configurations
  16488. */
  16489. export class RenderingManager {
  16490. /**
  16491. * The max id used for rendering groups (not included)
  16492. */
  16493. static MAX_RENDERINGGROUPS: number;
  16494. /**
  16495. * The min id used for rendering groups (included)
  16496. */
  16497. static MIN_RENDERINGGROUPS: number;
  16498. /**
  16499. * Used to globally prevent autoclearing scenes.
  16500. */
  16501. static AUTOCLEAR: boolean;
  16502. /**
  16503. * @hidden
  16504. */
  16505. _useSceneAutoClearSetup: boolean;
  16506. private _scene;
  16507. private _renderingGroups;
  16508. private _depthStencilBufferAlreadyCleaned;
  16509. private _autoClearDepthStencil;
  16510. private _customOpaqueSortCompareFn;
  16511. private _customAlphaTestSortCompareFn;
  16512. private _customTransparentSortCompareFn;
  16513. private _renderingGroupInfo;
  16514. /**
  16515. * Instantiates a new rendering group for a particular scene
  16516. * @param scene Defines the scene the groups belongs to
  16517. */
  16518. constructor(scene: Scene);
  16519. private _clearDepthStencilBuffer;
  16520. /**
  16521. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16522. * @hidden
  16523. */
  16524. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16525. /**
  16526. * Resets the different information of the group to prepare a new frame
  16527. * @hidden
  16528. */
  16529. reset(): void;
  16530. /**
  16531. * Dispose and release the group and its associated resources.
  16532. * @hidden
  16533. */
  16534. dispose(): void;
  16535. /**
  16536. * Clear the info related to rendering groups preventing retention points during dispose.
  16537. */
  16538. freeRenderingGroups(): void;
  16539. private _prepareRenderingGroup;
  16540. /**
  16541. * Add a sprite manager to the rendering manager in order to render it this frame.
  16542. * @param spriteManager Define the sprite manager to render
  16543. */
  16544. dispatchSprites(spriteManager: ISpriteManager): void;
  16545. /**
  16546. * Add a particle system to the rendering manager in order to render it this frame.
  16547. * @param particleSystem Define the particle system to render
  16548. */
  16549. dispatchParticles(particleSystem: IParticleSystem): void;
  16550. /**
  16551. * Add a submesh to the manager in order to render it this frame
  16552. * @param subMesh The submesh to dispatch
  16553. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16554. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16555. */
  16556. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16557. /**
  16558. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16559. * This allowed control for front to back rendering or reversly depending of the special needs.
  16560. *
  16561. * @param renderingGroupId The rendering group id corresponding to its index
  16562. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16563. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16564. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16565. */
  16566. 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;
  16567. /**
  16568. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16569. *
  16570. * @param renderingGroupId The rendering group id corresponding to its index
  16571. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16572. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16573. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16574. */
  16575. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16576. /**
  16577. * Gets the current auto clear configuration for one rendering group of the rendering
  16578. * manager.
  16579. * @param index the rendering group index to get the information for
  16580. * @returns The auto clear setup for the requested rendering group
  16581. */
  16582. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16583. }
  16584. }
  16585. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16586. import { SmartArray } from "babylonjs/Misc/smartArray";
  16587. import { Nullable } from "babylonjs/types";
  16588. import { Scene } from "babylonjs/scene";
  16589. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16592. import { Mesh } from "babylonjs/Meshes/mesh";
  16593. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16594. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16595. import { Effect } from "babylonjs/Materials/effect";
  16596. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16597. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16598. import "babylonjs/Shaders/shadowMap.fragment";
  16599. import "babylonjs/Shaders/shadowMap.vertex";
  16600. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16601. import { Observable } from "babylonjs/Misc/observable";
  16602. /**
  16603. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16604. */
  16605. export interface ICustomShaderOptions {
  16606. /**
  16607. * Gets or sets the custom shader name to use
  16608. */
  16609. shaderName: string;
  16610. /**
  16611. * The list of attribute names used in the shader
  16612. */
  16613. attributes?: string[];
  16614. /**
  16615. * The list of unifrom names used in the shader
  16616. */
  16617. uniforms?: string[];
  16618. /**
  16619. * The list of sampler names used in the shader
  16620. */
  16621. samplers?: string[];
  16622. /**
  16623. * The list of defines used in the shader
  16624. */
  16625. defines?: string[];
  16626. }
  16627. /**
  16628. * Interface to implement to create a shadow generator compatible with BJS.
  16629. */
  16630. export interface IShadowGenerator {
  16631. /**
  16632. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16633. * @returns The render target texture if present otherwise, null
  16634. */
  16635. getShadowMap(): Nullable<RenderTargetTexture>;
  16636. /**
  16637. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16638. * @param subMesh The submesh we want to render in the shadow map
  16639. * @param useInstances Defines wether will draw in the map using instances
  16640. * @returns true if ready otherwise, false
  16641. */
  16642. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16643. /**
  16644. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16645. * @param defines Defines of the material we want to update
  16646. * @param lightIndex Index of the light in the enabled light list of the material
  16647. */
  16648. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16649. /**
  16650. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16651. * defined in the generator but impacting the effect).
  16652. * It implies the unifroms available on the materials are the standard BJS ones.
  16653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16654. * @param effect The effect we are binfing the information for
  16655. */
  16656. bindShadowLight(lightIndex: string, effect: Effect): void;
  16657. /**
  16658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16659. * (eq to shadow prjection matrix * light transform matrix)
  16660. * @returns The transform matrix used to create the shadow map
  16661. */
  16662. getTransformMatrix(): Matrix;
  16663. /**
  16664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16665. * Cube and 2D textures for instance.
  16666. */
  16667. recreateShadowMap(): void;
  16668. /**
  16669. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16670. * @param onCompiled Callback triggered at the and of the effects compilation
  16671. * @param options Sets of optional options forcing the compilation with different modes
  16672. */
  16673. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16674. useInstances: boolean;
  16675. }>): void;
  16676. /**
  16677. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16678. * @param options Sets of optional options forcing the compilation with different modes
  16679. * @returns A promise that resolves when the compilation completes
  16680. */
  16681. forceCompilationAsync(options?: Partial<{
  16682. useInstances: boolean;
  16683. }>): Promise<void>;
  16684. /**
  16685. * Serializes the shadow generator setup to a json object.
  16686. * @returns The serialized JSON object
  16687. */
  16688. serialize(): any;
  16689. /**
  16690. * Disposes the Shadow map and related Textures and effects.
  16691. */
  16692. dispose(): void;
  16693. }
  16694. /**
  16695. * Default implementation IShadowGenerator.
  16696. * This is the main object responsible of generating shadows in the framework.
  16697. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16698. */
  16699. export class ShadowGenerator implements IShadowGenerator {
  16700. /**
  16701. * Name of the shadow generator class
  16702. */
  16703. static CLASSNAME: string;
  16704. /**
  16705. * Shadow generator mode None: no filtering applied.
  16706. */
  16707. static readonly FILTER_NONE: number;
  16708. /**
  16709. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16710. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16711. */
  16712. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16713. /**
  16714. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16715. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16716. */
  16717. static readonly FILTER_POISSONSAMPLING: number;
  16718. /**
  16719. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16720. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16721. */
  16722. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16723. /**
  16724. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16725. * edge artifacts on steep falloff.
  16726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16727. */
  16728. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16729. /**
  16730. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16731. * edge artifacts on steep falloff.
  16732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16733. */
  16734. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16735. /**
  16736. * Shadow generator mode PCF: Percentage Closer Filtering
  16737. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16738. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16739. */
  16740. static readonly FILTER_PCF: number;
  16741. /**
  16742. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16743. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16744. * Contact Hardening
  16745. */
  16746. static readonly FILTER_PCSS: number;
  16747. /**
  16748. * Reserved for PCF and PCSS
  16749. * Highest Quality.
  16750. *
  16751. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16752. *
  16753. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16754. */
  16755. static readonly QUALITY_HIGH: number;
  16756. /**
  16757. * Reserved for PCF and PCSS
  16758. * Good tradeoff for quality/perf cross devices
  16759. *
  16760. * Execute PCF on a 3*3 kernel.
  16761. *
  16762. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16763. */
  16764. static readonly QUALITY_MEDIUM: number;
  16765. /**
  16766. * Reserved for PCF and PCSS
  16767. * The lowest quality but the fastest.
  16768. *
  16769. * Execute PCF on a 1*1 kernel.
  16770. *
  16771. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16772. */
  16773. static readonly QUALITY_LOW: number;
  16774. /** Gets or sets the custom shader name to use */
  16775. customShaderOptions: ICustomShaderOptions;
  16776. /**
  16777. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16778. */
  16779. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16780. /**
  16781. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16782. */
  16783. onAfterShadowMapRenderObservable: Observable<Effect>;
  16784. /**
  16785. * Observable triggered before a mesh is rendered in the shadow map.
  16786. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16787. */
  16788. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16789. /**
  16790. * Observable triggered after a mesh is rendered in the shadow map.
  16791. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16792. */
  16793. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16794. protected _bias: number;
  16795. /**
  16796. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16797. */
  16798. get bias(): number;
  16799. /**
  16800. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16801. */
  16802. set bias(bias: number);
  16803. protected _normalBias: number;
  16804. /**
  16805. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16806. */
  16807. get normalBias(): number;
  16808. /**
  16809. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16810. */
  16811. set normalBias(normalBias: number);
  16812. protected _blurBoxOffset: number;
  16813. /**
  16814. * Gets the blur box offset: offset applied during the blur pass.
  16815. * Only useful if useKernelBlur = false
  16816. */
  16817. get blurBoxOffset(): number;
  16818. /**
  16819. * Sets the blur box offset: offset applied during the blur pass.
  16820. * Only useful if useKernelBlur = false
  16821. */
  16822. set blurBoxOffset(value: number);
  16823. protected _blurScale: number;
  16824. /**
  16825. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16826. * 2 means half of the size.
  16827. */
  16828. get blurScale(): number;
  16829. /**
  16830. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16831. * 2 means half of the size.
  16832. */
  16833. set blurScale(value: number);
  16834. protected _blurKernel: number;
  16835. /**
  16836. * Gets the blur kernel: kernel size of the blur pass.
  16837. * Only useful if useKernelBlur = true
  16838. */
  16839. get blurKernel(): number;
  16840. /**
  16841. * Sets the blur kernel: kernel size of the blur pass.
  16842. * Only useful if useKernelBlur = true
  16843. */
  16844. set blurKernel(value: number);
  16845. protected _useKernelBlur: boolean;
  16846. /**
  16847. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16848. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16849. */
  16850. get useKernelBlur(): boolean;
  16851. /**
  16852. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16853. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16854. */
  16855. set useKernelBlur(value: boolean);
  16856. protected _depthScale: number;
  16857. /**
  16858. * Gets the depth scale used in ESM mode.
  16859. */
  16860. get depthScale(): number;
  16861. /**
  16862. * Sets the depth scale used in ESM mode.
  16863. * This can override the scale stored on the light.
  16864. */
  16865. set depthScale(value: number);
  16866. protected _validateFilter(filter: number): number;
  16867. protected _filter: number;
  16868. /**
  16869. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16870. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16871. */
  16872. get filter(): number;
  16873. /**
  16874. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16875. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16876. */
  16877. set filter(value: number);
  16878. /**
  16879. * Gets if the current filter is set to Poisson Sampling.
  16880. */
  16881. get usePoissonSampling(): boolean;
  16882. /**
  16883. * Sets the current filter to Poisson Sampling.
  16884. */
  16885. set usePoissonSampling(value: boolean);
  16886. /**
  16887. * Gets if the current filter is set to ESM.
  16888. */
  16889. get useExponentialShadowMap(): boolean;
  16890. /**
  16891. * Sets the current filter is to ESM.
  16892. */
  16893. set useExponentialShadowMap(value: boolean);
  16894. /**
  16895. * Gets if the current filter is set to filtered ESM.
  16896. */
  16897. get useBlurExponentialShadowMap(): boolean;
  16898. /**
  16899. * Gets if the current filter is set to filtered ESM.
  16900. */
  16901. set useBlurExponentialShadowMap(value: boolean);
  16902. /**
  16903. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16904. * exponential to prevent steep falloff artifacts).
  16905. */
  16906. get useCloseExponentialShadowMap(): boolean;
  16907. /**
  16908. * Sets the current filter to "close ESM" (using the inverse of the
  16909. * exponential to prevent steep falloff artifacts).
  16910. */
  16911. set useCloseExponentialShadowMap(value: boolean);
  16912. /**
  16913. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16914. * exponential to prevent steep falloff artifacts).
  16915. */
  16916. get useBlurCloseExponentialShadowMap(): boolean;
  16917. /**
  16918. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16919. * exponential to prevent steep falloff artifacts).
  16920. */
  16921. set useBlurCloseExponentialShadowMap(value: boolean);
  16922. /**
  16923. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16924. */
  16925. get usePercentageCloserFiltering(): boolean;
  16926. /**
  16927. * Sets the current filter to "PCF" (percentage closer filtering).
  16928. */
  16929. set usePercentageCloserFiltering(value: boolean);
  16930. protected _filteringQuality: number;
  16931. /**
  16932. * Gets the PCF or PCSS Quality.
  16933. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16934. */
  16935. get filteringQuality(): number;
  16936. /**
  16937. * Sets the PCF or PCSS Quality.
  16938. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16939. */
  16940. set filteringQuality(filteringQuality: number);
  16941. /**
  16942. * Gets if the current filter is set to "PCSS" (contact hardening).
  16943. */
  16944. get useContactHardeningShadow(): boolean;
  16945. /**
  16946. * Sets the current filter to "PCSS" (contact hardening).
  16947. */
  16948. set useContactHardeningShadow(value: boolean);
  16949. protected _contactHardeningLightSizeUVRatio: number;
  16950. /**
  16951. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16952. * Using a ratio helps keeping shape stability independently of the map size.
  16953. *
  16954. * It does not account for the light projection as it was having too much
  16955. * instability during the light setup or during light position changes.
  16956. *
  16957. * Only valid if useContactHardeningShadow is true.
  16958. */
  16959. get contactHardeningLightSizeUVRatio(): number;
  16960. /**
  16961. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16962. * Using a ratio helps keeping shape stability independently of the map size.
  16963. *
  16964. * It does not account for the light projection as it was having too much
  16965. * instability during the light setup or during light position changes.
  16966. *
  16967. * Only valid if useContactHardeningShadow is true.
  16968. */
  16969. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16970. protected _darkness: number;
  16971. /** Gets or sets the actual darkness of a shadow */
  16972. get darkness(): number;
  16973. set darkness(value: number);
  16974. /**
  16975. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16976. * 0 means strongest and 1 would means no shadow.
  16977. * @returns the darkness.
  16978. */
  16979. getDarkness(): number;
  16980. /**
  16981. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16982. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16983. * @returns the shadow generator allowing fluent coding.
  16984. */
  16985. setDarkness(darkness: number): ShadowGenerator;
  16986. protected _transparencyShadow: boolean;
  16987. /** Gets or sets the ability to have transparent shadow */
  16988. get transparencyShadow(): boolean;
  16989. set transparencyShadow(value: boolean);
  16990. /**
  16991. * Sets the ability to have transparent shadow (boolean).
  16992. * @param transparent True if transparent else False
  16993. * @returns the shadow generator allowing fluent coding
  16994. */
  16995. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16996. protected _shadowMap: Nullable<RenderTargetTexture>;
  16997. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16998. /**
  16999. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17000. * @returns The render target texture if present otherwise, null
  17001. */
  17002. getShadowMap(): Nullable<RenderTargetTexture>;
  17003. /**
  17004. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17005. * @returns The render target texture if the shadow map is present otherwise, null
  17006. */
  17007. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17008. /**
  17009. * Gets the class name of that object
  17010. * @returns "ShadowGenerator"
  17011. */
  17012. getClassName(): string;
  17013. /**
  17014. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17015. * @param mesh Mesh to add
  17016. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17017. * @returns the Shadow Generator itself
  17018. */
  17019. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17020. /**
  17021. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17022. * @param mesh Mesh to remove
  17023. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17024. * @returns the Shadow Generator itself
  17025. */
  17026. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17027. /**
  17028. * Controls the extent to which the shadows fade out at the edge of the frustum
  17029. */
  17030. frustumEdgeFalloff: number;
  17031. protected _light: IShadowLight;
  17032. /**
  17033. * Returns the associated light object.
  17034. * @returns the light generating the shadow
  17035. */
  17036. getLight(): IShadowLight;
  17037. /**
  17038. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17039. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17040. * It might on the other hand introduce peter panning.
  17041. */
  17042. forceBackFacesOnly: boolean;
  17043. protected _scene: Scene;
  17044. protected _lightDirection: Vector3;
  17045. protected _effect: Effect;
  17046. protected _viewMatrix: Matrix;
  17047. protected _projectionMatrix: Matrix;
  17048. protected _transformMatrix: Matrix;
  17049. protected _cachedPosition: Vector3;
  17050. protected _cachedDirection: Vector3;
  17051. protected _cachedDefines: string;
  17052. protected _currentRenderID: number;
  17053. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17054. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17055. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17056. protected _blurPostProcesses: PostProcess[];
  17057. protected _mapSize: number;
  17058. protected _currentFaceIndex: number;
  17059. protected _currentFaceIndexCache: number;
  17060. protected _textureType: number;
  17061. protected _defaultTextureMatrix: Matrix;
  17062. protected _storedUniqueId: Nullable<number>;
  17063. /** @hidden */
  17064. static _SceneComponentInitialization: (scene: Scene) => void;
  17065. /**
  17066. * Creates a ShadowGenerator object.
  17067. * A ShadowGenerator is the required tool to use the shadows.
  17068. * Each light casting shadows needs to use its own ShadowGenerator.
  17069. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17070. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17071. * @param light The light object generating the shadows.
  17072. * @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.
  17073. */
  17074. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17075. protected _initializeGenerator(): void;
  17076. protected _createTargetRenderTexture(): void;
  17077. protected _initializeShadowMap(): void;
  17078. protected _initializeBlurRTTAndPostProcesses(): void;
  17079. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17080. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17081. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17082. protected _applyFilterValues(): void;
  17083. /**
  17084. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17085. * @param onCompiled Callback triggered at the and of the effects compilation
  17086. * @param options Sets of optional options forcing the compilation with different modes
  17087. */
  17088. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17089. useInstances: boolean;
  17090. }>): void;
  17091. /**
  17092. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17093. * @param options Sets of optional options forcing the compilation with different modes
  17094. * @returns A promise that resolves when the compilation completes
  17095. */
  17096. forceCompilationAsync(options?: Partial<{
  17097. useInstances: boolean;
  17098. }>): Promise<void>;
  17099. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17100. /**
  17101. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17102. * @param subMesh The submesh we want to render in the shadow map
  17103. * @param useInstances Defines wether will draw in the map using instances
  17104. * @returns true if ready otherwise, false
  17105. */
  17106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17107. /**
  17108. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17109. * @param defines Defines of the material we want to update
  17110. * @param lightIndex Index of the light in the enabled light list of the material
  17111. */
  17112. prepareDefines(defines: any, lightIndex: number): void;
  17113. /**
  17114. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17115. * defined in the generator but impacting the effect).
  17116. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17117. * @param effect The effect we are binfing the information for
  17118. */
  17119. bindShadowLight(lightIndex: string, effect: Effect): void;
  17120. /**
  17121. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17122. * (eq to shadow prjection matrix * light transform matrix)
  17123. * @returns The transform matrix used to create the shadow map
  17124. */
  17125. getTransformMatrix(): Matrix;
  17126. /**
  17127. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17128. * Cube and 2D textures for instance.
  17129. */
  17130. recreateShadowMap(): void;
  17131. protected _disposeBlurPostProcesses(): void;
  17132. protected _disposeRTTandPostProcesses(): void;
  17133. /**
  17134. * Disposes the ShadowGenerator.
  17135. * Returns nothing.
  17136. */
  17137. dispose(): void;
  17138. /**
  17139. * Serializes the shadow generator setup to a json object.
  17140. * @returns The serialized JSON object
  17141. */
  17142. serialize(): any;
  17143. /**
  17144. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17145. * @param parsedShadowGenerator The JSON object to parse
  17146. * @param scene The scene to create the shadow map for
  17147. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17148. * @returns The parsed shadow generator
  17149. */
  17150. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17151. }
  17152. }
  17153. declare module "babylonjs/Lights/light" {
  17154. import { Nullable } from "babylonjs/types";
  17155. import { Scene } from "babylonjs/scene";
  17156. import { Vector3 } from "babylonjs/Maths/math.vector";
  17157. import { Color3 } from "babylonjs/Maths/math.color";
  17158. import { Node } from "babylonjs/node";
  17159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17160. import { Effect } from "babylonjs/Materials/effect";
  17161. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17162. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17163. /**
  17164. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17165. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17166. * 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.
  17167. */
  17168. export abstract class Light extends Node {
  17169. /**
  17170. * Falloff Default: light is falling off following the material specification:
  17171. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17172. */
  17173. static readonly FALLOFF_DEFAULT: number;
  17174. /**
  17175. * Falloff Physical: light is falling off following the inverse squared distance law.
  17176. */
  17177. static readonly FALLOFF_PHYSICAL: number;
  17178. /**
  17179. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17180. * to enhance interoperability with other engines.
  17181. */
  17182. static readonly FALLOFF_GLTF: number;
  17183. /**
  17184. * Falloff Standard: light is falling off like in the standard material
  17185. * to enhance interoperability with other materials.
  17186. */
  17187. static readonly FALLOFF_STANDARD: number;
  17188. /**
  17189. * If every light affecting the material is in this lightmapMode,
  17190. * material.lightmapTexture adds or multiplies
  17191. * (depends on material.useLightmapAsShadowmap)
  17192. * after every other light calculations.
  17193. */
  17194. static readonly LIGHTMAP_DEFAULT: number;
  17195. /**
  17196. * material.lightmapTexture as only diffuse lighting from this light
  17197. * adds only specular lighting from this light
  17198. * adds dynamic shadows
  17199. */
  17200. static readonly LIGHTMAP_SPECULAR: number;
  17201. /**
  17202. * material.lightmapTexture as only lighting
  17203. * no light calculation from this light
  17204. * only adds dynamic shadows from this light
  17205. */
  17206. static readonly LIGHTMAP_SHADOWSONLY: number;
  17207. /**
  17208. * Each light type uses the default quantity according to its type:
  17209. * point/spot lights use luminous intensity
  17210. * directional lights use illuminance
  17211. */
  17212. static readonly INTENSITYMODE_AUTOMATIC: number;
  17213. /**
  17214. * lumen (lm)
  17215. */
  17216. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17217. /**
  17218. * candela (lm/sr)
  17219. */
  17220. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17221. /**
  17222. * lux (lm/m^2)
  17223. */
  17224. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17225. /**
  17226. * nit (cd/m^2)
  17227. */
  17228. static readonly INTENSITYMODE_LUMINANCE: number;
  17229. /**
  17230. * Light type const id of the point light.
  17231. */
  17232. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17233. /**
  17234. * Light type const id of the directional light.
  17235. */
  17236. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17237. /**
  17238. * Light type const id of the spot light.
  17239. */
  17240. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17241. /**
  17242. * Light type const id of the hemispheric light.
  17243. */
  17244. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17245. /**
  17246. * Diffuse gives the basic color to an object.
  17247. */
  17248. diffuse: Color3;
  17249. /**
  17250. * Specular produces a highlight color on an object.
  17251. * Note: This is note affecting PBR materials.
  17252. */
  17253. specular: Color3;
  17254. /**
  17255. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17256. * falling off base on range or angle.
  17257. * This can be set to any values in Light.FALLOFF_x.
  17258. *
  17259. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17260. * other types of materials.
  17261. */
  17262. falloffType: number;
  17263. /**
  17264. * Strength of the light.
  17265. * Note: By default it is define in the framework own unit.
  17266. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17267. */
  17268. intensity: number;
  17269. private _range;
  17270. protected _inverseSquaredRange: number;
  17271. /**
  17272. * Defines how far from the source the light is impacting in scene units.
  17273. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17274. */
  17275. get range(): number;
  17276. /**
  17277. * Defines how far from the source the light is impacting in scene units.
  17278. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17279. */
  17280. set range(value: number);
  17281. /**
  17282. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17283. * of light.
  17284. */
  17285. private _photometricScale;
  17286. private _intensityMode;
  17287. /**
  17288. * Gets the photometric scale used to interpret the intensity.
  17289. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17290. */
  17291. get intensityMode(): number;
  17292. /**
  17293. * Sets the photometric scale used to interpret the intensity.
  17294. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17295. */
  17296. set intensityMode(value: number);
  17297. private _radius;
  17298. /**
  17299. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17300. */
  17301. get radius(): number;
  17302. /**
  17303. * sets the light radius used by PBR Materials to simulate soft area lights.
  17304. */
  17305. set radius(value: number);
  17306. private _renderPriority;
  17307. /**
  17308. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17309. * exceeding the number allowed of the materials.
  17310. */
  17311. renderPriority: number;
  17312. private _shadowEnabled;
  17313. /**
  17314. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17315. * the current shadow generator.
  17316. */
  17317. get shadowEnabled(): boolean;
  17318. /**
  17319. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17320. * the current shadow generator.
  17321. */
  17322. set shadowEnabled(value: boolean);
  17323. private _includedOnlyMeshes;
  17324. /**
  17325. * Gets the only meshes impacted by this light.
  17326. */
  17327. get includedOnlyMeshes(): AbstractMesh[];
  17328. /**
  17329. * Sets the only meshes impacted by this light.
  17330. */
  17331. set includedOnlyMeshes(value: AbstractMesh[]);
  17332. private _excludedMeshes;
  17333. /**
  17334. * Gets the meshes not impacted by this light.
  17335. */
  17336. get excludedMeshes(): AbstractMesh[];
  17337. /**
  17338. * Sets the meshes not impacted by this light.
  17339. */
  17340. set excludedMeshes(value: AbstractMesh[]);
  17341. private _excludeWithLayerMask;
  17342. /**
  17343. * Gets the layer id use to find what meshes are not impacted by the light.
  17344. * Inactive if 0
  17345. */
  17346. get excludeWithLayerMask(): number;
  17347. /**
  17348. * Sets the layer id use to find what meshes are not impacted by the light.
  17349. * Inactive if 0
  17350. */
  17351. set excludeWithLayerMask(value: number);
  17352. private _includeOnlyWithLayerMask;
  17353. /**
  17354. * Gets the layer id use to find what meshes are impacted by the light.
  17355. * Inactive if 0
  17356. */
  17357. get includeOnlyWithLayerMask(): number;
  17358. /**
  17359. * Sets the layer id use to find what meshes are impacted by the light.
  17360. * Inactive if 0
  17361. */
  17362. set includeOnlyWithLayerMask(value: number);
  17363. private _lightmapMode;
  17364. /**
  17365. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17366. */
  17367. get lightmapMode(): number;
  17368. /**
  17369. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17370. */
  17371. set lightmapMode(value: number);
  17372. /**
  17373. * Shadow generator associted to the light.
  17374. * @hidden Internal use only.
  17375. */
  17376. _shadowGenerator: Nullable<IShadowGenerator>;
  17377. /**
  17378. * @hidden Internal use only.
  17379. */
  17380. _excludedMeshesIds: string[];
  17381. /**
  17382. * @hidden Internal use only.
  17383. */
  17384. _includedOnlyMeshesIds: string[];
  17385. /**
  17386. * The current light unifom buffer.
  17387. * @hidden Internal use only.
  17388. */
  17389. _uniformBuffer: UniformBuffer;
  17390. /** @hidden */
  17391. _renderId: number;
  17392. /**
  17393. * Creates a Light object in the scene.
  17394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17395. * @param name The firendly name of the light
  17396. * @param scene The scene the light belongs too
  17397. */
  17398. constructor(name: string, scene: Scene);
  17399. protected abstract _buildUniformLayout(): void;
  17400. /**
  17401. * Sets the passed Effect "effect" with the Light information.
  17402. * @param effect The effect to update
  17403. * @param lightIndex The index of the light in the effect to update
  17404. * @returns The light
  17405. */
  17406. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17407. /**
  17408. * Sets the passed Effect "effect" with the Light textures.
  17409. * @param effect The effect to update
  17410. * @param lightIndex The index of the light in the effect to update
  17411. * @returns The light
  17412. */
  17413. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17414. /**
  17415. * Binds the lights information from the scene to the effect for the given mesh.
  17416. * @param lightIndex Light index
  17417. * @param scene The scene where the light belongs to
  17418. * @param effect The effect we are binding the data to
  17419. * @param useSpecular Defines if specular is supported
  17420. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17421. */
  17422. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17423. /**
  17424. * Sets the passed Effect "effect" with the Light information.
  17425. * @param effect The effect to update
  17426. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17427. * @returns The light
  17428. */
  17429. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17430. /**
  17431. * Returns the string "Light".
  17432. * @returns the class name
  17433. */
  17434. getClassName(): string;
  17435. /** @hidden */
  17436. readonly _isLight: boolean;
  17437. /**
  17438. * Converts the light information to a readable string for debug purpose.
  17439. * @param fullDetails Supports for multiple levels of logging within scene loading
  17440. * @returns the human readable light info
  17441. */
  17442. toString(fullDetails?: boolean): string;
  17443. /** @hidden */
  17444. protected _syncParentEnabledState(): void;
  17445. /**
  17446. * Set the enabled state of this node.
  17447. * @param value - the new enabled state
  17448. */
  17449. setEnabled(value: boolean): void;
  17450. /**
  17451. * Returns the Light associated shadow generator if any.
  17452. * @return the associated shadow generator.
  17453. */
  17454. getShadowGenerator(): Nullable<IShadowGenerator>;
  17455. /**
  17456. * Returns a Vector3, the absolute light position in the World.
  17457. * @returns the world space position of the light
  17458. */
  17459. getAbsolutePosition(): Vector3;
  17460. /**
  17461. * Specifies if the light will affect the passed mesh.
  17462. * @param mesh The mesh to test against the light
  17463. * @return true the mesh is affected otherwise, false.
  17464. */
  17465. canAffectMesh(mesh: AbstractMesh): boolean;
  17466. /**
  17467. * Sort function to order lights for rendering.
  17468. * @param a First Light object to compare to second.
  17469. * @param b Second Light object to compare first.
  17470. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17471. */
  17472. static CompareLightsPriority(a: Light, b: Light): number;
  17473. /**
  17474. * Releases resources associated with this node.
  17475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17477. */
  17478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17479. /**
  17480. * Returns the light type ID (integer).
  17481. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17482. */
  17483. getTypeID(): number;
  17484. /**
  17485. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17486. * @returns the scaled intensity in intensity mode unit
  17487. */
  17488. getScaledIntensity(): number;
  17489. /**
  17490. * Returns a new Light object, named "name", from the current one.
  17491. * @param name The name of the cloned light
  17492. * @returns the new created light
  17493. */
  17494. clone(name: string): Nullable<Light>;
  17495. /**
  17496. * Serializes the current light into a Serialization object.
  17497. * @returns the serialized object.
  17498. */
  17499. serialize(): any;
  17500. /**
  17501. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17502. * This new light is named "name" and added to the passed scene.
  17503. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17504. * @param name The friendly name of the light
  17505. * @param scene The scene the new light will belong to
  17506. * @returns the constructor function
  17507. */
  17508. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17509. /**
  17510. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17511. * @param parsedLight The JSON representation of the light
  17512. * @param scene The scene to create the parsed light in
  17513. * @returns the created light after parsing
  17514. */
  17515. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17516. private _hookArrayForExcluded;
  17517. private _hookArrayForIncludedOnly;
  17518. private _resyncMeshes;
  17519. /**
  17520. * Forces the meshes to update their light related information in their rendering used effects
  17521. * @hidden Internal Use Only
  17522. */
  17523. _markMeshesAsLightDirty(): void;
  17524. /**
  17525. * Recomputes the cached photometric scale if needed.
  17526. */
  17527. private _computePhotometricScale;
  17528. /**
  17529. * Returns the Photometric Scale according to the light type and intensity mode.
  17530. */
  17531. private _getPhotometricScale;
  17532. /**
  17533. * Reorder the light in the scene according to their defined priority.
  17534. * @hidden Internal Use Only
  17535. */
  17536. _reorderLightsInScene(): void;
  17537. /**
  17538. * Prepares the list of defines specific to the light type.
  17539. * @param defines the list of defines
  17540. * @param lightIndex defines the index of the light for the effect
  17541. */
  17542. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17543. }
  17544. }
  17545. declare module "babylonjs/Actions/action" {
  17546. import { Observable } from "babylonjs/Misc/observable";
  17547. import { Condition } from "babylonjs/Actions/condition";
  17548. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17549. import { ActionManager } from "babylonjs/Actions/actionManager";
  17550. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17551. /**
  17552. * Interface used to define Action
  17553. */
  17554. export interface IAction {
  17555. /**
  17556. * Trigger for the action
  17557. */
  17558. trigger: number;
  17559. /** Options of the trigger */
  17560. triggerOptions: any;
  17561. /**
  17562. * Gets the trigger parameters
  17563. * @returns the trigger parameters
  17564. */
  17565. getTriggerParameter(): any;
  17566. /**
  17567. * Internal only - executes current action event
  17568. * @hidden
  17569. */
  17570. _executeCurrent(evt?: ActionEvent): void;
  17571. /**
  17572. * Serialize placeholder for child classes
  17573. * @param parent of child
  17574. * @returns the serialized object
  17575. */
  17576. serialize(parent: any): any;
  17577. /**
  17578. * Internal only
  17579. * @hidden
  17580. */
  17581. _prepare(): void;
  17582. /**
  17583. * Internal only - manager for action
  17584. * @hidden
  17585. */
  17586. _actionManager: AbstractActionManager;
  17587. /**
  17588. * Adds action to chain of actions, may be a DoNothingAction
  17589. * @param action defines the next action to execute
  17590. * @returns The action passed in
  17591. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17592. */
  17593. then(action: IAction): IAction;
  17594. }
  17595. /**
  17596. * The action to be carried out following a trigger
  17597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17598. */
  17599. export class Action implements IAction {
  17600. /** the trigger, with or without parameters, for the action */
  17601. triggerOptions: any;
  17602. /**
  17603. * Trigger for the action
  17604. */
  17605. trigger: number;
  17606. /**
  17607. * Internal only - manager for action
  17608. * @hidden
  17609. */
  17610. _actionManager: ActionManager;
  17611. private _nextActiveAction;
  17612. private _child;
  17613. private _condition?;
  17614. private _triggerParameter;
  17615. /**
  17616. * An event triggered prior to action being executed.
  17617. */
  17618. onBeforeExecuteObservable: Observable<Action>;
  17619. /**
  17620. * Creates a new Action
  17621. * @param triggerOptions the trigger, with or without parameters, for the action
  17622. * @param condition an optional determinant of action
  17623. */
  17624. constructor(
  17625. /** the trigger, with or without parameters, for the action */
  17626. triggerOptions: any, condition?: Condition);
  17627. /**
  17628. * Internal only
  17629. * @hidden
  17630. */
  17631. _prepare(): void;
  17632. /**
  17633. * Gets the trigger parameters
  17634. * @returns the trigger parameters
  17635. */
  17636. getTriggerParameter(): any;
  17637. /**
  17638. * Internal only - executes current action event
  17639. * @hidden
  17640. */
  17641. _executeCurrent(evt?: ActionEvent): void;
  17642. /**
  17643. * Execute placeholder for child classes
  17644. * @param evt optional action event
  17645. */
  17646. execute(evt?: ActionEvent): void;
  17647. /**
  17648. * Skips to next active action
  17649. */
  17650. skipToNextActiveAction(): void;
  17651. /**
  17652. * Adds action to chain of actions, may be a DoNothingAction
  17653. * @param action defines the next action to execute
  17654. * @returns The action passed in
  17655. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17656. */
  17657. then(action: Action): Action;
  17658. /**
  17659. * Internal only
  17660. * @hidden
  17661. */
  17662. _getProperty(propertyPath: string): string;
  17663. /**
  17664. * Internal only
  17665. * @hidden
  17666. */
  17667. _getEffectiveTarget(target: any, propertyPath: string): any;
  17668. /**
  17669. * Serialize placeholder for child classes
  17670. * @param parent of child
  17671. * @returns the serialized object
  17672. */
  17673. serialize(parent: any): any;
  17674. /**
  17675. * Internal only called by serialize
  17676. * @hidden
  17677. */
  17678. protected _serialize(serializedAction: any, parent?: any): any;
  17679. /**
  17680. * Internal only
  17681. * @hidden
  17682. */
  17683. static _SerializeValueAsString: (value: any) => string;
  17684. /**
  17685. * Internal only
  17686. * @hidden
  17687. */
  17688. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17689. name: string;
  17690. targetType: string;
  17691. value: string;
  17692. };
  17693. }
  17694. }
  17695. declare module "babylonjs/Actions/condition" {
  17696. import { ActionManager } from "babylonjs/Actions/actionManager";
  17697. /**
  17698. * A Condition applied to an Action
  17699. */
  17700. export class Condition {
  17701. /**
  17702. * Internal only - manager for action
  17703. * @hidden
  17704. */
  17705. _actionManager: ActionManager;
  17706. /**
  17707. * Internal only
  17708. * @hidden
  17709. */
  17710. _evaluationId: number;
  17711. /**
  17712. * Internal only
  17713. * @hidden
  17714. */
  17715. _currentResult: boolean;
  17716. /**
  17717. * Creates a new Condition
  17718. * @param actionManager the manager of the action the condition is applied to
  17719. */
  17720. constructor(actionManager: ActionManager);
  17721. /**
  17722. * Check if the current condition is valid
  17723. * @returns a boolean
  17724. */
  17725. isValid(): boolean;
  17726. /**
  17727. * Internal only
  17728. * @hidden
  17729. */
  17730. _getProperty(propertyPath: string): string;
  17731. /**
  17732. * Internal only
  17733. * @hidden
  17734. */
  17735. _getEffectiveTarget(target: any, propertyPath: string): any;
  17736. /**
  17737. * Serialize placeholder for child classes
  17738. * @returns the serialized object
  17739. */
  17740. serialize(): any;
  17741. /**
  17742. * Internal only
  17743. * @hidden
  17744. */
  17745. protected _serialize(serializedCondition: any): any;
  17746. }
  17747. /**
  17748. * Defines specific conditional operators as extensions of Condition
  17749. */
  17750. export class ValueCondition extends Condition {
  17751. /** path to specify the property of the target the conditional operator uses */
  17752. propertyPath: string;
  17753. /** the value compared by the conditional operator against the current value of the property */
  17754. value: any;
  17755. /** the conditional operator, default ValueCondition.IsEqual */
  17756. operator: number;
  17757. /**
  17758. * Internal only
  17759. * @hidden
  17760. */
  17761. private static _IsEqual;
  17762. /**
  17763. * Internal only
  17764. * @hidden
  17765. */
  17766. private static _IsDifferent;
  17767. /**
  17768. * Internal only
  17769. * @hidden
  17770. */
  17771. private static _IsGreater;
  17772. /**
  17773. * Internal only
  17774. * @hidden
  17775. */
  17776. private static _IsLesser;
  17777. /**
  17778. * returns the number for IsEqual
  17779. */
  17780. static get IsEqual(): number;
  17781. /**
  17782. * Returns the number for IsDifferent
  17783. */
  17784. static get IsDifferent(): number;
  17785. /**
  17786. * Returns the number for IsGreater
  17787. */
  17788. static get IsGreater(): number;
  17789. /**
  17790. * Returns the number for IsLesser
  17791. */
  17792. static get IsLesser(): number;
  17793. /**
  17794. * Internal only The action manager for the condition
  17795. * @hidden
  17796. */
  17797. _actionManager: ActionManager;
  17798. /**
  17799. * Internal only
  17800. * @hidden
  17801. */
  17802. private _target;
  17803. /**
  17804. * Internal only
  17805. * @hidden
  17806. */
  17807. private _effectiveTarget;
  17808. /**
  17809. * Internal only
  17810. * @hidden
  17811. */
  17812. private _property;
  17813. /**
  17814. * Creates a new ValueCondition
  17815. * @param actionManager manager for the action the condition applies to
  17816. * @param target for the action
  17817. * @param propertyPath path to specify the property of the target the conditional operator uses
  17818. * @param value the value compared by the conditional operator against the current value of the property
  17819. * @param operator the conditional operator, default ValueCondition.IsEqual
  17820. */
  17821. constructor(actionManager: ActionManager, target: any,
  17822. /** path to specify the property of the target the conditional operator uses */
  17823. propertyPath: string,
  17824. /** the value compared by the conditional operator against the current value of the property */
  17825. value: any,
  17826. /** the conditional operator, default ValueCondition.IsEqual */
  17827. operator?: number);
  17828. /**
  17829. * Compares the given value with the property value for the specified conditional operator
  17830. * @returns the result of the comparison
  17831. */
  17832. isValid(): boolean;
  17833. /**
  17834. * Serialize the ValueCondition into a JSON compatible object
  17835. * @returns serialization object
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * Gets the name of the conditional operator for the ValueCondition
  17840. * @param operator the conditional operator
  17841. * @returns the name
  17842. */
  17843. static GetOperatorName(operator: number): string;
  17844. }
  17845. /**
  17846. * Defines a predicate condition as an extension of Condition
  17847. */
  17848. export class PredicateCondition extends Condition {
  17849. /** defines the predicate function used to validate the condition */
  17850. predicate: () => boolean;
  17851. /**
  17852. * Internal only - manager for action
  17853. * @hidden
  17854. */
  17855. _actionManager: ActionManager;
  17856. /**
  17857. * Creates a new PredicateCondition
  17858. * @param actionManager manager for the action the condition applies to
  17859. * @param predicate defines the predicate function used to validate the condition
  17860. */
  17861. constructor(actionManager: ActionManager,
  17862. /** defines the predicate function used to validate the condition */
  17863. predicate: () => boolean);
  17864. /**
  17865. * @returns the validity of the predicate condition
  17866. */
  17867. isValid(): boolean;
  17868. }
  17869. /**
  17870. * Defines a state condition as an extension of Condition
  17871. */
  17872. export class StateCondition extends Condition {
  17873. /** Value to compare with target state */
  17874. value: string;
  17875. /**
  17876. * Internal only - manager for action
  17877. * @hidden
  17878. */
  17879. _actionManager: ActionManager;
  17880. /**
  17881. * Internal only
  17882. * @hidden
  17883. */
  17884. private _target;
  17885. /**
  17886. * Creates a new StateCondition
  17887. * @param actionManager manager for the action the condition applies to
  17888. * @param target of the condition
  17889. * @param value to compare with target state
  17890. */
  17891. constructor(actionManager: ActionManager, target: any,
  17892. /** Value to compare with target state */
  17893. value: string);
  17894. /**
  17895. * Gets a boolean indicating if the current condition is met
  17896. * @returns the validity of the state
  17897. */
  17898. isValid(): boolean;
  17899. /**
  17900. * Serialize the StateCondition into a JSON compatible object
  17901. * @returns serialization object
  17902. */
  17903. serialize(): any;
  17904. }
  17905. }
  17906. declare module "babylonjs/Actions/directActions" {
  17907. import { Action } from "babylonjs/Actions/action";
  17908. import { Condition } from "babylonjs/Actions/condition";
  17909. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17910. /**
  17911. * This defines an action responsible to toggle a boolean once triggered.
  17912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17913. */
  17914. export class SwitchBooleanAction extends Action {
  17915. /**
  17916. * The path to the boolean property in the target object
  17917. */
  17918. propertyPath: string;
  17919. private _target;
  17920. private _effectiveTarget;
  17921. private _property;
  17922. /**
  17923. * Instantiate the action
  17924. * @param triggerOptions defines the trigger options
  17925. * @param target defines the object containing the boolean
  17926. * @param propertyPath defines the path to the boolean property in the target object
  17927. * @param condition defines the trigger related conditions
  17928. */
  17929. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17930. /** @hidden */
  17931. _prepare(): void;
  17932. /**
  17933. * Execute the action toggle the boolean value.
  17934. */
  17935. execute(): void;
  17936. /**
  17937. * Serializes the actions and its related information.
  17938. * @param parent defines the object to serialize in
  17939. * @returns the serialized object
  17940. */
  17941. serialize(parent: any): any;
  17942. }
  17943. /**
  17944. * This defines an action responsible to set a the state field of the target
  17945. * to a desired value once triggered.
  17946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17947. */
  17948. export class SetStateAction extends Action {
  17949. /**
  17950. * The value to store in the state field.
  17951. */
  17952. value: string;
  17953. private _target;
  17954. /**
  17955. * Instantiate the action
  17956. * @param triggerOptions defines the trigger options
  17957. * @param target defines the object containing the state property
  17958. * @param value defines the value to store in the state field
  17959. * @param condition defines the trigger related conditions
  17960. */
  17961. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17962. /**
  17963. * Execute the action and store the value on the target state property.
  17964. */
  17965. execute(): void;
  17966. /**
  17967. * Serializes the actions and its related information.
  17968. * @param parent defines the object to serialize in
  17969. * @returns the serialized object
  17970. */
  17971. serialize(parent: any): any;
  17972. }
  17973. /**
  17974. * This defines an action responsible to set a property of the target
  17975. * to a desired value once triggered.
  17976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17977. */
  17978. export class SetValueAction extends Action {
  17979. /**
  17980. * The path of the property to set in the target.
  17981. */
  17982. propertyPath: string;
  17983. /**
  17984. * The value to set in the property
  17985. */
  17986. value: any;
  17987. private _target;
  17988. private _effectiveTarget;
  17989. private _property;
  17990. /**
  17991. * Instantiate the action
  17992. * @param triggerOptions defines the trigger options
  17993. * @param target defines the object containing the property
  17994. * @param propertyPath defines the path of the property to set in the target
  17995. * @param value defines the value to set in the property
  17996. * @param condition defines the trigger related conditions
  17997. */
  17998. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17999. /** @hidden */
  18000. _prepare(): void;
  18001. /**
  18002. * Execute the action and set the targetted property to the desired value.
  18003. */
  18004. execute(): void;
  18005. /**
  18006. * Serializes the actions and its related information.
  18007. * @param parent defines the object to serialize in
  18008. * @returns the serialized object
  18009. */
  18010. serialize(parent: any): any;
  18011. }
  18012. /**
  18013. * This defines an action responsible to increment the target value
  18014. * to a desired value once triggered.
  18015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18016. */
  18017. export class IncrementValueAction extends Action {
  18018. /**
  18019. * The path of the property to increment in the target.
  18020. */
  18021. propertyPath: string;
  18022. /**
  18023. * The value we should increment the property by.
  18024. */
  18025. value: any;
  18026. private _target;
  18027. private _effectiveTarget;
  18028. private _property;
  18029. /**
  18030. * Instantiate the action
  18031. * @param triggerOptions defines the trigger options
  18032. * @param target defines the object containing the property
  18033. * @param propertyPath defines the path of the property to increment in the target
  18034. * @param value defines the value value we should increment the property by
  18035. * @param condition defines the trigger related conditions
  18036. */
  18037. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18038. /** @hidden */
  18039. _prepare(): void;
  18040. /**
  18041. * Execute the action and increment the target of the value amount.
  18042. */
  18043. execute(): void;
  18044. /**
  18045. * Serializes the actions and its related information.
  18046. * @param parent defines the object to serialize in
  18047. * @returns the serialized object
  18048. */
  18049. serialize(parent: any): any;
  18050. }
  18051. /**
  18052. * This defines an action responsible to start an animation once triggered.
  18053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18054. */
  18055. export class PlayAnimationAction extends Action {
  18056. /**
  18057. * Where the animation should start (animation frame)
  18058. */
  18059. from: number;
  18060. /**
  18061. * Where the animation should stop (animation frame)
  18062. */
  18063. to: number;
  18064. /**
  18065. * Define if the animation should loop or stop after the first play.
  18066. */
  18067. loop?: boolean;
  18068. private _target;
  18069. /**
  18070. * Instantiate the action
  18071. * @param triggerOptions defines the trigger options
  18072. * @param target defines the target animation or animation name
  18073. * @param from defines from where the animation should start (animation frame)
  18074. * @param end defines where the animation should stop (animation frame)
  18075. * @param loop defines if the animation should loop or stop after the first play
  18076. * @param condition defines the trigger related conditions
  18077. */
  18078. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18079. /** @hidden */
  18080. _prepare(): void;
  18081. /**
  18082. * Execute the action and play the animation.
  18083. */
  18084. execute(): void;
  18085. /**
  18086. * Serializes the actions and its related information.
  18087. * @param parent defines the object to serialize in
  18088. * @returns the serialized object
  18089. */
  18090. serialize(parent: any): any;
  18091. }
  18092. /**
  18093. * This defines an action responsible to stop an animation once triggered.
  18094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18095. */
  18096. export class StopAnimationAction extends Action {
  18097. private _target;
  18098. /**
  18099. * Instantiate the action
  18100. * @param triggerOptions defines the trigger options
  18101. * @param target defines the target animation or animation name
  18102. * @param condition defines the trigger related conditions
  18103. */
  18104. constructor(triggerOptions: any, target: any, condition?: Condition);
  18105. /** @hidden */
  18106. _prepare(): void;
  18107. /**
  18108. * Execute the action and stop the animation.
  18109. */
  18110. execute(): void;
  18111. /**
  18112. * Serializes the actions and its related information.
  18113. * @param parent defines the object to serialize in
  18114. * @returns the serialized object
  18115. */
  18116. serialize(parent: any): any;
  18117. }
  18118. /**
  18119. * This defines an action responsible that does nothing once triggered.
  18120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18121. */
  18122. export class DoNothingAction extends Action {
  18123. /**
  18124. * Instantiate the action
  18125. * @param triggerOptions defines the trigger options
  18126. * @param condition defines the trigger related conditions
  18127. */
  18128. constructor(triggerOptions?: any, condition?: Condition);
  18129. /**
  18130. * Execute the action and do nothing.
  18131. */
  18132. execute(): void;
  18133. /**
  18134. * Serializes the actions and its related information.
  18135. * @param parent defines the object to serialize in
  18136. * @returns the serialized object
  18137. */
  18138. serialize(parent: any): any;
  18139. }
  18140. /**
  18141. * This defines an action responsible to trigger several actions once triggered.
  18142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18143. */
  18144. export class CombineAction extends Action {
  18145. /**
  18146. * The list of aggregated animations to run.
  18147. */
  18148. children: Action[];
  18149. /**
  18150. * Instantiate the action
  18151. * @param triggerOptions defines the trigger options
  18152. * @param children defines the list of aggregated animations to run
  18153. * @param condition defines the trigger related conditions
  18154. */
  18155. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18156. /** @hidden */
  18157. _prepare(): void;
  18158. /**
  18159. * Execute the action and executes all the aggregated actions.
  18160. */
  18161. execute(evt: ActionEvent): void;
  18162. /**
  18163. * Serializes the actions and its related information.
  18164. * @param parent defines the object to serialize in
  18165. * @returns the serialized object
  18166. */
  18167. serialize(parent: any): any;
  18168. }
  18169. /**
  18170. * This defines an action responsible to run code (external event) once triggered.
  18171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18172. */
  18173. export class ExecuteCodeAction extends Action {
  18174. /**
  18175. * The callback function to run.
  18176. */
  18177. func: (evt: ActionEvent) => void;
  18178. /**
  18179. * Instantiate the action
  18180. * @param triggerOptions defines the trigger options
  18181. * @param func defines the callback function to run
  18182. * @param condition defines the trigger related conditions
  18183. */
  18184. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18185. /**
  18186. * Execute the action and run the attached code.
  18187. */
  18188. execute(evt: ActionEvent): void;
  18189. }
  18190. /**
  18191. * This defines an action responsible to set the parent property of the target once triggered.
  18192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18193. */
  18194. export class SetParentAction extends Action {
  18195. private _parent;
  18196. private _target;
  18197. /**
  18198. * Instantiate the action
  18199. * @param triggerOptions defines the trigger options
  18200. * @param target defines the target containing the parent property
  18201. * @param parent defines from where the animation should start (animation frame)
  18202. * @param condition defines the trigger related conditions
  18203. */
  18204. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18205. /** @hidden */
  18206. _prepare(): void;
  18207. /**
  18208. * Execute the action and set the parent property.
  18209. */
  18210. execute(): void;
  18211. /**
  18212. * Serializes the actions and its related information.
  18213. * @param parent defines the object to serialize in
  18214. * @returns the serialized object
  18215. */
  18216. serialize(parent: any): any;
  18217. }
  18218. }
  18219. declare module "babylonjs/Actions/actionManager" {
  18220. import { Nullable } from "babylonjs/types";
  18221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18222. import { Scene } from "babylonjs/scene";
  18223. import { IAction } from "babylonjs/Actions/action";
  18224. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18225. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18226. /**
  18227. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18228. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18230. */
  18231. export class ActionManager extends AbstractActionManager {
  18232. /**
  18233. * Nothing
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly NothingTrigger: number;
  18237. /**
  18238. * On pick
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnPickTrigger: number;
  18242. /**
  18243. * On left pick
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnLeftPickTrigger: number;
  18247. /**
  18248. * On right pick
  18249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18250. */
  18251. static readonly OnRightPickTrigger: number;
  18252. /**
  18253. * On center pick
  18254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18255. */
  18256. static readonly OnCenterPickTrigger: number;
  18257. /**
  18258. * On pick down
  18259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18260. */
  18261. static readonly OnPickDownTrigger: number;
  18262. /**
  18263. * On double pick
  18264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18265. */
  18266. static readonly OnDoublePickTrigger: number;
  18267. /**
  18268. * On pick up
  18269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18270. */
  18271. static readonly OnPickUpTrigger: number;
  18272. /**
  18273. * On pick out.
  18274. * This trigger will only be raised if you also declared a OnPickDown
  18275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18276. */
  18277. static readonly OnPickOutTrigger: number;
  18278. /**
  18279. * On long press
  18280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18281. */
  18282. static readonly OnLongPressTrigger: number;
  18283. /**
  18284. * On pointer over
  18285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18286. */
  18287. static readonly OnPointerOverTrigger: number;
  18288. /**
  18289. * On pointer out
  18290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18291. */
  18292. static readonly OnPointerOutTrigger: number;
  18293. /**
  18294. * On every frame
  18295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18296. */
  18297. static readonly OnEveryFrameTrigger: number;
  18298. /**
  18299. * On intersection enter
  18300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18301. */
  18302. static readonly OnIntersectionEnterTrigger: number;
  18303. /**
  18304. * On intersection exit
  18305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18306. */
  18307. static readonly OnIntersectionExitTrigger: number;
  18308. /**
  18309. * On key down
  18310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18311. */
  18312. static readonly OnKeyDownTrigger: number;
  18313. /**
  18314. * On key up
  18315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18316. */
  18317. static readonly OnKeyUpTrigger: number;
  18318. private _scene;
  18319. /**
  18320. * Creates a new action manager
  18321. * @param scene defines the hosting scene
  18322. */
  18323. constructor(scene: Scene);
  18324. /**
  18325. * Releases all associated resources
  18326. */
  18327. dispose(): void;
  18328. /**
  18329. * Gets hosting scene
  18330. * @returns the hosting scene
  18331. */
  18332. getScene(): Scene;
  18333. /**
  18334. * Does this action manager handles actions of any of the given triggers
  18335. * @param triggers defines the triggers to be tested
  18336. * @return a boolean indicating whether one (or more) of the triggers is handled
  18337. */
  18338. hasSpecificTriggers(triggers: number[]): boolean;
  18339. /**
  18340. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18341. * speed.
  18342. * @param triggerA defines the trigger to be tested
  18343. * @param triggerB defines the trigger to be tested
  18344. * @return a boolean indicating whether one (or more) of the triggers is handled
  18345. */
  18346. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18347. /**
  18348. * Does this action manager handles actions of a given trigger
  18349. * @param trigger defines the trigger to be tested
  18350. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18351. * @return whether the trigger is handled
  18352. */
  18353. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18354. /**
  18355. * Does this action manager has pointer triggers
  18356. */
  18357. get hasPointerTriggers(): boolean;
  18358. /**
  18359. * Does this action manager has pick triggers
  18360. */
  18361. get hasPickTriggers(): boolean;
  18362. /**
  18363. * Registers an action to this action manager
  18364. * @param action defines the action to be registered
  18365. * @return the action amended (prepared) after registration
  18366. */
  18367. registerAction(action: IAction): Nullable<IAction>;
  18368. /**
  18369. * Unregisters an action to this action manager
  18370. * @param action defines the action to be unregistered
  18371. * @return a boolean indicating whether the action has been unregistered
  18372. */
  18373. unregisterAction(action: IAction): Boolean;
  18374. /**
  18375. * Process a specific trigger
  18376. * @param trigger defines the trigger to process
  18377. * @param evt defines the event details to be processed
  18378. */
  18379. processTrigger(trigger: number, evt?: IActionEvent): void;
  18380. /** @hidden */
  18381. _getEffectiveTarget(target: any, propertyPath: string): any;
  18382. /** @hidden */
  18383. _getProperty(propertyPath: string): string;
  18384. /**
  18385. * Serialize this manager to a JSON object
  18386. * @param name defines the property name to store this manager
  18387. * @returns a JSON representation of this manager
  18388. */
  18389. serialize(name: string): any;
  18390. /**
  18391. * Creates a new ActionManager from a JSON data
  18392. * @param parsedActions defines the JSON data to read from
  18393. * @param object defines the hosting mesh
  18394. * @param scene defines the hosting scene
  18395. */
  18396. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18397. /**
  18398. * Get a trigger name by index
  18399. * @param trigger defines the trigger index
  18400. * @returns a trigger name
  18401. */
  18402. static GetTriggerName(trigger: number): string;
  18403. }
  18404. }
  18405. declare module "babylonjs/Sprites/sprite" {
  18406. import { Vector3 } from "babylonjs/Maths/math.vector";
  18407. import { Nullable } from "babylonjs/types";
  18408. import { ActionManager } from "babylonjs/Actions/actionManager";
  18409. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18410. import { Color4 } from "babylonjs/Maths/math.color";
  18411. /**
  18412. * Class used to represent a sprite
  18413. * @see http://doc.babylonjs.com/babylon101/sprites
  18414. */
  18415. export class Sprite {
  18416. /** defines the name */
  18417. name: string;
  18418. /** Gets or sets the current world position */
  18419. position: Vector3;
  18420. /** Gets or sets the main color */
  18421. color: Color4;
  18422. /** Gets or sets the width */
  18423. width: number;
  18424. /** Gets or sets the height */
  18425. height: number;
  18426. /** Gets or sets rotation angle */
  18427. angle: number;
  18428. /** Gets or sets the cell index in the sprite sheet */
  18429. cellIndex: number;
  18430. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18431. cellRef: string;
  18432. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18433. invertU: number;
  18434. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18435. invertV: number;
  18436. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18437. disposeWhenFinishedAnimating: boolean;
  18438. /** Gets the list of attached animations */
  18439. animations: Animation[];
  18440. /** Gets or sets a boolean indicating if the sprite can be picked */
  18441. isPickable: boolean;
  18442. /**
  18443. * Gets or sets the associated action manager
  18444. */
  18445. actionManager: Nullable<ActionManager>;
  18446. private _animationStarted;
  18447. private _loopAnimation;
  18448. private _fromIndex;
  18449. private _toIndex;
  18450. private _delay;
  18451. private _direction;
  18452. private _manager;
  18453. private _time;
  18454. private _onAnimationEnd;
  18455. /**
  18456. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18457. */
  18458. isVisible: boolean;
  18459. /**
  18460. * Gets or sets the sprite size
  18461. */
  18462. get size(): number;
  18463. set size(value: number);
  18464. /**
  18465. * Creates a new Sprite
  18466. * @param name defines the name
  18467. * @param manager defines the manager
  18468. */
  18469. constructor(
  18470. /** defines the name */
  18471. name: string, manager: ISpriteManager);
  18472. /**
  18473. * Starts an animation
  18474. * @param from defines the initial key
  18475. * @param to defines the end key
  18476. * @param loop defines if the animation must loop
  18477. * @param delay defines the start delay (in ms)
  18478. * @param onAnimationEnd defines a callback to call when animation ends
  18479. */
  18480. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18481. /** Stops current animation (if any) */
  18482. stopAnimation(): void;
  18483. /** @hidden */
  18484. _animate(deltaTime: number): void;
  18485. /** Release associated resources */
  18486. dispose(): void;
  18487. }
  18488. }
  18489. declare module "babylonjs/Collisions/pickingInfo" {
  18490. import { Nullable } from "babylonjs/types";
  18491. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18493. import { Sprite } from "babylonjs/Sprites/sprite";
  18494. import { Ray } from "babylonjs/Culling/ray";
  18495. /**
  18496. * Information about the result of picking within a scene
  18497. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18498. */
  18499. export class PickingInfo {
  18500. /** @hidden */
  18501. _pickingUnavailable: boolean;
  18502. /**
  18503. * If the pick collided with an object
  18504. */
  18505. hit: boolean;
  18506. /**
  18507. * Distance away where the pick collided
  18508. */
  18509. distance: number;
  18510. /**
  18511. * The location of pick collision
  18512. */
  18513. pickedPoint: Nullable<Vector3>;
  18514. /**
  18515. * The mesh corresponding the the pick collision
  18516. */
  18517. pickedMesh: Nullable<AbstractMesh>;
  18518. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18519. bu: number;
  18520. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18521. bv: number;
  18522. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18523. faceId: number;
  18524. /** Id of the the submesh that was picked */
  18525. subMeshId: number;
  18526. /** If a sprite was picked, this will be the sprite the pick collided with */
  18527. pickedSprite: Nullable<Sprite>;
  18528. /**
  18529. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18530. */
  18531. originMesh: Nullable<AbstractMesh>;
  18532. /**
  18533. * The ray that was used to perform the picking.
  18534. */
  18535. ray: Nullable<Ray>;
  18536. /**
  18537. * Gets the normal correspodning to the face the pick collided with
  18538. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18539. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18540. * @returns The normal correspodning to the face the pick collided with
  18541. */
  18542. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18543. /**
  18544. * Gets the texture coordinates of where the pick occured
  18545. * @returns the vector containing the coordnates of the texture
  18546. */
  18547. getTextureCoordinates(): Nullable<Vector2>;
  18548. }
  18549. }
  18550. declare module "babylonjs/Events/pointerEvents" {
  18551. import { Nullable } from "babylonjs/types";
  18552. import { Vector2 } from "babylonjs/Maths/math.vector";
  18553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18554. import { Ray } from "babylonjs/Culling/ray";
  18555. /**
  18556. * Gather the list of pointer event types as constants.
  18557. */
  18558. export class PointerEventTypes {
  18559. /**
  18560. * 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.
  18561. */
  18562. static readonly POINTERDOWN: number;
  18563. /**
  18564. * The pointerup event is fired when a pointer is no longer active.
  18565. */
  18566. static readonly POINTERUP: number;
  18567. /**
  18568. * The pointermove event is fired when a pointer changes coordinates.
  18569. */
  18570. static readonly POINTERMOVE: number;
  18571. /**
  18572. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18573. */
  18574. static readonly POINTERWHEEL: number;
  18575. /**
  18576. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18577. */
  18578. static readonly POINTERPICK: number;
  18579. /**
  18580. * The pointertap event is fired when a the object has been touched and released without drag.
  18581. */
  18582. static readonly POINTERTAP: number;
  18583. /**
  18584. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18585. */
  18586. static readonly POINTERDOUBLETAP: number;
  18587. }
  18588. /**
  18589. * Base class of pointer info types.
  18590. */
  18591. export class PointerInfoBase {
  18592. /**
  18593. * Defines the type of event (PointerEventTypes)
  18594. */
  18595. type: number;
  18596. /**
  18597. * Defines the related dom event
  18598. */
  18599. event: PointerEvent | MouseWheelEvent;
  18600. /**
  18601. * Instantiates the base class of pointers info.
  18602. * @param type Defines the type of event (PointerEventTypes)
  18603. * @param event Defines the related dom event
  18604. */
  18605. constructor(
  18606. /**
  18607. * Defines the type of event (PointerEventTypes)
  18608. */
  18609. type: number,
  18610. /**
  18611. * Defines the related dom event
  18612. */
  18613. event: PointerEvent | MouseWheelEvent);
  18614. }
  18615. /**
  18616. * This class is used to store pointer related info for the onPrePointerObservable event.
  18617. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18618. */
  18619. export class PointerInfoPre extends PointerInfoBase {
  18620. /**
  18621. * Ray from a pointer if availible (eg. 6dof controller)
  18622. */
  18623. ray: Nullable<Ray>;
  18624. /**
  18625. * Defines the local position of the pointer on the canvas.
  18626. */
  18627. localPosition: Vector2;
  18628. /**
  18629. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18630. */
  18631. skipOnPointerObservable: boolean;
  18632. /**
  18633. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18634. * @param type Defines the type of event (PointerEventTypes)
  18635. * @param event Defines the related dom event
  18636. * @param localX Defines the local x coordinates of the pointer when the event occured
  18637. * @param localY Defines the local y coordinates of the pointer when the event occured
  18638. */
  18639. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18640. }
  18641. /**
  18642. * This type contains all the data related to a pointer event in Babylon.js.
  18643. * 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.
  18644. */
  18645. export class PointerInfo extends PointerInfoBase {
  18646. /**
  18647. * Defines the picking info associated to the info (if any)\
  18648. */
  18649. pickInfo: Nullable<PickingInfo>;
  18650. /**
  18651. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18652. * @param type Defines the type of event (PointerEventTypes)
  18653. * @param event Defines the related dom event
  18654. * @param pickInfo Defines the picking info associated to the info (if any)\
  18655. */
  18656. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18657. /**
  18658. * Defines the picking info associated to the info (if any)\
  18659. */
  18660. pickInfo: Nullable<PickingInfo>);
  18661. }
  18662. /**
  18663. * Data relating to a touch event on the screen.
  18664. */
  18665. export interface PointerTouch {
  18666. /**
  18667. * X coordinate of touch.
  18668. */
  18669. x: number;
  18670. /**
  18671. * Y coordinate of touch.
  18672. */
  18673. y: number;
  18674. /**
  18675. * Id of touch. Unique for each finger.
  18676. */
  18677. pointerId: number;
  18678. /**
  18679. * Event type passed from DOM.
  18680. */
  18681. type: any;
  18682. }
  18683. }
  18684. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18685. import { Observable } from "babylonjs/Misc/observable";
  18686. import { Nullable } from "babylonjs/types";
  18687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18688. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18689. /**
  18690. * Manage the mouse inputs to control the movement of a free camera.
  18691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18692. */
  18693. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18694. /**
  18695. * Define if touch is enabled in the mouse input
  18696. */
  18697. touchEnabled: boolean;
  18698. /**
  18699. * Defines the camera the input is attached to.
  18700. */
  18701. camera: FreeCamera;
  18702. /**
  18703. * Defines the buttons associated with the input to handle camera move.
  18704. */
  18705. buttons: number[];
  18706. /**
  18707. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18708. */
  18709. angularSensibility: number;
  18710. private _pointerInput;
  18711. private _onMouseMove;
  18712. private _observer;
  18713. private previousPosition;
  18714. /**
  18715. * Observable for when a pointer move event occurs containing the move offset
  18716. */
  18717. onPointerMovedObservable: Observable<{
  18718. offsetX: number;
  18719. offsetY: number;
  18720. }>;
  18721. /**
  18722. * @hidden
  18723. * If the camera should be rotated automatically based on pointer movement
  18724. */
  18725. _allowCameraRotation: boolean;
  18726. /**
  18727. * Manage the mouse inputs to control the movement of a free camera.
  18728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18729. * @param touchEnabled Defines if touch is enabled or not
  18730. */
  18731. constructor(
  18732. /**
  18733. * Define if touch is enabled in the mouse input
  18734. */
  18735. touchEnabled?: boolean);
  18736. /**
  18737. * Attach the input controls to a specific dom element to get the input from.
  18738. * @param element Defines the element the controls should be listened from
  18739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18740. */
  18741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18742. /**
  18743. * Called on JS contextmenu event.
  18744. * Override this method to provide functionality.
  18745. */
  18746. protected onContextMenu(evt: PointerEvent): void;
  18747. /**
  18748. * Detach the current controls from the specified dom element.
  18749. * @param element Defines the element to stop listening the inputs from
  18750. */
  18751. detachControl(element: Nullable<HTMLElement>): void;
  18752. /**
  18753. * Gets the class name of the current intput.
  18754. * @returns the class name
  18755. */
  18756. getClassName(): string;
  18757. /**
  18758. * Get the friendly name associated with the input class.
  18759. * @returns the input friendly name
  18760. */
  18761. getSimpleName(): string;
  18762. }
  18763. }
  18764. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18765. import { Nullable } from "babylonjs/types";
  18766. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18768. /**
  18769. * Manage the touch inputs to control the movement of a free camera.
  18770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18771. */
  18772. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18773. /**
  18774. * Defines the camera the input is attached to.
  18775. */
  18776. camera: FreeCamera;
  18777. /**
  18778. * Defines the touch sensibility for rotation.
  18779. * The higher the faster.
  18780. */
  18781. touchAngularSensibility: number;
  18782. /**
  18783. * Defines the touch sensibility for move.
  18784. * The higher the faster.
  18785. */
  18786. touchMoveSensibility: number;
  18787. private _offsetX;
  18788. private _offsetY;
  18789. private _pointerPressed;
  18790. private _pointerInput;
  18791. private _observer;
  18792. private _onLostFocus;
  18793. /**
  18794. * Attach the input controls to a specific dom element to get the input from.
  18795. * @param element Defines the element the controls should be listened from
  18796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18797. */
  18798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18799. /**
  18800. * Detach the current controls from the specified dom element.
  18801. * @param element Defines the element to stop listening the inputs from
  18802. */
  18803. detachControl(element: Nullable<HTMLElement>): void;
  18804. /**
  18805. * Update the current camera state depending on the inputs that have been used this frame.
  18806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18807. */
  18808. checkInputs(): void;
  18809. /**
  18810. * Gets the class name of the current intput.
  18811. * @returns the class name
  18812. */
  18813. getClassName(): string;
  18814. /**
  18815. * Get the friendly name associated with the input class.
  18816. * @returns the input friendly name
  18817. */
  18818. getSimpleName(): string;
  18819. }
  18820. }
  18821. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18822. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18823. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18824. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18825. import { Nullable } from "babylonjs/types";
  18826. /**
  18827. * Default Inputs manager for the FreeCamera.
  18828. * It groups all the default supported inputs for ease of use.
  18829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18830. */
  18831. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18832. /**
  18833. * @hidden
  18834. */
  18835. _mouseInput: Nullable<FreeCameraMouseInput>;
  18836. /**
  18837. * Instantiates a new FreeCameraInputsManager.
  18838. * @param camera Defines the camera the inputs belong to
  18839. */
  18840. constructor(camera: FreeCamera);
  18841. /**
  18842. * Add keyboard input support to the input manager.
  18843. * @returns the current input manager
  18844. */
  18845. addKeyboard(): FreeCameraInputsManager;
  18846. /**
  18847. * Add mouse input support to the input manager.
  18848. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18849. * @returns the current input manager
  18850. */
  18851. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18852. /**
  18853. * Removes the mouse input support from the manager
  18854. * @returns the current input manager
  18855. */
  18856. removeMouse(): FreeCameraInputsManager;
  18857. /**
  18858. * Add touch input support to the input manager.
  18859. * @returns the current input manager
  18860. */
  18861. addTouch(): FreeCameraInputsManager;
  18862. /**
  18863. * Remove all attached input methods from a camera
  18864. */
  18865. clear(): void;
  18866. }
  18867. }
  18868. declare module "babylonjs/Cameras/freeCamera" {
  18869. import { Vector3 } from "babylonjs/Maths/math.vector";
  18870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18871. import { Scene } from "babylonjs/scene";
  18872. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18873. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18874. /**
  18875. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18876. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18878. */
  18879. export class FreeCamera extends TargetCamera {
  18880. /**
  18881. * Define the collision ellipsoid of the camera.
  18882. * This is helpful to simulate a camera body like the player body around the camera
  18883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18884. */
  18885. ellipsoid: Vector3;
  18886. /**
  18887. * Define an offset for the position of the ellipsoid around the camera.
  18888. * This can be helpful to determine the center of the body near the gravity center of the body
  18889. * instead of its head.
  18890. */
  18891. ellipsoidOffset: Vector3;
  18892. /**
  18893. * Enable or disable collisions of the camera with the rest of the scene objects.
  18894. */
  18895. checkCollisions: boolean;
  18896. /**
  18897. * Enable or disable gravity on the camera.
  18898. */
  18899. applyGravity: boolean;
  18900. /**
  18901. * Define the input manager associated to the camera.
  18902. */
  18903. inputs: FreeCameraInputsManager;
  18904. /**
  18905. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18906. * Higher values reduce sensitivity.
  18907. */
  18908. get angularSensibility(): number;
  18909. /**
  18910. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18911. * Higher values reduce sensitivity.
  18912. */
  18913. set angularSensibility(value: number);
  18914. /**
  18915. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18916. */
  18917. get keysUp(): number[];
  18918. set keysUp(value: number[]);
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18921. */
  18922. get keysUpward(): number[];
  18923. set keysUpward(value: number[]);
  18924. /**
  18925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18926. */
  18927. get keysDown(): number[];
  18928. set keysDown(value: number[]);
  18929. /**
  18930. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18931. */
  18932. get keysDownward(): number[];
  18933. set keysDownward(value: number[]);
  18934. /**
  18935. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18936. */
  18937. get keysLeft(): number[];
  18938. set keysLeft(value: number[]);
  18939. /**
  18940. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18941. */
  18942. get keysRight(): number[];
  18943. set keysRight(value: number[]);
  18944. /**
  18945. * Event raised when the camera collide with a mesh in the scene.
  18946. */
  18947. onCollide: (collidedMesh: AbstractMesh) => void;
  18948. private _collider;
  18949. private _needMoveForGravity;
  18950. private _oldPosition;
  18951. private _diffPosition;
  18952. private _newPosition;
  18953. /** @hidden */
  18954. _localDirection: Vector3;
  18955. /** @hidden */
  18956. _transformedDirection: Vector3;
  18957. /**
  18958. * Instantiates a Free Camera.
  18959. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18960. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18962. * @param name Define the name of the camera in the scene
  18963. * @param position Define the start position of the camera in the scene
  18964. * @param scene Define the scene the camera belongs to
  18965. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18966. */
  18967. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18968. /**
  18969. * Attached controls to the current camera.
  18970. * @param element Defines the element the controls should be listened from
  18971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18972. */
  18973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18974. /**
  18975. * Detach the current controls from the camera.
  18976. * The camera will stop reacting to inputs.
  18977. * @param element Defines the element to stop listening the inputs from
  18978. */
  18979. detachControl(element: HTMLElement): void;
  18980. private _collisionMask;
  18981. /**
  18982. * Define a collision mask to limit the list of object the camera can collide with
  18983. */
  18984. get collisionMask(): number;
  18985. set collisionMask(mask: number);
  18986. /** @hidden */
  18987. _collideWithWorld(displacement: Vector3): void;
  18988. private _onCollisionPositionChange;
  18989. /** @hidden */
  18990. _checkInputs(): void;
  18991. /** @hidden */
  18992. _decideIfNeedsToMove(): boolean;
  18993. /** @hidden */
  18994. _updatePosition(): void;
  18995. /**
  18996. * Destroy the camera and release the current resources hold by it.
  18997. */
  18998. dispose(): void;
  18999. /**
  19000. * Gets the current object class name.
  19001. * @return the class name
  19002. */
  19003. getClassName(): string;
  19004. }
  19005. }
  19006. declare module "babylonjs/Gamepads/gamepad" {
  19007. import { Observable } from "babylonjs/Misc/observable";
  19008. /**
  19009. * Represents a gamepad control stick position
  19010. */
  19011. export class StickValues {
  19012. /**
  19013. * The x component of the control stick
  19014. */
  19015. x: number;
  19016. /**
  19017. * The y component of the control stick
  19018. */
  19019. y: number;
  19020. /**
  19021. * Initializes the gamepad x and y control stick values
  19022. * @param x The x component of the gamepad control stick value
  19023. * @param y The y component of the gamepad control stick value
  19024. */
  19025. constructor(
  19026. /**
  19027. * The x component of the control stick
  19028. */
  19029. x: number,
  19030. /**
  19031. * The y component of the control stick
  19032. */
  19033. y: number);
  19034. }
  19035. /**
  19036. * An interface which manages callbacks for gamepad button changes
  19037. */
  19038. export interface GamepadButtonChanges {
  19039. /**
  19040. * Called when a gamepad has been changed
  19041. */
  19042. changed: boolean;
  19043. /**
  19044. * Called when a gamepad press event has been triggered
  19045. */
  19046. pressChanged: boolean;
  19047. /**
  19048. * Called when a touch event has been triggered
  19049. */
  19050. touchChanged: boolean;
  19051. /**
  19052. * Called when a value has changed
  19053. */
  19054. valueChanged: boolean;
  19055. }
  19056. /**
  19057. * Represents a gamepad
  19058. */
  19059. export class Gamepad {
  19060. /**
  19061. * The id of the gamepad
  19062. */
  19063. id: string;
  19064. /**
  19065. * The index of the gamepad
  19066. */
  19067. index: number;
  19068. /**
  19069. * The browser gamepad
  19070. */
  19071. browserGamepad: any;
  19072. /**
  19073. * Specifies what type of gamepad this represents
  19074. */
  19075. type: number;
  19076. private _leftStick;
  19077. private _rightStick;
  19078. /** @hidden */
  19079. _isConnected: boolean;
  19080. private _leftStickAxisX;
  19081. private _leftStickAxisY;
  19082. private _rightStickAxisX;
  19083. private _rightStickAxisY;
  19084. /**
  19085. * Triggered when the left control stick has been changed
  19086. */
  19087. private _onleftstickchanged;
  19088. /**
  19089. * Triggered when the right control stick has been changed
  19090. */
  19091. private _onrightstickchanged;
  19092. /**
  19093. * Represents a gamepad controller
  19094. */
  19095. static GAMEPAD: number;
  19096. /**
  19097. * Represents a generic controller
  19098. */
  19099. static GENERIC: number;
  19100. /**
  19101. * Represents an XBox controller
  19102. */
  19103. static XBOX: number;
  19104. /**
  19105. * Represents a pose-enabled controller
  19106. */
  19107. static POSE_ENABLED: number;
  19108. /**
  19109. * Represents an Dual Shock controller
  19110. */
  19111. static DUALSHOCK: number;
  19112. /**
  19113. * Specifies whether the left control stick should be Y-inverted
  19114. */
  19115. protected _invertLeftStickY: boolean;
  19116. /**
  19117. * Specifies if the gamepad has been connected
  19118. */
  19119. get isConnected(): boolean;
  19120. /**
  19121. * Initializes the gamepad
  19122. * @param id The id of the gamepad
  19123. * @param index The index of the gamepad
  19124. * @param browserGamepad The browser gamepad
  19125. * @param leftStickX The x component of the left joystick
  19126. * @param leftStickY The y component of the left joystick
  19127. * @param rightStickX The x component of the right joystick
  19128. * @param rightStickY The y component of the right joystick
  19129. */
  19130. constructor(
  19131. /**
  19132. * The id of the gamepad
  19133. */
  19134. id: string,
  19135. /**
  19136. * The index of the gamepad
  19137. */
  19138. index: number,
  19139. /**
  19140. * The browser gamepad
  19141. */
  19142. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19143. /**
  19144. * Callback triggered when the left joystick has changed
  19145. * @param callback
  19146. */
  19147. onleftstickchanged(callback: (values: StickValues) => void): void;
  19148. /**
  19149. * Callback triggered when the right joystick has changed
  19150. * @param callback
  19151. */
  19152. onrightstickchanged(callback: (values: StickValues) => void): void;
  19153. /**
  19154. * Gets the left joystick
  19155. */
  19156. get leftStick(): StickValues;
  19157. /**
  19158. * Sets the left joystick values
  19159. */
  19160. set leftStick(newValues: StickValues);
  19161. /**
  19162. * Gets the right joystick
  19163. */
  19164. get rightStick(): StickValues;
  19165. /**
  19166. * Sets the right joystick value
  19167. */
  19168. set rightStick(newValues: StickValues);
  19169. /**
  19170. * Updates the gamepad joystick positions
  19171. */
  19172. update(): void;
  19173. /**
  19174. * Disposes the gamepad
  19175. */
  19176. dispose(): void;
  19177. }
  19178. /**
  19179. * Represents a generic gamepad
  19180. */
  19181. export class GenericPad extends Gamepad {
  19182. private _buttons;
  19183. private _onbuttondown;
  19184. private _onbuttonup;
  19185. /**
  19186. * Observable triggered when a button has been pressed
  19187. */
  19188. onButtonDownObservable: Observable<number>;
  19189. /**
  19190. * Observable triggered when a button has been released
  19191. */
  19192. onButtonUpObservable: Observable<number>;
  19193. /**
  19194. * Callback triggered when a button has been pressed
  19195. * @param callback Called when a button has been pressed
  19196. */
  19197. onbuttondown(callback: (buttonPressed: number) => void): void;
  19198. /**
  19199. * Callback triggered when a button has been released
  19200. * @param callback Called when a button has been released
  19201. */
  19202. onbuttonup(callback: (buttonReleased: number) => void): void;
  19203. /**
  19204. * Initializes the generic gamepad
  19205. * @param id The id of the generic gamepad
  19206. * @param index The index of the generic gamepad
  19207. * @param browserGamepad The browser gamepad
  19208. */
  19209. constructor(id: string, index: number, browserGamepad: any);
  19210. private _setButtonValue;
  19211. /**
  19212. * Updates the generic gamepad
  19213. */
  19214. update(): void;
  19215. /**
  19216. * Disposes the generic gamepad
  19217. */
  19218. dispose(): void;
  19219. }
  19220. }
  19221. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19222. import { Observable } from "babylonjs/Misc/observable";
  19223. import { Nullable } from "babylonjs/types";
  19224. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19227. import { Ray } from "babylonjs/Culling/ray";
  19228. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19229. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19230. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19231. /**
  19232. * Defines the types of pose enabled controllers that are supported
  19233. */
  19234. export enum PoseEnabledControllerType {
  19235. /**
  19236. * HTC Vive
  19237. */
  19238. VIVE = 0,
  19239. /**
  19240. * Oculus Rift
  19241. */
  19242. OCULUS = 1,
  19243. /**
  19244. * Windows mixed reality
  19245. */
  19246. WINDOWS = 2,
  19247. /**
  19248. * Samsung gear VR
  19249. */
  19250. GEAR_VR = 3,
  19251. /**
  19252. * Google Daydream
  19253. */
  19254. DAYDREAM = 4,
  19255. /**
  19256. * Generic
  19257. */
  19258. GENERIC = 5
  19259. }
  19260. /**
  19261. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19262. */
  19263. export interface MutableGamepadButton {
  19264. /**
  19265. * Value of the button/trigger
  19266. */
  19267. value: number;
  19268. /**
  19269. * If the button/trigger is currently touched
  19270. */
  19271. touched: boolean;
  19272. /**
  19273. * If the button/trigger is currently pressed
  19274. */
  19275. pressed: boolean;
  19276. }
  19277. /**
  19278. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19279. * @hidden
  19280. */
  19281. export interface ExtendedGamepadButton extends GamepadButton {
  19282. /**
  19283. * If the button/trigger is currently pressed
  19284. */
  19285. readonly pressed: boolean;
  19286. /**
  19287. * If the button/trigger is currently touched
  19288. */
  19289. readonly touched: boolean;
  19290. /**
  19291. * Value of the button/trigger
  19292. */
  19293. readonly value: number;
  19294. }
  19295. /** @hidden */
  19296. export interface _GamePadFactory {
  19297. /**
  19298. * Returns whether or not the current gamepad can be created for this type of controller.
  19299. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19300. * @returns true if it can be created, otherwise false
  19301. */
  19302. canCreate(gamepadInfo: any): boolean;
  19303. /**
  19304. * Creates a new instance of the Gamepad.
  19305. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19306. * @returns the new gamepad instance
  19307. */
  19308. create(gamepadInfo: any): Gamepad;
  19309. }
  19310. /**
  19311. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19312. */
  19313. export class PoseEnabledControllerHelper {
  19314. /** @hidden */
  19315. static _ControllerFactories: _GamePadFactory[];
  19316. /** @hidden */
  19317. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19318. /**
  19319. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19320. * @param vrGamepad the gamepad to initialized
  19321. * @returns a vr controller of the type the gamepad identified as
  19322. */
  19323. static InitiateController(vrGamepad: any): Gamepad;
  19324. }
  19325. /**
  19326. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19327. */
  19328. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19329. /**
  19330. * If the controller is used in a webXR session
  19331. */
  19332. isXR: boolean;
  19333. private _deviceRoomPosition;
  19334. private _deviceRoomRotationQuaternion;
  19335. /**
  19336. * The device position in babylon space
  19337. */
  19338. devicePosition: Vector3;
  19339. /**
  19340. * The device rotation in babylon space
  19341. */
  19342. deviceRotationQuaternion: Quaternion;
  19343. /**
  19344. * The scale factor of the device in babylon space
  19345. */
  19346. deviceScaleFactor: number;
  19347. /**
  19348. * (Likely devicePosition should be used instead) The device position in its room space
  19349. */
  19350. position: Vector3;
  19351. /**
  19352. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19353. */
  19354. rotationQuaternion: Quaternion;
  19355. /**
  19356. * The type of controller (Eg. Windows mixed reality)
  19357. */
  19358. controllerType: PoseEnabledControllerType;
  19359. protected _calculatedPosition: Vector3;
  19360. private _calculatedRotation;
  19361. /**
  19362. * The raw pose from the device
  19363. */
  19364. rawPose: DevicePose;
  19365. private _trackPosition;
  19366. private _maxRotationDistFromHeadset;
  19367. private _draggedRoomRotation;
  19368. /**
  19369. * @hidden
  19370. */
  19371. _disableTrackPosition(fixedPosition: Vector3): void;
  19372. /**
  19373. * Internal, the mesh attached to the controller
  19374. * @hidden
  19375. */
  19376. _mesh: Nullable<AbstractMesh>;
  19377. private _poseControlledCamera;
  19378. private _leftHandSystemQuaternion;
  19379. /**
  19380. * Internal, matrix used to convert room space to babylon space
  19381. * @hidden
  19382. */
  19383. _deviceToWorld: Matrix;
  19384. /**
  19385. * Node to be used when casting a ray from the controller
  19386. * @hidden
  19387. */
  19388. _pointingPoseNode: Nullable<TransformNode>;
  19389. /**
  19390. * Name of the child mesh that can be used to cast a ray from the controller
  19391. */
  19392. static readonly POINTING_POSE: string;
  19393. /**
  19394. * Creates a new PoseEnabledController from a gamepad
  19395. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19396. */
  19397. constructor(browserGamepad: any);
  19398. private _workingMatrix;
  19399. /**
  19400. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19401. */
  19402. update(): void;
  19403. /**
  19404. * Updates only the pose device and mesh without doing any button event checking
  19405. */
  19406. protected _updatePoseAndMesh(): void;
  19407. /**
  19408. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19409. * @param poseData raw pose fromthe device
  19410. */
  19411. updateFromDevice(poseData: DevicePose): void;
  19412. /**
  19413. * @hidden
  19414. */
  19415. _meshAttachedObservable: Observable<AbstractMesh>;
  19416. /**
  19417. * Attaches a mesh to the controller
  19418. * @param mesh the mesh to be attached
  19419. */
  19420. attachToMesh(mesh: AbstractMesh): void;
  19421. /**
  19422. * Attaches the controllers mesh to a camera
  19423. * @param camera the camera the mesh should be attached to
  19424. */
  19425. attachToPoseControlledCamera(camera: TargetCamera): void;
  19426. /**
  19427. * Disposes of the controller
  19428. */
  19429. dispose(): void;
  19430. /**
  19431. * The mesh that is attached to the controller
  19432. */
  19433. get mesh(): Nullable<AbstractMesh>;
  19434. /**
  19435. * Gets the ray of the controller in the direction the controller is pointing
  19436. * @param length the length the resulting ray should be
  19437. * @returns a ray in the direction the controller is pointing
  19438. */
  19439. getForwardRay(length?: number): Ray;
  19440. }
  19441. }
  19442. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19443. import { Observable } from "babylonjs/Misc/observable";
  19444. import { Scene } from "babylonjs/scene";
  19445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19446. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19447. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19448. import { Nullable } from "babylonjs/types";
  19449. /**
  19450. * Defines the WebVRController object that represents controllers tracked in 3D space
  19451. */
  19452. export abstract class WebVRController extends PoseEnabledController {
  19453. /**
  19454. * Internal, the default controller model for the controller
  19455. */
  19456. protected _defaultModel: Nullable<AbstractMesh>;
  19457. /**
  19458. * Fired when the trigger state has changed
  19459. */
  19460. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19461. /**
  19462. * Fired when the main button state has changed
  19463. */
  19464. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19465. /**
  19466. * Fired when the secondary button state has changed
  19467. */
  19468. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19469. /**
  19470. * Fired when the pad state has changed
  19471. */
  19472. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19473. /**
  19474. * Fired when controllers stick values have changed
  19475. */
  19476. onPadValuesChangedObservable: Observable<StickValues>;
  19477. /**
  19478. * Array of button availible on the controller
  19479. */
  19480. protected _buttons: Array<MutableGamepadButton>;
  19481. private _onButtonStateChange;
  19482. /**
  19483. * Fired when a controller button's state has changed
  19484. * @param callback the callback containing the button that was modified
  19485. */
  19486. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19487. /**
  19488. * X and Y axis corresponding to the controllers joystick
  19489. */
  19490. pad: StickValues;
  19491. /**
  19492. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19493. */
  19494. hand: string;
  19495. /**
  19496. * The default controller model for the controller
  19497. */
  19498. get defaultModel(): Nullable<AbstractMesh>;
  19499. /**
  19500. * Creates a new WebVRController from a gamepad
  19501. * @param vrGamepad the gamepad that the WebVRController should be created from
  19502. */
  19503. constructor(vrGamepad: any);
  19504. /**
  19505. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19506. */
  19507. update(): void;
  19508. /**
  19509. * Function to be called when a button is modified
  19510. */
  19511. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19512. /**
  19513. * Loads a mesh and attaches it to the controller
  19514. * @param scene the scene the mesh should be added to
  19515. * @param meshLoaded callback for when the mesh has been loaded
  19516. */
  19517. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19518. private _setButtonValue;
  19519. private _changes;
  19520. private _checkChanges;
  19521. /**
  19522. * Disposes of th webVRCOntroller
  19523. */
  19524. dispose(): void;
  19525. }
  19526. }
  19527. declare module "babylonjs/Lights/hemisphericLight" {
  19528. import { Nullable } from "babylonjs/types";
  19529. import { Scene } from "babylonjs/scene";
  19530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19531. import { Color3 } from "babylonjs/Maths/math.color";
  19532. import { Effect } from "babylonjs/Materials/effect";
  19533. import { Light } from "babylonjs/Lights/light";
  19534. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19535. /**
  19536. * The HemisphericLight simulates the ambient environment light,
  19537. * so the passed direction is the light reflection direction, not the incoming direction.
  19538. */
  19539. export class HemisphericLight extends Light {
  19540. /**
  19541. * The groundColor is the light in the opposite direction to the one specified during creation.
  19542. * 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.
  19543. */
  19544. groundColor: Color3;
  19545. /**
  19546. * The light reflection direction, not the incoming direction.
  19547. */
  19548. direction: Vector3;
  19549. /**
  19550. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19551. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19552. * The HemisphericLight can't cast shadows.
  19553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19554. * @param name The friendly name of the light
  19555. * @param direction The direction of the light reflection
  19556. * @param scene The scene the light belongs to
  19557. */
  19558. constructor(name: string, direction: Vector3, scene: Scene);
  19559. protected _buildUniformLayout(): void;
  19560. /**
  19561. * Returns the string "HemisphericLight".
  19562. * @return The class name
  19563. */
  19564. getClassName(): string;
  19565. /**
  19566. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19567. * Returns the updated direction.
  19568. * @param target The target the direction should point to
  19569. * @return The computed direction
  19570. */
  19571. setDirectionToTarget(target: Vector3): Vector3;
  19572. /**
  19573. * Returns the shadow generator associated to the light.
  19574. * @returns Always null for hemispheric lights because it does not support shadows.
  19575. */
  19576. getShadowGenerator(): Nullable<IShadowGenerator>;
  19577. /**
  19578. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19579. * @param effect The effect to update
  19580. * @param lightIndex The index of the light in the effect to update
  19581. * @returns The hemispheric light
  19582. */
  19583. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19584. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19585. /**
  19586. * Computes the world matrix of the node
  19587. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19588. * @param useWasUpdatedFlag defines a reserved property
  19589. * @returns the world matrix
  19590. */
  19591. computeWorldMatrix(): Matrix;
  19592. /**
  19593. * Returns the integer 3.
  19594. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19595. */
  19596. getTypeID(): number;
  19597. /**
  19598. * Prepares the list of defines specific to the light type.
  19599. * @param defines the list of defines
  19600. * @param lightIndex defines the index of the light for the effect
  19601. */
  19602. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19603. }
  19604. }
  19605. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19606. /** @hidden */
  19607. export var vrMultiviewToSingleviewPixelShader: {
  19608. name: string;
  19609. shader: string;
  19610. };
  19611. }
  19612. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19614. import { Scene } from "babylonjs/scene";
  19615. /**
  19616. * Renders to multiple views with a single draw call
  19617. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19618. */
  19619. export class MultiviewRenderTarget extends RenderTargetTexture {
  19620. /**
  19621. * Creates a multiview render target
  19622. * @param scene scene used with the render target
  19623. * @param size the size of the render target (used for each view)
  19624. */
  19625. constructor(scene: Scene, size?: number | {
  19626. width: number;
  19627. height: number;
  19628. } | {
  19629. ratio: number;
  19630. });
  19631. /**
  19632. * @hidden
  19633. * @param faceIndex the face index, if its a cube texture
  19634. */
  19635. _bindFrameBuffer(faceIndex?: number): void;
  19636. /**
  19637. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19638. * @returns the view count
  19639. */
  19640. getViewCount(): number;
  19641. }
  19642. }
  19643. declare module "babylonjs/Maths/math.frustum" {
  19644. import { Matrix } from "babylonjs/Maths/math.vector";
  19645. import { DeepImmutable } from "babylonjs/types";
  19646. import { Plane } from "babylonjs/Maths/math.plane";
  19647. /**
  19648. * Represents a camera frustum
  19649. */
  19650. export class Frustum {
  19651. /**
  19652. * Gets the planes representing the frustum
  19653. * @param transform matrix to be applied to the returned planes
  19654. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19655. */
  19656. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19657. /**
  19658. * Gets the near frustum plane transformed by the transform matrix
  19659. * @param transform transformation matrix to be applied to the resulting frustum plane
  19660. * @param frustumPlane the resuling frustum plane
  19661. */
  19662. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19663. /**
  19664. * Gets the far frustum plane transformed by the transform matrix
  19665. * @param transform transformation matrix to be applied to the resulting frustum plane
  19666. * @param frustumPlane the resuling frustum plane
  19667. */
  19668. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19669. /**
  19670. * Gets the left frustum plane transformed by the transform matrix
  19671. * @param transform transformation matrix to be applied to the resulting frustum plane
  19672. * @param frustumPlane the resuling frustum plane
  19673. */
  19674. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19675. /**
  19676. * Gets the right frustum plane transformed by the transform matrix
  19677. * @param transform transformation matrix to be applied to the resulting frustum plane
  19678. * @param frustumPlane the resuling frustum plane
  19679. */
  19680. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19681. /**
  19682. * Gets the top frustum plane transformed by the transform matrix
  19683. * @param transform transformation matrix to be applied to the resulting frustum plane
  19684. * @param frustumPlane the resuling frustum plane
  19685. */
  19686. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19687. /**
  19688. * Gets the bottom frustum plane transformed by the transform matrix
  19689. * @param transform transformation matrix to be applied to the resulting frustum plane
  19690. * @param frustumPlane the resuling frustum plane
  19691. */
  19692. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19693. /**
  19694. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19695. * @param transform transformation matrix to be applied to the resulting frustum planes
  19696. * @param frustumPlanes the resuling frustum planes
  19697. */
  19698. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19699. }
  19700. }
  19701. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19702. import { Camera } from "babylonjs/Cameras/camera";
  19703. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19704. import { Nullable } from "babylonjs/types";
  19705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19706. import { Matrix } from "babylonjs/Maths/math.vector";
  19707. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19708. module "babylonjs/Engines/engine" {
  19709. interface Engine {
  19710. /**
  19711. * Creates a new multiview render target
  19712. * @param width defines the width of the texture
  19713. * @param height defines the height of the texture
  19714. * @returns the created multiview texture
  19715. */
  19716. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19717. /**
  19718. * Binds a multiview framebuffer to be drawn to
  19719. * @param multiviewTexture texture to bind
  19720. */
  19721. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19722. }
  19723. }
  19724. module "babylonjs/Cameras/camera" {
  19725. interface Camera {
  19726. /**
  19727. * @hidden
  19728. * 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)
  19729. */
  19730. _useMultiviewToSingleView: boolean;
  19731. /**
  19732. * @hidden
  19733. * 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)
  19734. */
  19735. _multiviewTexture: Nullable<RenderTargetTexture>;
  19736. /**
  19737. * @hidden
  19738. * ensures the multiview texture of the camera exists and has the specified width/height
  19739. * @param width height to set on the multiview texture
  19740. * @param height width to set on the multiview texture
  19741. */
  19742. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19743. }
  19744. }
  19745. module "babylonjs/scene" {
  19746. interface Scene {
  19747. /** @hidden */
  19748. _transformMatrixR: Matrix;
  19749. /** @hidden */
  19750. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19751. /** @hidden */
  19752. _createMultiviewUbo(): void;
  19753. /** @hidden */
  19754. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19755. /** @hidden */
  19756. _renderMultiviewToSingleView(camera: Camera): void;
  19757. }
  19758. }
  19759. }
  19760. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19761. import { Camera } from "babylonjs/Cameras/camera";
  19762. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19763. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19764. import "babylonjs/Engines/Extensions/engine.multiview";
  19765. /**
  19766. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19767. * This will not be used for webXR as it supports displaying texture arrays directly
  19768. */
  19769. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19770. /**
  19771. * Initializes a VRMultiviewToSingleview
  19772. * @param name name of the post process
  19773. * @param camera camera to be applied to
  19774. * @param scaleFactor scaling factor to the size of the output texture
  19775. */
  19776. constructor(name: string, camera: Camera, scaleFactor: number);
  19777. }
  19778. }
  19779. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19780. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19781. import { Nullable } from "babylonjs/types";
  19782. import { Size } from "babylonjs/Maths/math.size";
  19783. import { Observable } from "babylonjs/Misc/observable";
  19784. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19785. /**
  19786. * Interface used to define additional presentation attributes
  19787. */
  19788. export interface IVRPresentationAttributes {
  19789. /**
  19790. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19791. */
  19792. highRefreshRate: boolean;
  19793. /**
  19794. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19795. */
  19796. foveationLevel: number;
  19797. }
  19798. module "babylonjs/Engines/engine" {
  19799. interface Engine {
  19800. /** @hidden */
  19801. _vrDisplay: any;
  19802. /** @hidden */
  19803. _vrSupported: boolean;
  19804. /** @hidden */
  19805. _oldSize: Size;
  19806. /** @hidden */
  19807. _oldHardwareScaleFactor: number;
  19808. /** @hidden */
  19809. _vrExclusivePointerMode: boolean;
  19810. /** @hidden */
  19811. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19812. /** @hidden */
  19813. _onVRDisplayPointerRestricted: () => void;
  19814. /** @hidden */
  19815. _onVRDisplayPointerUnrestricted: () => void;
  19816. /** @hidden */
  19817. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19818. /** @hidden */
  19819. _onVrDisplayDisconnect: Nullable<() => void>;
  19820. /** @hidden */
  19821. _onVrDisplayPresentChange: Nullable<() => void>;
  19822. /**
  19823. * Observable signaled when VR display mode changes
  19824. */
  19825. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19826. /**
  19827. * Observable signaled when VR request present is complete
  19828. */
  19829. onVRRequestPresentComplete: Observable<boolean>;
  19830. /**
  19831. * Observable signaled when VR request present starts
  19832. */
  19833. onVRRequestPresentStart: Observable<Engine>;
  19834. /**
  19835. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19836. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19837. */
  19838. isInVRExclusivePointerMode: boolean;
  19839. /**
  19840. * Gets a boolean indicating if a webVR device was detected
  19841. * @returns true if a webVR device was detected
  19842. */
  19843. isVRDevicePresent(): boolean;
  19844. /**
  19845. * Gets the current webVR device
  19846. * @returns the current webVR device (or null)
  19847. */
  19848. getVRDevice(): any;
  19849. /**
  19850. * Initializes a webVR display and starts listening to display change events
  19851. * The onVRDisplayChangedObservable will be notified upon these changes
  19852. * @returns A promise containing a VRDisplay and if vr is supported
  19853. */
  19854. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19855. /** @hidden */
  19856. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19857. /**
  19858. * Gets or sets the presentation attributes used to configure VR rendering
  19859. */
  19860. vrPresentationAttributes?: IVRPresentationAttributes;
  19861. /**
  19862. * Call this function to switch to webVR mode
  19863. * Will do nothing if webVR is not supported or if there is no webVR device
  19864. * @param options the webvr options provided to the camera. mainly used for multiview
  19865. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19866. */
  19867. enableVR(options: WebVROptions): void;
  19868. /** @hidden */
  19869. _onVRFullScreenTriggered(): void;
  19870. }
  19871. }
  19872. }
  19873. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Observable } from "babylonjs/Misc/observable";
  19876. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19877. import { Scene } from "babylonjs/scene";
  19878. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19879. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19880. import { Node } from "babylonjs/node";
  19881. import { Ray } from "babylonjs/Culling/ray";
  19882. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19883. import "babylonjs/Engines/Extensions/engine.webVR";
  19884. /**
  19885. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19886. * IMPORTANT!! The data is right-hand data.
  19887. * @export
  19888. * @interface DevicePose
  19889. */
  19890. export interface DevicePose {
  19891. /**
  19892. * The position of the device, values in array are [x,y,z].
  19893. */
  19894. readonly position: Nullable<Float32Array>;
  19895. /**
  19896. * The linearVelocity of the device, values in array are [x,y,z].
  19897. */
  19898. readonly linearVelocity: Nullable<Float32Array>;
  19899. /**
  19900. * The linearAcceleration of the device, values in array are [x,y,z].
  19901. */
  19902. readonly linearAcceleration: Nullable<Float32Array>;
  19903. /**
  19904. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19905. */
  19906. readonly orientation: Nullable<Float32Array>;
  19907. /**
  19908. * The angularVelocity of the device, values in array are [x,y,z].
  19909. */
  19910. readonly angularVelocity: Nullable<Float32Array>;
  19911. /**
  19912. * The angularAcceleration of the device, values in array are [x,y,z].
  19913. */
  19914. readonly angularAcceleration: Nullable<Float32Array>;
  19915. }
  19916. /**
  19917. * Interface representing a pose controlled object in Babylon.
  19918. * A pose controlled object has both regular pose values as well as pose values
  19919. * from an external device such as a VR head mounted display
  19920. */
  19921. export interface PoseControlled {
  19922. /**
  19923. * The position of the object in babylon space.
  19924. */
  19925. position: Vector3;
  19926. /**
  19927. * The rotation quaternion of the object in babylon space.
  19928. */
  19929. rotationQuaternion: Quaternion;
  19930. /**
  19931. * The position of the device in babylon space.
  19932. */
  19933. devicePosition?: Vector3;
  19934. /**
  19935. * The rotation quaternion of the device in babylon space.
  19936. */
  19937. deviceRotationQuaternion: Quaternion;
  19938. /**
  19939. * The raw pose coming from the device.
  19940. */
  19941. rawPose: Nullable<DevicePose>;
  19942. /**
  19943. * The scale of the device to be used when translating from device space to babylon space.
  19944. */
  19945. deviceScaleFactor: number;
  19946. /**
  19947. * Updates the poseControlled values based on the input device pose.
  19948. * @param poseData the pose data to update the object with
  19949. */
  19950. updateFromDevice(poseData: DevicePose): void;
  19951. }
  19952. /**
  19953. * Set of options to customize the webVRCamera
  19954. */
  19955. export interface WebVROptions {
  19956. /**
  19957. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19958. */
  19959. trackPosition?: boolean;
  19960. /**
  19961. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19962. */
  19963. positionScale?: number;
  19964. /**
  19965. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19966. */
  19967. displayName?: string;
  19968. /**
  19969. * Should the native controller meshes be initialized. (default: true)
  19970. */
  19971. controllerMeshes?: boolean;
  19972. /**
  19973. * Creating a default HemiLight only on controllers. (default: true)
  19974. */
  19975. defaultLightingOnControllers?: boolean;
  19976. /**
  19977. * If you don't want to use the default VR button of the helper. (default: false)
  19978. */
  19979. useCustomVRButton?: boolean;
  19980. /**
  19981. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19982. */
  19983. customVRButton?: HTMLButtonElement;
  19984. /**
  19985. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19986. */
  19987. rayLength?: number;
  19988. /**
  19989. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19990. */
  19991. defaultHeight?: number;
  19992. /**
  19993. * If multiview should be used if availible (default: false)
  19994. */
  19995. useMultiview?: boolean;
  19996. }
  19997. /**
  19998. * This represents a WebVR camera.
  19999. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20000. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20001. */
  20002. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20003. private webVROptions;
  20004. /**
  20005. * @hidden
  20006. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20007. */
  20008. _vrDevice: any;
  20009. /**
  20010. * The rawPose of the vrDevice.
  20011. */
  20012. rawPose: Nullable<DevicePose>;
  20013. private _onVREnabled;
  20014. private _specsVersion;
  20015. private _attached;
  20016. private _frameData;
  20017. protected _descendants: Array<Node>;
  20018. private _deviceRoomPosition;
  20019. /** @hidden */
  20020. _deviceRoomRotationQuaternion: Quaternion;
  20021. private _standingMatrix;
  20022. /**
  20023. * Represents device position in babylon space.
  20024. */
  20025. devicePosition: Vector3;
  20026. /**
  20027. * Represents device rotation in babylon space.
  20028. */
  20029. deviceRotationQuaternion: Quaternion;
  20030. /**
  20031. * The scale of the device to be used when translating from device space to babylon space.
  20032. */
  20033. deviceScaleFactor: number;
  20034. private _deviceToWorld;
  20035. private _worldToDevice;
  20036. /**
  20037. * References to the webVR controllers for the vrDevice.
  20038. */
  20039. controllers: Array<WebVRController>;
  20040. /**
  20041. * Emits an event when a controller is attached.
  20042. */
  20043. onControllersAttachedObservable: Observable<WebVRController[]>;
  20044. /**
  20045. * Emits an event when a controller's mesh has been loaded;
  20046. */
  20047. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20048. /**
  20049. * Emits an event when the HMD's pose has been updated.
  20050. */
  20051. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20052. private _poseSet;
  20053. /**
  20054. * If the rig cameras be used as parent instead of this camera.
  20055. */
  20056. rigParenting: boolean;
  20057. private _lightOnControllers;
  20058. private _defaultHeight?;
  20059. /**
  20060. * Instantiates a WebVRFreeCamera.
  20061. * @param name The name of the WebVRFreeCamera
  20062. * @param position The starting anchor position for the camera
  20063. * @param scene The scene the camera belongs to
  20064. * @param webVROptions a set of customizable options for the webVRCamera
  20065. */
  20066. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20067. /**
  20068. * Gets the device distance from the ground in meters.
  20069. * @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.
  20070. */
  20071. deviceDistanceToRoomGround(): number;
  20072. /**
  20073. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20074. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20075. */
  20076. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20077. /**
  20078. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20079. * @returns A promise with a boolean set to if the standing matrix is supported.
  20080. */
  20081. useStandingMatrixAsync(): Promise<boolean>;
  20082. /**
  20083. * Disposes the camera
  20084. */
  20085. dispose(): void;
  20086. /**
  20087. * Gets a vrController by name.
  20088. * @param name The name of the controller to retreive
  20089. * @returns the controller matching the name specified or null if not found
  20090. */
  20091. getControllerByName(name: string): Nullable<WebVRController>;
  20092. private _leftController;
  20093. /**
  20094. * The controller corresponding to the users left hand.
  20095. */
  20096. get leftController(): Nullable<WebVRController>;
  20097. private _rightController;
  20098. /**
  20099. * The controller corresponding to the users right hand.
  20100. */
  20101. get rightController(): Nullable<WebVRController>;
  20102. /**
  20103. * Casts a ray forward from the vrCamera's gaze.
  20104. * @param length Length of the ray (default: 100)
  20105. * @returns the ray corresponding to the gaze
  20106. */
  20107. getForwardRay(length?: number): Ray;
  20108. /**
  20109. * @hidden
  20110. * Updates the camera based on device's frame data
  20111. */
  20112. _checkInputs(): void;
  20113. /**
  20114. * Updates the poseControlled values based on the input device pose.
  20115. * @param poseData Pose coming from the device
  20116. */
  20117. updateFromDevice(poseData: DevicePose): void;
  20118. private _htmlElementAttached;
  20119. private _detachIfAttached;
  20120. /**
  20121. * WebVR's attach control will start broadcasting frames to the device.
  20122. * Note that in certain browsers (chrome for example) this function must be called
  20123. * within a user-interaction callback. Example:
  20124. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20125. *
  20126. * @param element html element to attach the vrDevice to
  20127. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20128. */
  20129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20130. /**
  20131. * Detaches the camera from the html element and disables VR
  20132. *
  20133. * @param element html element to detach from
  20134. */
  20135. detachControl(element: HTMLElement): void;
  20136. /**
  20137. * @returns the name of this class
  20138. */
  20139. getClassName(): string;
  20140. /**
  20141. * Calls resetPose on the vrDisplay
  20142. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20143. */
  20144. resetToCurrentRotation(): void;
  20145. /**
  20146. * @hidden
  20147. * Updates the rig cameras (left and right eye)
  20148. */
  20149. _updateRigCameras(): void;
  20150. private _workingVector;
  20151. private _oneVector;
  20152. private _workingMatrix;
  20153. private updateCacheCalled;
  20154. private _correctPositionIfNotTrackPosition;
  20155. /**
  20156. * @hidden
  20157. * Updates the cached values of the camera
  20158. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20159. */
  20160. _updateCache(ignoreParentClass?: boolean): void;
  20161. /**
  20162. * @hidden
  20163. * Get current device position in babylon world
  20164. */
  20165. _computeDevicePosition(): void;
  20166. /**
  20167. * Updates the current device position and rotation in the babylon world
  20168. */
  20169. update(): void;
  20170. /**
  20171. * @hidden
  20172. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20173. * @returns an identity matrix
  20174. */
  20175. _getViewMatrix(): Matrix;
  20176. private _tmpMatrix;
  20177. /**
  20178. * This function is called by the two RIG cameras.
  20179. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20180. * @hidden
  20181. */
  20182. _getWebVRViewMatrix(): Matrix;
  20183. /** @hidden */
  20184. _getWebVRProjectionMatrix(): Matrix;
  20185. private _onGamepadConnectedObserver;
  20186. private _onGamepadDisconnectedObserver;
  20187. private _updateCacheWhenTrackingDisabledObserver;
  20188. /**
  20189. * Initializes the controllers and their meshes
  20190. */
  20191. initControllers(): void;
  20192. }
  20193. }
  20194. declare module "babylonjs/PostProcesses/postProcess" {
  20195. import { Nullable } from "babylonjs/types";
  20196. import { SmartArray } from "babylonjs/Misc/smartArray";
  20197. import { Observable } from "babylonjs/Misc/observable";
  20198. import { Vector2 } from "babylonjs/Maths/math.vector";
  20199. import { Camera } from "babylonjs/Cameras/camera";
  20200. import { Effect } from "babylonjs/Materials/effect";
  20201. import "babylonjs/Shaders/postprocess.vertex";
  20202. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20203. import { Engine } from "babylonjs/Engines/engine";
  20204. import { Color4 } from "babylonjs/Maths/math.color";
  20205. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20207. /**
  20208. * Size options for a post process
  20209. */
  20210. export type PostProcessOptions = {
  20211. width: number;
  20212. height: number;
  20213. };
  20214. /**
  20215. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20217. */
  20218. export class PostProcess {
  20219. /** Name of the PostProcess. */
  20220. name: string;
  20221. /**
  20222. * Gets or sets the unique id of the post process
  20223. */
  20224. uniqueId: number;
  20225. /**
  20226. * Width of the texture to apply the post process on
  20227. */
  20228. width: number;
  20229. /**
  20230. * Height of the texture to apply the post process on
  20231. */
  20232. height: number;
  20233. /**
  20234. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20235. * @hidden
  20236. */
  20237. _outputTexture: Nullable<InternalTexture>;
  20238. /**
  20239. * Sampling mode used by the shader
  20240. * See https://doc.babylonjs.com/classes/3.1/texture
  20241. */
  20242. renderTargetSamplingMode: number;
  20243. /**
  20244. * Clear color to use when screen clearing
  20245. */
  20246. clearColor: Color4;
  20247. /**
  20248. * If the buffer needs to be cleared before applying the post process. (default: true)
  20249. * Should be set to false if shader will overwrite all previous pixels.
  20250. */
  20251. autoClear: boolean;
  20252. /**
  20253. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20254. */
  20255. alphaMode: number;
  20256. /**
  20257. * Sets the setAlphaBlendConstants of the babylon engine
  20258. */
  20259. alphaConstants: Color4;
  20260. /**
  20261. * Animations to be used for the post processing
  20262. */
  20263. animations: import("babylonjs/Animations/animation").Animation[];
  20264. /**
  20265. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20266. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20267. */
  20268. enablePixelPerfectMode: boolean;
  20269. /**
  20270. * Force the postprocess to be applied without taking in account viewport
  20271. */
  20272. forceFullscreenViewport: boolean;
  20273. /**
  20274. * List of inspectable custom properties (used by the Inspector)
  20275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20276. */
  20277. inspectableCustomProperties: IInspectable[];
  20278. /**
  20279. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20280. *
  20281. * | Value | Type | Description |
  20282. * | ----- | ----------------------------------- | ----------- |
  20283. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20284. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20285. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20286. *
  20287. */
  20288. scaleMode: number;
  20289. /**
  20290. * Force textures to be a power of two (default: false)
  20291. */
  20292. alwaysForcePOT: boolean;
  20293. private _samples;
  20294. /**
  20295. * Number of sample textures (default: 1)
  20296. */
  20297. get samples(): number;
  20298. set samples(n: number);
  20299. /**
  20300. * Modify the scale of the post process to be the same as the viewport (default: false)
  20301. */
  20302. adaptScaleToCurrentViewport: boolean;
  20303. private _camera;
  20304. private _scene;
  20305. private _engine;
  20306. private _options;
  20307. private _reusable;
  20308. private _textureType;
  20309. private _textureFormat;
  20310. /**
  20311. * Smart array of input and output textures for the post process.
  20312. * @hidden
  20313. */
  20314. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20315. /**
  20316. * The index in _textures that corresponds to the output texture.
  20317. * @hidden
  20318. */
  20319. _currentRenderTextureInd: number;
  20320. private _effect;
  20321. private _samplers;
  20322. private _fragmentUrl;
  20323. private _vertexUrl;
  20324. private _parameters;
  20325. private _scaleRatio;
  20326. protected _indexParameters: any;
  20327. private _shareOutputWithPostProcess;
  20328. private _texelSize;
  20329. private _forcedOutputTexture;
  20330. /**
  20331. * Returns the fragment url or shader name used in the post process.
  20332. * @returns the fragment url or name in the shader store.
  20333. */
  20334. getEffectName(): string;
  20335. /**
  20336. * An event triggered when the postprocess is activated.
  20337. */
  20338. onActivateObservable: Observable<Camera>;
  20339. private _onActivateObserver;
  20340. /**
  20341. * A function that is added to the onActivateObservable
  20342. */
  20343. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20344. /**
  20345. * An event triggered when the postprocess changes its size.
  20346. */
  20347. onSizeChangedObservable: Observable<PostProcess>;
  20348. private _onSizeChangedObserver;
  20349. /**
  20350. * A function that is added to the onSizeChangedObservable
  20351. */
  20352. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20353. /**
  20354. * An event triggered when the postprocess applies its effect.
  20355. */
  20356. onApplyObservable: Observable<Effect>;
  20357. private _onApplyObserver;
  20358. /**
  20359. * A function that is added to the onApplyObservable
  20360. */
  20361. set onApply(callback: (effect: Effect) => void);
  20362. /**
  20363. * An event triggered before rendering the postprocess
  20364. */
  20365. onBeforeRenderObservable: Observable<Effect>;
  20366. private _onBeforeRenderObserver;
  20367. /**
  20368. * A function that is added to the onBeforeRenderObservable
  20369. */
  20370. set onBeforeRender(callback: (effect: Effect) => void);
  20371. /**
  20372. * An event triggered after rendering the postprocess
  20373. */
  20374. onAfterRenderObservable: Observable<Effect>;
  20375. private _onAfterRenderObserver;
  20376. /**
  20377. * A function that is added to the onAfterRenderObservable
  20378. */
  20379. set onAfterRender(callback: (efect: Effect) => void);
  20380. /**
  20381. * 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
  20382. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20383. */
  20384. get inputTexture(): InternalTexture;
  20385. set inputTexture(value: InternalTexture);
  20386. /**
  20387. * Gets the camera which post process is applied to.
  20388. * @returns The camera the post process is applied to.
  20389. */
  20390. getCamera(): Camera;
  20391. /**
  20392. * Gets the texel size of the postprocess.
  20393. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20394. */
  20395. get texelSize(): Vector2;
  20396. /**
  20397. * Creates a new instance PostProcess
  20398. * @param name The name of the PostProcess.
  20399. * @param fragmentUrl The url of the fragment shader to be used.
  20400. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20401. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20402. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20403. * @param camera The camera to apply the render pass to.
  20404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20405. * @param engine The engine which the post process will be applied. (default: current engine)
  20406. * @param reusable If the post process can be reused on the same frame. (default: false)
  20407. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20408. * @param textureType Type of textures used when performing the post process. (default: 0)
  20409. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20410. * @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
  20411. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20412. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20413. */
  20414. constructor(
  20415. /** Name of the PostProcess. */
  20416. 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);
  20417. /**
  20418. * Gets a string idenfifying the name of the class
  20419. * @returns "PostProcess" string
  20420. */
  20421. getClassName(): string;
  20422. /**
  20423. * Gets the engine which this post process belongs to.
  20424. * @returns The engine the post process was enabled with.
  20425. */
  20426. getEngine(): Engine;
  20427. /**
  20428. * The effect that is created when initializing the post process.
  20429. * @returns The created effect corresponding the the postprocess.
  20430. */
  20431. getEffect(): Effect;
  20432. /**
  20433. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20434. * @param postProcess The post process to share the output with.
  20435. * @returns This post process.
  20436. */
  20437. shareOutputWith(postProcess: PostProcess): PostProcess;
  20438. /**
  20439. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20440. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20441. */
  20442. useOwnOutput(): void;
  20443. /**
  20444. * Updates the effect with the current post process compile time values and recompiles the shader.
  20445. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20446. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20447. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20448. * @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
  20449. * @param onCompiled Called when the shader has been compiled.
  20450. * @param onError Called if there is an error when compiling a shader.
  20451. */
  20452. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20453. /**
  20454. * The post process is reusable if it can be used multiple times within one frame.
  20455. * @returns If the post process is reusable
  20456. */
  20457. isReusable(): boolean;
  20458. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20459. markTextureDirty(): void;
  20460. /**
  20461. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20462. * 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.
  20463. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20464. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20465. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20466. * @returns The target texture that was bound to be written to.
  20467. */
  20468. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20469. /**
  20470. * If the post process is supported.
  20471. */
  20472. get isSupported(): boolean;
  20473. /**
  20474. * The aspect ratio of the output texture.
  20475. */
  20476. get aspectRatio(): number;
  20477. /**
  20478. * Get a value indicating if the post-process is ready to be used
  20479. * @returns true if the post-process is ready (shader is compiled)
  20480. */
  20481. isReady(): boolean;
  20482. /**
  20483. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20484. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20485. */
  20486. apply(): Nullable<Effect>;
  20487. private _disposeTextures;
  20488. /**
  20489. * Disposes the post process.
  20490. * @param camera The camera to dispose the post process on.
  20491. */
  20492. dispose(camera?: Camera): void;
  20493. }
  20494. }
  20495. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20496. /** @hidden */
  20497. export var kernelBlurVaryingDeclaration: {
  20498. name: string;
  20499. shader: string;
  20500. };
  20501. }
  20502. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20503. /** @hidden */
  20504. export var kernelBlurFragment: {
  20505. name: string;
  20506. shader: string;
  20507. };
  20508. }
  20509. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20510. /** @hidden */
  20511. export var kernelBlurFragment2: {
  20512. name: string;
  20513. shader: string;
  20514. };
  20515. }
  20516. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20517. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20518. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20519. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20520. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20521. /** @hidden */
  20522. export var kernelBlurPixelShader: {
  20523. name: string;
  20524. shader: string;
  20525. };
  20526. }
  20527. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20528. /** @hidden */
  20529. export var kernelBlurVertex: {
  20530. name: string;
  20531. shader: string;
  20532. };
  20533. }
  20534. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20535. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20536. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20537. /** @hidden */
  20538. export var kernelBlurVertexShader: {
  20539. name: string;
  20540. shader: string;
  20541. };
  20542. }
  20543. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20544. import { Vector2 } from "babylonjs/Maths/math.vector";
  20545. import { Nullable } from "babylonjs/types";
  20546. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20547. import { Camera } from "babylonjs/Cameras/camera";
  20548. import { Effect } from "babylonjs/Materials/effect";
  20549. import { Engine } from "babylonjs/Engines/engine";
  20550. import "babylonjs/Shaders/kernelBlur.fragment";
  20551. import "babylonjs/Shaders/kernelBlur.vertex";
  20552. /**
  20553. * The Blur Post Process which blurs an image based on a kernel and direction.
  20554. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20555. */
  20556. export class BlurPostProcess extends PostProcess {
  20557. /** The direction in which to blur the image. */
  20558. direction: Vector2;
  20559. private blockCompilation;
  20560. protected _kernel: number;
  20561. protected _idealKernel: number;
  20562. protected _packedFloat: boolean;
  20563. private _staticDefines;
  20564. /**
  20565. * Sets the length in pixels of the blur sample region
  20566. */
  20567. set kernel(v: number);
  20568. /**
  20569. * Gets the length in pixels of the blur sample region
  20570. */
  20571. get kernel(): number;
  20572. /**
  20573. * Sets wether or not the blur needs to unpack/repack floats
  20574. */
  20575. set packedFloat(v: boolean);
  20576. /**
  20577. * Gets wether or not the blur is unpacking/repacking floats
  20578. */
  20579. get packedFloat(): boolean;
  20580. /**
  20581. * Creates a new instance BlurPostProcess
  20582. * @param name The name of the effect.
  20583. * @param direction The direction in which to blur the image.
  20584. * @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.
  20585. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20586. * @param camera The camera to apply the render pass to.
  20587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20588. * @param engine The engine which the post process will be applied. (default: current engine)
  20589. * @param reusable If the post process can be reused on the same frame. (default: false)
  20590. * @param textureType Type of textures used when performing the post process. (default: 0)
  20591. * @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)
  20592. */
  20593. constructor(name: string,
  20594. /** The direction in which to blur the image. */
  20595. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20596. /**
  20597. * Updates the effect with the current post process compile time values and recompiles the shader.
  20598. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20599. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20600. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20601. * @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
  20602. * @param onCompiled Called when the shader has been compiled.
  20603. * @param onError Called if there is an error when compiling a shader.
  20604. */
  20605. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20606. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20607. /**
  20608. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20609. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20610. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20611. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20612. * The gaps between physical kernels are compensated for in the weighting of the samples
  20613. * @param idealKernel Ideal blur kernel.
  20614. * @return Nearest best kernel.
  20615. */
  20616. protected _nearestBestKernel(idealKernel: number): number;
  20617. /**
  20618. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20619. * @param x The point on the Gaussian distribution to sample.
  20620. * @return the value of the Gaussian function at x.
  20621. */
  20622. protected _gaussianWeight(x: number): number;
  20623. /**
  20624. * Generates a string that can be used as a floating point number in GLSL.
  20625. * @param x Value to print.
  20626. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20627. * @return GLSL float string.
  20628. */
  20629. protected _glslFloat(x: number, decimalFigures?: number): string;
  20630. }
  20631. }
  20632. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20633. import { Scene } from "babylonjs/scene";
  20634. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20635. import { Plane } from "babylonjs/Maths/math.plane";
  20636. /**
  20637. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20638. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20639. * You can then easily use it as a reflectionTexture on a flat surface.
  20640. * In case the surface is not a plane, please consider relying on reflection probes.
  20641. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20642. */
  20643. export class MirrorTexture extends RenderTargetTexture {
  20644. private scene;
  20645. /**
  20646. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20647. * 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.
  20648. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20649. */
  20650. mirrorPlane: Plane;
  20651. /**
  20652. * Define the blur ratio used to blur the reflection if needed.
  20653. */
  20654. set blurRatio(value: number);
  20655. get blurRatio(): number;
  20656. /**
  20657. * Define the adaptive blur kernel used to blur the reflection if needed.
  20658. * This will autocompute the closest best match for the `blurKernel`
  20659. */
  20660. set adaptiveBlurKernel(value: number);
  20661. /**
  20662. * Define the blur kernel used to blur the reflection if needed.
  20663. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20664. */
  20665. set blurKernel(value: number);
  20666. /**
  20667. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20668. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20669. */
  20670. set blurKernelX(value: number);
  20671. get blurKernelX(): number;
  20672. /**
  20673. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20674. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20675. */
  20676. set blurKernelY(value: number);
  20677. get blurKernelY(): number;
  20678. private _autoComputeBlurKernel;
  20679. protected _onRatioRescale(): void;
  20680. private _updateGammaSpace;
  20681. private _imageProcessingConfigChangeObserver;
  20682. private _transformMatrix;
  20683. private _mirrorMatrix;
  20684. private _savedViewMatrix;
  20685. private _blurX;
  20686. private _blurY;
  20687. private _adaptiveBlurKernel;
  20688. private _blurKernelX;
  20689. private _blurKernelY;
  20690. private _blurRatio;
  20691. /**
  20692. * Instantiates a Mirror Texture.
  20693. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20694. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20695. * You can then easily use it as a reflectionTexture on a flat surface.
  20696. * In case the surface is not a plane, please consider relying on reflection probes.
  20697. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20698. * @param name
  20699. * @param size
  20700. * @param scene
  20701. * @param generateMipMaps
  20702. * @param type
  20703. * @param samplingMode
  20704. * @param generateDepthBuffer
  20705. */
  20706. constructor(name: string, size: number | {
  20707. width: number;
  20708. height: number;
  20709. } | {
  20710. ratio: number;
  20711. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20712. private _preparePostProcesses;
  20713. /**
  20714. * Clone the mirror texture.
  20715. * @returns the cloned texture
  20716. */
  20717. clone(): MirrorTexture;
  20718. /**
  20719. * Serialize the texture to a JSON representation you could use in Parse later on
  20720. * @returns the serialized JSON representation
  20721. */
  20722. serialize(): any;
  20723. /**
  20724. * Dispose the texture and release its associated resources.
  20725. */
  20726. dispose(): void;
  20727. }
  20728. }
  20729. declare module "babylonjs/Materials/Textures/texture" {
  20730. import { Observable } from "babylonjs/Misc/observable";
  20731. import { Nullable } from "babylonjs/types";
  20732. import { Matrix } from "babylonjs/Maths/math.vector";
  20733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20734. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20735. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20736. import { Scene } from "babylonjs/scene";
  20737. /**
  20738. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20739. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20740. */
  20741. export class Texture extends BaseTexture {
  20742. /**
  20743. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20744. */
  20745. static SerializeBuffers: boolean;
  20746. /** @hidden */
  20747. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20748. /** @hidden */
  20749. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20750. /** @hidden */
  20751. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20752. /** nearest is mag = nearest and min = nearest and mip = linear */
  20753. static readonly NEAREST_SAMPLINGMODE: number;
  20754. /** nearest is mag = nearest and min = nearest and mip = linear */
  20755. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20757. static readonly BILINEAR_SAMPLINGMODE: number;
  20758. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20759. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20760. /** Trilinear is mag = linear and min = linear and mip = linear */
  20761. static readonly TRILINEAR_SAMPLINGMODE: number;
  20762. /** Trilinear is mag = linear and min = linear and mip = linear */
  20763. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20764. /** mag = nearest and min = nearest and mip = nearest */
  20765. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20766. /** mag = nearest and min = linear and mip = nearest */
  20767. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20768. /** mag = nearest and min = linear and mip = linear */
  20769. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20770. /** mag = nearest and min = linear and mip = none */
  20771. static readonly NEAREST_LINEAR: number;
  20772. /** mag = nearest and min = nearest and mip = none */
  20773. static readonly NEAREST_NEAREST: number;
  20774. /** mag = linear and min = nearest and mip = nearest */
  20775. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20776. /** mag = linear and min = nearest and mip = linear */
  20777. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20778. /** mag = linear and min = linear and mip = none */
  20779. static readonly LINEAR_LINEAR: number;
  20780. /** mag = linear and min = nearest and mip = none */
  20781. static readonly LINEAR_NEAREST: number;
  20782. /** Explicit coordinates mode */
  20783. static readonly EXPLICIT_MODE: number;
  20784. /** Spherical coordinates mode */
  20785. static readonly SPHERICAL_MODE: number;
  20786. /** Planar coordinates mode */
  20787. static readonly PLANAR_MODE: number;
  20788. /** Cubic coordinates mode */
  20789. static readonly CUBIC_MODE: number;
  20790. /** Projection coordinates mode */
  20791. static readonly PROJECTION_MODE: number;
  20792. /** Inverse Cubic coordinates mode */
  20793. static readonly SKYBOX_MODE: number;
  20794. /** Inverse Cubic coordinates mode */
  20795. static readonly INVCUBIC_MODE: number;
  20796. /** Equirectangular coordinates mode */
  20797. static readonly EQUIRECTANGULAR_MODE: number;
  20798. /** Equirectangular Fixed coordinates mode */
  20799. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20800. /** Equirectangular Fixed Mirrored coordinates mode */
  20801. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20802. /** Texture is not repeating outside of 0..1 UVs */
  20803. static readonly CLAMP_ADDRESSMODE: number;
  20804. /** Texture is repeating outside of 0..1 UVs */
  20805. static readonly WRAP_ADDRESSMODE: number;
  20806. /** Texture is repeating and mirrored */
  20807. static readonly MIRROR_ADDRESSMODE: number;
  20808. /**
  20809. * 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
  20810. */
  20811. static UseSerializedUrlIfAny: boolean;
  20812. /**
  20813. * Define the url of the texture.
  20814. */
  20815. url: Nullable<string>;
  20816. /**
  20817. * Define an offset on the texture to offset the u coordinates of the UVs
  20818. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20819. */
  20820. uOffset: number;
  20821. /**
  20822. * Define an offset on the texture to offset the v coordinates of the UVs
  20823. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20824. */
  20825. vOffset: number;
  20826. /**
  20827. * Define an offset on the texture to scale the u coordinates of the UVs
  20828. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20829. */
  20830. uScale: number;
  20831. /**
  20832. * Define an offset on the texture to scale the v coordinates of the UVs
  20833. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20834. */
  20835. vScale: number;
  20836. /**
  20837. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20838. * @see http://doc.babylonjs.com/how_to/more_materials
  20839. */
  20840. uAng: number;
  20841. /**
  20842. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20843. * @see http://doc.babylonjs.com/how_to/more_materials
  20844. */
  20845. vAng: number;
  20846. /**
  20847. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20848. * @see http://doc.babylonjs.com/how_to/more_materials
  20849. */
  20850. wAng: number;
  20851. /**
  20852. * Defines the center of rotation (U)
  20853. */
  20854. uRotationCenter: number;
  20855. /**
  20856. * Defines the center of rotation (V)
  20857. */
  20858. vRotationCenter: number;
  20859. /**
  20860. * Defines the center of rotation (W)
  20861. */
  20862. wRotationCenter: number;
  20863. /**
  20864. * Are mip maps generated for this texture or not.
  20865. */
  20866. get noMipmap(): boolean;
  20867. /**
  20868. * List of inspectable custom properties (used by the Inspector)
  20869. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20870. */
  20871. inspectableCustomProperties: Nullable<IInspectable[]>;
  20872. private _noMipmap;
  20873. /** @hidden */
  20874. _invertY: boolean;
  20875. private _rowGenerationMatrix;
  20876. private _cachedTextureMatrix;
  20877. private _projectionModeMatrix;
  20878. private _t0;
  20879. private _t1;
  20880. private _t2;
  20881. private _cachedUOffset;
  20882. private _cachedVOffset;
  20883. private _cachedUScale;
  20884. private _cachedVScale;
  20885. private _cachedUAng;
  20886. private _cachedVAng;
  20887. private _cachedWAng;
  20888. private _cachedProjectionMatrixId;
  20889. private _cachedCoordinatesMode;
  20890. /** @hidden */
  20891. protected _initialSamplingMode: number;
  20892. /** @hidden */
  20893. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20894. private _deleteBuffer;
  20895. protected _format: Nullable<number>;
  20896. private _delayedOnLoad;
  20897. private _delayedOnError;
  20898. private _mimeType?;
  20899. /**
  20900. * Observable triggered once the texture has been loaded.
  20901. */
  20902. onLoadObservable: Observable<Texture>;
  20903. protected _isBlocking: boolean;
  20904. /**
  20905. * Is the texture preventing material to render while loading.
  20906. * If false, a default texture will be used instead of the loading one during the preparation step.
  20907. */
  20908. set isBlocking(value: boolean);
  20909. get isBlocking(): boolean;
  20910. /**
  20911. * Get the current sampling mode associated with the texture.
  20912. */
  20913. get samplingMode(): number;
  20914. /**
  20915. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20916. */
  20917. get invertY(): boolean;
  20918. /**
  20919. * Instantiates a new texture.
  20920. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20921. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20922. * @param url defines the url of the picture to load as a texture
  20923. * @param scene defines the scene or engine the texture will belong to
  20924. * @param noMipmap defines if the texture will require mip maps or not
  20925. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20926. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20927. * @param onLoad defines a callback triggered when the texture has been loaded
  20928. * @param onError defines a callback triggered when an error occurred during the loading session
  20929. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20930. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20931. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20932. * @param mimeType defines an optional mime type information
  20933. */
  20934. 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);
  20935. /**
  20936. * Update the url (and optional buffer) of this texture if url was null during construction.
  20937. * @param url the url of the texture
  20938. * @param buffer the buffer of the texture (defaults to null)
  20939. * @param onLoad callback called when the texture is loaded (defaults to null)
  20940. */
  20941. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20942. /**
  20943. * Finish the loading sequence of a texture flagged as delayed load.
  20944. * @hidden
  20945. */
  20946. delayLoad(): void;
  20947. private _prepareRowForTextureGeneration;
  20948. /**
  20949. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20950. * @returns the transform matrix of the texture.
  20951. */
  20952. getTextureMatrix(uBase?: number): Matrix;
  20953. /**
  20954. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20955. * @returns The reflection texture transform
  20956. */
  20957. getReflectionTextureMatrix(): Matrix;
  20958. /**
  20959. * Clones the texture.
  20960. * @returns the cloned texture
  20961. */
  20962. clone(): Texture;
  20963. /**
  20964. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20965. * @returns The JSON representation of the texture
  20966. */
  20967. serialize(): any;
  20968. /**
  20969. * Get the current class name of the texture useful for serialization or dynamic coding.
  20970. * @returns "Texture"
  20971. */
  20972. getClassName(): string;
  20973. /**
  20974. * Dispose the texture and release its associated resources.
  20975. */
  20976. dispose(): void;
  20977. /**
  20978. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20979. * @param parsedTexture Define the JSON representation of the texture
  20980. * @param scene Define the scene the parsed texture should be instantiated in
  20981. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20982. * @returns The parsed texture if successful
  20983. */
  20984. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20985. /**
  20986. * Creates a texture from its base 64 representation.
  20987. * @param data Define the base64 payload without the data: prefix
  20988. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20989. * @param scene Define the scene the texture should belong to
  20990. * @param noMipmap Forces the texture to not create mip map information if true
  20991. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20992. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20993. * @param onLoad define a callback triggered when the texture has been loaded
  20994. * @param onError define a callback triggered when an error occurred during the loading session
  20995. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20996. * @returns the created texture
  20997. */
  20998. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20999. /**
  21000. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21001. * @param data Define the base64 payload without the data: prefix
  21002. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21003. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21004. * @param scene Define the scene the texture should belong to
  21005. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21006. * @param noMipmap Forces the texture to not create mip map information if true
  21007. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21008. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21009. * @param onLoad define a callback triggered when the texture has been loaded
  21010. * @param onError define a callback triggered when an error occurred during the loading session
  21011. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21012. * @returns the created texture
  21013. */
  21014. 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;
  21015. }
  21016. }
  21017. declare module "babylonjs/PostProcesses/postProcessManager" {
  21018. import { Nullable } from "babylonjs/types";
  21019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21020. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21021. import { Scene } from "babylonjs/scene";
  21022. /**
  21023. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21024. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21025. */
  21026. export class PostProcessManager {
  21027. private _scene;
  21028. private _indexBuffer;
  21029. private _vertexBuffers;
  21030. /**
  21031. * Creates a new instance PostProcess
  21032. * @param scene The scene that the post process is associated with.
  21033. */
  21034. constructor(scene: Scene);
  21035. private _prepareBuffers;
  21036. private _buildIndexBuffer;
  21037. /**
  21038. * Rebuilds the vertex buffers of the manager.
  21039. * @hidden
  21040. */
  21041. _rebuild(): void;
  21042. /**
  21043. * Prepares a frame to be run through a post process.
  21044. * @param sourceTexture The input texture to the post procesess. (default: null)
  21045. * @param postProcesses An array of post processes to be run. (default: null)
  21046. * @returns True if the post processes were able to be run.
  21047. * @hidden
  21048. */
  21049. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21050. /**
  21051. * Manually render a set of post processes to a texture.
  21052. * @param postProcesses An array of post processes to be run.
  21053. * @param targetTexture The target texture to render to.
  21054. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21055. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21056. * @param lodLevel defines which lod of the texture to render to
  21057. */
  21058. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21059. /**
  21060. * Finalize the result of the output of the postprocesses.
  21061. * @param doNotPresent If true the result will not be displayed to the screen.
  21062. * @param targetTexture The target texture to render to.
  21063. * @param faceIndex The index of the face to bind the target texture to.
  21064. * @param postProcesses The array of post processes to render.
  21065. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21066. * @hidden
  21067. */
  21068. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21069. /**
  21070. * Disposes of the post process manager.
  21071. */
  21072. dispose(): void;
  21073. }
  21074. }
  21075. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21076. import { Observable } from "babylonjs/Misc/observable";
  21077. import { SmartArray } from "babylonjs/Misc/smartArray";
  21078. import { Nullable, Immutable } from "babylonjs/types";
  21079. import { Camera } from "babylonjs/Cameras/camera";
  21080. import { Scene } from "babylonjs/scene";
  21081. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21082. import { Color4 } from "babylonjs/Maths/math.color";
  21083. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21085. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21087. import { Texture } from "babylonjs/Materials/Textures/texture";
  21088. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21089. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21090. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21091. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21092. import { Engine } from "babylonjs/Engines/engine";
  21093. /**
  21094. * This Helps creating a texture that will be created from a camera in your scene.
  21095. * It is basically a dynamic texture that could be used to create special effects for instance.
  21096. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21097. */
  21098. export class RenderTargetTexture extends Texture {
  21099. isCube: boolean;
  21100. /**
  21101. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21102. */
  21103. static readonly REFRESHRATE_RENDER_ONCE: number;
  21104. /**
  21105. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21106. */
  21107. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21108. /**
  21109. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21110. * the central point of your effect and can save a lot of performances.
  21111. */
  21112. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21113. /**
  21114. * Use this predicate to dynamically define the list of mesh you want to render.
  21115. * If set, the renderList property will be overwritten.
  21116. */
  21117. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21118. private _renderList;
  21119. /**
  21120. * Use this list to define the list of mesh you want to render.
  21121. */
  21122. get renderList(): Nullable<Array<AbstractMesh>>;
  21123. set renderList(value: Nullable<Array<AbstractMesh>>);
  21124. /**
  21125. * Use this function to overload the renderList array at rendering time.
  21126. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21127. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21128. * the cube (if the RTT is a cube, else layerOrFace=0).
  21129. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21130. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21131. * hold dummy elements!
  21132. */
  21133. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21134. private _hookArray;
  21135. /**
  21136. * Define if particles should be rendered in your texture.
  21137. */
  21138. renderParticles: boolean;
  21139. /**
  21140. * Define if sprites should be rendered in your texture.
  21141. */
  21142. renderSprites: boolean;
  21143. /**
  21144. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21145. */
  21146. coordinatesMode: number;
  21147. /**
  21148. * Define the camera used to render the texture.
  21149. */
  21150. activeCamera: Nullable<Camera>;
  21151. /**
  21152. * Override the render function of the texture with your own one.
  21153. */
  21154. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21155. /**
  21156. * Define if camera post processes should be use while rendering the texture.
  21157. */
  21158. useCameraPostProcesses: boolean;
  21159. /**
  21160. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21161. */
  21162. ignoreCameraViewport: boolean;
  21163. private _postProcessManager;
  21164. private _postProcesses;
  21165. private _resizeObserver;
  21166. /**
  21167. * An event triggered when the texture is unbind.
  21168. */
  21169. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21170. /**
  21171. * An event triggered when the texture is unbind.
  21172. */
  21173. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21174. private _onAfterUnbindObserver;
  21175. /**
  21176. * Set a after unbind callback in the texture.
  21177. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21178. */
  21179. set onAfterUnbind(callback: () => void);
  21180. /**
  21181. * An event triggered before rendering the texture
  21182. */
  21183. onBeforeRenderObservable: Observable<number>;
  21184. private _onBeforeRenderObserver;
  21185. /**
  21186. * Set a before render callback in the texture.
  21187. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21188. */
  21189. set onBeforeRender(callback: (faceIndex: number) => void);
  21190. /**
  21191. * An event triggered after rendering the texture
  21192. */
  21193. onAfterRenderObservable: Observable<number>;
  21194. private _onAfterRenderObserver;
  21195. /**
  21196. * Set a after render callback in the texture.
  21197. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21198. */
  21199. set onAfterRender(callback: (faceIndex: number) => void);
  21200. /**
  21201. * An event triggered after the texture clear
  21202. */
  21203. onClearObservable: Observable<Engine>;
  21204. private _onClearObserver;
  21205. /**
  21206. * Set a clear callback in the texture.
  21207. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21208. */
  21209. set onClear(callback: (Engine: Engine) => void);
  21210. /**
  21211. * An event triggered when the texture is resized.
  21212. */
  21213. onResizeObservable: Observable<RenderTargetTexture>;
  21214. /**
  21215. * Define the clear color of the Render Target if it should be different from the scene.
  21216. */
  21217. clearColor: Color4;
  21218. protected _size: number | {
  21219. width: number;
  21220. height: number;
  21221. layers?: number;
  21222. };
  21223. protected _initialSizeParameter: number | {
  21224. width: number;
  21225. height: number;
  21226. } | {
  21227. ratio: number;
  21228. };
  21229. protected _sizeRatio: Nullable<number>;
  21230. /** @hidden */
  21231. _generateMipMaps: boolean;
  21232. protected _renderingManager: RenderingManager;
  21233. /** @hidden */
  21234. _waitingRenderList: string[];
  21235. protected _doNotChangeAspectRatio: boolean;
  21236. protected _currentRefreshId: number;
  21237. protected _refreshRate: number;
  21238. protected _textureMatrix: Matrix;
  21239. protected _samples: number;
  21240. protected _renderTargetOptions: RenderTargetCreationOptions;
  21241. /**
  21242. * Gets render target creation options that were used.
  21243. */
  21244. get renderTargetOptions(): RenderTargetCreationOptions;
  21245. protected _engine: Engine;
  21246. protected _onRatioRescale(): void;
  21247. /**
  21248. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21249. * It must define where the camera used to render the texture is set
  21250. */
  21251. boundingBoxPosition: Vector3;
  21252. private _boundingBoxSize;
  21253. /**
  21254. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21255. * When defined, the cubemap will switch to local mode
  21256. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21257. * @example https://www.babylonjs-playground.com/#RNASML
  21258. */
  21259. set boundingBoxSize(value: Vector3);
  21260. get boundingBoxSize(): Vector3;
  21261. /**
  21262. * In case the RTT has been created with a depth texture, get the associated
  21263. * depth texture.
  21264. * Otherwise, return null.
  21265. */
  21266. get depthStencilTexture(): Nullable<InternalTexture>;
  21267. /**
  21268. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21269. * or used a shadow, depth texture...
  21270. * @param name The friendly name of the texture
  21271. * @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)
  21272. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21273. * @param generateMipMaps True if mip maps need to be generated after render.
  21274. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21275. * @param type The type of the buffer in the RTT (int, half float, float...)
  21276. * @param isCube True if a cube texture needs to be created
  21277. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21278. * @param generateDepthBuffer True to generate a depth buffer
  21279. * @param generateStencilBuffer True to generate a stencil buffer
  21280. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21281. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21282. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21283. */
  21284. constructor(name: string, size: number | {
  21285. width: number;
  21286. height: number;
  21287. layers?: number;
  21288. } | {
  21289. ratio: number;
  21290. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21291. /**
  21292. * Creates a depth stencil texture.
  21293. * This is only available in WebGL 2 or with the depth texture extension available.
  21294. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21295. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21296. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21297. */
  21298. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21299. private _processSizeParameter;
  21300. /**
  21301. * Define the number of samples to use in case of MSAA.
  21302. * It defaults to one meaning no MSAA has been enabled.
  21303. */
  21304. get samples(): number;
  21305. set samples(value: number);
  21306. /**
  21307. * Resets the refresh counter of the texture and start bak from scratch.
  21308. * Could be useful to regenerate the texture if it is setup to render only once.
  21309. */
  21310. resetRefreshCounter(): void;
  21311. /**
  21312. * Define the refresh rate of the texture or the rendering frequency.
  21313. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21314. */
  21315. get refreshRate(): number;
  21316. set refreshRate(value: number);
  21317. /**
  21318. * Adds a post process to the render target rendering passes.
  21319. * @param postProcess define the post process to add
  21320. */
  21321. addPostProcess(postProcess: PostProcess): void;
  21322. /**
  21323. * Clear all the post processes attached to the render target
  21324. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21325. */
  21326. clearPostProcesses(dispose?: boolean): void;
  21327. /**
  21328. * Remove one of the post process from the list of attached post processes to the texture
  21329. * @param postProcess define the post process to remove from the list
  21330. */
  21331. removePostProcess(postProcess: PostProcess): void;
  21332. /** @hidden */
  21333. _shouldRender(): boolean;
  21334. /**
  21335. * Gets the actual render size of the texture.
  21336. * @returns the width of the render size
  21337. */
  21338. getRenderSize(): number;
  21339. /**
  21340. * Gets the actual render width of the texture.
  21341. * @returns the width of the render size
  21342. */
  21343. getRenderWidth(): number;
  21344. /**
  21345. * Gets the actual render height of the texture.
  21346. * @returns the height of the render size
  21347. */
  21348. getRenderHeight(): number;
  21349. /**
  21350. * Gets the actual number of layers of the texture.
  21351. * @returns the number of layers
  21352. */
  21353. getRenderLayers(): number;
  21354. /**
  21355. * Get if the texture can be rescaled or not.
  21356. */
  21357. get canRescale(): boolean;
  21358. /**
  21359. * Resize the texture using a ratio.
  21360. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21361. */
  21362. scale(ratio: number): void;
  21363. /**
  21364. * Get the texture reflection matrix used to rotate/transform the reflection.
  21365. * @returns the reflection matrix
  21366. */
  21367. getReflectionTextureMatrix(): Matrix;
  21368. /**
  21369. * Resize the texture to a new desired size.
  21370. * Be carrefull as it will recreate all the data in the new texture.
  21371. * @param size Define the new size. It can be:
  21372. * - a number for squared texture,
  21373. * - an object containing { width: number, height: number }
  21374. * - or an object containing a ratio { ratio: number }
  21375. */
  21376. resize(size: number | {
  21377. width: number;
  21378. height: number;
  21379. } | {
  21380. ratio: number;
  21381. }): void;
  21382. private _defaultRenderListPrepared;
  21383. /**
  21384. * Renders all the objects from the render list into the texture.
  21385. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21386. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21387. */
  21388. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21389. private _bestReflectionRenderTargetDimension;
  21390. private _prepareRenderingManager;
  21391. /**
  21392. * @hidden
  21393. * @param faceIndex face index to bind to if this is a cubetexture
  21394. * @param layer defines the index of the texture to bind in the array
  21395. */
  21396. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21397. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21398. private renderToTarget;
  21399. /**
  21400. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21401. * This allowed control for front to back rendering or reversly depending of the special needs.
  21402. *
  21403. * @param renderingGroupId The rendering group id corresponding to its index
  21404. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21405. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21406. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21407. */
  21408. 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;
  21409. /**
  21410. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21411. *
  21412. * @param renderingGroupId The rendering group id corresponding to its index
  21413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21414. */
  21415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21416. /**
  21417. * Clones the texture.
  21418. * @returns the cloned texture
  21419. */
  21420. clone(): RenderTargetTexture;
  21421. /**
  21422. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21423. * @returns The JSON representation of the texture
  21424. */
  21425. serialize(): any;
  21426. /**
  21427. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21428. */
  21429. disposeFramebufferObjects(): void;
  21430. /**
  21431. * Dispose the texture and release its associated resources.
  21432. */
  21433. dispose(): void;
  21434. /** @hidden */
  21435. _rebuild(): void;
  21436. /**
  21437. * Clear the info related to rendering groups preventing retention point in material dispose.
  21438. */
  21439. freeRenderingGroups(): void;
  21440. /**
  21441. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21442. * @returns the view count
  21443. */
  21444. getViewCount(): number;
  21445. }
  21446. }
  21447. declare module "babylonjs/Materials/material" {
  21448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21449. import { SmartArray } from "babylonjs/Misc/smartArray";
  21450. import { Observable } from "babylonjs/Misc/observable";
  21451. import { Nullable } from "babylonjs/types";
  21452. import { Scene } from "babylonjs/scene";
  21453. import { Matrix } from "babylonjs/Maths/math.vector";
  21454. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21456. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21457. import { Effect } from "babylonjs/Materials/effect";
  21458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21460. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21461. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21462. import { Mesh } from "babylonjs/Meshes/mesh";
  21463. import { Animation } from "babylonjs/Animations/animation";
  21464. /**
  21465. * Options for compiling materials.
  21466. */
  21467. export interface IMaterialCompilationOptions {
  21468. /**
  21469. * Defines whether clip planes are enabled.
  21470. */
  21471. clipPlane: boolean;
  21472. /**
  21473. * Defines whether instances are enabled.
  21474. */
  21475. useInstances: boolean;
  21476. }
  21477. /**
  21478. * Base class for the main features of a material in Babylon.js
  21479. */
  21480. export class Material implements IAnimatable {
  21481. /**
  21482. * Returns the triangle fill mode
  21483. */
  21484. static readonly TriangleFillMode: number;
  21485. /**
  21486. * Returns the wireframe mode
  21487. */
  21488. static readonly WireFrameFillMode: number;
  21489. /**
  21490. * Returns the point fill mode
  21491. */
  21492. static readonly PointFillMode: number;
  21493. /**
  21494. * Returns the point list draw mode
  21495. */
  21496. static readonly PointListDrawMode: number;
  21497. /**
  21498. * Returns the line list draw mode
  21499. */
  21500. static readonly LineListDrawMode: number;
  21501. /**
  21502. * Returns the line loop draw mode
  21503. */
  21504. static readonly LineLoopDrawMode: number;
  21505. /**
  21506. * Returns the line strip draw mode
  21507. */
  21508. static readonly LineStripDrawMode: number;
  21509. /**
  21510. * Returns the triangle strip draw mode
  21511. */
  21512. static readonly TriangleStripDrawMode: number;
  21513. /**
  21514. * Returns the triangle fan draw mode
  21515. */
  21516. static readonly TriangleFanDrawMode: number;
  21517. /**
  21518. * Stores the clock-wise side orientation
  21519. */
  21520. static readonly ClockWiseSideOrientation: number;
  21521. /**
  21522. * Stores the counter clock-wise side orientation
  21523. */
  21524. static readonly CounterClockWiseSideOrientation: number;
  21525. /**
  21526. * The dirty texture flag value
  21527. */
  21528. static readonly TextureDirtyFlag: number;
  21529. /**
  21530. * The dirty light flag value
  21531. */
  21532. static readonly LightDirtyFlag: number;
  21533. /**
  21534. * The dirty fresnel flag value
  21535. */
  21536. static readonly FresnelDirtyFlag: number;
  21537. /**
  21538. * The dirty attribute flag value
  21539. */
  21540. static readonly AttributesDirtyFlag: number;
  21541. /**
  21542. * The dirty misc flag value
  21543. */
  21544. static readonly MiscDirtyFlag: number;
  21545. /**
  21546. * The all dirty flag value
  21547. */
  21548. static readonly AllDirtyFlag: number;
  21549. /**
  21550. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21551. */
  21552. static readonly MATERIAL_OPAQUE: number;
  21553. /**
  21554. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21555. */
  21556. static readonly MATERIAL_ALPHATEST: number;
  21557. /**
  21558. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21559. */
  21560. static readonly MATERIAL_ALPHABLEND: number;
  21561. /**
  21562. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21563. * They are also discarded below the alpha cutoff threshold to improve performances.
  21564. */
  21565. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21566. /**
  21567. * The ID of the material
  21568. */
  21569. id: string;
  21570. /**
  21571. * Gets or sets the unique id of the material
  21572. */
  21573. uniqueId: number;
  21574. /**
  21575. * The name of the material
  21576. */
  21577. name: string;
  21578. /**
  21579. * Gets or sets user defined metadata
  21580. */
  21581. metadata: any;
  21582. /**
  21583. * For internal use only. Please do not use.
  21584. */
  21585. reservedDataStore: any;
  21586. /**
  21587. * Specifies if the ready state should be checked on each call
  21588. */
  21589. checkReadyOnEveryCall: boolean;
  21590. /**
  21591. * Specifies if the ready state should be checked once
  21592. */
  21593. checkReadyOnlyOnce: boolean;
  21594. /**
  21595. * The state of the material
  21596. */
  21597. state: string;
  21598. /**
  21599. * The alpha value of the material
  21600. */
  21601. protected _alpha: number;
  21602. /**
  21603. * List of inspectable custom properties (used by the Inspector)
  21604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21605. */
  21606. inspectableCustomProperties: IInspectable[];
  21607. /**
  21608. * Sets the alpha value of the material
  21609. */
  21610. set alpha(value: number);
  21611. /**
  21612. * Gets the alpha value of the material
  21613. */
  21614. get alpha(): number;
  21615. /**
  21616. * Specifies if back face culling is enabled
  21617. */
  21618. protected _backFaceCulling: boolean;
  21619. /**
  21620. * Sets the back-face culling state
  21621. */
  21622. set backFaceCulling(value: boolean);
  21623. /**
  21624. * Gets the back-face culling state
  21625. */
  21626. get backFaceCulling(): boolean;
  21627. /**
  21628. * Stores the value for side orientation
  21629. */
  21630. sideOrientation: number;
  21631. /**
  21632. * Callback triggered when the material is compiled
  21633. */
  21634. onCompiled: Nullable<(effect: Effect) => void>;
  21635. /**
  21636. * Callback triggered when an error occurs
  21637. */
  21638. onError: Nullable<(effect: Effect, errors: string) => void>;
  21639. /**
  21640. * Callback triggered to get the render target textures
  21641. */
  21642. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21643. /**
  21644. * Gets a boolean indicating that current material needs to register RTT
  21645. */
  21646. get hasRenderTargetTextures(): boolean;
  21647. /**
  21648. * Specifies if the material should be serialized
  21649. */
  21650. doNotSerialize: boolean;
  21651. /**
  21652. * @hidden
  21653. */
  21654. _storeEffectOnSubMeshes: boolean;
  21655. /**
  21656. * Stores the animations for the material
  21657. */
  21658. animations: Nullable<Array<Animation>>;
  21659. /**
  21660. * An event triggered when the material is disposed
  21661. */
  21662. onDisposeObservable: Observable<Material>;
  21663. /**
  21664. * An observer which watches for dispose events
  21665. */
  21666. private _onDisposeObserver;
  21667. private _onUnBindObservable;
  21668. /**
  21669. * Called during a dispose event
  21670. */
  21671. set onDispose(callback: () => void);
  21672. private _onBindObservable;
  21673. /**
  21674. * An event triggered when the material is bound
  21675. */
  21676. get onBindObservable(): Observable<AbstractMesh>;
  21677. /**
  21678. * An observer which watches for bind events
  21679. */
  21680. private _onBindObserver;
  21681. /**
  21682. * Called during a bind event
  21683. */
  21684. set onBind(callback: (Mesh: AbstractMesh) => void);
  21685. /**
  21686. * An event triggered when the material is unbound
  21687. */
  21688. get onUnBindObservable(): Observable<Material>;
  21689. /**
  21690. * Stores the value of the alpha mode
  21691. */
  21692. private _alphaMode;
  21693. /**
  21694. * Sets the value of the alpha mode.
  21695. *
  21696. * | Value | Type | Description |
  21697. * | --- | --- | --- |
  21698. * | 0 | ALPHA_DISABLE | |
  21699. * | 1 | ALPHA_ADD | |
  21700. * | 2 | ALPHA_COMBINE | |
  21701. * | 3 | ALPHA_SUBTRACT | |
  21702. * | 4 | ALPHA_MULTIPLY | |
  21703. * | 5 | ALPHA_MAXIMIZED | |
  21704. * | 6 | ALPHA_ONEONE | |
  21705. * | 7 | ALPHA_PREMULTIPLIED | |
  21706. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21707. * | 9 | ALPHA_INTERPOLATE | |
  21708. * | 10 | ALPHA_SCREENMODE | |
  21709. *
  21710. */
  21711. set alphaMode(value: number);
  21712. /**
  21713. * Gets the value of the alpha mode
  21714. */
  21715. get alphaMode(): number;
  21716. /**
  21717. * Stores the state of the need depth pre-pass value
  21718. */
  21719. private _needDepthPrePass;
  21720. /**
  21721. * Sets the need depth pre-pass value
  21722. */
  21723. set needDepthPrePass(value: boolean);
  21724. /**
  21725. * Gets the depth pre-pass value
  21726. */
  21727. get needDepthPrePass(): boolean;
  21728. /**
  21729. * Specifies if depth writing should be disabled
  21730. */
  21731. disableDepthWrite: boolean;
  21732. /**
  21733. * Specifies if depth writing should be forced
  21734. */
  21735. forceDepthWrite: boolean;
  21736. /**
  21737. * Specifies the depth function that should be used. 0 means the default engine function
  21738. */
  21739. depthFunction: number;
  21740. /**
  21741. * Specifies if there should be a separate pass for culling
  21742. */
  21743. separateCullingPass: boolean;
  21744. /**
  21745. * Stores the state specifing if fog should be enabled
  21746. */
  21747. private _fogEnabled;
  21748. /**
  21749. * Sets the state for enabling fog
  21750. */
  21751. set fogEnabled(value: boolean);
  21752. /**
  21753. * Gets the value of the fog enabled state
  21754. */
  21755. get fogEnabled(): boolean;
  21756. /**
  21757. * Stores the size of points
  21758. */
  21759. pointSize: number;
  21760. /**
  21761. * Stores the z offset value
  21762. */
  21763. zOffset: number;
  21764. /**
  21765. * Gets a value specifying if wireframe mode is enabled
  21766. */
  21767. get wireframe(): boolean;
  21768. /**
  21769. * Sets the state of wireframe mode
  21770. */
  21771. set wireframe(value: boolean);
  21772. /**
  21773. * Gets the value specifying if point clouds are enabled
  21774. */
  21775. get pointsCloud(): boolean;
  21776. /**
  21777. * Sets the state of point cloud mode
  21778. */
  21779. set pointsCloud(value: boolean);
  21780. /**
  21781. * Gets the material fill mode
  21782. */
  21783. get fillMode(): number;
  21784. /**
  21785. * Sets the material fill mode
  21786. */
  21787. set fillMode(value: number);
  21788. /**
  21789. * @hidden
  21790. * Stores the effects for the material
  21791. */
  21792. _effect: Nullable<Effect>;
  21793. /**
  21794. * Specifies if uniform buffers should be used
  21795. */
  21796. private _useUBO;
  21797. /**
  21798. * Stores a reference to the scene
  21799. */
  21800. private _scene;
  21801. /**
  21802. * Stores the fill mode state
  21803. */
  21804. private _fillMode;
  21805. /**
  21806. * Specifies if the depth write state should be cached
  21807. */
  21808. private _cachedDepthWriteState;
  21809. /**
  21810. * Specifies if the depth function state should be cached
  21811. */
  21812. private _cachedDepthFunctionState;
  21813. /**
  21814. * Stores the uniform buffer
  21815. */
  21816. protected _uniformBuffer: UniformBuffer;
  21817. /** @hidden */
  21818. _indexInSceneMaterialArray: number;
  21819. /** @hidden */
  21820. meshMap: Nullable<{
  21821. [id: string]: AbstractMesh | undefined;
  21822. }>;
  21823. /**
  21824. * Creates a material instance
  21825. * @param name defines the name of the material
  21826. * @param scene defines the scene to reference
  21827. * @param doNotAdd specifies if the material should be added to the scene
  21828. */
  21829. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21830. /**
  21831. * Returns a string representation of the current material
  21832. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21833. * @returns a string with material information
  21834. */
  21835. toString(fullDetails?: boolean): string;
  21836. /**
  21837. * Gets the class name of the material
  21838. * @returns a string with the class name of the material
  21839. */
  21840. getClassName(): string;
  21841. /**
  21842. * Specifies if updates for the material been locked
  21843. */
  21844. get isFrozen(): boolean;
  21845. /**
  21846. * Locks updates for the material
  21847. */
  21848. freeze(): void;
  21849. /**
  21850. * Unlocks updates for the material
  21851. */
  21852. unfreeze(): void;
  21853. /**
  21854. * Specifies if the material is ready to be used
  21855. * @param mesh defines the mesh to check
  21856. * @param useInstances specifies if instances should be used
  21857. * @returns a boolean indicating if the material is ready to be used
  21858. */
  21859. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21860. /**
  21861. * Specifies that the submesh is ready to be used
  21862. * @param mesh defines the mesh to check
  21863. * @param subMesh defines which submesh to check
  21864. * @param useInstances specifies that instances should be used
  21865. * @returns a boolean indicating that the submesh is ready or not
  21866. */
  21867. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21868. /**
  21869. * Returns the material effect
  21870. * @returns the effect associated with the material
  21871. */
  21872. getEffect(): Nullable<Effect>;
  21873. /**
  21874. * Returns the current scene
  21875. * @returns a Scene
  21876. */
  21877. getScene(): Scene;
  21878. /**
  21879. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21880. */
  21881. protected _forceAlphaTest: boolean;
  21882. /**
  21883. * The transparency mode of the material.
  21884. */
  21885. protected _transparencyMode: Nullable<number>;
  21886. /**
  21887. * Gets the current transparency mode.
  21888. */
  21889. get transparencyMode(): Nullable<number>;
  21890. /**
  21891. * Sets the transparency mode of the material.
  21892. *
  21893. * | Value | Type | Description |
  21894. * | ----- | ----------------------------------- | ----------- |
  21895. * | 0 | OPAQUE | |
  21896. * | 1 | ALPHATEST | |
  21897. * | 2 | ALPHABLEND | |
  21898. * | 3 | ALPHATESTANDBLEND | |
  21899. *
  21900. */
  21901. set transparencyMode(value: Nullable<number>);
  21902. /**
  21903. * Returns true if alpha blending should be disabled.
  21904. */
  21905. protected get _disableAlphaBlending(): boolean;
  21906. /**
  21907. * Specifies whether or not this material should be rendered in alpha blend mode.
  21908. * @returns a boolean specifying if alpha blending is needed
  21909. */
  21910. needAlphaBlending(): boolean;
  21911. /**
  21912. * Specifies if the mesh will require alpha blending
  21913. * @param mesh defines the mesh to check
  21914. * @returns a boolean specifying if alpha blending is needed for the mesh
  21915. */
  21916. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21917. /**
  21918. * Specifies whether or not this material should be rendered in alpha test mode.
  21919. * @returns a boolean specifying if an alpha test is needed.
  21920. */
  21921. needAlphaTesting(): boolean;
  21922. /**
  21923. * Specifies if material alpha testing should be turned on for the mesh
  21924. * @param mesh defines the mesh to check
  21925. */
  21926. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21927. /**
  21928. * Gets the texture used for the alpha test
  21929. * @returns the texture to use for alpha testing
  21930. */
  21931. getAlphaTestTexture(): Nullable<BaseTexture>;
  21932. /**
  21933. * Marks the material to indicate that it needs to be re-calculated
  21934. */
  21935. markDirty(): void;
  21936. /** @hidden */
  21937. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21938. /**
  21939. * Binds the material to the mesh
  21940. * @param world defines the world transformation matrix
  21941. * @param mesh defines the mesh to bind the material to
  21942. */
  21943. bind(world: Matrix, mesh?: Mesh): void;
  21944. /**
  21945. * Binds the submesh to the material
  21946. * @param world defines the world transformation matrix
  21947. * @param mesh defines the mesh containing the submesh
  21948. * @param subMesh defines the submesh to bind the material to
  21949. */
  21950. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21951. /**
  21952. * Binds the world matrix to the material
  21953. * @param world defines the world transformation matrix
  21954. */
  21955. bindOnlyWorldMatrix(world: Matrix): void;
  21956. /**
  21957. * Binds the scene's uniform buffer to the effect.
  21958. * @param effect defines the effect to bind to the scene uniform buffer
  21959. * @param sceneUbo defines the uniform buffer storing scene data
  21960. */
  21961. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21962. /**
  21963. * Binds the view matrix to the effect
  21964. * @param effect defines the effect to bind the view matrix to
  21965. */
  21966. bindView(effect: Effect): void;
  21967. /**
  21968. * Binds the view projection matrix to the effect
  21969. * @param effect defines the effect to bind the view projection matrix to
  21970. */
  21971. bindViewProjection(effect: Effect): void;
  21972. /**
  21973. * Processes to execute after binding the material to a mesh
  21974. * @param mesh defines the rendered mesh
  21975. */
  21976. protected _afterBind(mesh?: Mesh): void;
  21977. /**
  21978. * Unbinds the material from the mesh
  21979. */
  21980. unbind(): void;
  21981. /**
  21982. * Gets the active textures from the material
  21983. * @returns an array of textures
  21984. */
  21985. getActiveTextures(): BaseTexture[];
  21986. /**
  21987. * Specifies if the material uses a texture
  21988. * @param texture defines the texture to check against the material
  21989. * @returns a boolean specifying if the material uses the texture
  21990. */
  21991. hasTexture(texture: BaseTexture): boolean;
  21992. /**
  21993. * Makes a duplicate of the material, and gives it a new name
  21994. * @param name defines the new name for the duplicated material
  21995. * @returns the cloned material
  21996. */
  21997. clone(name: string): Nullable<Material>;
  21998. /**
  21999. * Gets the meshes bound to the material
  22000. * @returns an array of meshes bound to the material
  22001. */
  22002. getBindedMeshes(): AbstractMesh[];
  22003. /**
  22004. * Force shader compilation
  22005. * @param mesh defines the mesh associated with this material
  22006. * @param onCompiled defines a function to execute once the material is compiled
  22007. * @param options defines the options to configure the compilation
  22008. * @param onError defines a function to execute if the material fails compiling
  22009. */
  22010. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22011. /**
  22012. * Force shader compilation
  22013. * @param mesh defines the mesh that will use this material
  22014. * @param options defines additional options for compiling the shaders
  22015. * @returns a promise that resolves when the compilation completes
  22016. */
  22017. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22018. private static readonly _AllDirtyCallBack;
  22019. private static readonly _ImageProcessingDirtyCallBack;
  22020. private static readonly _TextureDirtyCallBack;
  22021. private static readonly _FresnelDirtyCallBack;
  22022. private static readonly _MiscDirtyCallBack;
  22023. private static readonly _LightsDirtyCallBack;
  22024. private static readonly _AttributeDirtyCallBack;
  22025. private static _FresnelAndMiscDirtyCallBack;
  22026. private static _TextureAndMiscDirtyCallBack;
  22027. private static readonly _DirtyCallbackArray;
  22028. private static readonly _RunDirtyCallBacks;
  22029. /**
  22030. * Marks a define in the material to indicate that it needs to be re-computed
  22031. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22032. */
  22033. markAsDirty(flag: number): void;
  22034. /**
  22035. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22036. * @param func defines a function which checks material defines against the submeshes
  22037. */
  22038. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22039. /**
  22040. * Indicates that we need to re-calculated for all submeshes
  22041. */
  22042. protected _markAllSubMeshesAsAllDirty(): void;
  22043. /**
  22044. * Indicates that image processing needs to be re-calculated for all submeshes
  22045. */
  22046. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22047. /**
  22048. * Indicates that textures need to be re-calculated for all submeshes
  22049. */
  22050. protected _markAllSubMeshesAsTexturesDirty(): void;
  22051. /**
  22052. * Indicates that fresnel needs to be re-calculated for all submeshes
  22053. */
  22054. protected _markAllSubMeshesAsFresnelDirty(): void;
  22055. /**
  22056. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22057. */
  22058. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22059. /**
  22060. * Indicates that lights need to be re-calculated for all submeshes
  22061. */
  22062. protected _markAllSubMeshesAsLightsDirty(): void;
  22063. /**
  22064. * Indicates that attributes need to be re-calculated for all submeshes
  22065. */
  22066. protected _markAllSubMeshesAsAttributesDirty(): void;
  22067. /**
  22068. * Indicates that misc needs to be re-calculated for all submeshes
  22069. */
  22070. protected _markAllSubMeshesAsMiscDirty(): void;
  22071. /**
  22072. * Indicates that textures and misc need to be re-calculated for all submeshes
  22073. */
  22074. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22075. /**
  22076. * Disposes the material
  22077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22080. */
  22081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22082. /** @hidden */
  22083. private releaseVertexArrayObject;
  22084. /**
  22085. * Serializes this material
  22086. * @returns the serialized material object
  22087. */
  22088. serialize(): any;
  22089. /**
  22090. * Creates a material from parsed material data
  22091. * @param parsedMaterial defines parsed material data
  22092. * @param scene defines the hosting scene
  22093. * @param rootUrl defines the root URL to use to load textures
  22094. * @returns a new material
  22095. */
  22096. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22097. }
  22098. }
  22099. declare module "babylonjs/Materials/multiMaterial" {
  22100. import { Nullable } from "babylonjs/types";
  22101. import { Scene } from "babylonjs/scene";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22105. import { Material } from "babylonjs/Materials/material";
  22106. /**
  22107. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22108. * separate meshes. This can be use to improve performances.
  22109. * @see http://doc.babylonjs.com/how_to/multi_materials
  22110. */
  22111. export class MultiMaterial extends Material {
  22112. private _subMaterials;
  22113. /**
  22114. * Gets or Sets the list of Materials used within the multi material.
  22115. * They need to be ordered according to the submeshes order in the associated mesh
  22116. */
  22117. get subMaterials(): Nullable<Material>[];
  22118. set subMaterials(value: Nullable<Material>[]);
  22119. /**
  22120. * Function used to align with Node.getChildren()
  22121. * @returns the list of Materials used within the multi material
  22122. */
  22123. getChildren(): Nullable<Material>[];
  22124. /**
  22125. * Instantiates a new Multi Material
  22126. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22127. * separate meshes. This can be use to improve performances.
  22128. * @see http://doc.babylonjs.com/how_to/multi_materials
  22129. * @param name Define the name in the scene
  22130. * @param scene Define the scene the material belongs to
  22131. */
  22132. constructor(name: string, scene: Scene);
  22133. private _hookArray;
  22134. /**
  22135. * Get one of the submaterial by its index in the submaterials array
  22136. * @param index The index to look the sub material at
  22137. * @returns The Material if the index has been defined
  22138. */
  22139. getSubMaterial(index: number): Nullable<Material>;
  22140. /**
  22141. * Get the list of active textures for the whole sub materials list.
  22142. * @returns All the textures that will be used during the rendering
  22143. */
  22144. getActiveTextures(): BaseTexture[];
  22145. /**
  22146. * Gets the current class name of the material e.g. "MultiMaterial"
  22147. * Mainly use in serialization.
  22148. * @returns the class name
  22149. */
  22150. getClassName(): string;
  22151. /**
  22152. * Checks if the material is ready to render the requested sub mesh
  22153. * @param mesh Define the mesh the submesh belongs to
  22154. * @param subMesh Define the sub mesh to look readyness for
  22155. * @param useInstances Define whether or not the material is used with instances
  22156. * @returns true if ready, otherwise false
  22157. */
  22158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22159. /**
  22160. * Clones the current material and its related sub materials
  22161. * @param name Define the name of the newly cloned material
  22162. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22163. * @returns the cloned material
  22164. */
  22165. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22166. /**
  22167. * Serializes the materials into a JSON representation.
  22168. * @returns the JSON representation
  22169. */
  22170. serialize(): any;
  22171. /**
  22172. * Dispose the material and release its associated resources
  22173. * @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)
  22174. * @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)
  22175. * @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)
  22176. */
  22177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22178. /**
  22179. * Creates a MultiMaterial from parsed MultiMaterial data.
  22180. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22181. * @param scene defines the hosting scene
  22182. * @returns a new MultiMaterial
  22183. */
  22184. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22185. }
  22186. }
  22187. declare module "babylonjs/Meshes/subMesh" {
  22188. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22190. import { Engine } from "babylonjs/Engines/engine";
  22191. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22192. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22193. import { Effect } from "babylonjs/Materials/effect";
  22194. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22195. import { Plane } from "babylonjs/Maths/math.plane";
  22196. import { Collider } from "babylonjs/Collisions/collider";
  22197. import { Material } from "babylonjs/Materials/material";
  22198. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22200. import { Mesh } from "babylonjs/Meshes/mesh";
  22201. import { Ray } from "babylonjs/Culling/ray";
  22202. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22203. /**
  22204. * Base class for submeshes
  22205. */
  22206. export class BaseSubMesh {
  22207. /** @hidden */
  22208. _materialDefines: Nullable<MaterialDefines>;
  22209. /** @hidden */
  22210. _materialEffect: Nullable<Effect>;
  22211. /**
  22212. * Gets material defines used by the effect associated to the sub mesh
  22213. */
  22214. get materialDefines(): Nullable<MaterialDefines>;
  22215. /**
  22216. * Sets material defines used by the effect associated to the sub mesh
  22217. */
  22218. set materialDefines(defines: Nullable<MaterialDefines>);
  22219. /**
  22220. * Gets associated effect
  22221. */
  22222. get effect(): Nullable<Effect>;
  22223. /**
  22224. * Sets associated effect (effect used to render this submesh)
  22225. * @param effect defines the effect to associate with
  22226. * @param defines defines the set of defines used to compile this effect
  22227. */
  22228. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22229. }
  22230. /**
  22231. * Defines a subdivision inside a mesh
  22232. */
  22233. export class SubMesh extends BaseSubMesh implements ICullable {
  22234. /** the material index to use */
  22235. materialIndex: number;
  22236. /** vertex index start */
  22237. verticesStart: number;
  22238. /** vertices count */
  22239. verticesCount: number;
  22240. /** index start */
  22241. indexStart: number;
  22242. /** indices count */
  22243. indexCount: number;
  22244. /** @hidden */
  22245. _linesIndexCount: number;
  22246. private _mesh;
  22247. private _renderingMesh;
  22248. private _boundingInfo;
  22249. private _linesIndexBuffer;
  22250. /** @hidden */
  22251. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22252. /** @hidden */
  22253. _trianglePlanes: Plane[];
  22254. /** @hidden */
  22255. _lastColliderTransformMatrix: Nullable<Matrix>;
  22256. /** @hidden */
  22257. _renderId: number;
  22258. /** @hidden */
  22259. _alphaIndex: number;
  22260. /** @hidden */
  22261. _distanceToCamera: number;
  22262. /** @hidden */
  22263. _id: number;
  22264. private _currentMaterial;
  22265. /**
  22266. * Add a new submesh to a mesh
  22267. * @param materialIndex defines the material index to use
  22268. * @param verticesStart defines vertex index start
  22269. * @param verticesCount defines vertices count
  22270. * @param indexStart defines index start
  22271. * @param indexCount defines indices count
  22272. * @param mesh defines the parent mesh
  22273. * @param renderingMesh defines an optional rendering mesh
  22274. * @param createBoundingBox defines if bounding box should be created for this submesh
  22275. * @returns the new submesh
  22276. */
  22277. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22278. /**
  22279. * Creates a new submesh
  22280. * @param materialIndex defines the material index to use
  22281. * @param verticesStart defines vertex index start
  22282. * @param verticesCount defines vertices count
  22283. * @param indexStart defines index start
  22284. * @param indexCount defines indices count
  22285. * @param mesh defines the parent mesh
  22286. * @param renderingMesh defines an optional rendering mesh
  22287. * @param createBoundingBox defines if bounding box should be created for this submesh
  22288. */
  22289. constructor(
  22290. /** the material index to use */
  22291. materialIndex: number,
  22292. /** vertex index start */
  22293. verticesStart: number,
  22294. /** vertices count */
  22295. verticesCount: number,
  22296. /** index start */
  22297. indexStart: number,
  22298. /** indices count */
  22299. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22300. /**
  22301. * Returns true if this submesh covers the entire parent mesh
  22302. * @ignorenaming
  22303. */
  22304. get IsGlobal(): boolean;
  22305. /**
  22306. * Returns the submesh BoudingInfo object
  22307. * @returns current bounding info (or mesh's one if the submesh is global)
  22308. */
  22309. getBoundingInfo(): BoundingInfo;
  22310. /**
  22311. * Sets the submesh BoundingInfo
  22312. * @param boundingInfo defines the new bounding info to use
  22313. * @returns the SubMesh
  22314. */
  22315. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22316. /**
  22317. * Returns the mesh of the current submesh
  22318. * @return the parent mesh
  22319. */
  22320. getMesh(): AbstractMesh;
  22321. /**
  22322. * Returns the rendering mesh of the submesh
  22323. * @returns the rendering mesh (could be different from parent mesh)
  22324. */
  22325. getRenderingMesh(): Mesh;
  22326. /**
  22327. * Returns the submesh material
  22328. * @returns null or the current material
  22329. */
  22330. getMaterial(): Nullable<Material>;
  22331. /**
  22332. * Sets a new updated BoundingInfo object to the submesh
  22333. * @param data defines an optional position array to use to determine the bounding info
  22334. * @returns the SubMesh
  22335. */
  22336. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22337. /** @hidden */
  22338. _checkCollision(collider: Collider): boolean;
  22339. /**
  22340. * Updates the submesh BoundingInfo
  22341. * @param world defines the world matrix to use to update the bounding info
  22342. * @returns the submesh
  22343. */
  22344. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22345. /**
  22346. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22347. * @param frustumPlanes defines the frustum planes
  22348. * @returns true if the submesh is intersecting with the frustum
  22349. */
  22350. isInFrustum(frustumPlanes: Plane[]): boolean;
  22351. /**
  22352. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22353. * @param frustumPlanes defines the frustum planes
  22354. * @returns true if the submesh is inside the frustum
  22355. */
  22356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22357. /**
  22358. * Renders the submesh
  22359. * @param enableAlphaMode defines if alpha needs to be used
  22360. * @returns the submesh
  22361. */
  22362. render(enableAlphaMode: boolean): SubMesh;
  22363. /**
  22364. * @hidden
  22365. */
  22366. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22367. /**
  22368. * Checks if the submesh intersects with a ray
  22369. * @param ray defines the ray to test
  22370. * @returns true is the passed ray intersects the submesh bounding box
  22371. */
  22372. canIntersects(ray: Ray): boolean;
  22373. /**
  22374. * Intersects current submesh with a ray
  22375. * @param ray defines the ray to test
  22376. * @param positions defines mesh's positions array
  22377. * @param indices defines mesh's indices array
  22378. * @param fastCheck defines if only bounding info should be used
  22379. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22380. * @returns intersection info or null if no intersection
  22381. */
  22382. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22383. /** @hidden */
  22384. private _intersectLines;
  22385. /** @hidden */
  22386. private _intersectUnIndexedLines;
  22387. /** @hidden */
  22388. private _intersectTriangles;
  22389. /** @hidden */
  22390. private _intersectUnIndexedTriangles;
  22391. /** @hidden */
  22392. _rebuild(): void;
  22393. /**
  22394. * Creates a new submesh from the passed mesh
  22395. * @param newMesh defines the new hosting mesh
  22396. * @param newRenderingMesh defines an optional rendering mesh
  22397. * @returns the new submesh
  22398. */
  22399. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22400. /**
  22401. * Release associated resources
  22402. */
  22403. dispose(): void;
  22404. /**
  22405. * Gets the class name
  22406. * @returns the string "SubMesh".
  22407. */
  22408. getClassName(): string;
  22409. /**
  22410. * Creates a new submesh from indices data
  22411. * @param materialIndex the index of the main mesh material
  22412. * @param startIndex the index where to start the copy in the mesh indices array
  22413. * @param indexCount the number of indices to copy then from the startIndex
  22414. * @param mesh the main mesh to create the submesh from
  22415. * @param renderingMesh the optional rendering mesh
  22416. * @returns a new submesh
  22417. */
  22418. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22419. }
  22420. }
  22421. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22422. /**
  22423. * Class used to represent data loading progression
  22424. */
  22425. export class SceneLoaderFlags {
  22426. private static _ForceFullSceneLoadingForIncremental;
  22427. private static _ShowLoadingScreen;
  22428. private static _CleanBoneMatrixWeights;
  22429. private static _loggingLevel;
  22430. /**
  22431. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22432. */
  22433. static get ForceFullSceneLoadingForIncremental(): boolean;
  22434. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22435. /**
  22436. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22437. */
  22438. static get ShowLoadingScreen(): boolean;
  22439. static set ShowLoadingScreen(value: boolean);
  22440. /**
  22441. * Defines the current logging level (while loading the scene)
  22442. * @ignorenaming
  22443. */
  22444. static get loggingLevel(): number;
  22445. static set loggingLevel(value: number);
  22446. /**
  22447. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22448. */
  22449. static get CleanBoneMatrixWeights(): boolean;
  22450. static set CleanBoneMatrixWeights(value: boolean);
  22451. }
  22452. }
  22453. declare module "babylonjs/Meshes/geometry" {
  22454. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22455. import { Scene } from "babylonjs/scene";
  22456. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22457. import { Engine } from "babylonjs/Engines/engine";
  22458. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22459. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22460. import { Effect } from "babylonjs/Materials/effect";
  22461. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22462. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22463. import { Mesh } from "babylonjs/Meshes/mesh";
  22464. /**
  22465. * Class used to store geometry data (vertex buffers + index buffer)
  22466. */
  22467. export class Geometry implements IGetSetVerticesData {
  22468. /**
  22469. * Gets or sets the ID of the geometry
  22470. */
  22471. id: string;
  22472. /**
  22473. * Gets or sets the unique ID of the geometry
  22474. */
  22475. uniqueId: number;
  22476. /**
  22477. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22478. */
  22479. delayLoadState: number;
  22480. /**
  22481. * Gets the file containing the data to load when running in delay load state
  22482. */
  22483. delayLoadingFile: Nullable<string>;
  22484. /**
  22485. * Callback called when the geometry is updated
  22486. */
  22487. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22488. private _scene;
  22489. private _engine;
  22490. private _meshes;
  22491. private _totalVertices;
  22492. /** @hidden */
  22493. _indices: IndicesArray;
  22494. /** @hidden */
  22495. _vertexBuffers: {
  22496. [key: string]: VertexBuffer;
  22497. };
  22498. private _isDisposed;
  22499. private _extend;
  22500. private _boundingBias;
  22501. /** @hidden */
  22502. _delayInfo: Array<string>;
  22503. private _indexBuffer;
  22504. private _indexBufferIsUpdatable;
  22505. /** @hidden */
  22506. _boundingInfo: Nullable<BoundingInfo>;
  22507. /** @hidden */
  22508. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22509. /** @hidden */
  22510. _softwareSkinningFrameId: number;
  22511. private _vertexArrayObjects;
  22512. private _updatable;
  22513. /** @hidden */
  22514. _positions: Nullable<Vector3[]>;
  22515. /**
  22516. * 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
  22517. */
  22518. get boundingBias(): Vector2;
  22519. /**
  22520. * 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
  22521. */
  22522. set boundingBias(value: Vector2);
  22523. /**
  22524. * Static function used to attach a new empty geometry to a mesh
  22525. * @param mesh defines the mesh to attach the geometry to
  22526. * @returns the new Geometry
  22527. */
  22528. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22529. /**
  22530. * Creates a new geometry
  22531. * @param id defines the unique ID
  22532. * @param scene defines the hosting scene
  22533. * @param vertexData defines the VertexData used to get geometry data
  22534. * @param updatable defines if geometry must be updatable (false by default)
  22535. * @param mesh defines the mesh that will be associated with the geometry
  22536. */
  22537. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22538. /**
  22539. * Gets the current extend of the geometry
  22540. */
  22541. get extend(): {
  22542. minimum: Vector3;
  22543. maximum: Vector3;
  22544. };
  22545. /**
  22546. * Gets the hosting scene
  22547. * @returns the hosting Scene
  22548. */
  22549. getScene(): Scene;
  22550. /**
  22551. * Gets the hosting engine
  22552. * @returns the hosting Engine
  22553. */
  22554. getEngine(): Engine;
  22555. /**
  22556. * Defines if the geometry is ready to use
  22557. * @returns true if the geometry is ready to be used
  22558. */
  22559. isReady(): boolean;
  22560. /**
  22561. * Gets a value indicating that the geometry should not be serialized
  22562. */
  22563. get doNotSerialize(): boolean;
  22564. /** @hidden */
  22565. _rebuild(): void;
  22566. /**
  22567. * Affects all geometry data in one call
  22568. * @param vertexData defines the geometry data
  22569. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22570. */
  22571. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22572. /**
  22573. * Set specific vertex data
  22574. * @param kind defines the data kind (Position, normal, etc...)
  22575. * @param data defines the vertex data to use
  22576. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22577. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22578. */
  22579. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22580. /**
  22581. * Removes a specific vertex data
  22582. * @param kind defines the data kind (Position, normal, etc...)
  22583. */
  22584. removeVerticesData(kind: string): void;
  22585. /**
  22586. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22587. * @param buffer defines the vertex buffer to use
  22588. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22589. */
  22590. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22591. /**
  22592. * Update a specific vertex buffer
  22593. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22594. * It will do nothing if the buffer is not updatable
  22595. * @param kind defines the data kind (Position, normal, etc...)
  22596. * @param data defines the data to use
  22597. * @param offset defines the offset in the target buffer where to store the data
  22598. * @param useBytes set to true if the offset is in bytes
  22599. */
  22600. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22601. /**
  22602. * Update a specific vertex buffer
  22603. * This function will create a new buffer if the current one is not updatable
  22604. * @param kind defines the data kind (Position, normal, etc...)
  22605. * @param data defines the data to use
  22606. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22607. */
  22608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22609. private _updateBoundingInfo;
  22610. /** @hidden */
  22611. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22612. /**
  22613. * Gets total number of vertices
  22614. * @returns the total number of vertices
  22615. */
  22616. getTotalVertices(): number;
  22617. /**
  22618. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22619. * @param kind defines the data kind (Position, normal, etc...)
  22620. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22621. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22622. * @returns a float array containing vertex data
  22623. */
  22624. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22625. /**
  22626. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22627. * @param kind defines the data kind (Position, normal, etc...)
  22628. * @returns true if the vertex buffer with the specified kind is updatable
  22629. */
  22630. isVertexBufferUpdatable(kind: string): boolean;
  22631. /**
  22632. * Gets a specific vertex buffer
  22633. * @param kind defines the data kind (Position, normal, etc...)
  22634. * @returns a VertexBuffer
  22635. */
  22636. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22637. /**
  22638. * Returns all vertex buffers
  22639. * @return an object holding all vertex buffers indexed by kind
  22640. */
  22641. getVertexBuffers(): Nullable<{
  22642. [key: string]: VertexBuffer;
  22643. }>;
  22644. /**
  22645. * Gets a boolean indicating if specific vertex buffer is present
  22646. * @param kind defines the data kind (Position, normal, etc...)
  22647. * @returns true if data is present
  22648. */
  22649. isVerticesDataPresent(kind: string): boolean;
  22650. /**
  22651. * Gets a list of all attached data kinds (Position, normal, etc...)
  22652. * @returns a list of string containing all kinds
  22653. */
  22654. getVerticesDataKinds(): string[];
  22655. /**
  22656. * Update index buffer
  22657. * @param indices defines the indices to store in the index buffer
  22658. * @param offset defines the offset in the target buffer where to store the data
  22659. * @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)
  22660. */
  22661. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22662. /**
  22663. * Creates a new index buffer
  22664. * @param indices defines the indices to store in the index buffer
  22665. * @param totalVertices defines the total number of vertices (could be null)
  22666. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22667. */
  22668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22669. /**
  22670. * Return the total number of indices
  22671. * @returns the total number of indices
  22672. */
  22673. getTotalIndices(): number;
  22674. /**
  22675. * Gets the index buffer array
  22676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22678. * @returns the index buffer array
  22679. */
  22680. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22681. /**
  22682. * Gets the index buffer
  22683. * @return the index buffer
  22684. */
  22685. getIndexBuffer(): Nullable<DataBuffer>;
  22686. /** @hidden */
  22687. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22688. /**
  22689. * Release the associated resources for a specific mesh
  22690. * @param mesh defines the source mesh
  22691. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22692. */
  22693. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22694. /**
  22695. * Apply current geometry to a given mesh
  22696. * @param mesh defines the mesh to apply geometry to
  22697. */
  22698. applyToMesh(mesh: Mesh): void;
  22699. private _updateExtend;
  22700. private _applyToMesh;
  22701. private notifyUpdate;
  22702. /**
  22703. * Load the geometry if it was flagged as delay loaded
  22704. * @param scene defines the hosting scene
  22705. * @param onLoaded defines a callback called when the geometry is loaded
  22706. */
  22707. load(scene: Scene, onLoaded?: () => void): void;
  22708. private _queueLoad;
  22709. /**
  22710. * Invert the geometry to move from a right handed system to a left handed one.
  22711. */
  22712. toLeftHanded(): void;
  22713. /** @hidden */
  22714. _resetPointsArrayCache(): void;
  22715. /** @hidden */
  22716. _generatePointsArray(): boolean;
  22717. /**
  22718. * Gets a value indicating if the geometry is disposed
  22719. * @returns true if the geometry was disposed
  22720. */
  22721. isDisposed(): boolean;
  22722. private _disposeVertexArrayObjects;
  22723. /**
  22724. * Free all associated resources
  22725. */
  22726. dispose(): void;
  22727. /**
  22728. * Clone the current geometry into a new geometry
  22729. * @param id defines the unique ID of the new geometry
  22730. * @returns a new geometry object
  22731. */
  22732. copy(id: string): Geometry;
  22733. /**
  22734. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22735. * @return a JSON representation of the current geometry data (without the vertices data)
  22736. */
  22737. serialize(): any;
  22738. private toNumberArray;
  22739. /**
  22740. * Serialize all vertices data into a JSON oject
  22741. * @returns a JSON representation of the current geometry data
  22742. */
  22743. serializeVerticeData(): any;
  22744. /**
  22745. * Extracts a clone of a mesh geometry
  22746. * @param mesh defines the source mesh
  22747. * @param id defines the unique ID of the new geometry object
  22748. * @returns the new geometry object
  22749. */
  22750. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22751. /**
  22752. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22753. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22754. * Be aware Math.random() could cause collisions, but:
  22755. * "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"
  22756. * @returns a string containing a new GUID
  22757. */
  22758. static RandomId(): string;
  22759. /** @hidden */
  22760. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22761. private static _CleanMatricesWeights;
  22762. /**
  22763. * Create a new geometry from persisted data (Using .babylon file format)
  22764. * @param parsedVertexData defines the persisted data
  22765. * @param scene defines the hosting scene
  22766. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22767. * @returns the new geometry object
  22768. */
  22769. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22770. }
  22771. }
  22772. declare module "babylonjs/Meshes/mesh.vertexData" {
  22773. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22774. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22775. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22776. import { Geometry } from "babylonjs/Meshes/geometry";
  22777. import { Mesh } from "babylonjs/Meshes/mesh";
  22778. /**
  22779. * Define an interface for all classes that will get and set the data on vertices
  22780. */
  22781. export interface IGetSetVerticesData {
  22782. /**
  22783. * Gets a boolean indicating if specific vertex data is present
  22784. * @param kind defines the vertex data kind to use
  22785. * @returns true is data kind is present
  22786. */
  22787. isVerticesDataPresent(kind: string): boolean;
  22788. /**
  22789. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22790. * @param kind defines the data kind (Position, normal, etc...)
  22791. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22792. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22793. * @returns a float array containing vertex data
  22794. */
  22795. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22796. /**
  22797. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22798. * @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.
  22799. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22800. * @returns the indices array or an empty array if the mesh has no geometry
  22801. */
  22802. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22803. /**
  22804. * Set specific vertex data
  22805. * @param kind defines the data kind (Position, normal, etc...)
  22806. * @param data defines the vertex data to use
  22807. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22808. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22809. */
  22810. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22811. /**
  22812. * Update a specific associated vertex buffer
  22813. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22814. * - VertexBuffer.PositionKind
  22815. * - VertexBuffer.UVKind
  22816. * - VertexBuffer.UV2Kind
  22817. * - VertexBuffer.UV3Kind
  22818. * - VertexBuffer.UV4Kind
  22819. * - VertexBuffer.UV5Kind
  22820. * - VertexBuffer.UV6Kind
  22821. * - VertexBuffer.ColorKind
  22822. * - VertexBuffer.MatricesIndicesKind
  22823. * - VertexBuffer.MatricesIndicesExtraKind
  22824. * - VertexBuffer.MatricesWeightsKind
  22825. * - VertexBuffer.MatricesWeightsExtraKind
  22826. * @param data defines the data source
  22827. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22828. * @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)
  22829. */
  22830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22831. /**
  22832. * Creates a new index buffer
  22833. * @param indices defines the indices to store in the index buffer
  22834. * @param totalVertices defines the total number of vertices (could be null)
  22835. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22836. */
  22837. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22838. }
  22839. /**
  22840. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22841. */
  22842. export class VertexData {
  22843. /**
  22844. * Mesh side orientation : usually the external or front surface
  22845. */
  22846. static readonly FRONTSIDE: number;
  22847. /**
  22848. * Mesh side orientation : usually the internal or back surface
  22849. */
  22850. static readonly BACKSIDE: number;
  22851. /**
  22852. * Mesh side orientation : both internal and external or front and back surfaces
  22853. */
  22854. static readonly DOUBLESIDE: number;
  22855. /**
  22856. * Mesh side orientation : by default, `FRONTSIDE`
  22857. */
  22858. static readonly DEFAULTSIDE: number;
  22859. /**
  22860. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22861. */
  22862. positions: Nullable<FloatArray>;
  22863. /**
  22864. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22865. */
  22866. normals: Nullable<FloatArray>;
  22867. /**
  22868. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22869. */
  22870. tangents: Nullable<FloatArray>;
  22871. /**
  22872. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22873. */
  22874. uvs: Nullable<FloatArray>;
  22875. /**
  22876. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22877. */
  22878. uvs2: Nullable<FloatArray>;
  22879. /**
  22880. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22881. */
  22882. uvs3: Nullable<FloatArray>;
  22883. /**
  22884. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22885. */
  22886. uvs4: Nullable<FloatArray>;
  22887. /**
  22888. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22889. */
  22890. uvs5: Nullable<FloatArray>;
  22891. /**
  22892. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22893. */
  22894. uvs6: Nullable<FloatArray>;
  22895. /**
  22896. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22897. */
  22898. colors: Nullable<FloatArray>;
  22899. /**
  22900. * 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).
  22901. */
  22902. matricesIndices: Nullable<FloatArray>;
  22903. /**
  22904. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22905. */
  22906. matricesWeights: Nullable<FloatArray>;
  22907. /**
  22908. * An array extending the number of possible indices
  22909. */
  22910. matricesIndicesExtra: Nullable<FloatArray>;
  22911. /**
  22912. * An array extending the number of possible weights when the number of indices is extended
  22913. */
  22914. matricesWeightsExtra: Nullable<FloatArray>;
  22915. /**
  22916. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22917. */
  22918. indices: Nullable<IndicesArray>;
  22919. /**
  22920. * Uses the passed data array to set the set the values for the specified kind of data
  22921. * @param data a linear array of floating numbers
  22922. * @param kind the type of data that is being set, eg positions, colors etc
  22923. */
  22924. set(data: FloatArray, kind: string): void;
  22925. /**
  22926. * Associates the vertexData to the passed Mesh.
  22927. * Sets it as updatable or not (default `false`)
  22928. * @param mesh the mesh the vertexData is applied to
  22929. * @param updatable when used and having the value true allows new data to update the vertexData
  22930. * @returns the VertexData
  22931. */
  22932. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22933. /**
  22934. * Associates the vertexData to the passed Geometry.
  22935. * Sets it as updatable or not (default `false`)
  22936. * @param geometry the geometry the vertexData is applied to
  22937. * @param updatable when used and having the value true allows new data to update the vertexData
  22938. * @returns VertexData
  22939. */
  22940. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22941. /**
  22942. * Updates the associated mesh
  22943. * @param mesh the mesh to be updated
  22944. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22945. * @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
  22946. * @returns VertexData
  22947. */
  22948. updateMesh(mesh: Mesh): VertexData;
  22949. /**
  22950. * Updates the associated geometry
  22951. * @param geometry the geometry to be updated
  22952. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22953. * @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
  22954. * @returns VertexData.
  22955. */
  22956. updateGeometry(geometry: Geometry): VertexData;
  22957. private _applyTo;
  22958. private _update;
  22959. /**
  22960. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22961. * @param matrix the transforming matrix
  22962. * @returns the VertexData
  22963. */
  22964. transform(matrix: Matrix): VertexData;
  22965. /**
  22966. * Merges the passed VertexData into the current one
  22967. * @param other the VertexData to be merged into the current one
  22968. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22969. * @returns the modified VertexData
  22970. */
  22971. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22972. private _mergeElement;
  22973. private _validate;
  22974. /**
  22975. * Serializes the VertexData
  22976. * @returns a serialized object
  22977. */
  22978. serialize(): any;
  22979. /**
  22980. * Extracts the vertexData from a mesh
  22981. * @param mesh the mesh from which to extract the VertexData
  22982. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22983. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22984. * @returns the object VertexData associated to the passed mesh
  22985. */
  22986. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22987. /**
  22988. * Extracts the vertexData from the geometry
  22989. * @param geometry the geometry from which to extract the VertexData
  22990. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22991. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22992. * @returns the object VertexData associated to the passed mesh
  22993. */
  22994. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22995. private static _ExtractFrom;
  22996. /**
  22997. * Creates the VertexData for a Ribbon
  22998. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22999. * * pathArray array of paths, each of which an array of successive Vector3
  23000. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23001. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23002. * * 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
  23003. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23004. * * 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)
  23005. * * 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)
  23006. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23007. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23008. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23009. * @returns the VertexData of the ribbon
  23010. */
  23011. static CreateRibbon(options: {
  23012. pathArray: Vector3[][];
  23013. closeArray?: boolean;
  23014. closePath?: boolean;
  23015. offset?: number;
  23016. sideOrientation?: number;
  23017. frontUVs?: Vector4;
  23018. backUVs?: Vector4;
  23019. invertUV?: boolean;
  23020. uvs?: Vector2[];
  23021. colors?: Color4[];
  23022. }): VertexData;
  23023. /**
  23024. * Creates the VertexData for a box
  23025. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23026. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23027. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23028. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23029. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23030. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23031. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23033. * * 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)
  23034. * * 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)
  23035. * @returns the VertexData of the box
  23036. */
  23037. static CreateBox(options: {
  23038. size?: number;
  23039. width?: number;
  23040. height?: number;
  23041. depth?: number;
  23042. faceUV?: Vector4[];
  23043. faceColors?: Color4[];
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData for a tiled box
  23050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23051. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23052. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23053. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23055. * @returns the VertexData of the box
  23056. */
  23057. static CreateTiledBox(options: {
  23058. pattern?: number;
  23059. width?: number;
  23060. height?: number;
  23061. depth?: number;
  23062. tileSize?: number;
  23063. tileWidth?: number;
  23064. tileHeight?: number;
  23065. alignHorizontal?: number;
  23066. alignVertical?: number;
  23067. faceUV?: Vector4[];
  23068. faceColors?: Color4[];
  23069. sideOrientation?: number;
  23070. }): VertexData;
  23071. /**
  23072. * Creates the VertexData for a tiled plane
  23073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23074. * * pattern a limited pattern arrangement depending on the number
  23075. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23076. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23077. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23079. * * 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)
  23080. * * 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)
  23081. * @returns the VertexData of the tiled plane
  23082. */
  23083. static CreateTiledPlane(options: {
  23084. pattern?: number;
  23085. tileSize?: number;
  23086. tileWidth?: number;
  23087. tileHeight?: number;
  23088. size?: number;
  23089. width?: number;
  23090. height?: number;
  23091. alignHorizontal?: number;
  23092. alignVertical?: number;
  23093. sideOrientation?: number;
  23094. frontUVs?: Vector4;
  23095. backUVs?: Vector4;
  23096. }): VertexData;
  23097. /**
  23098. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23100. * * segments sets the number of horizontal strips optional, default 32
  23101. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23102. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23103. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23104. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23105. * * 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
  23106. * * 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
  23107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23108. * * 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)
  23109. * * 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)
  23110. * @returns the VertexData of the ellipsoid
  23111. */
  23112. static CreateSphere(options: {
  23113. segments?: number;
  23114. diameter?: number;
  23115. diameterX?: number;
  23116. diameterY?: number;
  23117. diameterZ?: number;
  23118. arc?: number;
  23119. slice?: number;
  23120. sideOrientation?: number;
  23121. frontUVs?: Vector4;
  23122. backUVs?: Vector4;
  23123. }): VertexData;
  23124. /**
  23125. * Creates the VertexData for a cylinder, cone or prism
  23126. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23127. * * height sets the height (y direction) of the cylinder, optional, default 2
  23128. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23129. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23130. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23131. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23132. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23133. * * 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
  23134. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23135. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23136. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23137. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23139. * * 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)
  23140. * * 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)
  23141. * @returns the VertexData of the cylinder, cone or prism
  23142. */
  23143. static CreateCylinder(options: {
  23144. height?: number;
  23145. diameterTop?: number;
  23146. diameterBottom?: number;
  23147. diameter?: number;
  23148. tessellation?: number;
  23149. subdivisions?: number;
  23150. arc?: number;
  23151. faceColors?: Color4[];
  23152. faceUV?: Vector4[];
  23153. hasRings?: boolean;
  23154. enclose?: boolean;
  23155. sideOrientation?: number;
  23156. frontUVs?: Vector4;
  23157. backUVs?: Vector4;
  23158. }): VertexData;
  23159. /**
  23160. * Creates the VertexData for a torus
  23161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23162. * * diameter the diameter of the torus, optional default 1
  23163. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23164. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23166. * * 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)
  23167. * * 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)
  23168. * @returns the VertexData of the torus
  23169. */
  23170. static CreateTorus(options: {
  23171. diameter?: number;
  23172. thickness?: number;
  23173. tessellation?: number;
  23174. sideOrientation?: number;
  23175. frontUVs?: Vector4;
  23176. backUVs?: Vector4;
  23177. }): VertexData;
  23178. /**
  23179. * Creates the VertexData of the LineSystem
  23180. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23181. * - lines an array of lines, each line being an array of successive Vector3
  23182. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23183. * @returns the VertexData of the LineSystem
  23184. */
  23185. static CreateLineSystem(options: {
  23186. lines: Vector3[][];
  23187. colors?: Nullable<Color4[][]>;
  23188. }): VertexData;
  23189. /**
  23190. * Create the VertexData for a DashedLines
  23191. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23192. * - points an array successive Vector3
  23193. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23194. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23195. * - dashNb the intended total number of dashes, optional, default 200
  23196. * @returns the VertexData for the DashedLines
  23197. */
  23198. static CreateDashedLines(options: {
  23199. points: Vector3[];
  23200. dashSize?: number;
  23201. gapSize?: number;
  23202. dashNb?: number;
  23203. }): VertexData;
  23204. /**
  23205. * Creates the VertexData for a Ground
  23206. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23207. * - width the width (x direction) of the ground, optional, default 1
  23208. * - height the height (z direction) of the ground, optional, default 1
  23209. * - subdivisions the number of subdivisions per side, optional, default 1
  23210. * @returns the VertexData of the Ground
  23211. */
  23212. static CreateGround(options: {
  23213. width?: number;
  23214. height?: number;
  23215. subdivisions?: number;
  23216. subdivisionsX?: number;
  23217. subdivisionsY?: number;
  23218. }): VertexData;
  23219. /**
  23220. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23221. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23222. * * xmin the ground minimum X coordinate, optional, default -1
  23223. * * zmin the ground minimum Z coordinate, optional, default -1
  23224. * * xmax the ground maximum X coordinate, optional, default 1
  23225. * * zmax the ground maximum Z coordinate, optional, default 1
  23226. * * 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}
  23227. * * 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}
  23228. * @returns the VertexData of the TiledGround
  23229. */
  23230. static CreateTiledGround(options: {
  23231. xmin: number;
  23232. zmin: number;
  23233. xmax: number;
  23234. zmax: number;
  23235. subdivisions?: {
  23236. w: number;
  23237. h: number;
  23238. };
  23239. precision?: {
  23240. w: number;
  23241. h: number;
  23242. };
  23243. }): VertexData;
  23244. /**
  23245. * Creates the VertexData of the Ground designed from a heightmap
  23246. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23247. * * width the width (x direction) of the ground
  23248. * * height the height (z direction) of the ground
  23249. * * subdivisions the number of subdivisions per side
  23250. * * minHeight the minimum altitude on the ground, optional, default 0
  23251. * * maxHeight the maximum altitude on the ground, optional default 1
  23252. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23253. * * buffer the array holding the image color data
  23254. * * bufferWidth the width of image
  23255. * * bufferHeight the height of image
  23256. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23257. * @returns the VertexData of the Ground designed from a heightmap
  23258. */
  23259. static CreateGroundFromHeightMap(options: {
  23260. width: number;
  23261. height: number;
  23262. subdivisions: number;
  23263. minHeight: number;
  23264. maxHeight: number;
  23265. colorFilter: Color3;
  23266. buffer: Uint8Array;
  23267. bufferWidth: number;
  23268. bufferHeight: number;
  23269. alphaFilter: number;
  23270. }): VertexData;
  23271. /**
  23272. * Creates the VertexData for a Plane
  23273. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23274. * * size sets the width and height of the plane to the value of size, optional default 1
  23275. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23276. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23278. * * 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)
  23279. * * 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)
  23280. * @returns the VertexData of the box
  23281. */
  23282. static CreatePlane(options: {
  23283. size?: number;
  23284. width?: number;
  23285. height?: number;
  23286. sideOrientation?: number;
  23287. frontUVs?: Vector4;
  23288. backUVs?: Vector4;
  23289. }): VertexData;
  23290. /**
  23291. * Creates the VertexData of the Disc or regular Polygon
  23292. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23293. * * radius the radius of the disc, optional default 0.5
  23294. * * tessellation the number of polygon sides, optional, default 64
  23295. * * 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
  23296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23297. * * 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)
  23298. * * 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)
  23299. * @returns the VertexData of the box
  23300. */
  23301. static CreateDisc(options: {
  23302. radius?: number;
  23303. tessellation?: number;
  23304. arc?: number;
  23305. sideOrientation?: number;
  23306. frontUVs?: Vector4;
  23307. backUVs?: Vector4;
  23308. }): VertexData;
  23309. /**
  23310. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23311. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23312. * @param polygon a mesh built from polygonTriangulation.build()
  23313. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23314. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23315. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23316. * @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)
  23317. * @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)
  23318. * @returns the VertexData of the Polygon
  23319. */
  23320. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23321. /**
  23322. * Creates the VertexData of the IcoSphere
  23323. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23324. * * radius the radius of the IcoSphere, optional default 1
  23325. * * radiusX allows stretching in the x direction, optional, default radius
  23326. * * radiusY allows stretching in the y direction, optional, default radius
  23327. * * radiusZ allows stretching in the z direction, optional, default radius
  23328. * * flat when true creates a flat shaded mesh, optional, default true
  23329. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23331. * * 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)
  23332. * * 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)
  23333. * @returns the VertexData of the IcoSphere
  23334. */
  23335. static CreateIcoSphere(options: {
  23336. radius?: number;
  23337. radiusX?: number;
  23338. radiusY?: number;
  23339. radiusZ?: number;
  23340. flat?: boolean;
  23341. subdivisions?: number;
  23342. sideOrientation?: number;
  23343. frontUVs?: Vector4;
  23344. backUVs?: Vector4;
  23345. }): VertexData;
  23346. /**
  23347. * Creates the VertexData for a Polyhedron
  23348. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23349. * * type provided types are:
  23350. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23351. * * 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)
  23352. * * size the size of the IcoSphere, optional default 1
  23353. * * sizeX allows stretching in the x direction, optional, default size
  23354. * * sizeY allows stretching in the y direction, optional, default size
  23355. * * sizeZ allows stretching in the z direction, optional, default size
  23356. * * 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
  23357. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23358. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23359. * * flat when true creates a flat shaded mesh, optional, default true
  23360. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23362. * * 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)
  23363. * * 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)
  23364. * @returns the VertexData of the Polyhedron
  23365. */
  23366. static CreatePolyhedron(options: {
  23367. type?: number;
  23368. size?: number;
  23369. sizeX?: number;
  23370. sizeY?: number;
  23371. sizeZ?: number;
  23372. custom?: any;
  23373. faceUV?: Vector4[];
  23374. faceColors?: Color4[];
  23375. flat?: boolean;
  23376. sideOrientation?: number;
  23377. frontUVs?: Vector4;
  23378. backUVs?: Vector4;
  23379. }): VertexData;
  23380. /**
  23381. * Creates the VertexData for a TorusKnot
  23382. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23383. * * radius the radius of the torus knot, optional, default 2
  23384. * * tube the thickness of the tube, optional, default 0.5
  23385. * * radialSegments the number of sides on each tube segments, optional, default 32
  23386. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23387. * * p the number of windings around the z axis, optional, default 2
  23388. * * q the number of windings around the x axis, optional, default 3
  23389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23390. * * 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)
  23391. * * 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)
  23392. * @returns the VertexData of the Torus Knot
  23393. */
  23394. static CreateTorusKnot(options: {
  23395. radius?: number;
  23396. tube?: number;
  23397. radialSegments?: number;
  23398. tubularSegments?: number;
  23399. p?: number;
  23400. q?: number;
  23401. sideOrientation?: number;
  23402. frontUVs?: Vector4;
  23403. backUVs?: Vector4;
  23404. }): VertexData;
  23405. /**
  23406. * Compute normals for given positions and indices
  23407. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23408. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23409. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23410. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23411. * * facetNormals : optional array of facet normals (vector3)
  23412. * * facetPositions : optional array of facet positions (vector3)
  23413. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23414. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23415. * * bInfo : optional bounding info, required for facetPartitioning computation
  23416. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23417. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23418. * * useRightHandedSystem: optional boolean to for right handed system computation
  23419. * * depthSort : optional boolean to enable the facet depth sort computation
  23420. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23421. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23422. */
  23423. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23424. facetNormals?: any;
  23425. facetPositions?: any;
  23426. facetPartitioning?: any;
  23427. ratio?: number;
  23428. bInfo?: any;
  23429. bbSize?: Vector3;
  23430. subDiv?: any;
  23431. useRightHandedSystem?: boolean;
  23432. depthSort?: boolean;
  23433. distanceTo?: Vector3;
  23434. depthSortedFacets?: any;
  23435. }): void;
  23436. /** @hidden */
  23437. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23438. /**
  23439. * Applies VertexData created from the imported parameters to the geometry
  23440. * @param parsedVertexData the parsed data from an imported file
  23441. * @param geometry the geometry to apply the VertexData to
  23442. */
  23443. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23444. }
  23445. }
  23446. declare module "babylonjs/Morph/morphTarget" {
  23447. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23448. import { Observable } from "babylonjs/Misc/observable";
  23449. import { Nullable, FloatArray } from "babylonjs/types";
  23450. import { Scene } from "babylonjs/scene";
  23451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23452. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23453. /**
  23454. * Defines a target to use with MorphTargetManager
  23455. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23456. */
  23457. export class MorphTarget implements IAnimatable {
  23458. /** defines the name of the target */
  23459. name: string;
  23460. /**
  23461. * Gets or sets the list of animations
  23462. */
  23463. animations: import("babylonjs/Animations/animation").Animation[];
  23464. private _scene;
  23465. private _positions;
  23466. private _normals;
  23467. private _tangents;
  23468. private _uvs;
  23469. private _influence;
  23470. private _uniqueId;
  23471. /**
  23472. * Observable raised when the influence changes
  23473. */
  23474. onInfluenceChanged: Observable<boolean>;
  23475. /** @hidden */
  23476. _onDataLayoutChanged: Observable<void>;
  23477. /**
  23478. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23479. */
  23480. get influence(): number;
  23481. set influence(influence: number);
  23482. /**
  23483. * Gets or sets the id of the morph Target
  23484. */
  23485. id: string;
  23486. private _animationPropertiesOverride;
  23487. /**
  23488. * Gets or sets the animation properties override
  23489. */
  23490. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23491. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23492. /**
  23493. * Creates a new MorphTarget
  23494. * @param name defines the name of the target
  23495. * @param influence defines the influence to use
  23496. * @param scene defines the scene the morphtarget belongs to
  23497. */
  23498. constructor(
  23499. /** defines the name of the target */
  23500. name: string, influence?: number, scene?: Nullable<Scene>);
  23501. /**
  23502. * Gets the unique ID of this manager
  23503. */
  23504. get uniqueId(): number;
  23505. /**
  23506. * Gets a boolean defining if the target contains position data
  23507. */
  23508. get hasPositions(): boolean;
  23509. /**
  23510. * Gets a boolean defining if the target contains normal data
  23511. */
  23512. get hasNormals(): boolean;
  23513. /**
  23514. * Gets a boolean defining if the target contains tangent data
  23515. */
  23516. get hasTangents(): boolean;
  23517. /**
  23518. * Gets a boolean defining if the target contains texture coordinates data
  23519. */
  23520. get hasUVs(): boolean;
  23521. /**
  23522. * Affects position data to this target
  23523. * @param data defines the position data to use
  23524. */
  23525. setPositions(data: Nullable<FloatArray>): void;
  23526. /**
  23527. * Gets the position data stored in this target
  23528. * @returns a FloatArray containing the position data (or null if not present)
  23529. */
  23530. getPositions(): Nullable<FloatArray>;
  23531. /**
  23532. * Affects normal data to this target
  23533. * @param data defines the normal data to use
  23534. */
  23535. setNormals(data: Nullable<FloatArray>): void;
  23536. /**
  23537. * Gets the normal data stored in this target
  23538. * @returns a FloatArray containing the normal data (or null if not present)
  23539. */
  23540. getNormals(): Nullable<FloatArray>;
  23541. /**
  23542. * Affects tangent data to this target
  23543. * @param data defines the tangent data to use
  23544. */
  23545. setTangents(data: Nullable<FloatArray>): void;
  23546. /**
  23547. * Gets the tangent data stored in this target
  23548. * @returns a FloatArray containing the tangent data (or null if not present)
  23549. */
  23550. getTangents(): Nullable<FloatArray>;
  23551. /**
  23552. * Affects texture coordinates data to this target
  23553. * @param data defines the texture coordinates data to use
  23554. */
  23555. setUVs(data: Nullable<FloatArray>): void;
  23556. /**
  23557. * Gets the texture coordinates data stored in this target
  23558. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23559. */
  23560. getUVs(): Nullable<FloatArray>;
  23561. /**
  23562. * Clone the current target
  23563. * @returns a new MorphTarget
  23564. */
  23565. clone(): MorphTarget;
  23566. /**
  23567. * Serializes the current target into a Serialization object
  23568. * @returns the serialized object
  23569. */
  23570. serialize(): any;
  23571. /**
  23572. * Returns the string "MorphTarget"
  23573. * @returns "MorphTarget"
  23574. */
  23575. getClassName(): string;
  23576. /**
  23577. * Creates a new target from serialized data
  23578. * @param serializationObject defines the serialized data to use
  23579. * @returns a new MorphTarget
  23580. */
  23581. static Parse(serializationObject: any): MorphTarget;
  23582. /**
  23583. * Creates a MorphTarget from mesh data
  23584. * @param mesh defines the source mesh
  23585. * @param name defines the name to use for the new target
  23586. * @param influence defines the influence to attach to the target
  23587. * @returns a new MorphTarget
  23588. */
  23589. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23590. }
  23591. }
  23592. declare module "babylonjs/Morph/morphTargetManager" {
  23593. import { Nullable } from "babylonjs/types";
  23594. import { Scene } from "babylonjs/scene";
  23595. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23596. /**
  23597. * This class is used to deform meshes using morphing between different targets
  23598. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23599. */
  23600. export class MorphTargetManager {
  23601. private _targets;
  23602. private _targetInfluenceChangedObservers;
  23603. private _targetDataLayoutChangedObservers;
  23604. private _activeTargets;
  23605. private _scene;
  23606. private _influences;
  23607. private _supportsNormals;
  23608. private _supportsTangents;
  23609. private _supportsUVs;
  23610. private _vertexCount;
  23611. private _uniqueId;
  23612. private _tempInfluences;
  23613. /**
  23614. * Gets or sets a boolean indicating if normals must be morphed
  23615. */
  23616. enableNormalMorphing: boolean;
  23617. /**
  23618. * Gets or sets a boolean indicating if tangents must be morphed
  23619. */
  23620. enableTangentMorphing: boolean;
  23621. /**
  23622. * Gets or sets a boolean indicating if UV must be morphed
  23623. */
  23624. enableUVMorphing: boolean;
  23625. /**
  23626. * Creates a new MorphTargetManager
  23627. * @param scene defines the current scene
  23628. */
  23629. constructor(scene?: Nullable<Scene>);
  23630. /**
  23631. * Gets the unique ID of this manager
  23632. */
  23633. get uniqueId(): number;
  23634. /**
  23635. * Gets the number of vertices handled by this manager
  23636. */
  23637. get vertexCount(): number;
  23638. /**
  23639. * Gets a boolean indicating if this manager supports morphing of normals
  23640. */
  23641. get supportsNormals(): boolean;
  23642. /**
  23643. * Gets a boolean indicating if this manager supports morphing of tangents
  23644. */
  23645. get supportsTangents(): boolean;
  23646. /**
  23647. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23648. */
  23649. get supportsUVs(): boolean;
  23650. /**
  23651. * Gets the number of targets stored in this manager
  23652. */
  23653. get numTargets(): number;
  23654. /**
  23655. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23656. */
  23657. get numInfluencers(): number;
  23658. /**
  23659. * Gets the list of influences (one per target)
  23660. */
  23661. get influences(): Float32Array;
  23662. /**
  23663. * Gets the active target at specified index. An active target is a target with an influence > 0
  23664. * @param index defines the index to check
  23665. * @returns the requested target
  23666. */
  23667. getActiveTarget(index: number): MorphTarget;
  23668. /**
  23669. * Gets the target at specified index
  23670. * @param index defines the index to check
  23671. * @returns the requested target
  23672. */
  23673. getTarget(index: number): MorphTarget;
  23674. /**
  23675. * Add a new target to this manager
  23676. * @param target defines the target to add
  23677. */
  23678. addTarget(target: MorphTarget): void;
  23679. /**
  23680. * Removes a target from the manager
  23681. * @param target defines the target to remove
  23682. */
  23683. removeTarget(target: MorphTarget): void;
  23684. /**
  23685. * Clone the current manager
  23686. * @returns a new MorphTargetManager
  23687. */
  23688. clone(): MorphTargetManager;
  23689. /**
  23690. * Serializes the current manager into a Serialization object
  23691. * @returns the serialized object
  23692. */
  23693. serialize(): any;
  23694. private _syncActiveTargets;
  23695. /**
  23696. * Syncrhonize the targets with all the meshes using this morph target manager
  23697. */
  23698. synchronize(): void;
  23699. /**
  23700. * Creates a new MorphTargetManager from serialized data
  23701. * @param serializationObject defines the serialized data
  23702. * @param scene defines the hosting scene
  23703. * @returns the new MorphTargetManager
  23704. */
  23705. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23706. }
  23707. }
  23708. declare module "babylonjs/Meshes/meshLODLevel" {
  23709. import { Mesh } from "babylonjs/Meshes/mesh";
  23710. import { Nullable } from "babylonjs/types";
  23711. /**
  23712. * Class used to represent a specific level of detail of a mesh
  23713. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23714. */
  23715. export class MeshLODLevel {
  23716. /** Defines the distance where this level should start being displayed */
  23717. distance: number;
  23718. /** Defines the mesh to use to render this level */
  23719. mesh: Nullable<Mesh>;
  23720. /**
  23721. * Creates a new LOD level
  23722. * @param distance defines the distance where this level should star being displayed
  23723. * @param mesh defines the mesh to use to render this level
  23724. */
  23725. constructor(
  23726. /** Defines the distance where this level should start being displayed */
  23727. distance: number,
  23728. /** Defines the mesh to use to render this level */
  23729. mesh: Nullable<Mesh>);
  23730. }
  23731. }
  23732. declare module "babylonjs/Meshes/groundMesh" {
  23733. import { Scene } from "babylonjs/scene";
  23734. import { Vector3 } from "babylonjs/Maths/math.vector";
  23735. import { Mesh } from "babylonjs/Meshes/mesh";
  23736. /**
  23737. * Mesh representing the gorund
  23738. */
  23739. export class GroundMesh extends Mesh {
  23740. /** If octree should be generated */
  23741. generateOctree: boolean;
  23742. private _heightQuads;
  23743. /** @hidden */
  23744. _subdivisionsX: number;
  23745. /** @hidden */
  23746. _subdivisionsY: number;
  23747. /** @hidden */
  23748. _width: number;
  23749. /** @hidden */
  23750. _height: number;
  23751. /** @hidden */
  23752. _minX: number;
  23753. /** @hidden */
  23754. _maxX: number;
  23755. /** @hidden */
  23756. _minZ: number;
  23757. /** @hidden */
  23758. _maxZ: number;
  23759. constructor(name: string, scene: Scene);
  23760. /**
  23761. * "GroundMesh"
  23762. * @returns "GroundMesh"
  23763. */
  23764. getClassName(): string;
  23765. /**
  23766. * The minimum of x and y subdivisions
  23767. */
  23768. get subdivisions(): number;
  23769. /**
  23770. * X subdivisions
  23771. */
  23772. get subdivisionsX(): number;
  23773. /**
  23774. * Y subdivisions
  23775. */
  23776. get subdivisionsY(): number;
  23777. /**
  23778. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23779. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23780. * @param chunksCount the number of subdivisions for x and y
  23781. * @param octreeBlocksSize (Default: 32)
  23782. */
  23783. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23784. /**
  23785. * Returns a height (y) value in the Worl system :
  23786. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23787. * @param x x coordinate
  23788. * @param z z coordinate
  23789. * @returns the ground y position if (x, z) are outside the ground surface.
  23790. */
  23791. getHeightAtCoordinates(x: number, z: number): number;
  23792. /**
  23793. * Returns a normalized vector (Vector3) orthogonal to the ground
  23794. * at the ground coordinates (x, z) expressed in the World system.
  23795. * @param x x coordinate
  23796. * @param z z coordinate
  23797. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23798. */
  23799. getNormalAtCoordinates(x: number, z: number): Vector3;
  23800. /**
  23801. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23802. * at the ground coordinates (x, z) expressed in the World system.
  23803. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23804. * @param x x coordinate
  23805. * @param z z coordinate
  23806. * @param ref vector to store the result
  23807. * @returns the GroundMesh.
  23808. */
  23809. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23810. /**
  23811. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23812. * if the ground has been updated.
  23813. * This can be used in the render loop.
  23814. * @returns the GroundMesh.
  23815. */
  23816. updateCoordinateHeights(): GroundMesh;
  23817. private _getFacetAt;
  23818. private _initHeightQuads;
  23819. private _computeHeightQuads;
  23820. /**
  23821. * Serializes this ground mesh
  23822. * @param serializationObject object to write serialization to
  23823. */
  23824. serialize(serializationObject: any): void;
  23825. /**
  23826. * Parses a serialized ground mesh
  23827. * @param parsedMesh the serialized mesh
  23828. * @param scene the scene to create the ground mesh in
  23829. * @returns the created ground mesh
  23830. */
  23831. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23832. }
  23833. }
  23834. declare module "babylonjs/Physics/physicsJoint" {
  23835. import { Vector3 } from "babylonjs/Maths/math.vector";
  23836. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23837. /**
  23838. * Interface for Physics-Joint data
  23839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23840. */
  23841. export interface PhysicsJointData {
  23842. /**
  23843. * The main pivot of the joint
  23844. */
  23845. mainPivot?: Vector3;
  23846. /**
  23847. * The connected pivot of the joint
  23848. */
  23849. connectedPivot?: Vector3;
  23850. /**
  23851. * The main axis of the joint
  23852. */
  23853. mainAxis?: Vector3;
  23854. /**
  23855. * The connected axis of the joint
  23856. */
  23857. connectedAxis?: Vector3;
  23858. /**
  23859. * The collision of the joint
  23860. */
  23861. collision?: boolean;
  23862. /**
  23863. * Native Oimo/Cannon/Energy data
  23864. */
  23865. nativeParams?: any;
  23866. }
  23867. /**
  23868. * This is a holder class for the physics joint created by the physics plugin
  23869. * It holds a set of functions to control the underlying joint
  23870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23871. */
  23872. export class PhysicsJoint {
  23873. /**
  23874. * The type of the physics joint
  23875. */
  23876. type: number;
  23877. /**
  23878. * The data for the physics joint
  23879. */
  23880. jointData: PhysicsJointData;
  23881. private _physicsJoint;
  23882. protected _physicsPlugin: IPhysicsEnginePlugin;
  23883. /**
  23884. * Initializes the physics joint
  23885. * @param type The type of the physics joint
  23886. * @param jointData The data for the physics joint
  23887. */
  23888. constructor(
  23889. /**
  23890. * The type of the physics joint
  23891. */
  23892. type: number,
  23893. /**
  23894. * The data for the physics joint
  23895. */
  23896. jointData: PhysicsJointData);
  23897. /**
  23898. * Gets the physics joint
  23899. */
  23900. get physicsJoint(): any;
  23901. /**
  23902. * Sets the physics joint
  23903. */
  23904. set physicsJoint(newJoint: any);
  23905. /**
  23906. * Sets the physics plugin
  23907. */
  23908. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23909. /**
  23910. * Execute a function that is physics-plugin specific.
  23911. * @param {Function} func the function that will be executed.
  23912. * It accepts two parameters: the physics world and the physics joint
  23913. */
  23914. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23915. /**
  23916. * Distance-Joint type
  23917. */
  23918. static DistanceJoint: number;
  23919. /**
  23920. * Hinge-Joint type
  23921. */
  23922. static HingeJoint: number;
  23923. /**
  23924. * Ball-and-Socket joint type
  23925. */
  23926. static BallAndSocketJoint: number;
  23927. /**
  23928. * Wheel-Joint type
  23929. */
  23930. static WheelJoint: number;
  23931. /**
  23932. * Slider-Joint type
  23933. */
  23934. static SliderJoint: number;
  23935. /**
  23936. * Prismatic-Joint type
  23937. */
  23938. static PrismaticJoint: number;
  23939. /**
  23940. * Universal-Joint type
  23941. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23942. */
  23943. static UniversalJoint: number;
  23944. /**
  23945. * Hinge-Joint 2 type
  23946. */
  23947. static Hinge2Joint: number;
  23948. /**
  23949. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23950. */
  23951. static PointToPointJoint: number;
  23952. /**
  23953. * Spring-Joint type
  23954. */
  23955. static SpringJoint: number;
  23956. /**
  23957. * Lock-Joint type
  23958. */
  23959. static LockJoint: number;
  23960. }
  23961. /**
  23962. * A class representing a physics distance joint
  23963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23964. */
  23965. export class DistanceJoint extends PhysicsJoint {
  23966. /**
  23967. *
  23968. * @param jointData The data for the Distance-Joint
  23969. */
  23970. constructor(jointData: DistanceJointData);
  23971. /**
  23972. * Update the predefined distance.
  23973. * @param maxDistance The maximum preferred distance
  23974. * @param minDistance The minimum preferred distance
  23975. */
  23976. updateDistance(maxDistance: number, minDistance?: number): void;
  23977. }
  23978. /**
  23979. * Represents a Motor-Enabled Joint
  23980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23981. */
  23982. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23983. /**
  23984. * Initializes the Motor-Enabled Joint
  23985. * @param type The type of the joint
  23986. * @param jointData The physica joint data for the joint
  23987. */
  23988. constructor(type: number, jointData: PhysicsJointData);
  23989. /**
  23990. * Set the motor values.
  23991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23992. * @param force the force to apply
  23993. * @param maxForce max force for this motor.
  23994. */
  23995. setMotor(force?: number, maxForce?: number): void;
  23996. /**
  23997. * Set the motor's limits.
  23998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23999. * @param upperLimit The upper limit of the motor
  24000. * @param lowerLimit The lower limit of the motor
  24001. */
  24002. setLimit(upperLimit: number, lowerLimit?: number): void;
  24003. }
  24004. /**
  24005. * This class represents a single physics Hinge-Joint
  24006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24007. */
  24008. export class HingeJoint extends MotorEnabledJoint {
  24009. /**
  24010. * Initializes the Hinge-Joint
  24011. * @param jointData The joint data for the Hinge-Joint
  24012. */
  24013. constructor(jointData: PhysicsJointData);
  24014. /**
  24015. * Set the motor values.
  24016. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24017. * @param {number} force the force to apply
  24018. * @param {number} maxForce max force for this motor.
  24019. */
  24020. setMotor(force?: number, maxForce?: number): void;
  24021. /**
  24022. * Set the motor's limits.
  24023. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24024. * @param upperLimit The upper limit of the motor
  24025. * @param lowerLimit The lower limit of the motor
  24026. */
  24027. setLimit(upperLimit: number, lowerLimit?: number): void;
  24028. }
  24029. /**
  24030. * This class represents a dual hinge physics joint (same as wheel joint)
  24031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24032. */
  24033. export class Hinge2Joint extends MotorEnabledJoint {
  24034. /**
  24035. * Initializes the Hinge2-Joint
  24036. * @param jointData The joint data for the Hinge2-Joint
  24037. */
  24038. constructor(jointData: PhysicsJointData);
  24039. /**
  24040. * Set the motor values.
  24041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24042. * @param {number} targetSpeed the speed the motor is to reach
  24043. * @param {number} maxForce max force for this motor.
  24044. * @param {motorIndex} the motor's index, 0 or 1.
  24045. */
  24046. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24047. /**
  24048. * Set the motor limits.
  24049. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24050. * @param {number} upperLimit the upper limit
  24051. * @param {number} lowerLimit lower limit
  24052. * @param {motorIndex} the motor's index, 0 or 1.
  24053. */
  24054. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24055. }
  24056. /**
  24057. * Interface for a motor enabled joint
  24058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24059. */
  24060. export interface IMotorEnabledJoint {
  24061. /**
  24062. * Physics joint
  24063. */
  24064. physicsJoint: any;
  24065. /**
  24066. * Sets the motor of the motor-enabled joint
  24067. * @param force The force of the motor
  24068. * @param maxForce The maximum force of the motor
  24069. * @param motorIndex The index of the motor
  24070. */
  24071. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24072. /**
  24073. * Sets the limit of the motor
  24074. * @param upperLimit The upper limit of the motor
  24075. * @param lowerLimit The lower limit of the motor
  24076. * @param motorIndex The index of the motor
  24077. */
  24078. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24079. }
  24080. /**
  24081. * Joint data for a Distance-Joint
  24082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24083. */
  24084. export interface DistanceJointData extends PhysicsJointData {
  24085. /**
  24086. * Max distance the 2 joint objects can be apart
  24087. */
  24088. maxDistance: number;
  24089. }
  24090. /**
  24091. * Joint data from a spring joint
  24092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24093. */
  24094. export interface SpringJointData extends PhysicsJointData {
  24095. /**
  24096. * Length of the spring
  24097. */
  24098. length: number;
  24099. /**
  24100. * Stiffness of the spring
  24101. */
  24102. stiffness: number;
  24103. /**
  24104. * Damping of the spring
  24105. */
  24106. damping: number;
  24107. /** this callback will be called when applying the force to the impostors. */
  24108. forceApplicationCallback: () => void;
  24109. }
  24110. }
  24111. declare module "babylonjs/Physics/physicsRaycastResult" {
  24112. import { Vector3 } from "babylonjs/Maths/math.vector";
  24113. /**
  24114. * Holds the data for the raycast result
  24115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24116. */
  24117. export class PhysicsRaycastResult {
  24118. private _hasHit;
  24119. private _hitDistance;
  24120. private _hitNormalWorld;
  24121. private _hitPointWorld;
  24122. private _rayFromWorld;
  24123. private _rayToWorld;
  24124. /**
  24125. * Gets if there was a hit
  24126. */
  24127. get hasHit(): boolean;
  24128. /**
  24129. * Gets the distance from the hit
  24130. */
  24131. get hitDistance(): number;
  24132. /**
  24133. * Gets the hit normal/direction in the world
  24134. */
  24135. get hitNormalWorld(): Vector3;
  24136. /**
  24137. * Gets the hit point in the world
  24138. */
  24139. get hitPointWorld(): Vector3;
  24140. /**
  24141. * Gets the ray "start point" of the ray in the world
  24142. */
  24143. get rayFromWorld(): Vector3;
  24144. /**
  24145. * Gets the ray "end point" of the ray in the world
  24146. */
  24147. get rayToWorld(): Vector3;
  24148. /**
  24149. * Sets the hit data (normal & point in world space)
  24150. * @param hitNormalWorld defines the normal in world space
  24151. * @param hitPointWorld defines the point in world space
  24152. */
  24153. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24154. /**
  24155. * Sets the distance from the start point to the hit point
  24156. * @param distance
  24157. */
  24158. setHitDistance(distance: number): void;
  24159. /**
  24160. * Calculates the distance manually
  24161. */
  24162. calculateHitDistance(): void;
  24163. /**
  24164. * Resets all the values to default
  24165. * @param from The from point on world space
  24166. * @param to The to point on world space
  24167. */
  24168. reset(from?: Vector3, to?: Vector3): void;
  24169. }
  24170. /**
  24171. * Interface for the size containing width and height
  24172. */
  24173. interface IXYZ {
  24174. /**
  24175. * X
  24176. */
  24177. x: number;
  24178. /**
  24179. * Y
  24180. */
  24181. y: number;
  24182. /**
  24183. * Z
  24184. */
  24185. z: number;
  24186. }
  24187. }
  24188. declare module "babylonjs/Physics/IPhysicsEngine" {
  24189. import { Nullable } from "babylonjs/types";
  24190. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24192. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24193. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24194. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24195. /**
  24196. * Interface used to describe a physics joint
  24197. */
  24198. export interface PhysicsImpostorJoint {
  24199. /** Defines the main impostor to which the joint is linked */
  24200. mainImpostor: PhysicsImpostor;
  24201. /** Defines the impostor that is connected to the main impostor using this joint */
  24202. connectedImpostor: PhysicsImpostor;
  24203. /** Defines the joint itself */
  24204. joint: PhysicsJoint;
  24205. }
  24206. /** @hidden */
  24207. export interface IPhysicsEnginePlugin {
  24208. world: any;
  24209. name: string;
  24210. setGravity(gravity: Vector3): void;
  24211. setTimeStep(timeStep: number): void;
  24212. getTimeStep(): number;
  24213. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24214. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24215. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24216. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24217. removePhysicsBody(impostor: PhysicsImpostor): void;
  24218. generateJoint(joint: PhysicsImpostorJoint): void;
  24219. removeJoint(joint: PhysicsImpostorJoint): void;
  24220. isSupported(): boolean;
  24221. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24222. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24223. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24224. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24225. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24226. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24227. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24228. getBodyMass(impostor: PhysicsImpostor): number;
  24229. getBodyFriction(impostor: PhysicsImpostor): number;
  24230. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24231. getBodyRestitution(impostor: PhysicsImpostor): number;
  24232. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24233. getBodyPressure?(impostor: PhysicsImpostor): number;
  24234. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24235. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24236. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24237. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24238. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24239. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24240. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24241. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24242. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24243. sleepBody(impostor: PhysicsImpostor): void;
  24244. wakeUpBody(impostor: PhysicsImpostor): void;
  24245. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24246. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24247. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24248. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24249. getRadius(impostor: PhysicsImpostor): number;
  24250. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24251. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24252. dispose(): void;
  24253. }
  24254. /**
  24255. * Interface used to define a physics engine
  24256. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24257. */
  24258. export interface IPhysicsEngine {
  24259. /**
  24260. * Gets the gravity vector used by the simulation
  24261. */
  24262. gravity: Vector3;
  24263. /**
  24264. * Sets the gravity vector used by the simulation
  24265. * @param gravity defines the gravity vector to use
  24266. */
  24267. setGravity(gravity: Vector3): void;
  24268. /**
  24269. * Set the time step of the physics engine.
  24270. * Default is 1/60.
  24271. * To slow it down, enter 1/600 for example.
  24272. * To speed it up, 1/30
  24273. * @param newTimeStep the new timestep to apply to this world.
  24274. */
  24275. setTimeStep(newTimeStep: number): void;
  24276. /**
  24277. * Get the time step of the physics engine.
  24278. * @returns the current time step
  24279. */
  24280. getTimeStep(): number;
  24281. /**
  24282. * Set the sub time step of the physics engine.
  24283. * Default is 0 meaning there is no sub steps
  24284. * To increase physics resolution precision, set a small value (like 1 ms)
  24285. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24286. */
  24287. setSubTimeStep(subTimeStep: number): void;
  24288. /**
  24289. * Get the sub time step of the physics engine.
  24290. * @returns the current sub time step
  24291. */
  24292. getSubTimeStep(): number;
  24293. /**
  24294. * Release all resources
  24295. */
  24296. dispose(): void;
  24297. /**
  24298. * Gets the name of the current physics plugin
  24299. * @returns the name of the plugin
  24300. */
  24301. getPhysicsPluginName(): string;
  24302. /**
  24303. * Adding a new impostor for the impostor tracking.
  24304. * This will be done by the impostor itself.
  24305. * @param impostor the impostor to add
  24306. */
  24307. addImpostor(impostor: PhysicsImpostor): void;
  24308. /**
  24309. * Remove an impostor from the engine.
  24310. * This impostor and its mesh will not longer be updated by the physics engine.
  24311. * @param impostor the impostor to remove
  24312. */
  24313. removeImpostor(impostor: PhysicsImpostor): void;
  24314. /**
  24315. * Add a joint to the physics engine
  24316. * @param mainImpostor defines the main impostor to which the joint is added.
  24317. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24318. * @param joint defines the joint that will connect both impostors.
  24319. */
  24320. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24321. /**
  24322. * Removes a joint from the simulation
  24323. * @param mainImpostor defines the impostor used with the joint
  24324. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24325. * @param joint defines the joint to remove
  24326. */
  24327. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24328. /**
  24329. * Gets the current plugin used to run the simulation
  24330. * @returns current plugin
  24331. */
  24332. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24333. /**
  24334. * Gets the list of physic impostors
  24335. * @returns an array of PhysicsImpostor
  24336. */
  24337. getImpostors(): Array<PhysicsImpostor>;
  24338. /**
  24339. * Gets the impostor for a physics enabled object
  24340. * @param object defines the object impersonated by the impostor
  24341. * @returns the PhysicsImpostor or null if not found
  24342. */
  24343. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24344. /**
  24345. * Gets the impostor for a physics body object
  24346. * @param body defines physics body used by the impostor
  24347. * @returns the PhysicsImpostor or null if not found
  24348. */
  24349. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24350. /**
  24351. * Does a raycast in the physics world
  24352. * @param from when should the ray start?
  24353. * @param to when should the ray end?
  24354. * @returns PhysicsRaycastResult
  24355. */
  24356. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24357. /**
  24358. * Called by the scene. No need to call it.
  24359. * @param delta defines the timespam between frames
  24360. */
  24361. _step(delta: number): void;
  24362. }
  24363. }
  24364. declare module "babylonjs/Physics/physicsImpostor" {
  24365. import { Nullable, IndicesArray } from "babylonjs/types";
  24366. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24369. import { Scene } from "babylonjs/scene";
  24370. import { Bone } from "babylonjs/Bones/bone";
  24371. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24372. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24373. import { Space } from "babylonjs/Maths/math.axis";
  24374. /**
  24375. * The interface for the physics imposter parameters
  24376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24377. */
  24378. export interface PhysicsImpostorParameters {
  24379. /**
  24380. * The mass of the physics imposter
  24381. */
  24382. mass: number;
  24383. /**
  24384. * The friction of the physics imposter
  24385. */
  24386. friction?: number;
  24387. /**
  24388. * The coefficient of restitution of the physics imposter
  24389. */
  24390. restitution?: number;
  24391. /**
  24392. * The native options of the physics imposter
  24393. */
  24394. nativeOptions?: any;
  24395. /**
  24396. * Specifies if the parent should be ignored
  24397. */
  24398. ignoreParent?: boolean;
  24399. /**
  24400. * Specifies if bi-directional transformations should be disabled
  24401. */
  24402. disableBidirectionalTransformation?: boolean;
  24403. /**
  24404. * The pressure inside the physics imposter, soft object only
  24405. */
  24406. pressure?: number;
  24407. /**
  24408. * The stiffness the physics imposter, soft object only
  24409. */
  24410. stiffness?: number;
  24411. /**
  24412. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24413. */
  24414. velocityIterations?: number;
  24415. /**
  24416. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24417. */
  24418. positionIterations?: number;
  24419. /**
  24420. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24421. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24422. * Add to fix multiple points
  24423. */
  24424. fixedPoints?: number;
  24425. /**
  24426. * The collision margin around a soft object
  24427. */
  24428. margin?: number;
  24429. /**
  24430. * The collision margin around a soft object
  24431. */
  24432. damping?: number;
  24433. /**
  24434. * The path for a rope based on an extrusion
  24435. */
  24436. path?: any;
  24437. /**
  24438. * The shape of an extrusion used for a rope based on an extrusion
  24439. */
  24440. shape?: any;
  24441. }
  24442. /**
  24443. * Interface for a physics-enabled object
  24444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24445. */
  24446. export interface IPhysicsEnabledObject {
  24447. /**
  24448. * The position of the physics-enabled object
  24449. */
  24450. position: Vector3;
  24451. /**
  24452. * The rotation of the physics-enabled object
  24453. */
  24454. rotationQuaternion: Nullable<Quaternion>;
  24455. /**
  24456. * The scale of the physics-enabled object
  24457. */
  24458. scaling: Vector3;
  24459. /**
  24460. * The rotation of the physics-enabled object
  24461. */
  24462. rotation?: Vector3;
  24463. /**
  24464. * The parent of the physics-enabled object
  24465. */
  24466. parent?: any;
  24467. /**
  24468. * The bounding info of the physics-enabled object
  24469. * @returns The bounding info of the physics-enabled object
  24470. */
  24471. getBoundingInfo(): BoundingInfo;
  24472. /**
  24473. * Computes the world matrix
  24474. * @param force Specifies if the world matrix should be computed by force
  24475. * @returns A world matrix
  24476. */
  24477. computeWorldMatrix(force: boolean): Matrix;
  24478. /**
  24479. * Gets the world matrix
  24480. * @returns A world matrix
  24481. */
  24482. getWorldMatrix?(): Matrix;
  24483. /**
  24484. * Gets the child meshes
  24485. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24486. * @returns An array of abstract meshes
  24487. */
  24488. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24489. /**
  24490. * Gets the vertex data
  24491. * @param kind The type of vertex data
  24492. * @returns A nullable array of numbers, or a float32 array
  24493. */
  24494. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24495. /**
  24496. * Gets the indices from the mesh
  24497. * @returns A nullable array of index arrays
  24498. */
  24499. getIndices?(): Nullable<IndicesArray>;
  24500. /**
  24501. * Gets the scene from the mesh
  24502. * @returns the indices array or null
  24503. */
  24504. getScene?(): Scene;
  24505. /**
  24506. * Gets the absolute position from the mesh
  24507. * @returns the absolute position
  24508. */
  24509. getAbsolutePosition(): Vector3;
  24510. /**
  24511. * Gets the absolute pivot point from the mesh
  24512. * @returns the absolute pivot point
  24513. */
  24514. getAbsolutePivotPoint(): Vector3;
  24515. /**
  24516. * Rotates the mesh
  24517. * @param axis The axis of rotation
  24518. * @param amount The amount of rotation
  24519. * @param space The space of the rotation
  24520. * @returns The rotation transform node
  24521. */
  24522. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24523. /**
  24524. * Translates the mesh
  24525. * @param axis The axis of translation
  24526. * @param distance The distance of translation
  24527. * @param space The space of the translation
  24528. * @returns The transform node
  24529. */
  24530. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24531. /**
  24532. * Sets the absolute position of the mesh
  24533. * @param absolutePosition The absolute position of the mesh
  24534. * @returns The transform node
  24535. */
  24536. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24537. /**
  24538. * Gets the class name of the mesh
  24539. * @returns The class name
  24540. */
  24541. getClassName(): string;
  24542. }
  24543. /**
  24544. * Represents a physics imposter
  24545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24546. */
  24547. export class PhysicsImpostor {
  24548. /**
  24549. * The physics-enabled object used as the physics imposter
  24550. */
  24551. object: IPhysicsEnabledObject;
  24552. /**
  24553. * The type of the physics imposter
  24554. */
  24555. type: number;
  24556. private _options;
  24557. private _scene?;
  24558. /**
  24559. * The default object size of the imposter
  24560. */
  24561. static DEFAULT_OBJECT_SIZE: Vector3;
  24562. /**
  24563. * The identity quaternion of the imposter
  24564. */
  24565. static IDENTITY_QUATERNION: Quaternion;
  24566. /** @hidden */
  24567. _pluginData: any;
  24568. private _physicsEngine;
  24569. private _physicsBody;
  24570. private _bodyUpdateRequired;
  24571. private _onBeforePhysicsStepCallbacks;
  24572. private _onAfterPhysicsStepCallbacks;
  24573. /** @hidden */
  24574. _onPhysicsCollideCallbacks: Array<{
  24575. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24576. otherImpostors: Array<PhysicsImpostor>;
  24577. }>;
  24578. private _deltaPosition;
  24579. private _deltaRotation;
  24580. private _deltaRotationConjugated;
  24581. /** @hidden */
  24582. _isFromLine: boolean;
  24583. private _parent;
  24584. private _isDisposed;
  24585. private static _tmpVecs;
  24586. private static _tmpQuat;
  24587. /**
  24588. * Specifies if the physics imposter is disposed
  24589. */
  24590. get isDisposed(): boolean;
  24591. /**
  24592. * Gets the mass of the physics imposter
  24593. */
  24594. get mass(): number;
  24595. set mass(value: number);
  24596. /**
  24597. * Gets the coefficient of friction
  24598. */
  24599. get friction(): number;
  24600. /**
  24601. * Sets the coefficient of friction
  24602. */
  24603. set friction(value: number);
  24604. /**
  24605. * Gets the coefficient of restitution
  24606. */
  24607. get restitution(): number;
  24608. /**
  24609. * Sets the coefficient of restitution
  24610. */
  24611. set restitution(value: number);
  24612. /**
  24613. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24614. */
  24615. get pressure(): number;
  24616. /**
  24617. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24618. */
  24619. set pressure(value: number);
  24620. /**
  24621. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24622. */
  24623. get stiffness(): number;
  24624. /**
  24625. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24626. */
  24627. set stiffness(value: number);
  24628. /**
  24629. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24630. */
  24631. get velocityIterations(): number;
  24632. /**
  24633. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24634. */
  24635. set velocityIterations(value: number);
  24636. /**
  24637. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24638. */
  24639. get positionIterations(): number;
  24640. /**
  24641. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24642. */
  24643. set positionIterations(value: number);
  24644. /**
  24645. * The unique id of the physics imposter
  24646. * set by the physics engine when adding this impostor to the array
  24647. */
  24648. uniqueId: number;
  24649. /**
  24650. * @hidden
  24651. */
  24652. soft: boolean;
  24653. /**
  24654. * @hidden
  24655. */
  24656. segments: number;
  24657. private _joints;
  24658. /**
  24659. * Initializes the physics imposter
  24660. * @param object The physics-enabled object used as the physics imposter
  24661. * @param type The type of the physics imposter
  24662. * @param _options The options for the physics imposter
  24663. * @param _scene The Babylon scene
  24664. */
  24665. constructor(
  24666. /**
  24667. * The physics-enabled object used as the physics imposter
  24668. */
  24669. object: IPhysicsEnabledObject,
  24670. /**
  24671. * The type of the physics imposter
  24672. */
  24673. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24674. /**
  24675. * This function will completly initialize this impostor.
  24676. * It will create a new body - but only if this mesh has no parent.
  24677. * If it has, this impostor will not be used other than to define the impostor
  24678. * of the child mesh.
  24679. * @hidden
  24680. */
  24681. _init(): void;
  24682. private _getPhysicsParent;
  24683. /**
  24684. * Should a new body be generated.
  24685. * @returns boolean specifying if body initialization is required
  24686. */
  24687. isBodyInitRequired(): boolean;
  24688. /**
  24689. * Sets the updated scaling
  24690. * @param updated Specifies if the scaling is updated
  24691. */
  24692. setScalingUpdated(): void;
  24693. /**
  24694. * Force a regeneration of this or the parent's impostor's body.
  24695. * Use under cautious - This will remove all joints already implemented.
  24696. */
  24697. forceUpdate(): void;
  24698. /**
  24699. * Gets the body that holds this impostor. Either its own, or its parent.
  24700. */
  24701. get physicsBody(): any;
  24702. /**
  24703. * Get the parent of the physics imposter
  24704. * @returns Physics imposter or null
  24705. */
  24706. get parent(): Nullable<PhysicsImpostor>;
  24707. /**
  24708. * Sets the parent of the physics imposter
  24709. */
  24710. set parent(value: Nullable<PhysicsImpostor>);
  24711. /**
  24712. * Set the physics body. Used mainly by the physics engine/plugin
  24713. */
  24714. set physicsBody(physicsBody: any);
  24715. /**
  24716. * Resets the update flags
  24717. */
  24718. resetUpdateFlags(): void;
  24719. /**
  24720. * Gets the object extend size
  24721. * @returns the object extend size
  24722. */
  24723. getObjectExtendSize(): Vector3;
  24724. /**
  24725. * Gets the object center
  24726. * @returns The object center
  24727. */
  24728. getObjectCenter(): Vector3;
  24729. /**
  24730. * Get a specific parameter from the options parameters
  24731. * @param paramName The object parameter name
  24732. * @returns The object parameter
  24733. */
  24734. getParam(paramName: string): any;
  24735. /**
  24736. * Sets a specific parameter in the options given to the physics plugin
  24737. * @param paramName The parameter name
  24738. * @param value The value of the parameter
  24739. */
  24740. setParam(paramName: string, value: number): void;
  24741. /**
  24742. * Specifically change the body's mass option. Won't recreate the physics body object
  24743. * @param mass The mass of the physics imposter
  24744. */
  24745. setMass(mass: number): void;
  24746. /**
  24747. * Gets the linear velocity
  24748. * @returns linear velocity or null
  24749. */
  24750. getLinearVelocity(): Nullable<Vector3>;
  24751. /**
  24752. * Sets the linear velocity
  24753. * @param velocity linear velocity or null
  24754. */
  24755. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24756. /**
  24757. * Gets the angular velocity
  24758. * @returns angular velocity or null
  24759. */
  24760. getAngularVelocity(): Nullable<Vector3>;
  24761. /**
  24762. * Sets the angular velocity
  24763. * @param velocity The velocity or null
  24764. */
  24765. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24766. /**
  24767. * Execute a function with the physics plugin native code
  24768. * Provide a function the will have two variables - the world object and the physics body object
  24769. * @param func The function to execute with the physics plugin native code
  24770. */
  24771. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24772. /**
  24773. * Register a function that will be executed before the physics world is stepping forward
  24774. * @param func The function to execute before the physics world is stepped forward
  24775. */
  24776. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24777. /**
  24778. * Unregister a function that will be executed before the physics world is stepping forward
  24779. * @param func The function to execute before the physics world is stepped forward
  24780. */
  24781. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24782. /**
  24783. * Register a function that will be executed after the physics step
  24784. * @param func The function to execute after physics step
  24785. */
  24786. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24787. /**
  24788. * Unregisters a function that will be executed after the physics step
  24789. * @param func The function to execute after physics step
  24790. */
  24791. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24792. /**
  24793. * register a function that will be executed when this impostor collides against a different body
  24794. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24795. * @param func Callback that is executed on collision
  24796. */
  24797. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24798. /**
  24799. * Unregisters the physics imposter on contact
  24800. * @param collideAgainst The physics object to collide against
  24801. * @param func Callback to execute on collision
  24802. */
  24803. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24804. private _tmpQuat;
  24805. private _tmpQuat2;
  24806. /**
  24807. * Get the parent rotation
  24808. * @returns The parent rotation
  24809. */
  24810. getParentsRotation(): Quaternion;
  24811. /**
  24812. * this function is executed by the physics engine.
  24813. */
  24814. beforeStep: () => void;
  24815. /**
  24816. * this function is executed by the physics engine
  24817. */
  24818. afterStep: () => void;
  24819. /**
  24820. * Legacy collision detection event support
  24821. */
  24822. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24823. /**
  24824. * event and body object due to cannon's event-based architecture.
  24825. */
  24826. onCollide: (e: {
  24827. body: any;
  24828. }) => void;
  24829. /**
  24830. * Apply a force
  24831. * @param force The force to apply
  24832. * @param contactPoint The contact point for the force
  24833. * @returns The physics imposter
  24834. */
  24835. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24836. /**
  24837. * Apply an impulse
  24838. * @param force The impulse force
  24839. * @param contactPoint The contact point for the impulse force
  24840. * @returns The physics imposter
  24841. */
  24842. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24843. /**
  24844. * A help function to create a joint
  24845. * @param otherImpostor A physics imposter used to create a joint
  24846. * @param jointType The type of joint
  24847. * @param jointData The data for the joint
  24848. * @returns The physics imposter
  24849. */
  24850. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24851. /**
  24852. * Add a joint to this impostor with a different impostor
  24853. * @param otherImpostor A physics imposter used to add a joint
  24854. * @param joint The joint to add
  24855. * @returns The physics imposter
  24856. */
  24857. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24858. /**
  24859. * Add an anchor to a cloth impostor
  24860. * @param otherImpostor rigid impostor to anchor to
  24861. * @param width ratio across width from 0 to 1
  24862. * @param height ratio up height from 0 to 1
  24863. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24864. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24865. * @returns impostor the soft imposter
  24866. */
  24867. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24868. /**
  24869. * Add a hook to a rope impostor
  24870. * @param otherImpostor rigid impostor to anchor to
  24871. * @param length ratio across rope from 0 to 1
  24872. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24874. * @returns impostor the rope imposter
  24875. */
  24876. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24877. /**
  24878. * Will keep this body still, in a sleep mode.
  24879. * @returns the physics imposter
  24880. */
  24881. sleep(): PhysicsImpostor;
  24882. /**
  24883. * Wake the body up.
  24884. * @returns The physics imposter
  24885. */
  24886. wakeUp(): PhysicsImpostor;
  24887. /**
  24888. * Clones the physics imposter
  24889. * @param newObject The physics imposter clones to this physics-enabled object
  24890. * @returns A nullable physics imposter
  24891. */
  24892. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24893. /**
  24894. * Disposes the physics imposter
  24895. */
  24896. dispose(): void;
  24897. /**
  24898. * Sets the delta position
  24899. * @param position The delta position amount
  24900. */
  24901. setDeltaPosition(position: Vector3): void;
  24902. /**
  24903. * Sets the delta rotation
  24904. * @param rotation The delta rotation amount
  24905. */
  24906. setDeltaRotation(rotation: Quaternion): void;
  24907. /**
  24908. * Gets the box size of the physics imposter and stores the result in the input parameter
  24909. * @param result Stores the box size
  24910. * @returns The physics imposter
  24911. */
  24912. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24913. /**
  24914. * Gets the radius of the physics imposter
  24915. * @returns Radius of the physics imposter
  24916. */
  24917. getRadius(): number;
  24918. /**
  24919. * Sync a bone with this impostor
  24920. * @param bone The bone to sync to the impostor.
  24921. * @param boneMesh The mesh that the bone is influencing.
  24922. * @param jointPivot The pivot of the joint / bone in local space.
  24923. * @param distToJoint Optional distance from the impostor to the joint.
  24924. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24925. */
  24926. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24927. /**
  24928. * Sync impostor to a bone
  24929. * @param bone The bone that the impostor will be synced to.
  24930. * @param boneMesh The mesh that the bone is influencing.
  24931. * @param jointPivot The pivot of the joint / bone in local space.
  24932. * @param distToJoint Optional distance from the impostor to the joint.
  24933. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24934. * @param boneAxis Optional vector3 axis the bone is aligned with
  24935. */
  24936. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24937. /**
  24938. * No-Imposter type
  24939. */
  24940. static NoImpostor: number;
  24941. /**
  24942. * Sphere-Imposter type
  24943. */
  24944. static SphereImpostor: number;
  24945. /**
  24946. * Box-Imposter type
  24947. */
  24948. static BoxImpostor: number;
  24949. /**
  24950. * Plane-Imposter type
  24951. */
  24952. static PlaneImpostor: number;
  24953. /**
  24954. * Mesh-imposter type
  24955. */
  24956. static MeshImpostor: number;
  24957. /**
  24958. * Capsule-Impostor type (Ammo.js plugin only)
  24959. */
  24960. static CapsuleImpostor: number;
  24961. /**
  24962. * Cylinder-Imposter type
  24963. */
  24964. static CylinderImpostor: number;
  24965. /**
  24966. * Particle-Imposter type
  24967. */
  24968. static ParticleImpostor: number;
  24969. /**
  24970. * Heightmap-Imposter type
  24971. */
  24972. static HeightmapImpostor: number;
  24973. /**
  24974. * ConvexHull-Impostor type (Ammo.js plugin only)
  24975. */
  24976. static ConvexHullImpostor: number;
  24977. /**
  24978. * Custom-Imposter type (Ammo.js plugin only)
  24979. */
  24980. static CustomImpostor: number;
  24981. /**
  24982. * Rope-Imposter type
  24983. */
  24984. static RopeImpostor: number;
  24985. /**
  24986. * Cloth-Imposter type
  24987. */
  24988. static ClothImpostor: number;
  24989. /**
  24990. * Softbody-Imposter type
  24991. */
  24992. static SoftbodyImpostor: number;
  24993. }
  24994. }
  24995. declare module "babylonjs/Meshes/mesh" {
  24996. import { Observable } from "babylonjs/Misc/observable";
  24997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24998. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24999. import { Camera } from "babylonjs/Cameras/camera";
  25000. import { Scene } from "babylonjs/scene";
  25001. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25002. import { Color4 } from "babylonjs/Maths/math.color";
  25003. import { Engine } from "babylonjs/Engines/engine";
  25004. import { Node } from "babylonjs/node";
  25005. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25006. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25007. import { Buffer } from "babylonjs/Meshes/buffer";
  25008. import { Geometry } from "babylonjs/Meshes/geometry";
  25009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25011. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25012. import { Effect } from "babylonjs/Materials/effect";
  25013. import { Material } from "babylonjs/Materials/material";
  25014. import { Skeleton } from "babylonjs/Bones/skeleton";
  25015. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25016. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25017. import { Path3D } from "babylonjs/Maths/math.path";
  25018. import { Plane } from "babylonjs/Maths/math.plane";
  25019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25020. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25022. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25023. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25024. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25025. /**
  25026. * @hidden
  25027. **/
  25028. export class _CreationDataStorage {
  25029. closePath?: boolean;
  25030. closeArray?: boolean;
  25031. idx: number[];
  25032. dashSize: number;
  25033. gapSize: number;
  25034. path3D: Path3D;
  25035. pathArray: Vector3[][];
  25036. arc: number;
  25037. radius: number;
  25038. cap: number;
  25039. tessellation: number;
  25040. }
  25041. /**
  25042. * @hidden
  25043. **/
  25044. class _InstanceDataStorage {
  25045. visibleInstances: any;
  25046. batchCache: _InstancesBatch;
  25047. instancesBufferSize: number;
  25048. instancesBuffer: Nullable<Buffer>;
  25049. instancesData: Float32Array;
  25050. overridenInstanceCount: number;
  25051. isFrozen: boolean;
  25052. previousBatch: Nullable<_InstancesBatch>;
  25053. hardwareInstancedRendering: boolean;
  25054. sideOrientation: number;
  25055. manualUpdate: boolean;
  25056. }
  25057. /**
  25058. * @hidden
  25059. **/
  25060. export class _InstancesBatch {
  25061. mustReturn: boolean;
  25062. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25063. renderSelf: boolean[];
  25064. hardwareInstancedRendering: boolean[];
  25065. }
  25066. /**
  25067. * Class used to represent renderable models
  25068. */
  25069. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25070. /**
  25071. * Mesh side orientation : usually the external or front surface
  25072. */
  25073. static readonly FRONTSIDE: number;
  25074. /**
  25075. * Mesh side orientation : usually the internal or back surface
  25076. */
  25077. static readonly BACKSIDE: number;
  25078. /**
  25079. * Mesh side orientation : both internal and external or front and back surfaces
  25080. */
  25081. static readonly DOUBLESIDE: number;
  25082. /**
  25083. * Mesh side orientation : by default, `FRONTSIDE`
  25084. */
  25085. static readonly DEFAULTSIDE: number;
  25086. /**
  25087. * Mesh cap setting : no cap
  25088. */
  25089. static readonly NO_CAP: number;
  25090. /**
  25091. * Mesh cap setting : one cap at the beginning of the mesh
  25092. */
  25093. static readonly CAP_START: number;
  25094. /**
  25095. * Mesh cap setting : one cap at the end of the mesh
  25096. */
  25097. static readonly CAP_END: number;
  25098. /**
  25099. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25100. */
  25101. static readonly CAP_ALL: number;
  25102. /**
  25103. * Mesh pattern setting : no flip or rotate
  25104. */
  25105. static readonly NO_FLIP: number;
  25106. /**
  25107. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25108. */
  25109. static readonly FLIP_TILE: number;
  25110. /**
  25111. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25112. */
  25113. static readonly ROTATE_TILE: number;
  25114. /**
  25115. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25116. */
  25117. static readonly FLIP_ROW: number;
  25118. /**
  25119. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25120. */
  25121. static readonly ROTATE_ROW: number;
  25122. /**
  25123. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25124. */
  25125. static readonly FLIP_N_ROTATE_TILE: number;
  25126. /**
  25127. * Mesh pattern setting : rotate pattern and rotate
  25128. */
  25129. static readonly FLIP_N_ROTATE_ROW: number;
  25130. /**
  25131. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25132. */
  25133. static readonly CENTER: number;
  25134. /**
  25135. * Mesh tile positioning : part tiles on left
  25136. */
  25137. static readonly LEFT: number;
  25138. /**
  25139. * Mesh tile positioning : part tiles on right
  25140. */
  25141. static readonly RIGHT: number;
  25142. /**
  25143. * Mesh tile positioning : part tiles on top
  25144. */
  25145. static readonly TOP: number;
  25146. /**
  25147. * Mesh tile positioning : part tiles on bottom
  25148. */
  25149. static readonly BOTTOM: number;
  25150. /**
  25151. * Gets the default side orientation.
  25152. * @param orientation the orientation to value to attempt to get
  25153. * @returns the default orientation
  25154. * @hidden
  25155. */
  25156. static _GetDefaultSideOrientation(orientation?: number): number;
  25157. private _internalMeshDataInfo;
  25158. /**
  25159. * An event triggered before rendering the mesh
  25160. */
  25161. get onBeforeRenderObservable(): Observable<Mesh>;
  25162. /**
  25163. * An event triggered before binding the mesh
  25164. */
  25165. get onBeforeBindObservable(): Observable<Mesh>;
  25166. /**
  25167. * An event triggered after rendering the mesh
  25168. */
  25169. get onAfterRenderObservable(): Observable<Mesh>;
  25170. /**
  25171. * An event triggered before drawing the mesh
  25172. */
  25173. get onBeforeDrawObservable(): Observable<Mesh>;
  25174. private _onBeforeDrawObserver;
  25175. /**
  25176. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25177. */
  25178. set onBeforeDraw(callback: () => void);
  25179. get hasInstances(): boolean;
  25180. /**
  25181. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25182. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25183. */
  25184. delayLoadState: number;
  25185. /**
  25186. * Gets the list of instances created from this mesh
  25187. * it is not supposed to be modified manually.
  25188. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25189. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25190. */
  25191. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25192. /**
  25193. * Gets the file containing delay loading data for this mesh
  25194. */
  25195. delayLoadingFile: string;
  25196. /** @hidden */
  25197. _binaryInfo: any;
  25198. /**
  25199. * User defined function used to change how LOD level selection is done
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25201. */
  25202. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25203. /**
  25204. * Gets or sets the morph target manager
  25205. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25206. */
  25207. get morphTargetManager(): Nullable<MorphTargetManager>;
  25208. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25209. /** @hidden */
  25210. _creationDataStorage: Nullable<_CreationDataStorage>;
  25211. /** @hidden */
  25212. _geometry: Nullable<Geometry>;
  25213. /** @hidden */
  25214. _delayInfo: Array<string>;
  25215. /** @hidden */
  25216. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25217. /** @hidden */
  25218. _instanceDataStorage: _InstanceDataStorage;
  25219. private _effectiveMaterial;
  25220. /** @hidden */
  25221. _shouldGenerateFlatShading: boolean;
  25222. /** @hidden */
  25223. _originalBuilderSideOrientation: number;
  25224. /**
  25225. * Use this property to change the original side orientation defined at construction time
  25226. */
  25227. overrideMaterialSideOrientation: Nullable<number>;
  25228. /**
  25229. * Gets the source mesh (the one used to clone this one from)
  25230. */
  25231. get source(): Nullable<Mesh>;
  25232. /**
  25233. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25234. */
  25235. get isUnIndexed(): boolean;
  25236. set isUnIndexed(value: boolean);
  25237. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25238. get worldMatrixInstancedBuffer(): Float32Array;
  25239. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25240. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25241. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25242. /**
  25243. * @constructor
  25244. * @param name The value used by scene.getMeshByName() to do a lookup.
  25245. * @param scene The scene to add this mesh to.
  25246. * @param parent The parent of this mesh, if it has one
  25247. * @param source An optional Mesh from which geometry is shared, cloned.
  25248. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25249. * When false, achieved by calling a clone(), also passing False.
  25250. * This will make creation of children, recursive.
  25251. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25252. */
  25253. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25254. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25255. doNotInstantiate: boolean;
  25256. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25257. /**
  25258. * Gets the class name
  25259. * @returns the string "Mesh".
  25260. */
  25261. getClassName(): string;
  25262. /** @hidden */
  25263. get _isMesh(): boolean;
  25264. /**
  25265. * Returns a description of this mesh
  25266. * @param fullDetails define if full details about this mesh must be used
  25267. * @returns a descriptive string representing this mesh
  25268. */
  25269. toString(fullDetails?: boolean): string;
  25270. /** @hidden */
  25271. _unBindEffect(): void;
  25272. /**
  25273. * Gets a boolean indicating if this mesh has LOD
  25274. */
  25275. get hasLODLevels(): boolean;
  25276. /**
  25277. * Gets the list of MeshLODLevel associated with the current mesh
  25278. * @returns an array of MeshLODLevel
  25279. */
  25280. getLODLevels(): MeshLODLevel[];
  25281. private _sortLODLevels;
  25282. /**
  25283. * Add a mesh as LOD level triggered at the given distance.
  25284. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25285. * @param distance The distance from the center of the object to show this level
  25286. * @param mesh The mesh to be added as LOD level (can be null)
  25287. * @return This mesh (for chaining)
  25288. */
  25289. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25290. /**
  25291. * Returns the LOD level mesh at the passed distance or null if not found.
  25292. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25293. * @param distance The distance from the center of the object to show this level
  25294. * @returns a Mesh or `null`
  25295. */
  25296. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25297. /**
  25298. * Remove a mesh from the LOD array
  25299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25300. * @param mesh defines the mesh to be removed
  25301. * @return This mesh (for chaining)
  25302. */
  25303. removeLODLevel(mesh: Mesh): Mesh;
  25304. /**
  25305. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25306. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25307. * @param camera defines the camera to use to compute distance
  25308. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25309. * @return This mesh (for chaining)
  25310. */
  25311. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25312. /**
  25313. * Gets the mesh internal Geometry object
  25314. */
  25315. get geometry(): Nullable<Geometry>;
  25316. /**
  25317. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25318. * @returns the total number of vertices
  25319. */
  25320. getTotalVertices(): number;
  25321. /**
  25322. * Returns the content of an associated vertex buffer
  25323. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25324. * - VertexBuffer.PositionKind
  25325. * - VertexBuffer.UVKind
  25326. * - VertexBuffer.UV2Kind
  25327. * - VertexBuffer.UV3Kind
  25328. * - VertexBuffer.UV4Kind
  25329. * - VertexBuffer.UV5Kind
  25330. * - VertexBuffer.UV6Kind
  25331. * - VertexBuffer.ColorKind
  25332. * - VertexBuffer.MatricesIndicesKind
  25333. * - VertexBuffer.MatricesIndicesExtraKind
  25334. * - VertexBuffer.MatricesWeightsKind
  25335. * - VertexBuffer.MatricesWeightsExtraKind
  25336. * @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
  25337. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25338. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25339. */
  25340. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25341. /**
  25342. * Returns the mesh VertexBuffer object from the requested `kind`
  25343. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25344. * - VertexBuffer.PositionKind
  25345. * - VertexBuffer.NormalKind
  25346. * - VertexBuffer.UVKind
  25347. * - VertexBuffer.UV2Kind
  25348. * - VertexBuffer.UV3Kind
  25349. * - VertexBuffer.UV4Kind
  25350. * - VertexBuffer.UV5Kind
  25351. * - VertexBuffer.UV6Kind
  25352. * - VertexBuffer.ColorKind
  25353. * - VertexBuffer.MatricesIndicesKind
  25354. * - VertexBuffer.MatricesIndicesExtraKind
  25355. * - VertexBuffer.MatricesWeightsKind
  25356. * - VertexBuffer.MatricesWeightsExtraKind
  25357. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25358. */
  25359. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25360. /**
  25361. * Tests if a specific vertex buffer is associated with this mesh
  25362. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25363. * - VertexBuffer.PositionKind
  25364. * - VertexBuffer.NormalKind
  25365. * - VertexBuffer.UVKind
  25366. * - VertexBuffer.UV2Kind
  25367. * - VertexBuffer.UV3Kind
  25368. * - VertexBuffer.UV4Kind
  25369. * - VertexBuffer.UV5Kind
  25370. * - VertexBuffer.UV6Kind
  25371. * - VertexBuffer.ColorKind
  25372. * - VertexBuffer.MatricesIndicesKind
  25373. * - VertexBuffer.MatricesIndicesExtraKind
  25374. * - VertexBuffer.MatricesWeightsKind
  25375. * - VertexBuffer.MatricesWeightsExtraKind
  25376. * @returns a boolean
  25377. */
  25378. isVerticesDataPresent(kind: string): boolean;
  25379. /**
  25380. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25381. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25382. * - VertexBuffer.PositionKind
  25383. * - VertexBuffer.UVKind
  25384. * - VertexBuffer.UV2Kind
  25385. * - VertexBuffer.UV3Kind
  25386. * - VertexBuffer.UV4Kind
  25387. * - VertexBuffer.UV5Kind
  25388. * - VertexBuffer.UV6Kind
  25389. * - VertexBuffer.ColorKind
  25390. * - VertexBuffer.MatricesIndicesKind
  25391. * - VertexBuffer.MatricesIndicesExtraKind
  25392. * - VertexBuffer.MatricesWeightsKind
  25393. * - VertexBuffer.MatricesWeightsExtraKind
  25394. * @returns a boolean
  25395. */
  25396. isVertexBufferUpdatable(kind: string): boolean;
  25397. /**
  25398. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25399. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25400. * - VertexBuffer.PositionKind
  25401. * - VertexBuffer.NormalKind
  25402. * - VertexBuffer.UVKind
  25403. * - VertexBuffer.UV2Kind
  25404. * - VertexBuffer.UV3Kind
  25405. * - VertexBuffer.UV4Kind
  25406. * - VertexBuffer.UV5Kind
  25407. * - VertexBuffer.UV6Kind
  25408. * - VertexBuffer.ColorKind
  25409. * - VertexBuffer.MatricesIndicesKind
  25410. * - VertexBuffer.MatricesIndicesExtraKind
  25411. * - VertexBuffer.MatricesWeightsKind
  25412. * - VertexBuffer.MatricesWeightsExtraKind
  25413. * @returns an array of strings
  25414. */
  25415. getVerticesDataKinds(): string[];
  25416. /**
  25417. * Returns a positive integer : the total number of indices in this mesh geometry.
  25418. * @returns the numner of indices or zero if the mesh has no geometry.
  25419. */
  25420. getTotalIndices(): number;
  25421. /**
  25422. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25423. * @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.
  25424. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25425. * @returns the indices array or an empty array if the mesh has no geometry
  25426. */
  25427. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25428. get isBlocked(): boolean;
  25429. /**
  25430. * Determine if the current mesh is ready to be rendered
  25431. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25432. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25433. * @returns true if all associated assets are ready (material, textures, shaders)
  25434. */
  25435. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25436. /**
  25437. * 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.
  25438. */
  25439. get areNormalsFrozen(): boolean;
  25440. /**
  25441. * 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.
  25442. * @returns the current mesh
  25443. */
  25444. freezeNormals(): Mesh;
  25445. /**
  25446. * 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
  25447. * @returns the current mesh
  25448. */
  25449. unfreezeNormals(): Mesh;
  25450. /**
  25451. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25452. */
  25453. set overridenInstanceCount(count: number);
  25454. /** @hidden */
  25455. _preActivate(): Mesh;
  25456. /** @hidden */
  25457. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25458. /** @hidden */
  25459. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25460. /**
  25461. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25462. * This means the mesh underlying bounding box and sphere are recomputed.
  25463. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25464. * @returns the current mesh
  25465. */
  25466. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25467. /** @hidden */
  25468. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25469. /**
  25470. * This function will subdivide the mesh into multiple submeshes
  25471. * @param count defines the expected number of submeshes
  25472. */
  25473. subdivide(count: number): void;
  25474. /**
  25475. * Copy a FloatArray into a specific associated vertex buffer
  25476. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25477. * - VertexBuffer.PositionKind
  25478. * - VertexBuffer.UVKind
  25479. * - VertexBuffer.UV2Kind
  25480. * - VertexBuffer.UV3Kind
  25481. * - VertexBuffer.UV4Kind
  25482. * - VertexBuffer.UV5Kind
  25483. * - VertexBuffer.UV6Kind
  25484. * - VertexBuffer.ColorKind
  25485. * - VertexBuffer.MatricesIndicesKind
  25486. * - VertexBuffer.MatricesIndicesExtraKind
  25487. * - VertexBuffer.MatricesWeightsKind
  25488. * - VertexBuffer.MatricesWeightsExtraKind
  25489. * @param data defines the data source
  25490. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25491. * @param stride defines the data stride size (can be null)
  25492. * @returns the current mesh
  25493. */
  25494. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25495. /**
  25496. * Delete a vertex buffer associated with this mesh
  25497. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25498. * - VertexBuffer.PositionKind
  25499. * - VertexBuffer.UVKind
  25500. * - VertexBuffer.UV2Kind
  25501. * - VertexBuffer.UV3Kind
  25502. * - VertexBuffer.UV4Kind
  25503. * - VertexBuffer.UV5Kind
  25504. * - VertexBuffer.UV6Kind
  25505. * - VertexBuffer.ColorKind
  25506. * - VertexBuffer.MatricesIndicesKind
  25507. * - VertexBuffer.MatricesIndicesExtraKind
  25508. * - VertexBuffer.MatricesWeightsKind
  25509. * - VertexBuffer.MatricesWeightsExtraKind
  25510. */
  25511. removeVerticesData(kind: string): void;
  25512. /**
  25513. * Flags an associated vertex buffer as updatable
  25514. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25515. * - VertexBuffer.PositionKind
  25516. * - VertexBuffer.UVKind
  25517. * - VertexBuffer.UV2Kind
  25518. * - VertexBuffer.UV3Kind
  25519. * - VertexBuffer.UV4Kind
  25520. * - VertexBuffer.UV5Kind
  25521. * - VertexBuffer.UV6Kind
  25522. * - VertexBuffer.ColorKind
  25523. * - VertexBuffer.MatricesIndicesKind
  25524. * - VertexBuffer.MatricesIndicesExtraKind
  25525. * - VertexBuffer.MatricesWeightsKind
  25526. * - VertexBuffer.MatricesWeightsExtraKind
  25527. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25528. */
  25529. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25530. /**
  25531. * Sets the mesh global Vertex Buffer
  25532. * @param buffer defines the buffer to use
  25533. * @returns the current mesh
  25534. */
  25535. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25536. /**
  25537. * Update a specific associated vertex buffer
  25538. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25539. * - VertexBuffer.PositionKind
  25540. * - VertexBuffer.UVKind
  25541. * - VertexBuffer.UV2Kind
  25542. * - VertexBuffer.UV3Kind
  25543. * - VertexBuffer.UV4Kind
  25544. * - VertexBuffer.UV5Kind
  25545. * - VertexBuffer.UV6Kind
  25546. * - VertexBuffer.ColorKind
  25547. * - VertexBuffer.MatricesIndicesKind
  25548. * - VertexBuffer.MatricesIndicesExtraKind
  25549. * - VertexBuffer.MatricesWeightsKind
  25550. * - VertexBuffer.MatricesWeightsExtraKind
  25551. * @param data defines the data source
  25552. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25553. * @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)
  25554. * @returns the current mesh
  25555. */
  25556. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25557. /**
  25558. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25559. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25560. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25561. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25562. * @returns the current mesh
  25563. */
  25564. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25565. /**
  25566. * Creates a un-shared specific occurence of the geometry for the mesh.
  25567. * @returns the current mesh
  25568. */
  25569. makeGeometryUnique(): Mesh;
  25570. /**
  25571. * Set the index buffer of this mesh
  25572. * @param indices defines the source data
  25573. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25574. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25575. * @returns the current mesh
  25576. */
  25577. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25578. /**
  25579. * Update the current index buffer
  25580. * @param indices defines the source data
  25581. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25582. * @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)
  25583. * @returns the current mesh
  25584. */
  25585. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25586. /**
  25587. * Invert the geometry to move from a right handed system to a left handed one.
  25588. * @returns the current mesh
  25589. */
  25590. toLeftHanded(): Mesh;
  25591. /** @hidden */
  25592. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25593. /** @hidden */
  25594. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25595. /**
  25596. * Registers for this mesh a javascript function called just before the rendering process
  25597. * @param func defines the function to call before rendering this mesh
  25598. * @returns the current mesh
  25599. */
  25600. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25601. /**
  25602. * Disposes a previously registered javascript function called before the rendering
  25603. * @param func defines the function to remove
  25604. * @returns the current mesh
  25605. */
  25606. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25607. /**
  25608. * Registers for this mesh a javascript function called just after the rendering is complete
  25609. * @param func defines the function to call after rendering this mesh
  25610. * @returns the current mesh
  25611. */
  25612. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25613. /**
  25614. * Disposes a previously registered javascript function called after the rendering.
  25615. * @param func defines the function to remove
  25616. * @returns the current mesh
  25617. */
  25618. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25619. /** @hidden */
  25620. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25621. /** @hidden */
  25622. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25623. /** @hidden */
  25624. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25625. /** @hidden */
  25626. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25627. /** @hidden */
  25628. _rebuild(): void;
  25629. /** @hidden */
  25630. _freeze(): void;
  25631. /** @hidden */
  25632. _unFreeze(): void;
  25633. /**
  25634. * 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
  25635. * @param subMesh defines the subMesh to render
  25636. * @param enableAlphaMode defines if alpha mode can be changed
  25637. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25638. * @returns the current mesh
  25639. */
  25640. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25641. private _onBeforeDraw;
  25642. /**
  25643. * Renormalize the mesh and patch it up if there are no weights
  25644. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25645. * However in the case of zero weights then we set just a single influence to 1.
  25646. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25647. */
  25648. cleanMatrixWeights(): void;
  25649. private normalizeSkinFourWeights;
  25650. private normalizeSkinWeightsAndExtra;
  25651. /**
  25652. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25653. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25654. * the user know there was an issue with importing the mesh
  25655. * @returns a validation object with skinned, valid and report string
  25656. */
  25657. validateSkinning(): {
  25658. skinned: boolean;
  25659. valid: boolean;
  25660. report: string;
  25661. };
  25662. /** @hidden */
  25663. _checkDelayState(): Mesh;
  25664. private _queueLoad;
  25665. /**
  25666. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25667. * A mesh is in the frustum if its bounding box intersects the frustum
  25668. * @param frustumPlanes defines the frustum to test
  25669. * @returns true if the mesh is in the frustum planes
  25670. */
  25671. isInFrustum(frustumPlanes: Plane[]): boolean;
  25672. /**
  25673. * Sets the mesh material by the material or multiMaterial `id` property
  25674. * @param id is a string identifying the material or the multiMaterial
  25675. * @returns the current mesh
  25676. */
  25677. setMaterialByID(id: string): Mesh;
  25678. /**
  25679. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25680. * @returns an array of IAnimatable
  25681. */
  25682. getAnimatables(): IAnimatable[];
  25683. /**
  25684. * Modifies the mesh geometry according to the passed transformation matrix.
  25685. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25686. * The mesh normals are modified using the same transformation.
  25687. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25688. * @param transform defines the transform matrix to use
  25689. * @see http://doc.babylonjs.com/resources/baking_transformations
  25690. * @returns the current mesh
  25691. */
  25692. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25693. /**
  25694. * Modifies the mesh geometry according to its own current World Matrix.
  25695. * The mesh World Matrix is then reset.
  25696. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25697. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25698. * @see http://doc.babylonjs.com/resources/baking_transformations
  25699. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25700. * @returns the current mesh
  25701. */
  25702. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25703. /** @hidden */
  25704. get _positions(): Nullable<Vector3[]>;
  25705. /** @hidden */
  25706. _resetPointsArrayCache(): Mesh;
  25707. /** @hidden */
  25708. _generatePointsArray(): boolean;
  25709. /**
  25710. * Returns a new Mesh object generated from the current mesh properties.
  25711. * This method must not get confused with createInstance()
  25712. * @param name is a string, the name given to the new mesh
  25713. * @param newParent can be any Node object (default `null`)
  25714. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25715. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25716. * @returns a new mesh
  25717. */
  25718. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25719. /**
  25720. * Releases resources associated with this mesh.
  25721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25723. */
  25724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25725. /** @hidden */
  25726. _disposeInstanceSpecificData(): void;
  25727. /**
  25728. * Modifies the mesh geometry according to a displacement map.
  25729. * 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.
  25730. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25731. * @param url is a string, the URL from the image file is to be downloaded.
  25732. * @param minHeight is the lower limit of the displacement.
  25733. * @param maxHeight is the upper limit of the displacement.
  25734. * @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.
  25735. * @param uvOffset is an optional vector2 used to offset UV.
  25736. * @param uvScale is an optional vector2 used to scale UV.
  25737. * @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.
  25738. * @returns the Mesh.
  25739. */
  25740. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25741. /**
  25742. * Modifies the mesh geometry according to a displacementMap buffer.
  25743. * 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.
  25744. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25745. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25746. * @param heightMapWidth is the width of the buffer image.
  25747. * @param heightMapHeight is the height of the buffer image.
  25748. * @param minHeight is the lower limit of the displacement.
  25749. * @param maxHeight is the upper limit of the displacement.
  25750. * @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.
  25751. * @param uvOffset is an optional vector2 used to offset UV.
  25752. * @param uvScale is an optional vector2 used to scale UV.
  25753. * @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.
  25754. * @returns the Mesh.
  25755. */
  25756. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25757. /**
  25758. * Modify the mesh to get a flat shading rendering.
  25759. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25760. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25761. * @returns current mesh
  25762. */
  25763. convertToFlatShadedMesh(): Mesh;
  25764. /**
  25765. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25766. * In other words, more vertices, no more indices and a single bigger VBO.
  25767. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25768. * @returns current mesh
  25769. */
  25770. convertToUnIndexedMesh(): Mesh;
  25771. /**
  25772. * Inverses facet orientations.
  25773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25774. * @param flipNormals will also inverts the normals
  25775. * @returns current mesh
  25776. */
  25777. flipFaces(flipNormals?: boolean): Mesh;
  25778. /**
  25779. * Increase the number of facets and hence vertices in a mesh
  25780. * Vertex normals are interpolated from existing vertex normals
  25781. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25782. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25783. */
  25784. increaseVertices(numberPerEdge: number): void;
  25785. /**
  25786. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25787. * This will undo any application of covertToFlatShadedMesh
  25788. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25789. */
  25790. forceSharedVertices(): void;
  25791. /** @hidden */
  25792. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25793. /** @hidden */
  25794. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25795. /**
  25796. * Creates a new InstancedMesh object from the mesh model.
  25797. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25798. * @param name defines the name of the new instance
  25799. * @returns a new InstancedMesh
  25800. */
  25801. createInstance(name: string): InstancedMesh;
  25802. /**
  25803. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25804. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25805. * @returns the current mesh
  25806. */
  25807. synchronizeInstances(): Mesh;
  25808. /**
  25809. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25810. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25811. * This should be used together with the simplification to avoid disappearing triangles.
  25812. * @param successCallback an optional success callback to be called after the optimization finished.
  25813. * @returns the current mesh
  25814. */
  25815. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25816. /**
  25817. * Serialize current mesh
  25818. * @param serializationObject defines the object which will receive the serialization data
  25819. */
  25820. serialize(serializationObject: any): void;
  25821. /** @hidden */
  25822. _syncGeometryWithMorphTargetManager(): void;
  25823. /** @hidden */
  25824. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25825. /**
  25826. * Returns a new Mesh object parsed from the source provided.
  25827. * @param parsedMesh is the source
  25828. * @param scene defines the hosting scene
  25829. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25830. * @returns a new Mesh
  25831. */
  25832. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25833. /**
  25834. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25835. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25836. * @param name defines the name of the mesh to create
  25837. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25838. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25839. * @param closePath creates a seam between the first and the last points of each path of the path array
  25840. * @param offset is taken in account only if the `pathArray` is containing a single path
  25841. * @param scene defines the hosting scene
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25844. * @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)
  25845. * @returns a new Mesh
  25846. */
  25847. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25848. /**
  25849. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25850. * @param name defines the name of the mesh to create
  25851. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25852. * @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
  25853. * @param scene defines the hosting scene
  25854. * @param updatable defines if the mesh must be flagged as updatable
  25855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25856. * @returns a new Mesh
  25857. */
  25858. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25859. /**
  25860. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25861. * @param name defines the name of the mesh to create
  25862. * @param size sets the size (float) of each box side (default 1)
  25863. * @param scene defines the hosting scene
  25864. * @param updatable defines if the mesh must be flagged as updatable
  25865. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25866. * @returns a new Mesh
  25867. */
  25868. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25869. /**
  25870. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25871. * @param name defines the name of the mesh to create
  25872. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25873. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25874. * @param scene defines the hosting scene
  25875. * @param updatable defines if the mesh must be flagged as updatable
  25876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25877. * @returns a new Mesh
  25878. */
  25879. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25880. /**
  25881. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25882. * @param name defines the name of the mesh to create
  25883. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25884. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25885. * @param scene defines the hosting scene
  25886. * @returns a new Mesh
  25887. */
  25888. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25889. /**
  25890. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25891. * @param name defines the name of the mesh to create
  25892. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25893. * @param diameterTop set the top cap diameter (floats, default 1)
  25894. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25895. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25896. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25897. * @param scene defines the hosting scene
  25898. * @param updatable defines if the mesh must be flagged as updatable
  25899. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25900. * @returns a new Mesh
  25901. */
  25902. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25903. /**
  25904. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25905. * @param name defines the name of the mesh to create
  25906. * @param diameter sets the diameter size (float) of the torus (default 1)
  25907. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25908. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25915. /**
  25916. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25917. * @param name defines the name of the mesh to create
  25918. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25919. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25920. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25921. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25922. * @param p the number of windings on X axis (positive integers, default 2)
  25923. * @param q the number of windings on Y axis (positive integers, default 3)
  25924. * @param scene defines the hosting scene
  25925. * @param updatable defines if the mesh must be flagged as updatable
  25926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25927. * @returns a new Mesh
  25928. */
  25929. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25930. /**
  25931. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25932. * @param name defines the name of the mesh to create
  25933. * @param points is an array successive Vector3
  25934. * @param scene defines the hosting scene
  25935. * @param updatable defines if the mesh must be flagged as updatable
  25936. * @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).
  25937. * @returns a new Mesh
  25938. */
  25939. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25940. /**
  25941. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25942. * @param name defines the name of the mesh to create
  25943. * @param points is an array successive Vector3
  25944. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25945. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25946. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25947. * @param scene defines the hosting scene
  25948. * @param updatable defines if the mesh must be flagged as updatable
  25949. * @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)
  25950. * @returns a new Mesh
  25951. */
  25952. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25953. /**
  25954. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25955. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25956. * 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.
  25957. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25958. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25959. * Remember you can only change the shape positions, not their number when updating a polygon.
  25960. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25961. * @param name defines the name of the mesh to create
  25962. * @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
  25963. * @param scene defines the hosting scene
  25964. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25965. * @param updatable defines if the mesh must be flagged as updatable
  25966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25967. * @param earcutInjection can be used to inject your own earcut reference
  25968. * @returns a new Mesh
  25969. */
  25970. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25971. /**
  25972. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25973. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25974. * @param name defines the name of the mesh to create
  25975. * @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
  25976. * @param depth defines the height of extrusion
  25977. * @param scene defines the hosting scene
  25978. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25979. * @param updatable defines if the mesh must be flagged as updatable
  25980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25981. * @param earcutInjection can be used to inject your own earcut reference
  25982. * @returns a new Mesh
  25983. */
  25984. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25985. /**
  25986. * Creates an extruded shape mesh.
  25987. * 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
  25988. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25989. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25990. * @param name defines the name of the mesh to create
  25991. * @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
  25992. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25993. * @param scale is the value to scale the shape
  25994. * @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
  25995. * @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
  25996. * @param scene defines the hosting scene
  25997. * @param updatable defines if the mesh must be flagged as updatable
  25998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25999. * @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)
  26000. * @returns a new Mesh
  26001. */
  26002. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26003. /**
  26004. * Creates an custom extruded shape mesh.
  26005. * The custom extrusion is a parametric shape.
  26006. * It has no predefined shape. Its final shape will depend on the input parameters.
  26007. * Please consider using the same method from the MeshBuilder class instead
  26008. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26009. * @param name defines the name of the mesh to create
  26010. * @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
  26011. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26012. * @param scaleFunction is a custom Javascript function called on each path point
  26013. * @param rotationFunction is a custom Javascript function called on each path point
  26014. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26015. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26016. * @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
  26017. * @param scene defines the hosting scene
  26018. * @param updatable defines if the mesh must be flagged as updatable
  26019. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26020. * @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)
  26021. * @returns a new Mesh
  26022. */
  26023. 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;
  26024. /**
  26025. * Creates lathe mesh.
  26026. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26027. * Please consider using the same method from the MeshBuilder class instead
  26028. * @param name defines the name of the mesh to create
  26029. * @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
  26030. * @param radius is the radius value of the lathe
  26031. * @param tessellation is the side number of the lathe.
  26032. * @param scene defines the hosting scene
  26033. * @param updatable defines if the mesh must be flagged as updatable
  26034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26035. * @returns a new Mesh
  26036. */
  26037. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26038. /**
  26039. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26040. * @param name defines the name of the mesh to create
  26041. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26042. * @param scene defines the hosting scene
  26043. * @param updatable defines if the mesh must be flagged as updatable
  26044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26045. * @returns a new Mesh
  26046. */
  26047. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26048. /**
  26049. * Creates a ground mesh.
  26050. * Please consider using the same method from the MeshBuilder class instead
  26051. * @param name defines the name of the mesh to create
  26052. * @param width set the width of the ground
  26053. * @param height set the height of the ground
  26054. * @param subdivisions sets the number of subdivisions per side
  26055. * @param scene defines the hosting scene
  26056. * @param updatable defines if the mesh must be flagged as updatable
  26057. * @returns a new Mesh
  26058. */
  26059. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26060. /**
  26061. * Creates a tiled ground mesh.
  26062. * Please consider using the same method from the MeshBuilder class instead
  26063. * @param name defines the name of the mesh to create
  26064. * @param xmin set the ground minimum X coordinate
  26065. * @param zmin set the ground minimum Y coordinate
  26066. * @param xmax set the ground maximum X coordinate
  26067. * @param zmax set the ground maximum Z coordinate
  26068. * @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
  26069. * @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
  26070. * @param scene defines the hosting scene
  26071. * @param updatable defines if the mesh must be flagged as updatable
  26072. * @returns a new Mesh
  26073. */
  26074. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26075. w: number;
  26076. h: number;
  26077. }, precision: {
  26078. w: number;
  26079. h: number;
  26080. }, scene: Scene, updatable?: boolean): Mesh;
  26081. /**
  26082. * Creates a ground mesh from a height map.
  26083. * Please consider using the same method from the MeshBuilder class instead
  26084. * @see http://doc.babylonjs.com/babylon101/height_map
  26085. * @param name defines the name of the mesh to create
  26086. * @param url sets the URL of the height map image resource
  26087. * @param width set the ground width size
  26088. * @param height set the ground height size
  26089. * @param subdivisions sets the number of subdivision per side
  26090. * @param minHeight is the minimum altitude on the ground
  26091. * @param maxHeight is the maximum altitude on the ground
  26092. * @param scene defines the hosting scene
  26093. * @param updatable defines if the mesh must be flagged as updatable
  26094. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26095. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26096. * @returns a new Mesh
  26097. */
  26098. 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;
  26099. /**
  26100. * Creates a tube mesh.
  26101. * The tube is a parametric shape.
  26102. * It has no predefined shape. Its final shape will depend on the input parameters.
  26103. * Please consider using the same method from the MeshBuilder class instead
  26104. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26105. * @param name defines the name of the mesh to create
  26106. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26107. * @param radius sets the tube radius size
  26108. * @param tessellation is the number of sides on the tubular surface
  26109. * @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
  26110. * @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
  26111. * @param scene defines the hosting scene
  26112. * @param updatable defines if the mesh must be flagged as updatable
  26113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26114. * @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)
  26115. * @returns a new Mesh
  26116. */
  26117. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26118. (i: number, distance: number): number;
  26119. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26120. /**
  26121. * Creates a polyhedron mesh.
  26122. * Please consider using the same method from the MeshBuilder class instead.
  26123. * * 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
  26124. * * The parameter `size` (positive float, default 1) sets the polygon size
  26125. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26126. * * 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`
  26127. * * 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
  26128. * * 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)`)
  26129. * * 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
  26130. * * 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
  26131. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26132. * * If you create a double-sided mesh, you can choose what parts of 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
  26133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26134. * @param name defines the name of the mesh to create
  26135. * @param options defines the options used to create the mesh
  26136. * @param scene defines the hosting scene
  26137. * @returns a new Mesh
  26138. */
  26139. static CreatePolyhedron(name: string, options: {
  26140. type?: number;
  26141. size?: number;
  26142. sizeX?: number;
  26143. sizeY?: number;
  26144. sizeZ?: number;
  26145. custom?: any;
  26146. faceUV?: Vector4[];
  26147. faceColors?: Color4[];
  26148. updatable?: boolean;
  26149. sideOrientation?: number;
  26150. }, scene: Scene): Mesh;
  26151. /**
  26152. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26153. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26154. * * 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`)
  26155. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26156. * * 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
  26157. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26158. * * If you create a double-sided mesh, you can choose what parts of 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
  26159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26160. * @param name defines the name of the mesh
  26161. * @param options defines the options used to create the mesh
  26162. * @param scene defines the hosting scene
  26163. * @returns a new Mesh
  26164. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26165. */
  26166. static CreateIcoSphere(name: string, options: {
  26167. radius?: number;
  26168. flat?: boolean;
  26169. subdivisions?: number;
  26170. sideOrientation?: number;
  26171. updatable?: boolean;
  26172. }, scene: Scene): Mesh;
  26173. /**
  26174. * Creates a decal mesh.
  26175. * Please consider using the same method from the MeshBuilder class instead.
  26176. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26177. * @param name defines the name of the mesh
  26178. * @param sourceMesh defines the mesh receiving the decal
  26179. * @param position sets the position of the decal in world coordinates
  26180. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26181. * @param size sets the decal scaling
  26182. * @param angle sets the angle to rotate the decal
  26183. * @returns a new Mesh
  26184. */
  26185. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26186. /**
  26187. * Prepare internal position array for software CPU skinning
  26188. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26189. */
  26190. setPositionsForCPUSkinning(): Float32Array;
  26191. /**
  26192. * Prepare internal normal array for software CPU skinning
  26193. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26194. */
  26195. setNormalsForCPUSkinning(): Float32Array;
  26196. /**
  26197. * Updates the vertex buffer by applying transformation from the bones
  26198. * @param skeleton defines the skeleton to apply to current mesh
  26199. * @returns the current mesh
  26200. */
  26201. applySkeleton(skeleton: Skeleton): Mesh;
  26202. /**
  26203. * 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
  26204. * @param meshes defines the list of meshes to scan
  26205. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26206. */
  26207. static MinMax(meshes: AbstractMesh[]): {
  26208. min: Vector3;
  26209. max: Vector3;
  26210. };
  26211. /**
  26212. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26213. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26214. * @returns a vector3
  26215. */
  26216. static Center(meshesOrMinMaxVector: {
  26217. min: Vector3;
  26218. max: Vector3;
  26219. } | AbstractMesh[]): Vector3;
  26220. /**
  26221. * Merge the array of meshes into a single mesh for performance reasons.
  26222. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26223. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26224. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26225. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26226. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26227. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26228. * @returns a new mesh
  26229. */
  26230. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26231. /** @hidden */
  26232. addInstance(instance: InstancedMesh): void;
  26233. /** @hidden */
  26234. removeInstance(instance: InstancedMesh): void;
  26235. }
  26236. }
  26237. declare module "babylonjs/Cameras/camera" {
  26238. import { SmartArray } from "babylonjs/Misc/smartArray";
  26239. import { Observable } from "babylonjs/Misc/observable";
  26240. import { Nullable } from "babylonjs/types";
  26241. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26242. import { Scene } from "babylonjs/scene";
  26243. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26244. import { Node } from "babylonjs/node";
  26245. import { Mesh } from "babylonjs/Meshes/mesh";
  26246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26247. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26248. import { Viewport } from "babylonjs/Maths/math.viewport";
  26249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26251. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26252. import { Ray } from "babylonjs/Culling/ray";
  26253. /**
  26254. * This is the base class of all the camera used in the application.
  26255. * @see http://doc.babylonjs.com/features/cameras
  26256. */
  26257. export class Camera extends Node {
  26258. /** @hidden */
  26259. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26260. /**
  26261. * This is the default projection mode used by the cameras.
  26262. * It helps recreating a feeling of perspective and better appreciate depth.
  26263. * This is the best way to simulate real life cameras.
  26264. */
  26265. static readonly PERSPECTIVE_CAMERA: number;
  26266. /**
  26267. * This helps creating camera with an orthographic mode.
  26268. * 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.
  26269. */
  26270. static readonly ORTHOGRAPHIC_CAMERA: number;
  26271. /**
  26272. * This is the default FOV mode for perspective cameras.
  26273. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26274. */
  26275. static readonly FOVMODE_VERTICAL_FIXED: number;
  26276. /**
  26277. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26278. */
  26279. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26280. /**
  26281. * This specifies ther is no need for a camera rig.
  26282. * Basically only one eye is rendered corresponding to the camera.
  26283. */
  26284. static readonly RIG_MODE_NONE: number;
  26285. /**
  26286. * Simulates a camera Rig with one blue eye and one red eye.
  26287. * This can be use with 3d blue and red glasses.
  26288. */
  26289. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26290. /**
  26291. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26292. */
  26293. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26294. /**
  26295. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26296. */
  26297. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26298. /**
  26299. * Defines that both eyes of the camera will be rendered over under each other.
  26300. */
  26301. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26302. /**
  26303. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26304. */
  26305. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26306. /**
  26307. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26308. */
  26309. static readonly RIG_MODE_VR: number;
  26310. /**
  26311. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26312. */
  26313. static readonly RIG_MODE_WEBVR: number;
  26314. /**
  26315. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26316. */
  26317. static readonly RIG_MODE_CUSTOM: number;
  26318. /**
  26319. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26320. */
  26321. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26322. /**
  26323. * Define the input manager associated with the camera.
  26324. */
  26325. inputs: CameraInputsManager<Camera>;
  26326. /** @hidden */
  26327. _position: Vector3;
  26328. /**
  26329. * Define the current local position of the camera in the scene
  26330. */
  26331. get position(): Vector3;
  26332. set position(newPosition: Vector3);
  26333. /**
  26334. * The vector the camera should consider as up.
  26335. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26336. */
  26337. upVector: Vector3;
  26338. /**
  26339. * Define the current limit on the left side for an orthographic camera
  26340. * In scene unit
  26341. */
  26342. orthoLeft: Nullable<number>;
  26343. /**
  26344. * Define the current limit on the right side for an orthographic camera
  26345. * In scene unit
  26346. */
  26347. orthoRight: Nullable<number>;
  26348. /**
  26349. * Define the current limit on the bottom side for an orthographic camera
  26350. * In scene unit
  26351. */
  26352. orthoBottom: Nullable<number>;
  26353. /**
  26354. * Define the current limit on the top side for an orthographic camera
  26355. * In scene unit
  26356. */
  26357. orthoTop: Nullable<number>;
  26358. /**
  26359. * Field Of View is set in Radians. (default is 0.8)
  26360. */
  26361. fov: number;
  26362. /**
  26363. * Define the minimum distance the camera can see from.
  26364. * This is important to note that the depth buffer are not infinite and the closer it starts
  26365. * the more your scene might encounter depth fighting issue.
  26366. */
  26367. minZ: number;
  26368. /**
  26369. * Define the maximum distance the camera can see to.
  26370. * This is important to note that the depth buffer are not infinite and the further it end
  26371. * the more your scene might encounter depth fighting issue.
  26372. */
  26373. maxZ: number;
  26374. /**
  26375. * Define the default inertia of the camera.
  26376. * This helps giving a smooth feeling to the camera movement.
  26377. */
  26378. inertia: number;
  26379. /**
  26380. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26381. */
  26382. mode: number;
  26383. /**
  26384. * Define whether the camera is intermediate.
  26385. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26386. */
  26387. isIntermediate: boolean;
  26388. /**
  26389. * Define the viewport of the camera.
  26390. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26391. */
  26392. viewport: Viewport;
  26393. /**
  26394. * Restricts the camera to viewing objects with the same layerMask.
  26395. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26396. */
  26397. layerMask: number;
  26398. /**
  26399. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26400. */
  26401. fovMode: number;
  26402. /**
  26403. * Rig mode of the camera.
  26404. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26405. * This is normally controlled byt the camera themselves as internal use.
  26406. */
  26407. cameraRigMode: number;
  26408. /**
  26409. * Defines the distance between both "eyes" in case of a RIG
  26410. */
  26411. interaxialDistance: number;
  26412. /**
  26413. * Defines if stereoscopic rendering is done side by side or over under.
  26414. */
  26415. isStereoscopicSideBySide: boolean;
  26416. /**
  26417. * 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
  26418. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26419. * else in the scene. (Eg. security camera)
  26420. *
  26421. * 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)
  26422. */
  26423. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26424. /**
  26425. * When set, the camera will render to this render target instead of the default canvas
  26426. *
  26427. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26428. */
  26429. outputRenderTarget: Nullable<RenderTargetTexture>;
  26430. /**
  26431. * Observable triggered when the camera view matrix has changed.
  26432. */
  26433. onViewMatrixChangedObservable: Observable<Camera>;
  26434. /**
  26435. * Observable triggered when the camera Projection matrix has changed.
  26436. */
  26437. onProjectionMatrixChangedObservable: Observable<Camera>;
  26438. /**
  26439. * Observable triggered when the inputs have been processed.
  26440. */
  26441. onAfterCheckInputsObservable: Observable<Camera>;
  26442. /**
  26443. * Observable triggered when reset has been called and applied to the camera.
  26444. */
  26445. onRestoreStateObservable: Observable<Camera>;
  26446. /**
  26447. * Is this camera a part of a rig system?
  26448. */
  26449. isRigCamera: boolean;
  26450. /**
  26451. * If isRigCamera set to true this will be set with the parent camera.
  26452. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26453. */
  26454. rigParent?: Camera;
  26455. /** @hidden */
  26456. _cameraRigParams: any;
  26457. /** @hidden */
  26458. _rigCameras: Camera[];
  26459. /** @hidden */
  26460. _rigPostProcess: Nullable<PostProcess>;
  26461. protected _webvrViewMatrix: Matrix;
  26462. /** @hidden */
  26463. _skipRendering: boolean;
  26464. /** @hidden */
  26465. _projectionMatrix: Matrix;
  26466. /** @hidden */
  26467. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26468. /** @hidden */
  26469. _activeMeshes: SmartArray<AbstractMesh>;
  26470. protected _globalPosition: Vector3;
  26471. /** @hidden */
  26472. _computedViewMatrix: Matrix;
  26473. private _doNotComputeProjectionMatrix;
  26474. private _transformMatrix;
  26475. private _frustumPlanes;
  26476. private _refreshFrustumPlanes;
  26477. private _storedFov;
  26478. private _stateStored;
  26479. /**
  26480. * Instantiates a new camera object.
  26481. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26482. * @see http://doc.babylonjs.com/features/cameras
  26483. * @param name Defines the name of the camera in the scene
  26484. * @param position Defines the position of the camera
  26485. * @param scene Defines the scene the camera belongs too
  26486. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26487. */
  26488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26489. /**
  26490. * Store current camera state (fov, position, etc..)
  26491. * @returns the camera
  26492. */
  26493. storeState(): Camera;
  26494. /**
  26495. * Restores the camera state values if it has been stored. You must call storeState() first
  26496. */
  26497. protected _restoreStateValues(): boolean;
  26498. /**
  26499. * Restored camera state. You must call storeState() first.
  26500. * @returns true if restored and false otherwise
  26501. */
  26502. restoreState(): boolean;
  26503. /**
  26504. * Gets the class name of the camera.
  26505. * @returns the class name
  26506. */
  26507. getClassName(): string;
  26508. /** @hidden */
  26509. readonly _isCamera: boolean;
  26510. /**
  26511. * Gets a string representation of the camera useful for debug purpose.
  26512. * @param fullDetails Defines that a more verboe level of logging is required
  26513. * @returns the string representation
  26514. */
  26515. toString(fullDetails?: boolean): string;
  26516. /**
  26517. * Gets the current world space position of the camera.
  26518. */
  26519. get globalPosition(): Vector3;
  26520. /**
  26521. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26522. * @returns the active meshe list
  26523. */
  26524. getActiveMeshes(): SmartArray<AbstractMesh>;
  26525. /**
  26526. * Check whether a mesh is part of the current active mesh list of the camera
  26527. * @param mesh Defines the mesh to check
  26528. * @returns true if active, false otherwise
  26529. */
  26530. isActiveMesh(mesh: Mesh): boolean;
  26531. /**
  26532. * Is this camera ready to be used/rendered
  26533. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26534. * @return true if the camera is ready
  26535. */
  26536. isReady(completeCheck?: boolean): boolean;
  26537. /** @hidden */
  26538. _initCache(): void;
  26539. /** @hidden */
  26540. _updateCache(ignoreParentClass?: boolean): void;
  26541. /** @hidden */
  26542. _isSynchronized(): boolean;
  26543. /** @hidden */
  26544. _isSynchronizedViewMatrix(): boolean;
  26545. /** @hidden */
  26546. _isSynchronizedProjectionMatrix(): boolean;
  26547. /**
  26548. * Attach the input controls to a specific dom element to get the input from.
  26549. * @param element Defines the element the controls should be listened from
  26550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26551. */
  26552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26553. /**
  26554. * Detach the current controls from the specified dom element.
  26555. * @param element Defines the element to stop listening the inputs from
  26556. */
  26557. detachControl(element: HTMLElement): void;
  26558. /**
  26559. * Update the camera state according to the different inputs gathered during the frame.
  26560. */
  26561. update(): void;
  26562. /** @hidden */
  26563. _checkInputs(): void;
  26564. /** @hidden */
  26565. get rigCameras(): Camera[];
  26566. /**
  26567. * Gets the post process used by the rig cameras
  26568. */
  26569. get rigPostProcess(): Nullable<PostProcess>;
  26570. /**
  26571. * Internal, gets the first post proces.
  26572. * @returns the first post process to be run on this camera.
  26573. */
  26574. _getFirstPostProcess(): Nullable<PostProcess>;
  26575. private _cascadePostProcessesToRigCams;
  26576. /**
  26577. * Attach a post process to the camera.
  26578. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26579. * @param postProcess The post process to attach to the camera
  26580. * @param insertAt The position of the post process in case several of them are in use in the scene
  26581. * @returns the position the post process has been inserted at
  26582. */
  26583. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26584. /**
  26585. * Detach a post process to the camera.
  26586. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26587. * @param postProcess The post process to detach from the camera
  26588. */
  26589. detachPostProcess(postProcess: PostProcess): void;
  26590. /**
  26591. * Gets the current world matrix of the camera
  26592. */
  26593. getWorldMatrix(): Matrix;
  26594. /** @hidden */
  26595. _getViewMatrix(): Matrix;
  26596. /**
  26597. * Gets the current view matrix of the camera.
  26598. * @param force forces the camera to recompute the matrix without looking at the cached state
  26599. * @returns the view matrix
  26600. */
  26601. getViewMatrix(force?: boolean): Matrix;
  26602. /**
  26603. * Freeze the projection matrix.
  26604. * It will prevent the cache check of the camera projection compute and can speed up perf
  26605. * if no parameter of the camera are meant to change
  26606. * @param projection Defines manually a projection if necessary
  26607. */
  26608. freezeProjectionMatrix(projection?: Matrix): void;
  26609. /**
  26610. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26611. */
  26612. unfreezeProjectionMatrix(): void;
  26613. /**
  26614. * Gets the current projection matrix of the camera.
  26615. * @param force forces the camera to recompute the matrix without looking at the cached state
  26616. * @returns the projection matrix
  26617. */
  26618. getProjectionMatrix(force?: boolean): Matrix;
  26619. /**
  26620. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26621. * @returns a Matrix
  26622. */
  26623. getTransformationMatrix(): Matrix;
  26624. private _updateFrustumPlanes;
  26625. /**
  26626. * Checks if a cullable object (mesh...) is in the camera frustum
  26627. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26628. * @param target The object to check
  26629. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26630. * @returns true if the object is in frustum otherwise false
  26631. */
  26632. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26633. /**
  26634. * Checks if a cullable object (mesh...) is in the camera frustum
  26635. * Unlike isInFrustum this cheks the full bounding box
  26636. * @param target The object to check
  26637. * @returns true if the object is in frustum otherwise false
  26638. */
  26639. isCompletelyInFrustum(target: ICullable): boolean;
  26640. /**
  26641. * Gets a ray in the forward direction from the camera.
  26642. * @param length Defines the length of the ray to create
  26643. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26644. * @param origin Defines the start point of the ray which defaults to the camera position
  26645. * @returns the forward ray
  26646. */
  26647. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26648. /**
  26649. * Releases resources associated with this node.
  26650. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26651. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26652. */
  26653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26654. /** @hidden */
  26655. _isLeftCamera: boolean;
  26656. /**
  26657. * Gets the left camera of a rig setup in case of Rigged Camera
  26658. */
  26659. get isLeftCamera(): boolean;
  26660. /** @hidden */
  26661. _isRightCamera: boolean;
  26662. /**
  26663. * Gets the right camera of a rig setup in case of Rigged Camera
  26664. */
  26665. get isRightCamera(): boolean;
  26666. /**
  26667. * Gets the left camera of a rig setup in case of Rigged Camera
  26668. */
  26669. get leftCamera(): Nullable<FreeCamera>;
  26670. /**
  26671. * Gets the right camera of a rig setup in case of Rigged Camera
  26672. */
  26673. get rightCamera(): Nullable<FreeCamera>;
  26674. /**
  26675. * Gets the left camera target of a rig setup in case of Rigged Camera
  26676. * @returns the target position
  26677. */
  26678. getLeftTarget(): Nullable<Vector3>;
  26679. /**
  26680. * Gets the right camera target of a rig setup in case of Rigged Camera
  26681. * @returns the target position
  26682. */
  26683. getRightTarget(): Nullable<Vector3>;
  26684. /**
  26685. * @hidden
  26686. */
  26687. setCameraRigMode(mode: number, rigParams: any): void;
  26688. /** @hidden */
  26689. static _setStereoscopicRigMode(camera: Camera): void;
  26690. /** @hidden */
  26691. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26692. /** @hidden */
  26693. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26694. /** @hidden */
  26695. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26696. /** @hidden */
  26697. _getVRProjectionMatrix(): Matrix;
  26698. protected _updateCameraRotationMatrix(): void;
  26699. protected _updateWebVRCameraRotationMatrix(): void;
  26700. /**
  26701. * This function MUST be overwritten by the different WebVR cameras available.
  26702. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26703. * @hidden
  26704. */
  26705. _getWebVRProjectionMatrix(): Matrix;
  26706. /**
  26707. * This function MUST be overwritten by the different WebVR cameras available.
  26708. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26709. * @hidden
  26710. */
  26711. _getWebVRViewMatrix(): Matrix;
  26712. /** @hidden */
  26713. setCameraRigParameter(name: string, value: any): void;
  26714. /**
  26715. * needs to be overridden by children so sub has required properties to be copied
  26716. * @hidden
  26717. */
  26718. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26719. /**
  26720. * May need to be overridden by children
  26721. * @hidden
  26722. */
  26723. _updateRigCameras(): void;
  26724. /** @hidden */
  26725. _setupInputs(): void;
  26726. /**
  26727. * Serialiaze the camera setup to a json represention
  26728. * @returns the JSON representation
  26729. */
  26730. serialize(): any;
  26731. /**
  26732. * Clones the current camera.
  26733. * @param name The cloned camera name
  26734. * @returns the cloned camera
  26735. */
  26736. clone(name: string): Camera;
  26737. /**
  26738. * Gets the direction of the camera relative to a given local axis.
  26739. * @param localAxis Defines the reference axis to provide a relative direction.
  26740. * @return the direction
  26741. */
  26742. getDirection(localAxis: Vector3): Vector3;
  26743. /**
  26744. * Returns the current camera absolute rotation
  26745. */
  26746. get absoluteRotation(): Quaternion;
  26747. /**
  26748. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26749. * @param localAxis Defines the reference axis to provide a relative direction.
  26750. * @param result Defines the vector to store the result in
  26751. */
  26752. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26753. /**
  26754. * Gets a camera constructor for a given camera type
  26755. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26756. * @param name The name of the camera the result will be able to instantiate
  26757. * @param scene The scene the result will construct the camera in
  26758. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26759. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26760. * @returns a factory method to construc the camera
  26761. */
  26762. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26763. /**
  26764. * Compute the world matrix of the camera.
  26765. * @returns the camera world matrix
  26766. */
  26767. computeWorldMatrix(): Matrix;
  26768. /**
  26769. * Parse a JSON and creates the camera from the parsed information
  26770. * @param parsedCamera The JSON to parse
  26771. * @param scene The scene to instantiate the camera in
  26772. * @returns the newly constructed camera
  26773. */
  26774. static Parse(parsedCamera: any, scene: Scene): Camera;
  26775. }
  26776. }
  26777. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26778. import { Nullable } from "babylonjs/types";
  26779. import { Scene } from "babylonjs/scene";
  26780. import { Vector4 } from "babylonjs/Maths/math.vector";
  26781. import { Mesh } from "babylonjs/Meshes/mesh";
  26782. /**
  26783. * Class containing static functions to help procedurally build meshes
  26784. */
  26785. export class DiscBuilder {
  26786. /**
  26787. * Creates a plane polygonal mesh. By default, this is a disc
  26788. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26789. * * 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
  26790. * * 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
  26791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26794. * @param name defines the name of the mesh
  26795. * @param options defines the options used to create the mesh
  26796. * @param scene defines the hosting scene
  26797. * @returns the plane polygonal mesh
  26798. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26799. */
  26800. static CreateDisc(name: string, options: {
  26801. radius?: number;
  26802. tessellation?: number;
  26803. arc?: number;
  26804. updatable?: boolean;
  26805. sideOrientation?: number;
  26806. frontUVs?: Vector4;
  26807. backUVs?: Vector4;
  26808. }, scene?: Nullable<Scene>): Mesh;
  26809. }
  26810. }
  26811. declare module "babylonjs/Materials/fresnelParameters" {
  26812. import { Color3 } from "babylonjs/Maths/math.color";
  26813. /**
  26814. * This represents all the required information to add a fresnel effect on a material:
  26815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26816. */
  26817. export class FresnelParameters {
  26818. private _isEnabled;
  26819. /**
  26820. * Define if the fresnel effect is enable or not.
  26821. */
  26822. get isEnabled(): boolean;
  26823. set isEnabled(value: boolean);
  26824. /**
  26825. * Define the color used on edges (grazing angle)
  26826. */
  26827. leftColor: Color3;
  26828. /**
  26829. * Define the color used on center
  26830. */
  26831. rightColor: Color3;
  26832. /**
  26833. * Define bias applied to computed fresnel term
  26834. */
  26835. bias: number;
  26836. /**
  26837. * Defined the power exponent applied to fresnel term
  26838. */
  26839. power: number;
  26840. /**
  26841. * Clones the current fresnel and its valuues
  26842. * @returns a clone fresnel configuration
  26843. */
  26844. clone(): FresnelParameters;
  26845. /**
  26846. * Serializes the current fresnel parameters to a JSON representation.
  26847. * @return the JSON serialization
  26848. */
  26849. serialize(): any;
  26850. /**
  26851. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26852. * @param parsedFresnelParameters Define the JSON representation
  26853. * @returns the parsed parameters
  26854. */
  26855. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26856. }
  26857. }
  26858. declare module "babylonjs/Materials/pushMaterial" {
  26859. import { Nullable } from "babylonjs/types";
  26860. import { Scene } from "babylonjs/scene";
  26861. import { Matrix } from "babylonjs/Maths/math.vector";
  26862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26863. import { Mesh } from "babylonjs/Meshes/mesh";
  26864. import { Material } from "babylonjs/Materials/material";
  26865. import { Effect } from "babylonjs/Materials/effect";
  26866. /**
  26867. * Base class of materials working in push mode in babylon JS
  26868. * @hidden
  26869. */
  26870. export class PushMaterial extends Material {
  26871. protected _activeEffect: Effect;
  26872. protected _normalMatrix: Matrix;
  26873. /**
  26874. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26875. * This means that the material can keep using a previous shader while a new one is being compiled.
  26876. * This is mostly used when shader parallel compilation is supported (true by default)
  26877. */
  26878. allowShaderHotSwapping: boolean;
  26879. constructor(name: string, scene: Scene);
  26880. getEffect(): Effect;
  26881. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26882. /**
  26883. * Binds the given world matrix to the active effect
  26884. *
  26885. * @param world the matrix to bind
  26886. */
  26887. bindOnlyWorldMatrix(world: Matrix): void;
  26888. /**
  26889. * Binds the given normal matrix to the active effect
  26890. *
  26891. * @param normalMatrix the matrix to bind
  26892. */
  26893. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26894. bind(world: Matrix, mesh?: Mesh): void;
  26895. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26896. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26897. }
  26898. }
  26899. declare module "babylonjs/Materials/materialFlags" {
  26900. /**
  26901. * This groups all the flags used to control the materials channel.
  26902. */
  26903. export class MaterialFlags {
  26904. private static _DiffuseTextureEnabled;
  26905. /**
  26906. * Are diffuse textures enabled in the application.
  26907. */
  26908. static get DiffuseTextureEnabled(): boolean;
  26909. static set DiffuseTextureEnabled(value: boolean);
  26910. private static _AmbientTextureEnabled;
  26911. /**
  26912. * Are ambient textures enabled in the application.
  26913. */
  26914. static get AmbientTextureEnabled(): boolean;
  26915. static set AmbientTextureEnabled(value: boolean);
  26916. private static _OpacityTextureEnabled;
  26917. /**
  26918. * Are opacity textures enabled in the application.
  26919. */
  26920. static get OpacityTextureEnabled(): boolean;
  26921. static set OpacityTextureEnabled(value: boolean);
  26922. private static _ReflectionTextureEnabled;
  26923. /**
  26924. * Are reflection textures enabled in the application.
  26925. */
  26926. static get ReflectionTextureEnabled(): boolean;
  26927. static set ReflectionTextureEnabled(value: boolean);
  26928. private static _EmissiveTextureEnabled;
  26929. /**
  26930. * Are emissive textures enabled in the application.
  26931. */
  26932. static get EmissiveTextureEnabled(): boolean;
  26933. static set EmissiveTextureEnabled(value: boolean);
  26934. private static _SpecularTextureEnabled;
  26935. /**
  26936. * Are specular textures enabled in the application.
  26937. */
  26938. static get SpecularTextureEnabled(): boolean;
  26939. static set SpecularTextureEnabled(value: boolean);
  26940. private static _BumpTextureEnabled;
  26941. /**
  26942. * Are bump textures enabled in the application.
  26943. */
  26944. static get BumpTextureEnabled(): boolean;
  26945. static set BumpTextureEnabled(value: boolean);
  26946. private static _LightmapTextureEnabled;
  26947. /**
  26948. * Are lightmap textures enabled in the application.
  26949. */
  26950. static get LightmapTextureEnabled(): boolean;
  26951. static set LightmapTextureEnabled(value: boolean);
  26952. private static _RefractionTextureEnabled;
  26953. /**
  26954. * Are refraction textures enabled in the application.
  26955. */
  26956. static get RefractionTextureEnabled(): boolean;
  26957. static set RefractionTextureEnabled(value: boolean);
  26958. private static _ColorGradingTextureEnabled;
  26959. /**
  26960. * Are color grading textures enabled in the application.
  26961. */
  26962. static get ColorGradingTextureEnabled(): boolean;
  26963. static set ColorGradingTextureEnabled(value: boolean);
  26964. private static _FresnelEnabled;
  26965. /**
  26966. * Are fresnels enabled in the application.
  26967. */
  26968. static get FresnelEnabled(): boolean;
  26969. static set FresnelEnabled(value: boolean);
  26970. private static _ClearCoatTextureEnabled;
  26971. /**
  26972. * Are clear coat textures enabled in the application.
  26973. */
  26974. static get ClearCoatTextureEnabled(): boolean;
  26975. static set ClearCoatTextureEnabled(value: boolean);
  26976. private static _ClearCoatBumpTextureEnabled;
  26977. /**
  26978. * Are clear coat bump textures enabled in the application.
  26979. */
  26980. static get ClearCoatBumpTextureEnabled(): boolean;
  26981. static set ClearCoatBumpTextureEnabled(value: boolean);
  26982. private static _ClearCoatTintTextureEnabled;
  26983. /**
  26984. * Are clear coat tint textures enabled in the application.
  26985. */
  26986. static get ClearCoatTintTextureEnabled(): boolean;
  26987. static set ClearCoatTintTextureEnabled(value: boolean);
  26988. private static _SheenTextureEnabled;
  26989. /**
  26990. * Are sheen textures enabled in the application.
  26991. */
  26992. static get SheenTextureEnabled(): boolean;
  26993. static set SheenTextureEnabled(value: boolean);
  26994. private static _AnisotropicTextureEnabled;
  26995. /**
  26996. * Are anisotropic textures enabled in the application.
  26997. */
  26998. static get AnisotropicTextureEnabled(): boolean;
  26999. static set AnisotropicTextureEnabled(value: boolean);
  27000. private static _ThicknessTextureEnabled;
  27001. /**
  27002. * Are thickness textures enabled in the application.
  27003. */
  27004. static get ThicknessTextureEnabled(): boolean;
  27005. static set ThicknessTextureEnabled(value: boolean);
  27006. }
  27007. }
  27008. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27009. /** @hidden */
  27010. export var defaultFragmentDeclaration: {
  27011. name: string;
  27012. shader: string;
  27013. };
  27014. }
  27015. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27016. /** @hidden */
  27017. export var defaultUboDeclaration: {
  27018. name: string;
  27019. shader: string;
  27020. };
  27021. }
  27022. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27023. /** @hidden */
  27024. export var lightFragmentDeclaration: {
  27025. name: string;
  27026. shader: string;
  27027. };
  27028. }
  27029. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27030. /** @hidden */
  27031. export var lightUboDeclaration: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27037. /** @hidden */
  27038. export var lightsFragmentFunctions: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27044. /** @hidden */
  27045. export var shadowsFragmentFunctions: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27051. /** @hidden */
  27052. export var fresnelFunction: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27058. /** @hidden */
  27059. export var reflectionFunction: {
  27060. name: string;
  27061. shader: string;
  27062. };
  27063. }
  27064. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27065. /** @hidden */
  27066. export var bumpFragmentFunctions: {
  27067. name: string;
  27068. shader: string;
  27069. };
  27070. }
  27071. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27072. /** @hidden */
  27073. export var logDepthDeclaration: {
  27074. name: string;
  27075. shader: string;
  27076. };
  27077. }
  27078. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27079. /** @hidden */
  27080. export var bumpFragment: {
  27081. name: string;
  27082. shader: string;
  27083. };
  27084. }
  27085. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27086. /** @hidden */
  27087. export var depthPrePass: {
  27088. name: string;
  27089. shader: string;
  27090. };
  27091. }
  27092. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27093. /** @hidden */
  27094. export var lightFragment: {
  27095. name: string;
  27096. shader: string;
  27097. };
  27098. }
  27099. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27100. /** @hidden */
  27101. export var logDepthFragment: {
  27102. name: string;
  27103. shader: string;
  27104. };
  27105. }
  27106. declare module "babylonjs/Shaders/default.fragment" {
  27107. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27108. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27109. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27110. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27111. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27112. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27113. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27114. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27115. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27116. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27118. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27120. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27121. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27122. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27123. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27124. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27125. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27126. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27127. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27128. /** @hidden */
  27129. export var defaultPixelShader: {
  27130. name: string;
  27131. shader: string;
  27132. };
  27133. }
  27134. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27135. /** @hidden */
  27136. export var defaultVertexDeclaration: {
  27137. name: string;
  27138. shader: string;
  27139. };
  27140. }
  27141. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27142. /** @hidden */
  27143. export var bumpVertexDeclaration: {
  27144. name: string;
  27145. shader: string;
  27146. };
  27147. }
  27148. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27149. /** @hidden */
  27150. export var bumpVertex: {
  27151. name: string;
  27152. shader: string;
  27153. };
  27154. }
  27155. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27156. /** @hidden */
  27157. export var fogVertex: {
  27158. name: string;
  27159. shader: string;
  27160. };
  27161. }
  27162. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27163. /** @hidden */
  27164. export var shadowsVertex: {
  27165. name: string;
  27166. shader: string;
  27167. };
  27168. }
  27169. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27170. /** @hidden */
  27171. export var pointCloudVertex: {
  27172. name: string;
  27173. shader: string;
  27174. };
  27175. }
  27176. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27177. /** @hidden */
  27178. export var logDepthVertex: {
  27179. name: string;
  27180. shader: string;
  27181. };
  27182. }
  27183. declare module "babylonjs/Shaders/default.vertex" {
  27184. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27185. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27186. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27187. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27188. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27189. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27190. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27191. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27192. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27193. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27194. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27195. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27196. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27198. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27199. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27200. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27202. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27203. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27204. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27205. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27206. /** @hidden */
  27207. export var defaultVertexShader: {
  27208. name: string;
  27209. shader: string;
  27210. };
  27211. }
  27212. declare module "babylonjs/Materials/standardMaterial" {
  27213. import { SmartArray } from "babylonjs/Misc/smartArray";
  27214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27215. import { Nullable } from "babylonjs/types";
  27216. import { Scene } from "babylonjs/scene";
  27217. import { Matrix } from "babylonjs/Maths/math.vector";
  27218. import { Color3 } from "babylonjs/Maths/math.color";
  27219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27221. import { Mesh } from "babylonjs/Meshes/mesh";
  27222. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27223. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27224. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27226. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27228. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27229. import "babylonjs/Shaders/default.fragment";
  27230. import "babylonjs/Shaders/default.vertex";
  27231. /** @hidden */
  27232. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27233. MAINUV1: boolean;
  27234. MAINUV2: boolean;
  27235. DIFFUSE: boolean;
  27236. DIFFUSEDIRECTUV: number;
  27237. AMBIENT: boolean;
  27238. AMBIENTDIRECTUV: number;
  27239. OPACITY: boolean;
  27240. OPACITYDIRECTUV: number;
  27241. OPACITYRGB: boolean;
  27242. REFLECTION: boolean;
  27243. EMISSIVE: boolean;
  27244. EMISSIVEDIRECTUV: number;
  27245. SPECULAR: boolean;
  27246. SPECULARDIRECTUV: number;
  27247. BUMP: boolean;
  27248. BUMPDIRECTUV: number;
  27249. PARALLAX: boolean;
  27250. PARALLAXOCCLUSION: boolean;
  27251. SPECULAROVERALPHA: boolean;
  27252. CLIPPLANE: boolean;
  27253. CLIPPLANE2: boolean;
  27254. CLIPPLANE3: boolean;
  27255. CLIPPLANE4: boolean;
  27256. CLIPPLANE5: boolean;
  27257. CLIPPLANE6: boolean;
  27258. ALPHATEST: boolean;
  27259. DEPTHPREPASS: boolean;
  27260. ALPHAFROMDIFFUSE: boolean;
  27261. POINTSIZE: boolean;
  27262. FOG: boolean;
  27263. SPECULARTERM: boolean;
  27264. DIFFUSEFRESNEL: boolean;
  27265. OPACITYFRESNEL: boolean;
  27266. REFLECTIONFRESNEL: boolean;
  27267. REFRACTIONFRESNEL: boolean;
  27268. EMISSIVEFRESNEL: boolean;
  27269. FRESNEL: boolean;
  27270. NORMAL: boolean;
  27271. UV1: boolean;
  27272. UV2: boolean;
  27273. VERTEXCOLOR: boolean;
  27274. VERTEXALPHA: boolean;
  27275. NUM_BONE_INFLUENCERS: number;
  27276. BonesPerMesh: number;
  27277. BONETEXTURE: boolean;
  27278. INSTANCES: boolean;
  27279. GLOSSINESS: boolean;
  27280. ROUGHNESS: boolean;
  27281. EMISSIVEASILLUMINATION: boolean;
  27282. LINKEMISSIVEWITHDIFFUSE: boolean;
  27283. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27284. LIGHTMAP: boolean;
  27285. LIGHTMAPDIRECTUV: number;
  27286. OBJECTSPACE_NORMALMAP: boolean;
  27287. USELIGHTMAPASSHADOWMAP: boolean;
  27288. REFLECTIONMAP_3D: boolean;
  27289. REFLECTIONMAP_SPHERICAL: boolean;
  27290. REFLECTIONMAP_PLANAR: boolean;
  27291. REFLECTIONMAP_CUBIC: boolean;
  27292. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27293. REFLECTIONMAP_PROJECTION: boolean;
  27294. REFLECTIONMAP_SKYBOX: boolean;
  27295. REFLECTIONMAP_EXPLICIT: boolean;
  27296. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27297. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27298. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27299. INVERTCUBICMAP: boolean;
  27300. LOGARITHMICDEPTH: boolean;
  27301. REFRACTION: boolean;
  27302. REFRACTIONMAP_3D: boolean;
  27303. REFLECTIONOVERALPHA: boolean;
  27304. TWOSIDEDLIGHTING: boolean;
  27305. SHADOWFLOAT: boolean;
  27306. MORPHTARGETS: boolean;
  27307. MORPHTARGETS_NORMAL: boolean;
  27308. MORPHTARGETS_TANGENT: boolean;
  27309. MORPHTARGETS_UV: boolean;
  27310. NUM_MORPH_INFLUENCERS: number;
  27311. NONUNIFORMSCALING: boolean;
  27312. PREMULTIPLYALPHA: boolean;
  27313. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27314. ALPHABLEND: boolean;
  27315. IMAGEPROCESSING: boolean;
  27316. VIGNETTE: boolean;
  27317. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27318. VIGNETTEBLENDMODEOPAQUE: boolean;
  27319. TONEMAPPING: boolean;
  27320. TONEMAPPING_ACES: boolean;
  27321. CONTRAST: boolean;
  27322. COLORCURVES: boolean;
  27323. COLORGRADING: boolean;
  27324. COLORGRADING3D: boolean;
  27325. SAMPLER3DGREENDEPTH: boolean;
  27326. SAMPLER3DBGRMAP: boolean;
  27327. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27328. MULTIVIEW: boolean;
  27329. /**
  27330. * If the reflection texture on this material is in linear color space
  27331. * @hidden
  27332. */
  27333. IS_REFLECTION_LINEAR: boolean;
  27334. /**
  27335. * If the refraction texture on this material is in linear color space
  27336. * @hidden
  27337. */
  27338. IS_REFRACTION_LINEAR: boolean;
  27339. EXPOSURE: boolean;
  27340. constructor();
  27341. setReflectionMode(modeToEnable: string): void;
  27342. }
  27343. /**
  27344. * This is the default material used in Babylon. It is the best trade off between quality
  27345. * and performances.
  27346. * @see http://doc.babylonjs.com/babylon101/materials
  27347. */
  27348. export class StandardMaterial extends PushMaterial {
  27349. private _diffuseTexture;
  27350. /**
  27351. * The basic texture of the material as viewed under a light.
  27352. */
  27353. diffuseTexture: Nullable<BaseTexture>;
  27354. private _ambientTexture;
  27355. /**
  27356. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27357. */
  27358. ambientTexture: Nullable<BaseTexture>;
  27359. private _opacityTexture;
  27360. /**
  27361. * Define the transparency of the material from a texture.
  27362. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27363. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27364. */
  27365. opacityTexture: Nullable<BaseTexture>;
  27366. private _reflectionTexture;
  27367. /**
  27368. * Define the texture used to display the reflection.
  27369. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27370. */
  27371. reflectionTexture: Nullable<BaseTexture>;
  27372. private _emissiveTexture;
  27373. /**
  27374. * Define texture of the material as if self lit.
  27375. * This will be mixed in the final result even in the absence of light.
  27376. */
  27377. emissiveTexture: Nullable<BaseTexture>;
  27378. private _specularTexture;
  27379. /**
  27380. * Define how the color and intensity of the highlight given by the light in the material.
  27381. */
  27382. specularTexture: Nullable<BaseTexture>;
  27383. private _bumpTexture;
  27384. /**
  27385. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27386. * 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.
  27387. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27388. */
  27389. bumpTexture: Nullable<BaseTexture>;
  27390. private _lightmapTexture;
  27391. /**
  27392. * Complex lighting can be computationally expensive to compute at runtime.
  27393. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27394. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27395. */
  27396. lightmapTexture: Nullable<BaseTexture>;
  27397. private _refractionTexture;
  27398. /**
  27399. * Define the texture used to display the refraction.
  27400. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27401. */
  27402. refractionTexture: Nullable<BaseTexture>;
  27403. /**
  27404. * The color of the material lit by the environmental background lighting.
  27405. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27406. */
  27407. ambientColor: Color3;
  27408. /**
  27409. * The basic color of the material as viewed under a light.
  27410. */
  27411. diffuseColor: Color3;
  27412. /**
  27413. * Define how the color and intensity of the highlight given by the light in the material.
  27414. */
  27415. specularColor: Color3;
  27416. /**
  27417. * Define the color of the material as if self lit.
  27418. * This will be mixed in the final result even in the absence of light.
  27419. */
  27420. emissiveColor: Color3;
  27421. /**
  27422. * Defines how sharp are the highlights in the material.
  27423. * The bigger the value the sharper giving a more glossy feeling to the result.
  27424. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27425. */
  27426. specularPower: number;
  27427. private _useAlphaFromDiffuseTexture;
  27428. /**
  27429. * Does the transparency come from the diffuse texture alpha channel.
  27430. */
  27431. useAlphaFromDiffuseTexture: boolean;
  27432. private _useEmissiveAsIllumination;
  27433. /**
  27434. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27435. */
  27436. useEmissiveAsIllumination: boolean;
  27437. private _linkEmissiveWithDiffuse;
  27438. /**
  27439. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27440. * the emissive level when the final color is close to one.
  27441. */
  27442. linkEmissiveWithDiffuse: boolean;
  27443. private _useSpecularOverAlpha;
  27444. /**
  27445. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27446. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27447. */
  27448. useSpecularOverAlpha: boolean;
  27449. private _useReflectionOverAlpha;
  27450. /**
  27451. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27452. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27453. */
  27454. useReflectionOverAlpha: boolean;
  27455. private _disableLighting;
  27456. /**
  27457. * Does lights from the scene impacts this material.
  27458. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27459. */
  27460. disableLighting: boolean;
  27461. private _useObjectSpaceNormalMap;
  27462. /**
  27463. * Allows using an object space normal map (instead of tangent space).
  27464. */
  27465. useObjectSpaceNormalMap: boolean;
  27466. private _useParallax;
  27467. /**
  27468. * Is parallax enabled or not.
  27469. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27470. */
  27471. useParallax: boolean;
  27472. private _useParallaxOcclusion;
  27473. /**
  27474. * Is parallax occlusion enabled or not.
  27475. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27476. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27477. */
  27478. useParallaxOcclusion: boolean;
  27479. /**
  27480. * 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.
  27481. */
  27482. parallaxScaleBias: number;
  27483. private _roughness;
  27484. /**
  27485. * Helps to define how blurry the reflections should appears in the material.
  27486. */
  27487. roughness: number;
  27488. /**
  27489. * In case of refraction, define the value of the index of refraction.
  27490. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27491. */
  27492. indexOfRefraction: number;
  27493. /**
  27494. * Invert the refraction texture alongside the y axis.
  27495. * It can be useful with procedural textures or probe for instance.
  27496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27497. */
  27498. invertRefractionY: boolean;
  27499. /**
  27500. * Defines the alpha limits in alpha test mode.
  27501. */
  27502. alphaCutOff: number;
  27503. private _useLightmapAsShadowmap;
  27504. /**
  27505. * In case of light mapping, define whether the map contains light or shadow informations.
  27506. */
  27507. useLightmapAsShadowmap: boolean;
  27508. private _diffuseFresnelParameters;
  27509. /**
  27510. * Define the diffuse fresnel parameters of the material.
  27511. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27512. */
  27513. diffuseFresnelParameters: FresnelParameters;
  27514. private _opacityFresnelParameters;
  27515. /**
  27516. * Define the opacity fresnel parameters of the material.
  27517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27518. */
  27519. opacityFresnelParameters: FresnelParameters;
  27520. private _reflectionFresnelParameters;
  27521. /**
  27522. * Define the reflection fresnel parameters of the material.
  27523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27524. */
  27525. reflectionFresnelParameters: FresnelParameters;
  27526. private _refractionFresnelParameters;
  27527. /**
  27528. * Define the refraction fresnel parameters of the material.
  27529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27530. */
  27531. refractionFresnelParameters: FresnelParameters;
  27532. private _emissiveFresnelParameters;
  27533. /**
  27534. * Define the emissive fresnel parameters of the material.
  27535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27536. */
  27537. emissiveFresnelParameters: FresnelParameters;
  27538. private _useReflectionFresnelFromSpecular;
  27539. /**
  27540. * If true automatically deducts the fresnels values from the material specularity.
  27541. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27542. */
  27543. useReflectionFresnelFromSpecular: boolean;
  27544. private _useGlossinessFromSpecularMapAlpha;
  27545. /**
  27546. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27547. */
  27548. useGlossinessFromSpecularMapAlpha: boolean;
  27549. private _maxSimultaneousLights;
  27550. /**
  27551. * Defines the maximum number of lights that can be used in the material
  27552. */
  27553. maxSimultaneousLights: number;
  27554. private _invertNormalMapX;
  27555. /**
  27556. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27557. */
  27558. invertNormalMapX: boolean;
  27559. private _invertNormalMapY;
  27560. /**
  27561. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27562. */
  27563. invertNormalMapY: boolean;
  27564. private _twoSidedLighting;
  27565. /**
  27566. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27567. */
  27568. twoSidedLighting: boolean;
  27569. /**
  27570. * Default configuration related to image processing available in the standard Material.
  27571. */
  27572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27573. /**
  27574. * Gets the image processing configuration used either in this material.
  27575. */
  27576. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27577. /**
  27578. * Sets the Default image processing configuration used either in the this material.
  27579. *
  27580. * If sets to null, the scene one is in use.
  27581. */
  27582. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27583. /**
  27584. * Keep track of the image processing observer to allow dispose and replace.
  27585. */
  27586. private _imageProcessingObserver;
  27587. /**
  27588. * Attaches a new image processing configuration to the Standard Material.
  27589. * @param configuration
  27590. */
  27591. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27592. /**
  27593. * Gets wether the color curves effect is enabled.
  27594. */
  27595. get cameraColorCurvesEnabled(): boolean;
  27596. /**
  27597. * Sets wether the color curves effect is enabled.
  27598. */
  27599. set cameraColorCurvesEnabled(value: boolean);
  27600. /**
  27601. * Gets wether the color grading effect is enabled.
  27602. */
  27603. get cameraColorGradingEnabled(): boolean;
  27604. /**
  27605. * Gets wether the color grading effect is enabled.
  27606. */
  27607. set cameraColorGradingEnabled(value: boolean);
  27608. /**
  27609. * Gets wether tonemapping is enabled or not.
  27610. */
  27611. get cameraToneMappingEnabled(): boolean;
  27612. /**
  27613. * Sets wether tonemapping is enabled or not
  27614. */
  27615. set cameraToneMappingEnabled(value: boolean);
  27616. /**
  27617. * The camera exposure used on this material.
  27618. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27619. * This corresponds to a photographic exposure.
  27620. */
  27621. get cameraExposure(): number;
  27622. /**
  27623. * The camera exposure used on this material.
  27624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27625. * This corresponds to a photographic exposure.
  27626. */
  27627. set cameraExposure(value: number);
  27628. /**
  27629. * Gets The camera contrast used on this material.
  27630. */
  27631. get cameraContrast(): number;
  27632. /**
  27633. * Sets The camera contrast used on this material.
  27634. */
  27635. set cameraContrast(value: number);
  27636. /**
  27637. * Gets the Color Grading 2D Lookup Texture.
  27638. */
  27639. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27640. /**
  27641. * Sets the Color Grading 2D Lookup Texture.
  27642. */
  27643. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27644. /**
  27645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27647. * 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;
  27648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27649. */
  27650. get cameraColorCurves(): Nullable<ColorCurves>;
  27651. /**
  27652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27654. * 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;
  27655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27656. */
  27657. set cameraColorCurves(value: Nullable<ColorCurves>);
  27658. /**
  27659. * Custom callback helping to override the default shader used in the material.
  27660. */
  27661. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27662. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27663. protected _worldViewProjectionMatrix: Matrix;
  27664. protected _globalAmbientColor: Color3;
  27665. protected _useLogarithmicDepth: boolean;
  27666. protected _rebuildInParallel: boolean;
  27667. /**
  27668. * Instantiates a new standard material.
  27669. * This is the default material used in Babylon. It is the best trade off between quality
  27670. * and performances.
  27671. * @see http://doc.babylonjs.com/babylon101/materials
  27672. * @param name Define the name of the material in the scene
  27673. * @param scene Define the scene the material belong to
  27674. */
  27675. constructor(name: string, scene: Scene);
  27676. /**
  27677. * Gets a boolean indicating that current material needs to register RTT
  27678. */
  27679. get hasRenderTargetTextures(): boolean;
  27680. /**
  27681. * Gets the current class name of the material e.g. "StandardMaterial"
  27682. * Mainly use in serialization.
  27683. * @returns the class name
  27684. */
  27685. getClassName(): string;
  27686. /**
  27687. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27688. * You can try switching to logarithmic depth.
  27689. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27690. */
  27691. get useLogarithmicDepth(): boolean;
  27692. set useLogarithmicDepth(value: boolean);
  27693. /**
  27694. * Specifies if the material will require alpha blending
  27695. * @returns a boolean specifying if alpha blending is needed
  27696. */
  27697. needAlphaBlending(): boolean;
  27698. /**
  27699. * Specifies if this material should be rendered in alpha test mode
  27700. * @returns a boolean specifying if an alpha test is needed.
  27701. */
  27702. needAlphaTesting(): boolean;
  27703. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27704. /**
  27705. * Get the texture used for alpha test purpose.
  27706. * @returns the diffuse texture in case of the standard material.
  27707. */
  27708. getAlphaTestTexture(): Nullable<BaseTexture>;
  27709. /**
  27710. * Get if the submesh is ready to be used and all its information available.
  27711. * Child classes can use it to update shaders
  27712. * @param mesh defines the mesh to check
  27713. * @param subMesh defines which submesh to check
  27714. * @param useInstances specifies that instances should be used
  27715. * @returns a boolean indicating that the submesh is ready or not
  27716. */
  27717. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27718. /**
  27719. * Builds the material UBO layouts.
  27720. * Used internally during the effect preparation.
  27721. */
  27722. buildUniformLayout(): void;
  27723. /**
  27724. * Unbinds the material from the mesh
  27725. */
  27726. unbind(): void;
  27727. /**
  27728. * Binds the submesh to this material by preparing the effect and shader to draw
  27729. * @param world defines the world transformation matrix
  27730. * @param mesh defines the mesh containing the submesh
  27731. * @param subMesh defines the submesh to bind the material to
  27732. */
  27733. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27734. /**
  27735. * Get the list of animatables in the material.
  27736. * @returns the list of animatables object used in the material
  27737. */
  27738. getAnimatables(): IAnimatable[];
  27739. /**
  27740. * Gets the active textures from the material
  27741. * @returns an array of textures
  27742. */
  27743. getActiveTextures(): BaseTexture[];
  27744. /**
  27745. * Specifies if the material uses a texture
  27746. * @param texture defines the texture to check against the material
  27747. * @returns a boolean specifying if the material uses the texture
  27748. */
  27749. hasTexture(texture: BaseTexture): boolean;
  27750. /**
  27751. * Disposes the material
  27752. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27753. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27754. */
  27755. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27756. /**
  27757. * Makes a duplicate of the material, and gives it a new name
  27758. * @param name defines the new name for the duplicated material
  27759. * @returns the cloned material
  27760. */
  27761. clone(name: string): StandardMaterial;
  27762. /**
  27763. * Serializes this material in a JSON representation
  27764. * @returns the serialized material object
  27765. */
  27766. serialize(): any;
  27767. /**
  27768. * Creates a standard material from parsed material data
  27769. * @param source defines the JSON representation of the material
  27770. * @param scene defines the hosting scene
  27771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27772. * @returns a new standard material
  27773. */
  27774. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27775. /**
  27776. * Are diffuse textures enabled in the application.
  27777. */
  27778. static get DiffuseTextureEnabled(): boolean;
  27779. static set DiffuseTextureEnabled(value: boolean);
  27780. /**
  27781. * Are ambient textures enabled in the application.
  27782. */
  27783. static get AmbientTextureEnabled(): boolean;
  27784. static set AmbientTextureEnabled(value: boolean);
  27785. /**
  27786. * Are opacity textures enabled in the application.
  27787. */
  27788. static get OpacityTextureEnabled(): boolean;
  27789. static set OpacityTextureEnabled(value: boolean);
  27790. /**
  27791. * Are reflection textures enabled in the application.
  27792. */
  27793. static get ReflectionTextureEnabled(): boolean;
  27794. static set ReflectionTextureEnabled(value: boolean);
  27795. /**
  27796. * Are emissive textures enabled in the application.
  27797. */
  27798. static get EmissiveTextureEnabled(): boolean;
  27799. static set EmissiveTextureEnabled(value: boolean);
  27800. /**
  27801. * Are specular textures enabled in the application.
  27802. */
  27803. static get SpecularTextureEnabled(): boolean;
  27804. static set SpecularTextureEnabled(value: boolean);
  27805. /**
  27806. * Are bump textures enabled in the application.
  27807. */
  27808. static get BumpTextureEnabled(): boolean;
  27809. static set BumpTextureEnabled(value: boolean);
  27810. /**
  27811. * Are lightmap textures enabled in the application.
  27812. */
  27813. static get LightmapTextureEnabled(): boolean;
  27814. static set LightmapTextureEnabled(value: boolean);
  27815. /**
  27816. * Are refraction textures enabled in the application.
  27817. */
  27818. static get RefractionTextureEnabled(): boolean;
  27819. static set RefractionTextureEnabled(value: boolean);
  27820. /**
  27821. * Are color grading textures enabled in the application.
  27822. */
  27823. static get ColorGradingTextureEnabled(): boolean;
  27824. static set ColorGradingTextureEnabled(value: boolean);
  27825. /**
  27826. * Are fresnels enabled in the application.
  27827. */
  27828. static get FresnelEnabled(): boolean;
  27829. static set FresnelEnabled(value: boolean);
  27830. }
  27831. }
  27832. declare module "babylonjs/Particles/solidParticleSystem" {
  27833. import { Nullable } from "babylonjs/types";
  27834. import { Vector3 } from "babylonjs/Maths/math.vector";
  27835. import { Mesh } from "babylonjs/Meshes/mesh";
  27836. import { Scene, IDisposable } from "babylonjs/scene";
  27837. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27838. import { Material } from "babylonjs/Materials/material";
  27839. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27840. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  27841. /**
  27842. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27843. *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.
  27844. * The SPS is also a particle system. It provides some methods to manage the particles.
  27845. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27846. *
  27847. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27848. */
  27849. export class SolidParticleSystem implements IDisposable {
  27850. /**
  27851. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27852. * Example : var p = SPS.particles[i];
  27853. */
  27854. particles: SolidParticle[];
  27855. /**
  27856. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27857. */
  27858. nbParticles: number;
  27859. /**
  27860. * If the particles must ever face the camera (default false). Useful for planar particles.
  27861. */
  27862. billboard: boolean;
  27863. /**
  27864. * Recompute normals when adding a shape
  27865. */
  27866. recomputeNormals: boolean;
  27867. /**
  27868. * This a counter ofr your own usage. It's not set by any SPS functions.
  27869. */
  27870. counter: number;
  27871. /**
  27872. * The SPS name. This name is also given to the underlying mesh.
  27873. */
  27874. name: string;
  27875. /**
  27876. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27877. */
  27878. mesh: Mesh;
  27879. /**
  27880. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27881. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27882. */
  27883. vars: any;
  27884. /**
  27885. * This array is populated when the SPS is set as 'pickable'.
  27886. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27887. * Each element of this array is an object `{idx: int, faceId: int}`.
  27888. * `idx` is the picked particle index in the `SPS.particles` array
  27889. * `faceId` is the picked face index counted within this particle.
  27890. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27891. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27892. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27893. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27894. */
  27895. pickedParticles: {
  27896. idx: number;
  27897. faceId: number;
  27898. }[];
  27899. /**
  27900. * This array is populated when the SPS is set as 'pickable'
  27901. * Each key of this array is a submesh index.
  27902. * Each element of this array is a second array defined like this :
  27903. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27904. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27905. * `idx` is the picked particle index in the `SPS.particles` array
  27906. * `faceId` is the picked face index counted within this particle.
  27907. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27908. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27909. */
  27910. pickedBySubMesh: {
  27911. idx: number;
  27912. faceId: number;
  27913. }[][];
  27914. /**
  27915. * This array is populated when `enableDepthSort` is set to true.
  27916. * Each element of this array is an instance of the class DepthSortedParticle.
  27917. */
  27918. depthSortedParticles: DepthSortedParticle[];
  27919. /**
  27920. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27921. * @hidden
  27922. */
  27923. _bSphereOnly: boolean;
  27924. /**
  27925. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27926. * @hidden
  27927. */
  27928. _bSphereRadiusFactor: number;
  27929. private _scene;
  27930. private _positions;
  27931. private _indices;
  27932. private _normals;
  27933. private _colors;
  27934. private _uvs;
  27935. private _indices32;
  27936. private _positions32;
  27937. private _normals32;
  27938. private _fixedNormal32;
  27939. private _colors32;
  27940. private _uvs32;
  27941. private _index;
  27942. private _updatable;
  27943. private _pickable;
  27944. private _isVisibilityBoxLocked;
  27945. private _alwaysVisible;
  27946. private _depthSort;
  27947. private _expandable;
  27948. private _shapeCounter;
  27949. private _copy;
  27950. private _color;
  27951. private _computeParticleColor;
  27952. private _computeParticleTexture;
  27953. private _computeParticleRotation;
  27954. private _computeParticleVertex;
  27955. private _computeBoundingBox;
  27956. private _depthSortParticles;
  27957. private _camera;
  27958. private _mustUnrotateFixedNormals;
  27959. private _particlesIntersect;
  27960. private _needs32Bits;
  27961. private _isNotBuilt;
  27962. private _lastParticleId;
  27963. private _idxOfId;
  27964. private _multimaterialEnabled;
  27965. private _useModelMaterial;
  27966. private _indicesByMaterial;
  27967. private _materialIndexes;
  27968. private _depthSortFunction;
  27969. private _materialSortFunction;
  27970. private _materials;
  27971. private _multimaterial;
  27972. private _materialIndexesById;
  27973. private _defaultMaterial;
  27974. private _autoUpdateSubMeshes;
  27975. /**
  27976. * Creates a SPS (Solid Particle System) object.
  27977. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27978. * @param scene (Scene) is the scene in which the SPS is added.
  27979. * @param options defines the options of the sps e.g.
  27980. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27981. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27982. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27983. * * 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.
  27984. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27985. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27986. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27987. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27988. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27989. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27990. */
  27991. constructor(name: string, scene: Scene, options?: {
  27992. updatable?: boolean;
  27993. isPickable?: boolean;
  27994. enableDepthSort?: boolean;
  27995. particleIntersection?: boolean;
  27996. boundingSphereOnly?: boolean;
  27997. bSphereRadiusFactor?: number;
  27998. expandable?: boolean;
  27999. useModelMaterial?: boolean;
  28000. enableMultiMaterial?: boolean;
  28001. });
  28002. /**
  28003. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28004. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28005. * @returns the created mesh
  28006. */
  28007. buildMesh(): Mesh;
  28008. /**
  28009. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28010. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28011. * Thus the particles generated from `digest()` have their property `position` set yet.
  28012. * @param mesh ( Mesh ) is the mesh to be digested
  28013. * @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
  28014. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28015. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28016. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28017. * @returns the current SPS
  28018. */
  28019. digest(mesh: Mesh, options?: {
  28020. facetNb?: number;
  28021. number?: number;
  28022. delta?: number;
  28023. storage?: [];
  28024. }): SolidParticleSystem;
  28025. /**
  28026. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28027. * @hidden
  28028. */
  28029. private _unrotateFixedNormals;
  28030. /**
  28031. * Resets the temporary working copy particle
  28032. * @hidden
  28033. */
  28034. private _resetCopy;
  28035. /**
  28036. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28037. * @param p the current index in the positions array to be updated
  28038. * @param ind the current index in the indices array
  28039. * @param shape a Vector3 array, the shape geometry
  28040. * @param positions the positions array to be updated
  28041. * @param meshInd the shape indices array
  28042. * @param indices the indices array to be updated
  28043. * @param meshUV the shape uv array
  28044. * @param uvs the uv array to be updated
  28045. * @param meshCol the shape color array
  28046. * @param colors the color array to be updated
  28047. * @param meshNor the shape normals array
  28048. * @param normals the normals array to be updated
  28049. * @param idx the particle index
  28050. * @param idxInShape the particle index in its shape
  28051. * @param options the addShape() method passed options
  28052. * @model the particle model
  28053. * @hidden
  28054. */
  28055. private _meshBuilder;
  28056. /**
  28057. * Returns a shape Vector3 array from positions float array
  28058. * @param positions float array
  28059. * @returns a vector3 array
  28060. * @hidden
  28061. */
  28062. private _posToShape;
  28063. /**
  28064. * Returns a shapeUV array from a float uvs (array deep copy)
  28065. * @param uvs as a float array
  28066. * @returns a shapeUV array
  28067. * @hidden
  28068. */
  28069. private _uvsToShapeUV;
  28070. /**
  28071. * Adds a new particle object in the particles array
  28072. * @param idx particle index in particles array
  28073. * @param id particle id
  28074. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28075. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28076. * @param model particle ModelShape object
  28077. * @param shapeId model shape identifier
  28078. * @param idxInShape index of the particle in the current model
  28079. * @param bInfo model bounding info object
  28080. * @param storage target storage array, if any
  28081. * @hidden
  28082. */
  28083. private _addParticle;
  28084. /**
  28085. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28086. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28087. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28088. * @param nb (positive integer) the number of particles to be created from this model
  28089. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28090. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28091. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28092. * @returns the number of shapes in the system
  28093. */
  28094. addShape(mesh: Mesh, nb: number, options?: {
  28095. positionFunction?: any;
  28096. vertexFunction?: any;
  28097. storage?: [];
  28098. }): number;
  28099. /**
  28100. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28101. * @hidden
  28102. */
  28103. private _rebuildParticle;
  28104. /**
  28105. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28106. * @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.
  28107. * @returns the SPS.
  28108. */
  28109. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28110. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28111. * Returns an array with the removed particles.
  28112. * 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.
  28113. * The SPS can't be empty so at least one particle needs to remain in place.
  28114. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28115. * @param start index of the first particle to remove
  28116. * @param end index of the last particle to remove (included)
  28117. * @returns an array populated with the removed particles
  28118. */
  28119. removeParticles(start: number, end: number): SolidParticle[];
  28120. /**
  28121. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28122. * @param solidParticleArray an array populated with Solid Particles objects
  28123. * @returns the SPS
  28124. */
  28125. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28126. /**
  28127. * Creates a new particle and modifies the SPS mesh geometry :
  28128. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28129. * - calls _addParticle() to populate the particle array
  28130. * factorized code from addShape() and insertParticlesFromArray()
  28131. * @param idx particle index in the particles array
  28132. * @param i particle index in its shape
  28133. * @param modelShape particle ModelShape object
  28134. * @param shape shape vertex array
  28135. * @param meshInd shape indices array
  28136. * @param meshUV shape uv array
  28137. * @param meshCol shape color array
  28138. * @param meshNor shape normals array
  28139. * @param bbInfo shape bounding info
  28140. * @param storage target particle storage
  28141. * @options addShape() passed options
  28142. * @hidden
  28143. */
  28144. private _insertNewParticle;
  28145. /**
  28146. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28147. * This method calls `updateParticle()` for each particle of the SPS.
  28148. * For an animated SPS, it is usually called within the render loop.
  28149. * 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.
  28150. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28151. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28152. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28153. * @returns the SPS.
  28154. */
  28155. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28156. /**
  28157. * Disposes the SPS.
  28158. */
  28159. dispose(): void;
  28160. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28161. * idx is the particle index in the SPS
  28162. * faceId is the picked face index counted within this particle.
  28163. * Returns null if the pickInfo can't identify a picked particle.
  28164. * @param pickingInfo (PickingInfo object)
  28165. * @returns {idx: number, faceId: number} or null
  28166. */
  28167. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28168. idx: number;
  28169. faceId: number;
  28170. }>;
  28171. /**
  28172. * Returns a SolidParticle object from its identifier : particle.id
  28173. * @param id (integer) the particle Id
  28174. * @returns the searched particle or null if not found in the SPS.
  28175. */
  28176. getParticleById(id: number): Nullable<SolidParticle>;
  28177. /**
  28178. * Returns a new array populated with the particles having the passed shapeId.
  28179. * @param shapeId (integer) the shape identifier
  28180. * @returns a new solid particle array
  28181. */
  28182. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28183. /**
  28184. * Populates the passed array "ref" with the particles having the passed shapeId.
  28185. * @param shapeId the shape identifier
  28186. * @returns the SPS
  28187. * @param ref
  28188. */
  28189. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28190. /**
  28191. * Computes the required SubMeshes according the materials assigned to the particles.
  28192. * @returns the solid particle system.
  28193. * Does nothing if called before the SPS mesh is built.
  28194. */
  28195. computeSubMeshes(): SolidParticleSystem;
  28196. /**
  28197. * Sorts the solid particles by material when MultiMaterial is enabled.
  28198. * Updates the indices32 array.
  28199. * Updates the indicesByMaterial array.
  28200. * Updates the mesh indices array.
  28201. * @returns the SPS
  28202. * @hidden
  28203. */
  28204. private _sortParticlesByMaterial;
  28205. /**
  28206. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28207. * @hidden
  28208. */
  28209. private _setMaterialIndexesById;
  28210. /**
  28211. * Returns an array with unique values of Materials from the passed array
  28212. * @param array the material array to be checked and filtered
  28213. * @hidden
  28214. */
  28215. private _filterUniqueMaterialId;
  28216. /**
  28217. * Sets a new Standard Material as _defaultMaterial if not already set.
  28218. * @hidden
  28219. */
  28220. private _setDefaultMaterial;
  28221. /**
  28222. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28224. * @returns the SPS.
  28225. */
  28226. refreshVisibleSize(): SolidParticleSystem;
  28227. /**
  28228. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28229. * @param size the size (float) of the visibility box
  28230. * note : this doesn't lock the SPS mesh bounding box.
  28231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28232. */
  28233. setVisibilityBox(size: number): void;
  28234. /**
  28235. * Gets whether the SPS as always visible or not
  28236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28237. */
  28238. get isAlwaysVisible(): boolean;
  28239. /**
  28240. * Sets the SPS as always visible or not
  28241. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28242. */
  28243. set isAlwaysVisible(val: boolean);
  28244. /**
  28245. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28247. */
  28248. set isVisibilityBoxLocked(val: boolean);
  28249. /**
  28250. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28252. */
  28253. get isVisibilityBoxLocked(): boolean;
  28254. /**
  28255. * Tells to `setParticles()` to compute the particle rotations or not.
  28256. * Default value : true. The SPS is faster when it's set to false.
  28257. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28258. */
  28259. set computeParticleRotation(val: boolean);
  28260. /**
  28261. * Tells to `setParticles()` to compute the particle colors or not.
  28262. * Default value : true. The SPS is faster when it's set to false.
  28263. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28264. */
  28265. set computeParticleColor(val: boolean);
  28266. set computeParticleTexture(val: boolean);
  28267. /**
  28268. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28269. * Default value : false. The SPS is faster when it's set to false.
  28270. * Note : the particle custom vertex positions aren't stored values.
  28271. */
  28272. set computeParticleVertex(val: boolean);
  28273. /**
  28274. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28275. */
  28276. set computeBoundingBox(val: boolean);
  28277. /**
  28278. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28279. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28280. * Default : `true`
  28281. */
  28282. set depthSortParticles(val: boolean);
  28283. /**
  28284. * Gets if `setParticles()` computes the particle rotations or not.
  28285. * Default value : true. The SPS is faster when it's set to false.
  28286. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28287. */
  28288. get computeParticleRotation(): boolean;
  28289. /**
  28290. * Gets if `setParticles()` computes the particle colors or not.
  28291. * Default value : true. The SPS is faster when it's set to false.
  28292. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28293. */
  28294. get computeParticleColor(): boolean;
  28295. /**
  28296. * Gets if `setParticles()` computes the particle textures or not.
  28297. * Default value : true. The SPS is faster when it's set to false.
  28298. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28299. */
  28300. get computeParticleTexture(): boolean;
  28301. /**
  28302. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28303. * Default value : false. The SPS is faster when it's set to false.
  28304. * Note : the particle custom vertex positions aren't stored values.
  28305. */
  28306. get computeParticleVertex(): boolean;
  28307. /**
  28308. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28309. */
  28310. get computeBoundingBox(): boolean;
  28311. /**
  28312. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28313. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28314. * Default : `true`
  28315. */
  28316. get depthSortParticles(): boolean;
  28317. /**
  28318. * Gets if the SPS is created as expandable at construction time.
  28319. * Default : `false`
  28320. */
  28321. get expandable(): boolean;
  28322. /**
  28323. * Gets if the SPS supports the Multi Materials
  28324. */
  28325. get multimaterialEnabled(): boolean;
  28326. /**
  28327. * Gets if the SPS uses the model materials for its own multimaterial.
  28328. */
  28329. get useModelMaterial(): boolean;
  28330. /**
  28331. * The SPS used material array.
  28332. */
  28333. get materials(): Material[];
  28334. /**
  28335. * Sets the SPS MultiMaterial from the passed materials.
  28336. * Note : the passed array is internally copied and not used then by reference.
  28337. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28338. */
  28339. setMultiMaterial(materials: Material[]): void;
  28340. /**
  28341. * The SPS computed multimaterial object
  28342. */
  28343. get multimaterial(): MultiMaterial;
  28344. set multimaterial(mm: MultiMaterial);
  28345. /**
  28346. * If the subMeshes must be updated on the next call to setParticles()
  28347. */
  28348. get autoUpdateSubMeshes(): boolean;
  28349. set autoUpdateSubMeshes(val: boolean);
  28350. /**
  28351. * This function does nothing. It may be overwritten to set all the particle first values.
  28352. * The SPS doesn't call this function, you may have to call it by your own.
  28353. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28354. */
  28355. initParticles(): void;
  28356. /**
  28357. * This function does nothing. It may be overwritten to recycle a particle.
  28358. * The SPS doesn't call this function, you may have to call it by your own.
  28359. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28360. * @param particle The particle to recycle
  28361. * @returns the recycled particle
  28362. */
  28363. recycleParticle(particle: SolidParticle): SolidParticle;
  28364. /**
  28365. * Updates a particle : this function should be overwritten by the user.
  28366. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28367. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28368. * @example : just set a particle position or velocity and recycle conditions
  28369. * @param particle The particle to update
  28370. * @returns the updated particle
  28371. */
  28372. updateParticle(particle: SolidParticle): SolidParticle;
  28373. /**
  28374. * Updates a vertex of a particle : it can be overwritten by the user.
  28375. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28376. * @param particle the current particle
  28377. * @param vertex the current index of the current particle
  28378. * @param pt the index of the current vertex in the particle shape
  28379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28380. * @example : just set a vertex particle position
  28381. * @returns the updated vertex
  28382. */
  28383. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28384. /**
  28385. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28386. * This does nothing and may be overwritten by the user.
  28387. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28388. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28389. * @param update the boolean update value actually passed to setParticles()
  28390. */
  28391. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28392. /**
  28393. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28394. * This will be passed three parameters.
  28395. * This does nothing and may be overwritten by the user.
  28396. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28397. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28398. * @param update the boolean update value actually passed to setParticles()
  28399. */
  28400. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28401. }
  28402. }
  28403. declare module "babylonjs/Particles/solidParticle" {
  28404. import { Nullable } from "babylonjs/types";
  28405. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28406. import { Color4 } from "babylonjs/Maths/math.color";
  28407. import { Mesh } from "babylonjs/Meshes/mesh";
  28408. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28409. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28410. import { Plane } from "babylonjs/Maths/math.plane";
  28411. import { Material } from "babylonjs/Materials/material";
  28412. /**
  28413. * Represents one particle of a solid particle system.
  28414. */
  28415. export class SolidParticle {
  28416. /**
  28417. * particle global index
  28418. */
  28419. idx: number;
  28420. /**
  28421. * particle identifier
  28422. */
  28423. id: number;
  28424. /**
  28425. * The color of the particle
  28426. */
  28427. color: Nullable<Color4>;
  28428. /**
  28429. * The world space position of the particle.
  28430. */
  28431. position: Vector3;
  28432. /**
  28433. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28434. */
  28435. rotation: Vector3;
  28436. /**
  28437. * The world space rotation quaternion of the particle.
  28438. */
  28439. rotationQuaternion: Nullable<Quaternion>;
  28440. /**
  28441. * The scaling of the particle.
  28442. */
  28443. scaling: Vector3;
  28444. /**
  28445. * The uvs of the particle.
  28446. */
  28447. uvs: Vector4;
  28448. /**
  28449. * The current speed of the particle.
  28450. */
  28451. velocity: Vector3;
  28452. /**
  28453. * The pivot point in the particle local space.
  28454. */
  28455. pivot: Vector3;
  28456. /**
  28457. * Must the particle be translated from its pivot point in its local space ?
  28458. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28459. * Default : false
  28460. */
  28461. translateFromPivot: boolean;
  28462. /**
  28463. * Is the particle active or not ?
  28464. */
  28465. alive: boolean;
  28466. /**
  28467. * Is the particle visible or not ?
  28468. */
  28469. isVisible: boolean;
  28470. /**
  28471. * Index of this particle in the global "positions" array (Internal use)
  28472. * @hidden
  28473. */
  28474. _pos: number;
  28475. /**
  28476. * @hidden Index of this particle in the global "indices" array (Internal use)
  28477. */
  28478. _ind: number;
  28479. /**
  28480. * @hidden ModelShape of this particle (Internal use)
  28481. */
  28482. _model: ModelShape;
  28483. /**
  28484. * ModelShape id of this particle
  28485. */
  28486. shapeId: number;
  28487. /**
  28488. * Index of the particle in its shape id
  28489. */
  28490. idxInShape: number;
  28491. /**
  28492. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28493. */
  28494. _modelBoundingInfo: BoundingInfo;
  28495. /**
  28496. * @hidden Particle BoundingInfo object (Internal use)
  28497. */
  28498. _boundingInfo: BoundingInfo;
  28499. /**
  28500. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28501. */
  28502. _sps: SolidParticleSystem;
  28503. /**
  28504. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28505. */
  28506. _stillInvisible: boolean;
  28507. /**
  28508. * @hidden Last computed particle rotation matrix
  28509. */
  28510. _rotationMatrix: number[];
  28511. /**
  28512. * Parent particle Id, if any.
  28513. * Default null.
  28514. */
  28515. parentId: Nullable<number>;
  28516. /**
  28517. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28518. */
  28519. materialIndex: Nullable<number>;
  28520. /**
  28521. * Custom object or properties.
  28522. */
  28523. props: Nullable<any>;
  28524. /**
  28525. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28526. * The possible values are :
  28527. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28528. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28529. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28530. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28531. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28532. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28533. * */
  28534. cullingStrategy: number;
  28535. /**
  28536. * @hidden Internal global position in the SPS.
  28537. */
  28538. _globalPosition: Vector3;
  28539. /**
  28540. * Creates a Solid Particle object.
  28541. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28542. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28543. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28544. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28545. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28546. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28547. * @param shapeId (integer) is the model shape identifier in the SPS.
  28548. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28549. * @param sps defines the sps it is associated to
  28550. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28551. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28552. */
  28553. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28554. /**
  28555. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28556. * @param target the particle target
  28557. * @returns the current particle
  28558. */
  28559. copyToRef(target: SolidParticle): SolidParticle;
  28560. /**
  28561. * Legacy support, changed scale to scaling
  28562. */
  28563. get scale(): Vector3;
  28564. /**
  28565. * Legacy support, changed scale to scaling
  28566. */
  28567. set scale(scale: Vector3);
  28568. /**
  28569. * Legacy support, changed quaternion to rotationQuaternion
  28570. */
  28571. get quaternion(): Nullable<Quaternion>;
  28572. /**
  28573. * Legacy support, changed quaternion to rotationQuaternion
  28574. */
  28575. set quaternion(q: Nullable<Quaternion>);
  28576. /**
  28577. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28578. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28579. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28580. * @returns true if it intersects
  28581. */
  28582. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28583. /**
  28584. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28585. * A particle is in the frustum if its bounding box intersects the frustum
  28586. * @param frustumPlanes defines the frustum to test
  28587. * @returns true if the particle is in the frustum planes
  28588. */
  28589. isInFrustum(frustumPlanes: Plane[]): boolean;
  28590. /**
  28591. * get the rotation matrix of the particle
  28592. * @hidden
  28593. */
  28594. getRotationMatrix(m: Matrix): void;
  28595. }
  28596. /**
  28597. * Represents the shape of the model used by one particle of a solid particle system.
  28598. * SPS internal tool, don't use it manually.
  28599. */
  28600. export class ModelShape {
  28601. /**
  28602. * The shape id
  28603. * @hidden
  28604. */
  28605. shapeID: number;
  28606. /**
  28607. * flat array of model positions (internal use)
  28608. * @hidden
  28609. */
  28610. _shape: Vector3[];
  28611. /**
  28612. * flat array of model UVs (internal use)
  28613. * @hidden
  28614. */
  28615. _shapeUV: number[];
  28616. /**
  28617. * color array of the model
  28618. * @hidden
  28619. */
  28620. _shapeColors: number[];
  28621. /**
  28622. * indices array of the model
  28623. * @hidden
  28624. */
  28625. _indices: number[];
  28626. /**
  28627. * normals array of the model
  28628. * @hidden
  28629. */
  28630. _normals: number[];
  28631. /**
  28632. * length of the shape in the model indices array (internal use)
  28633. * @hidden
  28634. */
  28635. _indicesLength: number;
  28636. /**
  28637. * Custom position function (internal use)
  28638. * @hidden
  28639. */
  28640. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28641. /**
  28642. * Custom vertex function (internal use)
  28643. * @hidden
  28644. */
  28645. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28646. /**
  28647. * Model material (internal use)
  28648. * @hidden
  28649. */
  28650. _material: Nullable<Material>;
  28651. /**
  28652. * 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.
  28653. * SPS internal tool, don't use it manually.
  28654. * @hidden
  28655. */
  28656. 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>);
  28657. }
  28658. /**
  28659. * Represents a Depth Sorted Particle in the solid particle system.
  28660. * @hidden
  28661. */
  28662. export class DepthSortedParticle {
  28663. /**
  28664. * Particle index
  28665. */
  28666. idx: number;
  28667. /**
  28668. * Index of the particle in the "indices" array
  28669. */
  28670. ind: number;
  28671. /**
  28672. * Length of the particle shape in the "indices" array
  28673. */
  28674. indicesLength: number;
  28675. /**
  28676. * Squared distance from the particle to the camera
  28677. */
  28678. sqDistance: number;
  28679. /**
  28680. * Material index when used with MultiMaterials
  28681. */
  28682. materialIndex: number;
  28683. /**
  28684. * Creates a new sorted particle
  28685. * @param materialIndex
  28686. */
  28687. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28688. }
  28689. }
  28690. declare module "babylonjs/Collisions/meshCollisionData" {
  28691. import { Collider } from "babylonjs/Collisions/collider";
  28692. import { Vector3 } from "babylonjs/Maths/math.vector";
  28693. import { Nullable } from "babylonjs/types";
  28694. import { Observer } from "babylonjs/Misc/observable";
  28695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28696. /**
  28697. * @hidden
  28698. */
  28699. export class _MeshCollisionData {
  28700. _checkCollisions: boolean;
  28701. _collisionMask: number;
  28702. _collisionGroup: number;
  28703. _collider: Nullable<Collider>;
  28704. _oldPositionForCollisions: Vector3;
  28705. _diffPositionForCollisions: Vector3;
  28706. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28707. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28708. }
  28709. }
  28710. declare module "babylonjs/Meshes/abstractMesh" {
  28711. import { Observable } from "babylonjs/Misc/observable";
  28712. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28713. import { Camera } from "babylonjs/Cameras/camera";
  28714. import { Scene, IDisposable } from "babylonjs/scene";
  28715. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28716. import { Node } from "babylonjs/node";
  28717. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28718. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28720. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28721. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28722. import { Material } from "babylonjs/Materials/material";
  28723. import { Light } from "babylonjs/Lights/light";
  28724. import { Skeleton } from "babylonjs/Bones/skeleton";
  28725. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28726. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28727. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28728. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28729. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28730. import { Plane } from "babylonjs/Maths/math.plane";
  28731. import { Ray } from "babylonjs/Culling/ray";
  28732. import { Collider } from "babylonjs/Collisions/collider";
  28733. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28734. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28735. /** @hidden */
  28736. class _FacetDataStorage {
  28737. facetPositions: Vector3[];
  28738. facetNormals: Vector3[];
  28739. facetPartitioning: number[][];
  28740. facetNb: number;
  28741. partitioningSubdivisions: number;
  28742. partitioningBBoxRatio: number;
  28743. facetDataEnabled: boolean;
  28744. facetParameters: any;
  28745. bbSize: Vector3;
  28746. subDiv: {
  28747. max: number;
  28748. X: number;
  28749. Y: number;
  28750. Z: number;
  28751. };
  28752. facetDepthSort: boolean;
  28753. facetDepthSortEnabled: boolean;
  28754. depthSortedIndices: IndicesArray;
  28755. depthSortedFacets: {
  28756. ind: number;
  28757. sqDistance: number;
  28758. }[];
  28759. facetDepthSortFunction: (f1: {
  28760. ind: number;
  28761. sqDistance: number;
  28762. }, f2: {
  28763. ind: number;
  28764. sqDistance: number;
  28765. }) => number;
  28766. facetDepthSortFrom: Vector3;
  28767. facetDepthSortOrigin: Vector3;
  28768. invertedMatrix: Matrix;
  28769. }
  28770. /**
  28771. * @hidden
  28772. **/
  28773. class _InternalAbstractMeshDataInfo {
  28774. _hasVertexAlpha: boolean;
  28775. _useVertexColors: boolean;
  28776. _numBoneInfluencers: number;
  28777. _applyFog: boolean;
  28778. _receiveShadows: boolean;
  28779. _facetData: _FacetDataStorage;
  28780. _visibility: number;
  28781. _skeleton: Nullable<Skeleton>;
  28782. _layerMask: number;
  28783. _computeBonesUsingShaders: boolean;
  28784. _isActive: boolean;
  28785. _onlyForInstances: boolean;
  28786. _isActiveIntermediate: boolean;
  28787. _onlyForInstancesIntermediate: boolean;
  28788. _actAsRegularMesh: boolean;
  28789. }
  28790. /**
  28791. * Class used to store all common mesh properties
  28792. */
  28793. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28794. /** No occlusion */
  28795. static OCCLUSION_TYPE_NONE: number;
  28796. /** Occlusion set to optimisitic */
  28797. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28798. /** Occlusion set to strict */
  28799. static OCCLUSION_TYPE_STRICT: number;
  28800. /** Use an accurante occlusion algorithm */
  28801. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28802. /** Use a conservative occlusion algorithm */
  28803. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28804. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28805. * Test order :
  28806. * Is the bounding sphere outside the frustum ?
  28807. * If not, are the bounding box vertices outside the frustum ?
  28808. * It not, then the cullable object is in the frustum.
  28809. */
  28810. static readonly CULLINGSTRATEGY_STANDARD: number;
  28811. /** Culling strategy : Bounding Sphere Only.
  28812. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28813. * It's also less accurate than the standard because some not visible objects can still be selected.
  28814. * Test : is the bounding sphere outside the frustum ?
  28815. * If not, then the cullable object is in the frustum.
  28816. */
  28817. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28818. /** Culling strategy : Optimistic Inclusion.
  28819. * This in an inclusion test first, then the standard exclusion test.
  28820. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28821. * 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.
  28822. * Anyway, it's as accurate as the standard strategy.
  28823. * Test :
  28824. * Is the cullable object bounding sphere center in the frustum ?
  28825. * If not, apply the default culling strategy.
  28826. */
  28827. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28828. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28829. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28830. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28831. * 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.
  28832. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28833. * Test :
  28834. * Is the cullable object bounding sphere center in the frustum ?
  28835. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28836. */
  28837. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28838. /**
  28839. * No billboard
  28840. */
  28841. static get BILLBOARDMODE_NONE(): number;
  28842. /** Billboard on X axis */
  28843. static get BILLBOARDMODE_X(): number;
  28844. /** Billboard on Y axis */
  28845. static get BILLBOARDMODE_Y(): number;
  28846. /** Billboard on Z axis */
  28847. static get BILLBOARDMODE_Z(): number;
  28848. /** Billboard on all axes */
  28849. static get BILLBOARDMODE_ALL(): number;
  28850. /** Billboard on using position instead of orientation */
  28851. static get BILLBOARDMODE_USE_POSITION(): number;
  28852. /** @hidden */
  28853. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28854. /**
  28855. * The culling strategy to use to check whether the mesh must be rendered or not.
  28856. * This value can be changed at any time and will be used on the next render mesh selection.
  28857. * The possible values are :
  28858. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28859. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28860. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28861. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28862. * Please read each static variable documentation to get details about the culling process.
  28863. * */
  28864. cullingStrategy: number;
  28865. /**
  28866. * Gets the number of facets in the mesh
  28867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28868. */
  28869. get facetNb(): number;
  28870. /**
  28871. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28873. */
  28874. get partitioningSubdivisions(): number;
  28875. set partitioningSubdivisions(nb: number);
  28876. /**
  28877. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28878. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28880. */
  28881. get partitioningBBoxRatio(): number;
  28882. set partitioningBBoxRatio(ratio: number);
  28883. /**
  28884. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28885. * Works only for updatable meshes.
  28886. * Doesn't work with multi-materials
  28887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28888. */
  28889. get mustDepthSortFacets(): boolean;
  28890. set mustDepthSortFacets(sort: boolean);
  28891. /**
  28892. * The location (Vector3) where the facet depth sort must be computed from.
  28893. * By default, the active camera position.
  28894. * Used only when facet depth sort is enabled
  28895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28896. */
  28897. get facetDepthSortFrom(): Vector3;
  28898. set facetDepthSortFrom(location: Vector3);
  28899. /**
  28900. * gets a boolean indicating if facetData is enabled
  28901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28902. */
  28903. get isFacetDataEnabled(): boolean;
  28904. /** @hidden */
  28905. _updateNonUniformScalingState(value: boolean): boolean;
  28906. /**
  28907. * An event triggered when this mesh collides with another one
  28908. */
  28909. onCollideObservable: Observable<AbstractMesh>;
  28910. /** Set a function to call when this mesh collides with another one */
  28911. set onCollide(callback: () => void);
  28912. /**
  28913. * An event triggered when the collision's position changes
  28914. */
  28915. onCollisionPositionChangeObservable: Observable<Vector3>;
  28916. /** Set a function to call when the collision's position changes */
  28917. set onCollisionPositionChange(callback: () => void);
  28918. /**
  28919. * An event triggered when material is changed
  28920. */
  28921. onMaterialChangedObservable: Observable<AbstractMesh>;
  28922. /**
  28923. * Gets or sets the orientation for POV movement & rotation
  28924. */
  28925. definedFacingForward: boolean;
  28926. /** @hidden */
  28927. _occlusionQuery: Nullable<WebGLQuery>;
  28928. /** @hidden */
  28929. _renderingGroup: Nullable<RenderingGroup>;
  28930. /**
  28931. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28932. */
  28933. get visibility(): number;
  28934. /**
  28935. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28936. */
  28937. set visibility(value: number);
  28938. /** Gets or sets the alpha index used to sort transparent meshes
  28939. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28940. */
  28941. alphaIndex: number;
  28942. /**
  28943. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28944. */
  28945. isVisible: boolean;
  28946. /**
  28947. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28948. */
  28949. isPickable: boolean;
  28950. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28951. showSubMeshesBoundingBox: boolean;
  28952. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28953. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28954. */
  28955. isBlocker: boolean;
  28956. /**
  28957. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28958. */
  28959. enablePointerMoveEvents: boolean;
  28960. /**
  28961. * Specifies the rendering group id for this mesh (0 by default)
  28962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28963. */
  28964. renderingGroupId: number;
  28965. private _material;
  28966. /** Gets or sets current material */
  28967. get material(): Nullable<Material>;
  28968. set material(value: Nullable<Material>);
  28969. /**
  28970. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28971. * @see http://doc.babylonjs.com/babylon101/shadows
  28972. */
  28973. get receiveShadows(): boolean;
  28974. set receiveShadows(value: boolean);
  28975. /** Defines color to use when rendering outline */
  28976. outlineColor: Color3;
  28977. /** Define width to use when rendering outline */
  28978. outlineWidth: number;
  28979. /** Defines color to use when rendering overlay */
  28980. overlayColor: Color3;
  28981. /** Defines alpha to use when rendering overlay */
  28982. overlayAlpha: number;
  28983. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28984. get hasVertexAlpha(): boolean;
  28985. set hasVertexAlpha(value: boolean);
  28986. /** 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) */
  28987. get useVertexColors(): boolean;
  28988. set useVertexColors(value: boolean);
  28989. /**
  28990. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28991. */
  28992. get computeBonesUsingShaders(): boolean;
  28993. set computeBonesUsingShaders(value: boolean);
  28994. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28995. get numBoneInfluencers(): number;
  28996. set numBoneInfluencers(value: number);
  28997. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28998. get applyFog(): boolean;
  28999. set applyFog(value: boolean);
  29000. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29001. useOctreeForRenderingSelection: boolean;
  29002. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29003. useOctreeForPicking: boolean;
  29004. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29005. useOctreeForCollisions: boolean;
  29006. /**
  29007. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29008. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29009. */
  29010. get layerMask(): number;
  29011. set layerMask(value: number);
  29012. /**
  29013. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29014. */
  29015. alwaysSelectAsActiveMesh: boolean;
  29016. /**
  29017. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29018. */
  29019. doNotSyncBoundingInfo: boolean;
  29020. /**
  29021. * Gets or sets the current action manager
  29022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29023. */
  29024. actionManager: Nullable<AbstractActionManager>;
  29025. private _meshCollisionData;
  29026. /**
  29027. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29029. */
  29030. ellipsoid: Vector3;
  29031. /**
  29032. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29034. */
  29035. ellipsoidOffset: Vector3;
  29036. /**
  29037. * Gets or sets a collision mask used to mask collisions (default is -1).
  29038. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29039. */
  29040. get collisionMask(): number;
  29041. set collisionMask(mask: number);
  29042. /**
  29043. * Gets or sets the current collision group mask (-1 by default).
  29044. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29045. */
  29046. get collisionGroup(): number;
  29047. set collisionGroup(mask: number);
  29048. /**
  29049. * Defines edge width used when edgesRenderer is enabled
  29050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29051. */
  29052. edgesWidth: number;
  29053. /**
  29054. * Defines edge color used when edgesRenderer is enabled
  29055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29056. */
  29057. edgesColor: Color4;
  29058. /** @hidden */
  29059. _edgesRenderer: Nullable<IEdgesRenderer>;
  29060. /** @hidden */
  29061. _masterMesh: Nullable<AbstractMesh>;
  29062. /** @hidden */
  29063. _boundingInfo: Nullable<BoundingInfo>;
  29064. /** @hidden */
  29065. _renderId: number;
  29066. /**
  29067. * Gets or sets the list of subMeshes
  29068. * @see http://doc.babylonjs.com/how_to/multi_materials
  29069. */
  29070. subMeshes: SubMesh[];
  29071. /** @hidden */
  29072. _intersectionsInProgress: AbstractMesh[];
  29073. /** @hidden */
  29074. _unIndexed: boolean;
  29075. /** @hidden */
  29076. _lightSources: Light[];
  29077. /** Gets the list of lights affecting that mesh */
  29078. get lightSources(): Light[];
  29079. /** @hidden */
  29080. get _positions(): Nullable<Vector3[]>;
  29081. /** @hidden */
  29082. _waitingData: {
  29083. lods: Nullable<any>;
  29084. actions: Nullable<any>;
  29085. freezeWorldMatrix: Nullable<boolean>;
  29086. };
  29087. /** @hidden */
  29088. _bonesTransformMatrices: Nullable<Float32Array>;
  29089. /** @hidden */
  29090. _transformMatrixTexture: Nullable<RawTexture>;
  29091. /**
  29092. * Gets or sets a skeleton to apply skining transformations
  29093. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29094. */
  29095. set skeleton(value: Nullable<Skeleton>);
  29096. get skeleton(): Nullable<Skeleton>;
  29097. /**
  29098. * An event triggered when the mesh is rebuilt.
  29099. */
  29100. onRebuildObservable: Observable<AbstractMesh>;
  29101. /**
  29102. * Creates a new AbstractMesh
  29103. * @param name defines the name of the mesh
  29104. * @param scene defines the hosting scene
  29105. */
  29106. constructor(name: string, scene?: Nullable<Scene>);
  29107. /**
  29108. * Returns the string "AbstractMesh"
  29109. * @returns "AbstractMesh"
  29110. */
  29111. getClassName(): string;
  29112. /**
  29113. * Gets a string representation of the current mesh
  29114. * @param fullDetails defines a boolean indicating if full details must be included
  29115. * @returns a string representation of the current mesh
  29116. */
  29117. toString(fullDetails?: boolean): string;
  29118. /**
  29119. * @hidden
  29120. */
  29121. protected _getEffectiveParent(): Nullable<Node>;
  29122. /** @hidden */
  29123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29124. /** @hidden */
  29125. _rebuild(): void;
  29126. /** @hidden */
  29127. _resyncLightSources(): void;
  29128. /** @hidden */
  29129. _resyncLightSource(light: Light): void;
  29130. /** @hidden */
  29131. _unBindEffect(): void;
  29132. /** @hidden */
  29133. _removeLightSource(light: Light, dispose: boolean): void;
  29134. private _markSubMeshesAsDirty;
  29135. /** @hidden */
  29136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29137. /** @hidden */
  29138. _markSubMeshesAsAttributesDirty(): void;
  29139. /** @hidden */
  29140. _markSubMeshesAsMiscDirty(): void;
  29141. /**
  29142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29143. */
  29144. get scaling(): Vector3;
  29145. set scaling(newScaling: Vector3);
  29146. /**
  29147. * Returns true if the mesh is blocked. Implemented by child classes
  29148. */
  29149. get isBlocked(): boolean;
  29150. /**
  29151. * Returns the mesh itself by default. Implemented by child classes
  29152. * @param camera defines the camera to use to pick the right LOD level
  29153. * @returns the currentAbstractMesh
  29154. */
  29155. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29156. /**
  29157. * Returns 0 by default. Implemented by child classes
  29158. * @returns an integer
  29159. */
  29160. getTotalVertices(): number;
  29161. /**
  29162. * Returns a positive integer : the total number of indices in this mesh geometry.
  29163. * @returns the numner of indices or zero if the mesh has no geometry.
  29164. */
  29165. getTotalIndices(): number;
  29166. /**
  29167. * Returns null by default. Implemented by child classes
  29168. * @returns null
  29169. */
  29170. getIndices(): Nullable<IndicesArray>;
  29171. /**
  29172. * Returns the array of the requested vertex data kind. Implemented by child classes
  29173. * @param kind defines the vertex data kind to use
  29174. * @returns null
  29175. */
  29176. getVerticesData(kind: string): Nullable<FloatArray>;
  29177. /**
  29178. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29179. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29180. * Note that a new underlying VertexBuffer object is created each call.
  29181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29182. * @param kind defines vertex data kind:
  29183. * * VertexBuffer.PositionKind
  29184. * * VertexBuffer.UVKind
  29185. * * VertexBuffer.UV2Kind
  29186. * * VertexBuffer.UV3Kind
  29187. * * VertexBuffer.UV4Kind
  29188. * * VertexBuffer.UV5Kind
  29189. * * VertexBuffer.UV6Kind
  29190. * * VertexBuffer.ColorKind
  29191. * * VertexBuffer.MatricesIndicesKind
  29192. * * VertexBuffer.MatricesIndicesExtraKind
  29193. * * VertexBuffer.MatricesWeightsKind
  29194. * * VertexBuffer.MatricesWeightsExtraKind
  29195. * @param data defines the data source
  29196. * @param updatable defines if the data must be flagged as updatable (or static)
  29197. * @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
  29198. * @returns the current mesh
  29199. */
  29200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29201. /**
  29202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29203. * If the mesh has no geometry, it is simply returned as it is.
  29204. * @param kind defines vertex data kind:
  29205. * * VertexBuffer.PositionKind
  29206. * * VertexBuffer.UVKind
  29207. * * VertexBuffer.UV2Kind
  29208. * * VertexBuffer.UV3Kind
  29209. * * VertexBuffer.UV4Kind
  29210. * * VertexBuffer.UV5Kind
  29211. * * VertexBuffer.UV6Kind
  29212. * * VertexBuffer.ColorKind
  29213. * * VertexBuffer.MatricesIndicesKind
  29214. * * VertexBuffer.MatricesIndicesExtraKind
  29215. * * VertexBuffer.MatricesWeightsKind
  29216. * * VertexBuffer.MatricesWeightsExtraKind
  29217. * @param data defines the data source
  29218. * @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
  29219. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29220. * @returns the current mesh
  29221. */
  29222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29223. /**
  29224. * Sets the mesh indices,
  29225. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29226. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29227. * @param totalVertices Defines the total number of vertices
  29228. * @returns the current mesh
  29229. */
  29230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29231. /**
  29232. * Gets a boolean indicating if specific vertex data is present
  29233. * @param kind defines the vertex data kind to use
  29234. * @returns true is data kind is present
  29235. */
  29236. isVerticesDataPresent(kind: string): boolean;
  29237. /**
  29238. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29239. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29240. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29241. * @returns a BoundingInfo
  29242. */
  29243. getBoundingInfo(): BoundingInfo;
  29244. /**
  29245. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29246. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29247. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29248. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29249. * @returns the current mesh
  29250. */
  29251. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29252. /**
  29253. * Overwrite the current bounding info
  29254. * @param boundingInfo defines the new bounding info
  29255. * @returns the current mesh
  29256. */
  29257. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29258. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29259. get useBones(): boolean;
  29260. /** @hidden */
  29261. _preActivate(): void;
  29262. /** @hidden */
  29263. _preActivateForIntermediateRendering(renderId: number): void;
  29264. /** @hidden */
  29265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29266. /** @hidden */
  29267. _postActivate(): void;
  29268. /** @hidden */
  29269. _freeze(): void;
  29270. /** @hidden */
  29271. _unFreeze(): void;
  29272. /**
  29273. * Gets the current world matrix
  29274. * @returns a Matrix
  29275. */
  29276. getWorldMatrix(): Matrix;
  29277. /** @hidden */
  29278. _getWorldMatrixDeterminant(): number;
  29279. /**
  29280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29281. */
  29282. get isAnInstance(): boolean;
  29283. /**
  29284. * Gets a boolean indicating if this mesh has instances
  29285. */
  29286. get hasInstances(): boolean;
  29287. /**
  29288. * Perform relative position change from the point of view of behind the front of the mesh.
  29289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29290. * Supports definition of mesh facing forward or backward
  29291. * @param amountRight defines the distance on the right axis
  29292. * @param amountUp defines the distance on the up axis
  29293. * @param amountForward defines the distance on the forward axis
  29294. * @returns the current mesh
  29295. */
  29296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29297. /**
  29298. * Calculate relative position change from the point of view of behind the front of the mesh.
  29299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29300. * Supports definition of mesh facing forward or backward
  29301. * @param amountRight defines the distance on the right axis
  29302. * @param amountUp defines the distance on the up axis
  29303. * @param amountForward defines the distance on the forward axis
  29304. * @returns the new displacement vector
  29305. */
  29306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29307. /**
  29308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29309. * Supports definition of mesh facing forward or backward
  29310. * @param flipBack defines the flip
  29311. * @param twirlClockwise defines the twirl
  29312. * @param tiltRight defines the tilt
  29313. * @returns the current mesh
  29314. */
  29315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29316. /**
  29317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29318. * Supports definition of mesh facing forward or backward.
  29319. * @param flipBack defines the flip
  29320. * @param twirlClockwise defines the twirl
  29321. * @param tiltRight defines the tilt
  29322. * @returns the new rotation vector
  29323. */
  29324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29325. /**
  29326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29327. * This means the mesh underlying bounding box and sphere are recomputed.
  29328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29329. * @returns the current mesh
  29330. */
  29331. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29332. /** @hidden */
  29333. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29334. /** @hidden */
  29335. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29336. /** @hidden */
  29337. _updateBoundingInfo(): AbstractMesh;
  29338. /** @hidden */
  29339. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29340. /** @hidden */
  29341. protected _afterComputeWorldMatrix(): void;
  29342. /** @hidden */
  29343. get _effectiveMesh(): AbstractMesh;
  29344. /**
  29345. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29346. * A mesh is in the frustum if its bounding box intersects the frustum
  29347. * @param frustumPlanes defines the frustum to test
  29348. * @returns true if the mesh is in the frustum planes
  29349. */
  29350. isInFrustum(frustumPlanes: Plane[]): boolean;
  29351. /**
  29352. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29353. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29354. * @param frustumPlanes defines the frustum to test
  29355. * @returns true if the mesh is completely in the frustum planes
  29356. */
  29357. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29358. /**
  29359. * True if the mesh intersects another mesh or a SolidParticle object
  29360. * @param mesh defines a target mesh or SolidParticle to test
  29361. * @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)
  29362. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29363. * @returns true if there is an intersection
  29364. */
  29365. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29366. /**
  29367. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29368. * @param point defines the point to test
  29369. * @returns true if there is an intersection
  29370. */
  29371. intersectsPoint(point: Vector3): boolean;
  29372. /**
  29373. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29375. */
  29376. get checkCollisions(): boolean;
  29377. set checkCollisions(collisionEnabled: boolean);
  29378. /**
  29379. * Gets Collider object used to compute collisions (not physics)
  29380. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29381. */
  29382. get collider(): Nullable<Collider>;
  29383. /**
  29384. * Move the mesh using collision engine
  29385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29386. * @param displacement defines the requested displacement vector
  29387. * @returns the current mesh
  29388. */
  29389. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29390. private _onCollisionPositionChange;
  29391. /** @hidden */
  29392. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29393. /** @hidden */
  29394. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29395. /** @hidden */
  29396. _checkCollision(collider: Collider): AbstractMesh;
  29397. /** @hidden */
  29398. _generatePointsArray(): boolean;
  29399. /**
  29400. * Checks if the passed Ray intersects with the mesh
  29401. * @param ray defines the ray to use
  29402. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29404. * @returns the picking info
  29405. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29406. */
  29407. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29408. /**
  29409. * Clones the current mesh
  29410. * @param name defines the mesh name
  29411. * @param newParent defines the new mesh parent
  29412. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29413. * @returns the new mesh
  29414. */
  29415. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29416. /**
  29417. * Disposes all the submeshes of the current meshnp
  29418. * @returns the current mesh
  29419. */
  29420. releaseSubMeshes(): AbstractMesh;
  29421. /**
  29422. * Releases resources associated with this abstract mesh.
  29423. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29424. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29425. */
  29426. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29427. /**
  29428. * Adds the passed mesh as a child to the current mesh
  29429. * @param mesh defines the child mesh
  29430. * @returns the current mesh
  29431. */
  29432. addChild(mesh: AbstractMesh): AbstractMesh;
  29433. /**
  29434. * Removes the passed mesh from the current mesh children list
  29435. * @param mesh defines the child mesh
  29436. * @returns the current mesh
  29437. */
  29438. removeChild(mesh: AbstractMesh): AbstractMesh;
  29439. /** @hidden */
  29440. private _initFacetData;
  29441. /**
  29442. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29443. * This method can be called within the render loop.
  29444. * 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
  29445. * @returns the current mesh
  29446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29447. */
  29448. updateFacetData(): AbstractMesh;
  29449. /**
  29450. * Returns the facetLocalNormals array.
  29451. * The normals are expressed in the mesh local spac
  29452. * @returns an array of Vector3
  29453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29454. */
  29455. getFacetLocalNormals(): Vector3[];
  29456. /**
  29457. * Returns the facetLocalPositions array.
  29458. * The facet positions are expressed in the mesh local space
  29459. * @returns an array of Vector3
  29460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29461. */
  29462. getFacetLocalPositions(): Vector3[];
  29463. /**
  29464. * Returns the facetLocalPartioning array
  29465. * @returns an array of array of numbers
  29466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29467. */
  29468. getFacetLocalPartitioning(): number[][];
  29469. /**
  29470. * Returns the i-th facet position in the world system.
  29471. * This method allocates a new Vector3 per call
  29472. * @param i defines the facet index
  29473. * @returns a new Vector3
  29474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29475. */
  29476. getFacetPosition(i: number): Vector3;
  29477. /**
  29478. * Sets the reference Vector3 with the i-th facet position in the world system
  29479. * @param i defines the facet index
  29480. * @param ref defines the target vector
  29481. * @returns the current mesh
  29482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29483. */
  29484. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29485. /**
  29486. * Returns the i-th facet normal in the world system.
  29487. * This method allocates a new Vector3 per call
  29488. * @param i defines the facet index
  29489. * @returns a new Vector3
  29490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29491. */
  29492. getFacetNormal(i: number): Vector3;
  29493. /**
  29494. * Sets the reference Vector3 with the i-th facet normal in the world system
  29495. * @param i defines the facet index
  29496. * @param ref defines the target vector
  29497. * @returns the current mesh
  29498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29499. */
  29500. getFacetNormalToRef(i: number, ref: Vector3): this;
  29501. /**
  29502. * 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)
  29503. * @param x defines x coordinate
  29504. * @param y defines y coordinate
  29505. * @param z defines z coordinate
  29506. * @returns the array of facet indexes
  29507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29508. */
  29509. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29510. /**
  29511. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29512. * @param projected sets as the (x,y,z) world projection on the facet
  29513. * @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
  29514. * @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
  29515. * @param x defines x coordinate
  29516. * @param y defines y coordinate
  29517. * @param z defines z coordinate
  29518. * @returns the face index if found (or null instead)
  29519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29520. */
  29521. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29522. /**
  29523. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29524. * @param projected sets as the (x,y,z) local projection on the facet
  29525. * @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
  29526. * @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
  29527. * @param x defines x coordinate
  29528. * @param y defines y coordinate
  29529. * @param z defines z coordinate
  29530. * @returns the face index if found (or null instead)
  29531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29532. */
  29533. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29534. /**
  29535. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29536. * @returns the parameters
  29537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29538. */
  29539. getFacetDataParameters(): any;
  29540. /**
  29541. * Disables the feature FacetData and frees the related memory
  29542. * @returns the current mesh
  29543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29544. */
  29545. disableFacetData(): AbstractMesh;
  29546. /**
  29547. * Updates the AbstractMesh indices array
  29548. * @param indices defines the data source
  29549. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29550. * @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)
  29551. * @returns the current mesh
  29552. */
  29553. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29554. /**
  29555. * Creates new normals data for the mesh
  29556. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29557. * @returns the current mesh
  29558. */
  29559. createNormals(updatable: boolean): AbstractMesh;
  29560. /**
  29561. * Align the mesh with a normal
  29562. * @param normal defines the normal to use
  29563. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29564. * @returns the current mesh
  29565. */
  29566. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29567. /** @hidden */
  29568. _checkOcclusionQuery(): boolean;
  29569. /**
  29570. * Disables the mesh edge rendering mode
  29571. * @returns the currentAbstractMesh
  29572. */
  29573. disableEdgesRendering(): AbstractMesh;
  29574. /**
  29575. * Enables the edge rendering mode on the mesh.
  29576. * This mode makes the mesh edges visible
  29577. * @param epsilon defines the maximal distance between two angles to detect a face
  29578. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29579. * @returns the currentAbstractMesh
  29580. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29581. */
  29582. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29583. }
  29584. }
  29585. declare module "babylonjs/Actions/actionEvent" {
  29586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29587. import { Nullable } from "babylonjs/types";
  29588. import { Sprite } from "babylonjs/Sprites/sprite";
  29589. import { Scene } from "babylonjs/scene";
  29590. import { Vector2 } from "babylonjs/Maths/math.vector";
  29591. /**
  29592. * Interface used to define ActionEvent
  29593. */
  29594. export interface IActionEvent {
  29595. /** The mesh or sprite that triggered the action */
  29596. source: any;
  29597. /** The X mouse cursor position at the time of the event */
  29598. pointerX: number;
  29599. /** The Y mouse cursor position at the time of the event */
  29600. pointerY: number;
  29601. /** The mesh that is currently pointed at (can be null) */
  29602. meshUnderPointer: Nullable<AbstractMesh>;
  29603. /** the original (browser) event that triggered the ActionEvent */
  29604. sourceEvent?: any;
  29605. /** additional data for the event */
  29606. additionalData?: any;
  29607. }
  29608. /**
  29609. * ActionEvent is the event being sent when an action is triggered.
  29610. */
  29611. export class ActionEvent implements IActionEvent {
  29612. /** The mesh or sprite that triggered the action */
  29613. source: any;
  29614. /** The X mouse cursor position at the time of the event */
  29615. pointerX: number;
  29616. /** The Y mouse cursor position at the time of the event */
  29617. pointerY: number;
  29618. /** The mesh that is currently pointed at (can be null) */
  29619. meshUnderPointer: Nullable<AbstractMesh>;
  29620. /** the original (browser) event that triggered the ActionEvent */
  29621. sourceEvent?: any;
  29622. /** additional data for the event */
  29623. additionalData?: any;
  29624. /**
  29625. * Creates a new ActionEvent
  29626. * @param source The mesh or sprite that triggered the action
  29627. * @param pointerX The X mouse cursor position at the time of the event
  29628. * @param pointerY The Y mouse cursor position at the time of the event
  29629. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29630. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29631. * @param additionalData additional data for the event
  29632. */
  29633. constructor(
  29634. /** The mesh or sprite that triggered the action */
  29635. source: any,
  29636. /** The X mouse cursor position at the time of the event */
  29637. pointerX: number,
  29638. /** The Y mouse cursor position at the time of the event */
  29639. pointerY: number,
  29640. /** The mesh that is currently pointed at (can be null) */
  29641. meshUnderPointer: Nullable<AbstractMesh>,
  29642. /** the original (browser) event that triggered the ActionEvent */
  29643. sourceEvent?: any,
  29644. /** additional data for the event */
  29645. additionalData?: any);
  29646. /**
  29647. * Helper function to auto-create an ActionEvent from a source mesh.
  29648. * @param source The source mesh that triggered the event
  29649. * @param evt The original (browser) event
  29650. * @param additionalData additional data for the event
  29651. * @returns the new ActionEvent
  29652. */
  29653. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29654. /**
  29655. * Helper function to auto-create an ActionEvent from a source sprite
  29656. * @param source The source sprite that triggered the event
  29657. * @param scene Scene associated with the sprite
  29658. * @param evt The original (browser) event
  29659. * @param additionalData additional data for the event
  29660. * @returns the new ActionEvent
  29661. */
  29662. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29663. /**
  29664. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29665. * @param scene the scene where the event occurred
  29666. * @param evt The original (browser) event
  29667. * @returns the new ActionEvent
  29668. */
  29669. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29670. /**
  29671. * Helper function to auto-create an ActionEvent from a primitive
  29672. * @param prim defines the target primitive
  29673. * @param pointerPos defines the pointer position
  29674. * @param evt The original (browser) event
  29675. * @param additionalData additional data for the event
  29676. * @returns the new ActionEvent
  29677. */
  29678. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29679. }
  29680. }
  29681. declare module "babylonjs/Actions/abstractActionManager" {
  29682. import { IDisposable } from "babylonjs/scene";
  29683. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29684. import { IAction } from "babylonjs/Actions/action";
  29685. import { Nullable } from "babylonjs/types";
  29686. /**
  29687. * Abstract class used to decouple action Manager from scene and meshes.
  29688. * Do not instantiate.
  29689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29690. */
  29691. export abstract class AbstractActionManager implements IDisposable {
  29692. /** Gets the list of active triggers */
  29693. static Triggers: {
  29694. [key: string]: number;
  29695. };
  29696. /** Gets the cursor to use when hovering items */
  29697. hoverCursor: string;
  29698. /** Gets the list of actions */
  29699. actions: IAction[];
  29700. /**
  29701. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29702. */
  29703. isRecursive: boolean;
  29704. /**
  29705. * Releases all associated resources
  29706. */
  29707. abstract dispose(): void;
  29708. /**
  29709. * Does this action manager has pointer triggers
  29710. */
  29711. abstract get hasPointerTriggers(): boolean;
  29712. /**
  29713. * Does this action manager has pick triggers
  29714. */
  29715. abstract get hasPickTriggers(): boolean;
  29716. /**
  29717. * Process a specific trigger
  29718. * @param trigger defines the trigger to process
  29719. * @param evt defines the event details to be processed
  29720. */
  29721. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29722. /**
  29723. * Does this action manager handles actions of any of the given triggers
  29724. * @param triggers defines the triggers to be tested
  29725. * @return a boolean indicating whether one (or more) of the triggers is handled
  29726. */
  29727. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29728. /**
  29729. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29730. * speed.
  29731. * @param triggerA defines the trigger to be tested
  29732. * @param triggerB defines the trigger to be tested
  29733. * @return a boolean indicating whether one (or more) of the triggers is handled
  29734. */
  29735. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29736. /**
  29737. * Does this action manager handles actions of a given trigger
  29738. * @param trigger defines the trigger to be tested
  29739. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29740. * @return whether the trigger is handled
  29741. */
  29742. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29743. /**
  29744. * Serialize this manager to a JSON object
  29745. * @param name defines the property name to store this manager
  29746. * @returns a JSON representation of this manager
  29747. */
  29748. abstract serialize(name: string): any;
  29749. /**
  29750. * Registers an action to this action manager
  29751. * @param action defines the action to be registered
  29752. * @return the action amended (prepared) after registration
  29753. */
  29754. abstract registerAction(action: IAction): Nullable<IAction>;
  29755. /**
  29756. * Unregisters an action to this action manager
  29757. * @param action defines the action to be unregistered
  29758. * @return a boolean indicating whether the action has been unregistered
  29759. */
  29760. abstract unregisterAction(action: IAction): Boolean;
  29761. /**
  29762. * Does exist one action manager with at least one trigger
  29763. **/
  29764. static get HasTriggers(): boolean;
  29765. /**
  29766. * Does exist one action manager with at least one pick trigger
  29767. **/
  29768. static get HasPickTriggers(): boolean;
  29769. /**
  29770. * Does exist one action manager that handles actions of a given trigger
  29771. * @param trigger defines the trigger to be tested
  29772. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29773. **/
  29774. static HasSpecificTrigger(trigger: number): boolean;
  29775. }
  29776. }
  29777. declare module "babylonjs/node" {
  29778. import { Scene } from "babylonjs/scene";
  29779. import { Nullable } from "babylonjs/types";
  29780. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29781. import { Engine } from "babylonjs/Engines/engine";
  29782. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29783. import { Observable } from "babylonjs/Misc/observable";
  29784. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29785. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29786. import { Animatable } from "babylonjs/Animations/animatable";
  29787. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29788. import { Animation } from "babylonjs/Animations/animation";
  29789. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29791. /**
  29792. * Defines how a node can be built from a string name.
  29793. */
  29794. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29795. /**
  29796. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29797. */
  29798. export class Node implements IBehaviorAware<Node> {
  29799. /** @hidden */
  29800. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29801. private static _NodeConstructors;
  29802. /**
  29803. * Add a new node constructor
  29804. * @param type defines the type name of the node to construct
  29805. * @param constructorFunc defines the constructor function
  29806. */
  29807. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29808. /**
  29809. * Returns a node constructor based on type name
  29810. * @param type defines the type name
  29811. * @param name defines the new node name
  29812. * @param scene defines the hosting scene
  29813. * @param options defines optional options to transmit to constructors
  29814. * @returns the new constructor or null
  29815. */
  29816. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29817. /**
  29818. * Gets or sets the name of the node
  29819. */
  29820. name: string;
  29821. /**
  29822. * Gets or sets the id of the node
  29823. */
  29824. id: string;
  29825. /**
  29826. * Gets or sets the unique id of the node
  29827. */
  29828. uniqueId: number;
  29829. /**
  29830. * Gets or sets a string used to store user defined state for the node
  29831. */
  29832. state: string;
  29833. /**
  29834. * Gets or sets an object used to store user defined information for the node
  29835. */
  29836. metadata: any;
  29837. /**
  29838. * For internal use only. Please do not use.
  29839. */
  29840. reservedDataStore: any;
  29841. /**
  29842. * List of inspectable custom properties (used by the Inspector)
  29843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29844. */
  29845. inspectableCustomProperties: IInspectable[];
  29846. private _doNotSerialize;
  29847. /**
  29848. * Gets or sets a boolean used to define if the node must be serialized
  29849. */
  29850. get doNotSerialize(): boolean;
  29851. set doNotSerialize(value: boolean);
  29852. /** @hidden */
  29853. _isDisposed: boolean;
  29854. /**
  29855. * Gets a list of Animations associated with the node
  29856. */
  29857. animations: import("babylonjs/Animations/animation").Animation[];
  29858. protected _ranges: {
  29859. [name: string]: Nullable<AnimationRange>;
  29860. };
  29861. /**
  29862. * Callback raised when the node is ready to be used
  29863. */
  29864. onReady: Nullable<(node: Node) => void>;
  29865. private _isEnabled;
  29866. private _isParentEnabled;
  29867. private _isReady;
  29868. /** @hidden */
  29869. _currentRenderId: number;
  29870. private _parentUpdateId;
  29871. /** @hidden */
  29872. _childUpdateId: number;
  29873. /** @hidden */
  29874. _waitingParentId: Nullable<string>;
  29875. /** @hidden */
  29876. _scene: Scene;
  29877. /** @hidden */
  29878. _cache: any;
  29879. private _parentNode;
  29880. private _children;
  29881. /** @hidden */
  29882. _worldMatrix: Matrix;
  29883. /** @hidden */
  29884. _worldMatrixDeterminant: number;
  29885. /** @hidden */
  29886. _worldMatrixDeterminantIsDirty: boolean;
  29887. /** @hidden */
  29888. private _sceneRootNodesIndex;
  29889. /**
  29890. * Gets a boolean indicating if the node has been disposed
  29891. * @returns true if the node was disposed
  29892. */
  29893. isDisposed(): boolean;
  29894. /**
  29895. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29896. * @see https://doc.babylonjs.com/how_to/parenting
  29897. */
  29898. set parent(parent: Nullable<Node>);
  29899. get parent(): Nullable<Node>;
  29900. /** @hidden */
  29901. _addToSceneRootNodes(): void;
  29902. /** @hidden */
  29903. _removeFromSceneRootNodes(): void;
  29904. private _animationPropertiesOverride;
  29905. /**
  29906. * Gets or sets the animation properties override
  29907. */
  29908. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29909. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29910. /**
  29911. * Gets a string idenfifying the name of the class
  29912. * @returns "Node" string
  29913. */
  29914. getClassName(): string;
  29915. /** @hidden */
  29916. readonly _isNode: boolean;
  29917. /**
  29918. * An event triggered when the mesh is disposed
  29919. */
  29920. onDisposeObservable: Observable<Node>;
  29921. private _onDisposeObserver;
  29922. /**
  29923. * Sets a callback that will be raised when the node will be disposed
  29924. */
  29925. set onDispose(callback: () => void);
  29926. /**
  29927. * Creates a new Node
  29928. * @param name the name and id to be given to this node
  29929. * @param scene the scene this node will be added to
  29930. */
  29931. constructor(name: string, scene?: Nullable<Scene>);
  29932. /**
  29933. * Gets the scene of the node
  29934. * @returns a scene
  29935. */
  29936. getScene(): Scene;
  29937. /**
  29938. * Gets the engine of the node
  29939. * @returns a Engine
  29940. */
  29941. getEngine(): Engine;
  29942. private _behaviors;
  29943. /**
  29944. * Attach a behavior to the node
  29945. * @see http://doc.babylonjs.com/features/behaviour
  29946. * @param behavior defines the behavior to attach
  29947. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29948. * @returns the current Node
  29949. */
  29950. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29951. /**
  29952. * Remove an attached behavior
  29953. * @see http://doc.babylonjs.com/features/behaviour
  29954. * @param behavior defines the behavior to attach
  29955. * @returns the current Node
  29956. */
  29957. removeBehavior(behavior: Behavior<Node>): Node;
  29958. /**
  29959. * Gets the list of attached behaviors
  29960. * @see http://doc.babylonjs.com/features/behaviour
  29961. */
  29962. get behaviors(): Behavior<Node>[];
  29963. /**
  29964. * Gets an attached behavior by name
  29965. * @param name defines the name of the behavior to look for
  29966. * @see http://doc.babylonjs.com/features/behaviour
  29967. * @returns null if behavior was not found else the requested behavior
  29968. */
  29969. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29970. /**
  29971. * Returns the latest update of the World matrix
  29972. * @returns a Matrix
  29973. */
  29974. getWorldMatrix(): Matrix;
  29975. /** @hidden */
  29976. _getWorldMatrixDeterminant(): number;
  29977. /**
  29978. * Returns directly the latest state of the mesh World matrix.
  29979. * A Matrix is returned.
  29980. */
  29981. get worldMatrixFromCache(): Matrix;
  29982. /** @hidden */
  29983. _initCache(): void;
  29984. /** @hidden */
  29985. updateCache(force?: boolean): void;
  29986. /** @hidden */
  29987. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29988. /** @hidden */
  29989. _updateCache(ignoreParentClass?: boolean): void;
  29990. /** @hidden */
  29991. _isSynchronized(): boolean;
  29992. /** @hidden */
  29993. _markSyncedWithParent(): void;
  29994. /** @hidden */
  29995. isSynchronizedWithParent(): boolean;
  29996. /** @hidden */
  29997. isSynchronized(): boolean;
  29998. /**
  29999. * Is this node ready to be used/rendered
  30000. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30001. * @return true if the node is ready
  30002. */
  30003. isReady(completeCheck?: boolean): boolean;
  30004. /**
  30005. * Is this node enabled?
  30006. * 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
  30007. * @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
  30008. * @return whether this node (and its parent) is enabled
  30009. */
  30010. isEnabled(checkAncestors?: boolean): boolean;
  30011. /** @hidden */
  30012. protected _syncParentEnabledState(): void;
  30013. /**
  30014. * Set the enabled state of this node
  30015. * @param value defines the new enabled state
  30016. */
  30017. setEnabled(value: boolean): void;
  30018. /**
  30019. * Is this node a descendant of the given node?
  30020. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30021. * @param ancestor defines the parent node to inspect
  30022. * @returns a boolean indicating if this node is a descendant of the given node
  30023. */
  30024. isDescendantOf(ancestor: Node): boolean;
  30025. /** @hidden */
  30026. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30027. /**
  30028. * Will return all nodes that have this node as ascendant
  30029. * @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
  30030. * @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
  30031. * @return all children nodes of all types
  30032. */
  30033. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30034. /**
  30035. * Get all child-meshes of this node
  30036. * @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)
  30037. * @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
  30038. * @returns an array of AbstractMesh
  30039. */
  30040. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30041. /**
  30042. * Get all direct children of this node
  30043. * @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
  30044. * @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)
  30045. * @returns an array of Node
  30046. */
  30047. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30048. /** @hidden */
  30049. _setReady(state: boolean): void;
  30050. /**
  30051. * Get an animation by name
  30052. * @param name defines the name of the animation to look for
  30053. * @returns null if not found else the requested animation
  30054. */
  30055. getAnimationByName(name: string): Nullable<Animation>;
  30056. /**
  30057. * Creates an animation range for this node
  30058. * @param name defines the name of the range
  30059. * @param from defines the starting key
  30060. * @param to defines the end key
  30061. */
  30062. createAnimationRange(name: string, from: number, to: number): void;
  30063. /**
  30064. * Delete a specific animation range
  30065. * @param name defines the name of the range to delete
  30066. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30067. */
  30068. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30069. /**
  30070. * Get an animation range by name
  30071. * @param name defines the name of the animation range to look for
  30072. * @returns null if not found else the requested animation range
  30073. */
  30074. getAnimationRange(name: string): Nullable<AnimationRange>;
  30075. /**
  30076. * Gets the list of all animation ranges defined on this node
  30077. * @returns an array
  30078. */
  30079. getAnimationRanges(): Nullable<AnimationRange>[];
  30080. /**
  30081. * Will start the animation sequence
  30082. * @param name defines the range frames for animation sequence
  30083. * @param loop defines if the animation should loop (false by default)
  30084. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30085. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30086. * @returns the object created for this animation. If range does not exist, it will return null
  30087. */
  30088. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30089. /**
  30090. * Serialize animation ranges into a JSON compatible object
  30091. * @returns serialization object
  30092. */
  30093. serializeAnimationRanges(): any;
  30094. /**
  30095. * Computes the world matrix of the node
  30096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30097. * @returns the world matrix
  30098. */
  30099. computeWorldMatrix(force?: boolean): Matrix;
  30100. /**
  30101. * Releases resources associated with this node.
  30102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30104. */
  30105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30106. /**
  30107. * Parse animation range data from a serialization object and store them into a given node
  30108. * @param node defines where to store the animation ranges
  30109. * @param parsedNode defines the serialization object to read data from
  30110. * @param scene defines the hosting scene
  30111. */
  30112. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30113. /**
  30114. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30115. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30116. * @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
  30117. * @returns the new bounding vectors
  30118. */
  30119. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30120. min: Vector3;
  30121. max: Vector3;
  30122. };
  30123. }
  30124. }
  30125. declare module "babylonjs/Animations/animation" {
  30126. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30127. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30128. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30129. import { Nullable } from "babylonjs/types";
  30130. import { Scene } from "babylonjs/scene";
  30131. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30132. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30133. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30134. import { Node } from "babylonjs/node";
  30135. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30136. import { Size } from "babylonjs/Maths/math.size";
  30137. import { Animatable } from "babylonjs/Animations/animatable";
  30138. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30139. /**
  30140. * @hidden
  30141. */
  30142. export class _IAnimationState {
  30143. key: number;
  30144. repeatCount: number;
  30145. workValue?: any;
  30146. loopMode?: number;
  30147. offsetValue?: any;
  30148. highLimitValue?: any;
  30149. }
  30150. /**
  30151. * Class used to store any kind of animation
  30152. */
  30153. export class Animation {
  30154. /**Name of the animation */
  30155. name: string;
  30156. /**Property to animate */
  30157. targetProperty: string;
  30158. /**The frames per second of the animation */
  30159. framePerSecond: number;
  30160. /**The data type of the animation */
  30161. dataType: number;
  30162. /**The loop mode of the animation */
  30163. loopMode?: number | undefined;
  30164. /**Specifies if blending should be enabled */
  30165. enableBlending?: boolean | undefined;
  30166. /**
  30167. * Use matrix interpolation instead of using direct key value when animating matrices
  30168. */
  30169. static AllowMatricesInterpolation: boolean;
  30170. /**
  30171. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30172. */
  30173. static AllowMatrixDecomposeForInterpolation: boolean;
  30174. /**
  30175. * Stores the key frames of the animation
  30176. */
  30177. private _keys;
  30178. /**
  30179. * Stores the easing function of the animation
  30180. */
  30181. private _easingFunction;
  30182. /**
  30183. * @hidden Internal use only
  30184. */
  30185. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30186. /**
  30187. * The set of event that will be linked to this animation
  30188. */
  30189. private _events;
  30190. /**
  30191. * Stores an array of target property paths
  30192. */
  30193. targetPropertyPath: string[];
  30194. /**
  30195. * Stores the blending speed of the animation
  30196. */
  30197. blendingSpeed: number;
  30198. /**
  30199. * Stores the animation ranges for the animation
  30200. */
  30201. private _ranges;
  30202. /**
  30203. * @hidden Internal use
  30204. */
  30205. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30206. /**
  30207. * Sets up an animation
  30208. * @param property The property to animate
  30209. * @param animationType The animation type to apply
  30210. * @param framePerSecond The frames per second of the animation
  30211. * @param easingFunction The easing function used in the animation
  30212. * @returns The created animation
  30213. */
  30214. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30215. /**
  30216. * Create and start an animation on a node
  30217. * @param name defines the name of the global animation that will be run on all nodes
  30218. * @param node defines the root node where the animation will take place
  30219. * @param targetProperty defines property to animate
  30220. * @param framePerSecond defines the number of frame per second yo use
  30221. * @param totalFrame defines the number of frames in total
  30222. * @param from defines the initial value
  30223. * @param to defines the final value
  30224. * @param loopMode defines which loop mode you want to use (off by default)
  30225. * @param easingFunction defines the easing function to use (linear by default)
  30226. * @param onAnimationEnd defines the callback to call when animation end
  30227. * @returns the animatable created for this animation
  30228. */
  30229. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30230. /**
  30231. * Create and start an animation on a node and its descendants
  30232. * @param name defines the name of the global animation that will be run on all nodes
  30233. * @param node defines the root node where the animation will take place
  30234. * @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
  30235. * @param targetProperty defines property to animate
  30236. * @param framePerSecond defines the number of frame per second to use
  30237. * @param totalFrame defines the number of frames in total
  30238. * @param from defines the initial value
  30239. * @param to defines the final value
  30240. * @param loopMode defines which loop mode you want to use (off by default)
  30241. * @param easingFunction defines the easing function to use (linear by default)
  30242. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30243. * @returns the list of animatables created for all nodes
  30244. * @example https://www.babylonjs-playground.com/#MH0VLI
  30245. */
  30246. 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[]>;
  30247. /**
  30248. * Creates a new animation, merges it with the existing animations and starts it
  30249. * @param name Name of the animation
  30250. * @param node Node which contains the scene that begins the animations
  30251. * @param targetProperty Specifies which property to animate
  30252. * @param framePerSecond The frames per second of the animation
  30253. * @param totalFrame The total number of frames
  30254. * @param from The frame at the beginning of the animation
  30255. * @param to The frame at the end of the animation
  30256. * @param loopMode Specifies the loop mode of the animation
  30257. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30258. * @param onAnimationEnd Callback to run once the animation is complete
  30259. * @returns Nullable animation
  30260. */
  30261. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30262. /**
  30263. * Transition property of an host to the target Value
  30264. * @param property The property to transition
  30265. * @param targetValue The target Value of the property
  30266. * @param host The object where the property to animate belongs
  30267. * @param scene Scene used to run the animation
  30268. * @param frameRate Framerate (in frame/s) to use
  30269. * @param transition The transition type we want to use
  30270. * @param duration The duration of the animation, in milliseconds
  30271. * @param onAnimationEnd Callback trigger at the end of the animation
  30272. * @returns Nullable animation
  30273. */
  30274. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30275. /**
  30276. * Return the array of runtime animations currently using this animation
  30277. */
  30278. get runtimeAnimations(): RuntimeAnimation[];
  30279. /**
  30280. * Specifies if any of the runtime animations are currently running
  30281. */
  30282. get hasRunningRuntimeAnimations(): boolean;
  30283. /**
  30284. * Initializes the animation
  30285. * @param name Name of the animation
  30286. * @param targetProperty Property to animate
  30287. * @param framePerSecond The frames per second of the animation
  30288. * @param dataType The data type of the animation
  30289. * @param loopMode The loop mode of the animation
  30290. * @param enableBlending Specifies if blending should be enabled
  30291. */
  30292. constructor(
  30293. /**Name of the animation */
  30294. name: string,
  30295. /**Property to animate */
  30296. targetProperty: string,
  30297. /**The frames per second of the animation */
  30298. framePerSecond: number,
  30299. /**The data type of the animation */
  30300. dataType: number,
  30301. /**The loop mode of the animation */
  30302. loopMode?: number | undefined,
  30303. /**Specifies if blending should be enabled */
  30304. enableBlending?: boolean | undefined);
  30305. /**
  30306. * Converts the animation to a string
  30307. * @param fullDetails support for multiple levels of logging within scene loading
  30308. * @returns String form of the animation
  30309. */
  30310. toString(fullDetails?: boolean): string;
  30311. /**
  30312. * Add an event to this animation
  30313. * @param event Event to add
  30314. */
  30315. addEvent(event: AnimationEvent): void;
  30316. /**
  30317. * Remove all events found at the given frame
  30318. * @param frame The frame to remove events from
  30319. */
  30320. removeEvents(frame: number): void;
  30321. /**
  30322. * Retrieves all the events from the animation
  30323. * @returns Events from the animation
  30324. */
  30325. getEvents(): AnimationEvent[];
  30326. /**
  30327. * Creates an animation range
  30328. * @param name Name of the animation range
  30329. * @param from Starting frame of the animation range
  30330. * @param to Ending frame of the animation
  30331. */
  30332. createRange(name: string, from: number, to: number): void;
  30333. /**
  30334. * Deletes an animation range by name
  30335. * @param name Name of the animation range to delete
  30336. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30337. */
  30338. deleteRange(name: string, deleteFrames?: boolean): void;
  30339. /**
  30340. * Gets the animation range by name, or null if not defined
  30341. * @param name Name of the animation range
  30342. * @returns Nullable animation range
  30343. */
  30344. getRange(name: string): Nullable<AnimationRange>;
  30345. /**
  30346. * Gets the key frames from the animation
  30347. * @returns The key frames of the animation
  30348. */
  30349. getKeys(): Array<IAnimationKey>;
  30350. /**
  30351. * Gets the highest frame rate of the animation
  30352. * @returns Highest frame rate of the animation
  30353. */
  30354. getHighestFrame(): number;
  30355. /**
  30356. * Gets the easing function of the animation
  30357. * @returns Easing function of the animation
  30358. */
  30359. getEasingFunction(): IEasingFunction;
  30360. /**
  30361. * Sets the easing function of the animation
  30362. * @param easingFunction A custom mathematical formula for animation
  30363. */
  30364. setEasingFunction(easingFunction: EasingFunction): void;
  30365. /**
  30366. * Interpolates a scalar linearly
  30367. * @param startValue Start value of the animation curve
  30368. * @param endValue End value of the animation curve
  30369. * @param gradient Scalar amount to interpolate
  30370. * @returns Interpolated scalar value
  30371. */
  30372. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30373. /**
  30374. * Interpolates a scalar cubically
  30375. * @param startValue Start value of the animation curve
  30376. * @param outTangent End tangent of the animation
  30377. * @param endValue End value of the animation curve
  30378. * @param inTangent Start tangent of the animation curve
  30379. * @param gradient Scalar amount to interpolate
  30380. * @returns Interpolated scalar value
  30381. */
  30382. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30383. /**
  30384. * Interpolates a quaternion using a spherical linear interpolation
  30385. * @param startValue Start value of the animation curve
  30386. * @param endValue End value of the animation curve
  30387. * @param gradient Scalar amount to interpolate
  30388. * @returns Interpolated quaternion value
  30389. */
  30390. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30391. /**
  30392. * Interpolates a quaternion cubically
  30393. * @param startValue Start value of the animation curve
  30394. * @param outTangent End tangent of the animation curve
  30395. * @param endValue End value of the animation curve
  30396. * @param inTangent Start tangent of the animation curve
  30397. * @param gradient Scalar amount to interpolate
  30398. * @returns Interpolated quaternion value
  30399. */
  30400. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30401. /**
  30402. * Interpolates a Vector3 linearl
  30403. * @param startValue Start value of the animation curve
  30404. * @param endValue End value of the animation curve
  30405. * @param gradient Scalar amount to interpolate
  30406. * @returns Interpolated scalar value
  30407. */
  30408. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30409. /**
  30410. * Interpolates a Vector3 cubically
  30411. * @param startValue Start value of the animation curve
  30412. * @param outTangent End tangent of the animation
  30413. * @param endValue End value of the animation curve
  30414. * @param inTangent Start tangent of the animation curve
  30415. * @param gradient Scalar amount to interpolate
  30416. * @returns InterpolatedVector3 value
  30417. */
  30418. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30419. /**
  30420. * Interpolates a Vector2 linearly
  30421. * @param startValue Start value of the animation curve
  30422. * @param endValue End value of the animation curve
  30423. * @param gradient Scalar amount to interpolate
  30424. * @returns Interpolated Vector2 value
  30425. */
  30426. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30427. /**
  30428. * Interpolates a Vector2 cubically
  30429. * @param startValue Start value of the animation curve
  30430. * @param outTangent End tangent of the animation
  30431. * @param endValue End value of the animation curve
  30432. * @param inTangent Start tangent of the animation curve
  30433. * @param gradient Scalar amount to interpolate
  30434. * @returns Interpolated Vector2 value
  30435. */
  30436. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30437. /**
  30438. * Interpolates a size linearly
  30439. * @param startValue Start value of the animation curve
  30440. * @param endValue End value of the animation curve
  30441. * @param gradient Scalar amount to interpolate
  30442. * @returns Interpolated Size value
  30443. */
  30444. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30445. /**
  30446. * Interpolates a Color3 linearly
  30447. * @param startValue Start value of the animation curve
  30448. * @param endValue End value of the animation curve
  30449. * @param gradient Scalar amount to interpolate
  30450. * @returns Interpolated Color3 value
  30451. */
  30452. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30453. /**
  30454. * Interpolates a Color4 linearly
  30455. * @param startValue Start value of the animation curve
  30456. * @param endValue End value of the animation curve
  30457. * @param gradient Scalar amount to interpolate
  30458. * @returns Interpolated Color3 value
  30459. */
  30460. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30461. /**
  30462. * @hidden Internal use only
  30463. */
  30464. _getKeyValue(value: any): any;
  30465. /**
  30466. * @hidden Internal use only
  30467. */
  30468. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30469. /**
  30470. * Defines the function to use to interpolate matrices
  30471. * @param startValue defines the start matrix
  30472. * @param endValue defines the end matrix
  30473. * @param gradient defines the gradient between both matrices
  30474. * @param result defines an optional target matrix where to store the interpolation
  30475. * @returns the interpolated matrix
  30476. */
  30477. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30478. /**
  30479. * Makes a copy of the animation
  30480. * @returns Cloned animation
  30481. */
  30482. clone(): Animation;
  30483. /**
  30484. * Sets the key frames of the animation
  30485. * @param values The animation key frames to set
  30486. */
  30487. setKeys(values: Array<IAnimationKey>): void;
  30488. /**
  30489. * Serializes the animation to an object
  30490. * @returns Serialized object
  30491. */
  30492. serialize(): any;
  30493. /**
  30494. * Float animation type
  30495. */
  30496. static readonly ANIMATIONTYPE_FLOAT: number;
  30497. /**
  30498. * Vector3 animation type
  30499. */
  30500. static readonly ANIMATIONTYPE_VECTOR3: number;
  30501. /**
  30502. * Quaternion animation type
  30503. */
  30504. static readonly ANIMATIONTYPE_QUATERNION: number;
  30505. /**
  30506. * Matrix animation type
  30507. */
  30508. static readonly ANIMATIONTYPE_MATRIX: number;
  30509. /**
  30510. * Color3 animation type
  30511. */
  30512. static readonly ANIMATIONTYPE_COLOR3: number;
  30513. /**
  30514. * Color3 animation type
  30515. */
  30516. static readonly ANIMATIONTYPE_COLOR4: number;
  30517. /**
  30518. * Vector2 animation type
  30519. */
  30520. static readonly ANIMATIONTYPE_VECTOR2: number;
  30521. /**
  30522. * Size animation type
  30523. */
  30524. static readonly ANIMATIONTYPE_SIZE: number;
  30525. /**
  30526. * Relative Loop Mode
  30527. */
  30528. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30529. /**
  30530. * Cycle Loop Mode
  30531. */
  30532. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30533. /**
  30534. * Constant Loop Mode
  30535. */
  30536. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30537. /** @hidden */
  30538. static _UniversalLerp(left: any, right: any, amount: number): any;
  30539. /**
  30540. * Parses an animation object and creates an animation
  30541. * @param parsedAnimation Parsed animation object
  30542. * @returns Animation object
  30543. */
  30544. static Parse(parsedAnimation: any): Animation;
  30545. /**
  30546. * Appends the serialized animations from the source animations
  30547. * @param source Source containing the animations
  30548. * @param destination Target to store the animations
  30549. */
  30550. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30551. }
  30552. }
  30553. declare module "babylonjs/Animations/animatable.interface" {
  30554. import { Nullable } from "babylonjs/types";
  30555. import { Animation } from "babylonjs/Animations/animation";
  30556. /**
  30557. * Interface containing an array of animations
  30558. */
  30559. export interface IAnimatable {
  30560. /**
  30561. * Array of animations
  30562. */
  30563. animations: Nullable<Array<Animation>>;
  30564. }
  30565. }
  30566. declare module "babylonjs/Misc/decorators" {
  30567. import { Nullable } from "babylonjs/types";
  30568. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30569. import { Scene } from "babylonjs/scene";
  30570. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30571. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30572. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30573. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30574. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30575. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30576. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30577. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30578. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30579. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30580. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30581. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30582. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30583. /**
  30584. * Decorator used to define property that can be serialized as reference to a camera
  30585. * @param sourceName defines the name of the property to decorate
  30586. */
  30587. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30588. /**
  30589. * Class used to help serialization objects
  30590. */
  30591. export class SerializationHelper {
  30592. /** @hidden */
  30593. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30594. /** @hidden */
  30595. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30596. /** @hidden */
  30597. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30598. /** @hidden */
  30599. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30600. /**
  30601. * Appends the serialized animations from the source animations
  30602. * @param source Source containing the animations
  30603. * @param destination Target to store the animations
  30604. */
  30605. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30606. /**
  30607. * Static function used to serialized a specific entity
  30608. * @param entity defines the entity to serialize
  30609. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30610. * @returns a JSON compatible object representing the serialization of the entity
  30611. */
  30612. static Serialize<T>(entity: T, serializationObject?: any): any;
  30613. /**
  30614. * Creates a new entity from a serialization data object
  30615. * @param creationFunction defines a function used to instanciated the new entity
  30616. * @param source defines the source serialization data
  30617. * @param scene defines the hosting scene
  30618. * @param rootUrl defines the root url for resources
  30619. * @returns a new entity
  30620. */
  30621. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30622. /**
  30623. * Clones an object
  30624. * @param creationFunction defines the function used to instanciate the new object
  30625. * @param source defines the source object
  30626. * @returns the cloned object
  30627. */
  30628. static Clone<T>(creationFunction: () => T, source: T): T;
  30629. /**
  30630. * Instanciates a new object based on a source one (some data will be shared between both object)
  30631. * @param creationFunction defines the function used to instanciate the new object
  30632. * @param source defines the source object
  30633. * @returns the new object
  30634. */
  30635. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30636. }
  30637. }
  30638. declare module "babylonjs/Misc/guid" {
  30639. /**
  30640. * Class used to manipulate GUIDs
  30641. */
  30642. export class GUID {
  30643. /**
  30644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30645. * Be aware Math.random() could cause collisions, but:
  30646. * "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"
  30647. * @returns a pseudo random id
  30648. */
  30649. static RandomId(): string;
  30650. }
  30651. }
  30652. declare module "babylonjs/Materials/Textures/baseTexture" {
  30653. import { Observable } from "babylonjs/Misc/observable";
  30654. import { Nullable } from "babylonjs/types";
  30655. import { Scene } from "babylonjs/scene";
  30656. import { Matrix } from "babylonjs/Maths/math.vector";
  30657. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30658. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30659. import { ISize } from "babylonjs/Maths/math.size";
  30660. import "babylonjs/Misc/fileTools";
  30661. /**
  30662. * Base class of all the textures in babylon.
  30663. * It groups all the common properties the materials, post process, lights... might need
  30664. * in order to make a correct use of the texture.
  30665. */
  30666. export class BaseTexture implements IAnimatable {
  30667. /**
  30668. * Default anisotropic filtering level for the application.
  30669. * It is set to 4 as a good tradeoff between perf and quality.
  30670. */
  30671. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30672. /**
  30673. * Gets or sets the unique id of the texture
  30674. */
  30675. uniqueId: number;
  30676. /**
  30677. * Define the name of the texture.
  30678. */
  30679. name: string;
  30680. /**
  30681. * Gets or sets an object used to store user defined information.
  30682. */
  30683. metadata: any;
  30684. /**
  30685. * For internal use only. Please do not use.
  30686. */
  30687. reservedDataStore: any;
  30688. private _hasAlpha;
  30689. /**
  30690. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30691. */
  30692. set hasAlpha(value: boolean);
  30693. get hasAlpha(): boolean;
  30694. /**
  30695. * Defines if the alpha value should be determined via the rgb values.
  30696. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30697. */
  30698. getAlphaFromRGB: boolean;
  30699. /**
  30700. * Intensity or strength of the texture.
  30701. * It is commonly used by materials to fine tune the intensity of the texture
  30702. */
  30703. level: number;
  30704. /**
  30705. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30706. * This is part of the texture as textures usually maps to one uv set.
  30707. */
  30708. coordinatesIndex: number;
  30709. private _coordinatesMode;
  30710. /**
  30711. * How a texture is mapped.
  30712. *
  30713. * | Value | Type | Description |
  30714. * | ----- | ----------------------------------- | ----------- |
  30715. * | 0 | EXPLICIT_MODE | |
  30716. * | 1 | SPHERICAL_MODE | |
  30717. * | 2 | PLANAR_MODE | |
  30718. * | 3 | CUBIC_MODE | |
  30719. * | 4 | PROJECTION_MODE | |
  30720. * | 5 | SKYBOX_MODE | |
  30721. * | 6 | INVCUBIC_MODE | |
  30722. * | 7 | EQUIRECTANGULAR_MODE | |
  30723. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30724. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30725. */
  30726. set coordinatesMode(value: number);
  30727. get coordinatesMode(): number;
  30728. /**
  30729. * | Value | Type | Description |
  30730. * | ----- | ------------------ | ----------- |
  30731. * | 0 | CLAMP_ADDRESSMODE | |
  30732. * | 1 | WRAP_ADDRESSMODE | |
  30733. * | 2 | MIRROR_ADDRESSMODE | |
  30734. */
  30735. wrapU: number;
  30736. /**
  30737. * | Value | Type | Description |
  30738. * | ----- | ------------------ | ----------- |
  30739. * | 0 | CLAMP_ADDRESSMODE | |
  30740. * | 1 | WRAP_ADDRESSMODE | |
  30741. * | 2 | MIRROR_ADDRESSMODE | |
  30742. */
  30743. wrapV: number;
  30744. /**
  30745. * | Value | Type | Description |
  30746. * | ----- | ------------------ | ----------- |
  30747. * | 0 | CLAMP_ADDRESSMODE | |
  30748. * | 1 | WRAP_ADDRESSMODE | |
  30749. * | 2 | MIRROR_ADDRESSMODE | |
  30750. */
  30751. wrapR: number;
  30752. /**
  30753. * With compliant hardware and browser (supporting anisotropic filtering)
  30754. * this defines the level of anisotropic filtering in the texture.
  30755. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30756. */
  30757. anisotropicFilteringLevel: number;
  30758. /**
  30759. * Define if the texture is a cube texture or if false a 2d texture.
  30760. */
  30761. get isCube(): boolean;
  30762. set isCube(value: boolean);
  30763. /**
  30764. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30765. */
  30766. get is3D(): boolean;
  30767. set is3D(value: boolean);
  30768. /**
  30769. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30770. */
  30771. get is2DArray(): boolean;
  30772. set is2DArray(value: boolean);
  30773. /**
  30774. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30775. * HDR texture are usually stored in linear space.
  30776. * This only impacts the PBR and Background materials
  30777. */
  30778. gammaSpace: boolean;
  30779. /**
  30780. * Gets or sets whether or not the texture contains RGBD data.
  30781. */
  30782. get isRGBD(): boolean;
  30783. set isRGBD(value: boolean);
  30784. /**
  30785. * Is Z inverted in the texture (useful in a cube texture).
  30786. */
  30787. invertZ: boolean;
  30788. /**
  30789. * Are mip maps generated for this texture or not.
  30790. */
  30791. get noMipmap(): boolean;
  30792. /**
  30793. * @hidden
  30794. */
  30795. lodLevelInAlpha: boolean;
  30796. /**
  30797. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30798. */
  30799. get lodGenerationOffset(): number;
  30800. set lodGenerationOffset(value: number);
  30801. /**
  30802. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30803. */
  30804. get lodGenerationScale(): number;
  30805. set lodGenerationScale(value: number);
  30806. /**
  30807. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30808. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30809. * average roughness values.
  30810. */
  30811. get linearSpecularLOD(): boolean;
  30812. set linearSpecularLOD(value: boolean);
  30813. /**
  30814. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30815. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30816. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30817. */
  30818. get irradianceTexture(): Nullable<BaseTexture>;
  30819. set irradianceTexture(value: Nullable<BaseTexture>);
  30820. /**
  30821. * Define if the texture is a render target.
  30822. */
  30823. isRenderTarget: boolean;
  30824. /**
  30825. * Define the unique id of the texture in the scene.
  30826. */
  30827. get uid(): string;
  30828. /**
  30829. * Return a string representation of the texture.
  30830. * @returns the texture as a string
  30831. */
  30832. toString(): string;
  30833. /**
  30834. * Get the class name of the texture.
  30835. * @returns "BaseTexture"
  30836. */
  30837. getClassName(): string;
  30838. /**
  30839. * Define the list of animation attached to the texture.
  30840. */
  30841. animations: import("babylonjs/Animations/animation").Animation[];
  30842. /**
  30843. * An event triggered when the texture is disposed.
  30844. */
  30845. onDisposeObservable: Observable<BaseTexture>;
  30846. private _onDisposeObserver;
  30847. /**
  30848. * Callback triggered when the texture has been disposed.
  30849. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30850. */
  30851. set onDispose(callback: () => void);
  30852. /**
  30853. * Define the current state of the loading sequence when in delayed load mode.
  30854. */
  30855. delayLoadState: number;
  30856. private _scene;
  30857. /** @hidden */
  30858. _texture: Nullable<InternalTexture>;
  30859. private _uid;
  30860. /**
  30861. * Define if the texture is preventinga material to render or not.
  30862. * If not and the texture is not ready, the engine will use a default black texture instead.
  30863. */
  30864. get isBlocking(): boolean;
  30865. /**
  30866. * Instantiates a new BaseTexture.
  30867. * Base class of all the textures in babylon.
  30868. * It groups all the common properties the materials, post process, lights... might need
  30869. * in order to make a correct use of the texture.
  30870. * @param scene Define the scene the texture blongs to
  30871. */
  30872. constructor(scene: Nullable<Scene>);
  30873. /**
  30874. * Get the scene the texture belongs to.
  30875. * @returns the scene or null if undefined
  30876. */
  30877. getScene(): Nullable<Scene>;
  30878. /**
  30879. * Get the texture transform matrix used to offset tile the texture for istance.
  30880. * @returns the transformation matrix
  30881. */
  30882. getTextureMatrix(): Matrix;
  30883. /**
  30884. * Get the texture reflection matrix used to rotate/transform the reflection.
  30885. * @returns the reflection matrix
  30886. */
  30887. getReflectionTextureMatrix(): Matrix;
  30888. /**
  30889. * Get the underlying lower level texture from Babylon.
  30890. * @returns the insternal texture
  30891. */
  30892. getInternalTexture(): Nullable<InternalTexture>;
  30893. /**
  30894. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30895. * @returns true if ready or not blocking
  30896. */
  30897. isReadyOrNotBlocking(): boolean;
  30898. /**
  30899. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30900. * @returns true if fully ready
  30901. */
  30902. isReady(): boolean;
  30903. private _cachedSize;
  30904. /**
  30905. * Get the size of the texture.
  30906. * @returns the texture size.
  30907. */
  30908. getSize(): ISize;
  30909. /**
  30910. * Get the base size of the texture.
  30911. * It can be different from the size if the texture has been resized for POT for instance
  30912. * @returns the base size
  30913. */
  30914. getBaseSize(): ISize;
  30915. /**
  30916. * Update the sampling mode of the texture.
  30917. * Default is Trilinear mode.
  30918. *
  30919. * | Value | Type | Description |
  30920. * | ----- | ------------------ | ----------- |
  30921. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30922. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30923. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30924. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30925. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30926. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30927. * | 7 | NEAREST_LINEAR | |
  30928. * | 8 | NEAREST_NEAREST | |
  30929. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30930. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30931. * | 11 | LINEAR_LINEAR | |
  30932. * | 12 | LINEAR_NEAREST | |
  30933. *
  30934. * > _mag_: magnification filter (close to the viewer)
  30935. * > _min_: minification filter (far from the viewer)
  30936. * > _mip_: filter used between mip map levels
  30937. *@param samplingMode Define the new sampling mode of the texture
  30938. */
  30939. updateSamplingMode(samplingMode: number): void;
  30940. /**
  30941. * Scales the texture if is `canRescale()`
  30942. * @param ratio the resize factor we want to use to rescale
  30943. */
  30944. scale(ratio: number): void;
  30945. /**
  30946. * Get if the texture can rescale.
  30947. */
  30948. get canRescale(): boolean;
  30949. /** @hidden */
  30950. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30951. /** @hidden */
  30952. _rebuild(): void;
  30953. /**
  30954. * Triggers the load sequence in delayed load mode.
  30955. */
  30956. delayLoad(): void;
  30957. /**
  30958. * Clones the texture.
  30959. * @returns the cloned texture
  30960. */
  30961. clone(): Nullable<BaseTexture>;
  30962. /**
  30963. * Get the texture underlying type (INT, FLOAT...)
  30964. */
  30965. get textureType(): number;
  30966. /**
  30967. * Get the texture underlying format (RGB, RGBA...)
  30968. */
  30969. get textureFormat(): number;
  30970. /**
  30971. * Indicates that textures need to be re-calculated for all materials
  30972. */
  30973. protected _markAllSubMeshesAsTexturesDirty(): void;
  30974. /**
  30975. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30976. * This will returns an RGBA array buffer containing either in values (0-255) or
  30977. * float values (0-1) depending of the underlying buffer type.
  30978. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30979. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30980. * @param buffer defines a user defined buffer to fill with data (can be null)
  30981. * @returns The Array buffer containing the pixels data.
  30982. */
  30983. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30984. /**
  30985. * Release and destroy the underlying lower level texture aka internalTexture.
  30986. */
  30987. releaseInternalTexture(): void;
  30988. /** @hidden */
  30989. get _lodTextureHigh(): Nullable<BaseTexture>;
  30990. /** @hidden */
  30991. get _lodTextureMid(): Nullable<BaseTexture>;
  30992. /** @hidden */
  30993. get _lodTextureLow(): Nullable<BaseTexture>;
  30994. /**
  30995. * Dispose the texture and release its associated resources.
  30996. */
  30997. dispose(): void;
  30998. /**
  30999. * Serialize the texture into a JSON representation that can be parsed later on.
  31000. * @returns the JSON representation of the texture
  31001. */
  31002. serialize(): any;
  31003. /**
  31004. * Helper function to be called back once a list of texture contains only ready textures.
  31005. * @param textures Define the list of textures to wait for
  31006. * @param callback Define the callback triggered once the entire list will be ready
  31007. */
  31008. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31009. }
  31010. }
  31011. declare module "babylonjs/Materials/effect" {
  31012. import { Observable } from "babylonjs/Misc/observable";
  31013. import { Nullable } from "babylonjs/types";
  31014. import { IDisposable } from "babylonjs/scene";
  31015. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31016. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31017. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31018. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31019. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31020. import { Engine } from "babylonjs/Engines/engine";
  31021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31025. /**
  31026. * Options to be used when creating an effect.
  31027. */
  31028. export interface IEffectCreationOptions {
  31029. /**
  31030. * Atrributes that will be used in the shader.
  31031. */
  31032. attributes: string[];
  31033. /**
  31034. * Uniform varible names that will be set in the shader.
  31035. */
  31036. uniformsNames: string[];
  31037. /**
  31038. * Uniform buffer variable names that will be set in the shader.
  31039. */
  31040. uniformBuffersNames: string[];
  31041. /**
  31042. * Sampler texture variable names that will be set in the shader.
  31043. */
  31044. samplers: string[];
  31045. /**
  31046. * Define statements that will be set in the shader.
  31047. */
  31048. defines: any;
  31049. /**
  31050. * Possible fallbacks for this effect to improve performance when needed.
  31051. */
  31052. fallbacks: Nullable<IEffectFallbacks>;
  31053. /**
  31054. * Callback that will be called when the shader is compiled.
  31055. */
  31056. onCompiled: Nullable<(effect: Effect) => void>;
  31057. /**
  31058. * Callback that will be called if an error occurs during shader compilation.
  31059. */
  31060. onError: Nullable<(effect: Effect, errors: string) => void>;
  31061. /**
  31062. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31063. */
  31064. indexParameters?: any;
  31065. /**
  31066. * Max number of lights that can be used in the shader.
  31067. */
  31068. maxSimultaneousLights?: number;
  31069. /**
  31070. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31071. */
  31072. transformFeedbackVaryings?: Nullable<string[]>;
  31073. }
  31074. /**
  31075. * Effect containing vertex and fragment shader that can be executed on an object.
  31076. */
  31077. export class Effect implements IDisposable {
  31078. /**
  31079. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31080. */
  31081. static ShadersRepository: string;
  31082. /**
  31083. * Enable logging of the shader code when a compilation error occurs
  31084. */
  31085. static LogShaderCodeOnCompilationError: boolean;
  31086. /**
  31087. * Name of the effect.
  31088. */
  31089. name: any;
  31090. /**
  31091. * String container all the define statements that should be set on the shader.
  31092. */
  31093. defines: string;
  31094. /**
  31095. * Callback that will be called when the shader is compiled.
  31096. */
  31097. onCompiled: Nullable<(effect: Effect) => void>;
  31098. /**
  31099. * Callback that will be called if an error occurs during shader compilation.
  31100. */
  31101. onError: Nullable<(effect: Effect, errors: string) => void>;
  31102. /**
  31103. * Callback that will be called when effect is bound.
  31104. */
  31105. onBind: Nullable<(effect: Effect) => void>;
  31106. /**
  31107. * Unique ID of the effect.
  31108. */
  31109. uniqueId: number;
  31110. /**
  31111. * Observable that will be called when the shader is compiled.
  31112. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31113. */
  31114. onCompileObservable: Observable<Effect>;
  31115. /**
  31116. * Observable that will be called if an error occurs during shader compilation.
  31117. */
  31118. onErrorObservable: Observable<Effect>;
  31119. /** @hidden */
  31120. _onBindObservable: Nullable<Observable<Effect>>;
  31121. /**
  31122. * @hidden
  31123. * Specifies if the effect was previously ready
  31124. */
  31125. _wasPreviouslyReady: boolean;
  31126. /**
  31127. * Observable that will be called when effect is bound.
  31128. */
  31129. get onBindObservable(): Observable<Effect>;
  31130. /** @hidden */
  31131. _bonesComputationForcedToCPU: boolean;
  31132. private static _uniqueIdSeed;
  31133. private _engine;
  31134. private _uniformBuffersNames;
  31135. private _uniformsNames;
  31136. private _samplerList;
  31137. private _samplers;
  31138. private _isReady;
  31139. private _compilationError;
  31140. private _allFallbacksProcessed;
  31141. private _attributesNames;
  31142. private _attributes;
  31143. private _attributeLocationByName;
  31144. private _uniforms;
  31145. /**
  31146. * Key for the effect.
  31147. * @hidden
  31148. */
  31149. _key: string;
  31150. private _indexParameters;
  31151. private _fallbacks;
  31152. private _vertexSourceCode;
  31153. private _fragmentSourceCode;
  31154. private _vertexSourceCodeOverride;
  31155. private _fragmentSourceCodeOverride;
  31156. private _transformFeedbackVaryings;
  31157. /**
  31158. * Compiled shader to webGL program.
  31159. * @hidden
  31160. */
  31161. _pipelineContext: Nullable<IPipelineContext>;
  31162. private _valueCache;
  31163. private static _baseCache;
  31164. /**
  31165. * Instantiates an effect.
  31166. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31167. * @param baseName Name of the effect.
  31168. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31169. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31170. * @param samplers List of sampler variables that will be passed to the shader.
  31171. * @param engine Engine to be used to render the effect
  31172. * @param defines Define statements to be added to the shader.
  31173. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31174. * @param onCompiled Callback that will be called when the shader is compiled.
  31175. * @param onError Callback that will be called if an error occurs during shader compilation.
  31176. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31177. */
  31178. 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);
  31179. private _useFinalCode;
  31180. /**
  31181. * Unique key for this effect
  31182. */
  31183. get key(): string;
  31184. /**
  31185. * If the effect has been compiled and prepared.
  31186. * @returns if the effect is compiled and prepared.
  31187. */
  31188. isReady(): boolean;
  31189. private _isReadyInternal;
  31190. /**
  31191. * The engine the effect was initialized with.
  31192. * @returns the engine.
  31193. */
  31194. getEngine(): Engine;
  31195. /**
  31196. * The pipeline context for this effect
  31197. * @returns the associated pipeline context
  31198. */
  31199. getPipelineContext(): Nullable<IPipelineContext>;
  31200. /**
  31201. * The set of names of attribute variables for the shader.
  31202. * @returns An array of attribute names.
  31203. */
  31204. getAttributesNames(): string[];
  31205. /**
  31206. * Returns the attribute at the given index.
  31207. * @param index The index of the attribute.
  31208. * @returns The location of the attribute.
  31209. */
  31210. getAttributeLocation(index: number): number;
  31211. /**
  31212. * Returns the attribute based on the name of the variable.
  31213. * @param name of the attribute to look up.
  31214. * @returns the attribute location.
  31215. */
  31216. getAttributeLocationByName(name: string): number;
  31217. /**
  31218. * The number of attributes.
  31219. * @returns the numnber of attributes.
  31220. */
  31221. getAttributesCount(): number;
  31222. /**
  31223. * Gets the index of a uniform variable.
  31224. * @param uniformName of the uniform to look up.
  31225. * @returns the index.
  31226. */
  31227. getUniformIndex(uniformName: string): number;
  31228. /**
  31229. * Returns the attribute based on the name of the variable.
  31230. * @param uniformName of the uniform to look up.
  31231. * @returns the location of the uniform.
  31232. */
  31233. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31234. /**
  31235. * Returns an array of sampler variable names
  31236. * @returns The array of sampler variable neames.
  31237. */
  31238. getSamplers(): string[];
  31239. /**
  31240. * The error from the last compilation.
  31241. * @returns the error string.
  31242. */
  31243. getCompilationError(): string;
  31244. /**
  31245. * Gets a boolean indicating that all fallbacks were used during compilation
  31246. * @returns true if all fallbacks were used
  31247. */
  31248. allFallbacksProcessed(): boolean;
  31249. /**
  31250. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31251. * @param func The callback to be used.
  31252. */
  31253. executeWhenCompiled(func: (effect: Effect) => void): void;
  31254. private _checkIsReady;
  31255. private _loadShader;
  31256. /**
  31257. * Recompiles the webGL program
  31258. * @param vertexSourceCode The source code for the vertex shader.
  31259. * @param fragmentSourceCode The source code for the fragment shader.
  31260. * @param onCompiled Callback called when completed.
  31261. * @param onError Callback called on error.
  31262. * @hidden
  31263. */
  31264. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31265. /**
  31266. * Prepares the effect
  31267. * @hidden
  31268. */
  31269. _prepareEffect(): void;
  31270. private _getShaderCodeAndErrorLine;
  31271. private _processCompilationErrors;
  31272. /**
  31273. * Checks if the effect is supported. (Must be called after compilation)
  31274. */
  31275. get isSupported(): boolean;
  31276. /**
  31277. * Binds a texture to the engine to be used as output of the shader.
  31278. * @param channel Name of the output variable.
  31279. * @param texture Texture to bind.
  31280. * @hidden
  31281. */
  31282. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31283. /**
  31284. * Sets a texture on the engine to be used in the shader.
  31285. * @param channel Name of the sampler variable.
  31286. * @param texture Texture to set.
  31287. */
  31288. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31289. /**
  31290. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31291. * @param channel Name of the sampler variable.
  31292. * @param texture Texture to set.
  31293. */
  31294. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31295. /**
  31296. * Sets an array of textures on the engine to be used in the shader.
  31297. * @param channel Name of the variable.
  31298. * @param textures Textures to set.
  31299. */
  31300. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31301. /**
  31302. * 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)
  31303. * @param channel Name of the sampler variable.
  31304. * @param postProcess Post process to get the input texture from.
  31305. */
  31306. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31307. /**
  31308. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31309. * 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)
  31310. * @param channel Name of the sampler variable.
  31311. * @param postProcess Post process to get the output texture from.
  31312. */
  31313. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31314. /** @hidden */
  31315. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31316. /** @hidden */
  31317. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31318. /** @hidden */
  31319. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31320. /** @hidden */
  31321. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31322. /**
  31323. * Binds a buffer to a uniform.
  31324. * @param buffer Buffer to bind.
  31325. * @param name Name of the uniform variable to bind to.
  31326. */
  31327. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31328. /**
  31329. * Binds block to a uniform.
  31330. * @param blockName Name of the block to bind.
  31331. * @param index Index to bind.
  31332. */
  31333. bindUniformBlock(blockName: string, index: number): void;
  31334. /**
  31335. * Sets an interger value on a uniform variable.
  31336. * @param uniformName Name of the variable.
  31337. * @param value Value to be set.
  31338. * @returns this effect.
  31339. */
  31340. setInt(uniformName: string, value: number): Effect;
  31341. /**
  31342. * Sets an int array on a uniform variable.
  31343. * @param uniformName Name of the variable.
  31344. * @param array array to be set.
  31345. * @returns this effect.
  31346. */
  31347. setIntArray(uniformName: string, array: Int32Array): Effect;
  31348. /**
  31349. * 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)
  31350. * @param uniformName Name of the variable.
  31351. * @param array array to be set.
  31352. * @returns this effect.
  31353. */
  31354. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31355. /**
  31356. * 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)
  31357. * @param uniformName Name of the variable.
  31358. * @param array array to be set.
  31359. * @returns this effect.
  31360. */
  31361. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31362. /**
  31363. * 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)
  31364. * @param uniformName Name of the variable.
  31365. * @param array array to be set.
  31366. * @returns this effect.
  31367. */
  31368. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31369. /**
  31370. * Sets an float array on a uniform variable.
  31371. * @param uniformName Name of the variable.
  31372. * @param array array to be set.
  31373. * @returns this effect.
  31374. */
  31375. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31376. /**
  31377. * 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)
  31378. * @param uniformName Name of the variable.
  31379. * @param array array to be set.
  31380. * @returns this effect.
  31381. */
  31382. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31383. /**
  31384. * 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)
  31385. * @param uniformName Name of the variable.
  31386. * @param array array to be set.
  31387. * @returns this effect.
  31388. */
  31389. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31390. /**
  31391. * 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)
  31392. * @param uniformName Name of the variable.
  31393. * @param array array to be set.
  31394. * @returns this effect.
  31395. */
  31396. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31397. /**
  31398. * Sets an array on a uniform variable.
  31399. * @param uniformName Name of the variable.
  31400. * @param array array to be set.
  31401. * @returns this effect.
  31402. */
  31403. setArray(uniformName: string, array: number[]): Effect;
  31404. /**
  31405. * 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)
  31406. * @param uniformName Name of the variable.
  31407. * @param array array to be set.
  31408. * @returns this effect.
  31409. */
  31410. setArray2(uniformName: string, array: number[]): Effect;
  31411. /**
  31412. * 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)
  31413. * @param uniformName Name of the variable.
  31414. * @param array array to be set.
  31415. * @returns this effect.
  31416. */
  31417. setArray3(uniformName: string, array: number[]): Effect;
  31418. /**
  31419. * 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)
  31420. * @param uniformName Name of the variable.
  31421. * @param array array to be set.
  31422. * @returns this effect.
  31423. */
  31424. setArray4(uniformName: string, array: number[]): Effect;
  31425. /**
  31426. * Sets matrices on a uniform variable.
  31427. * @param uniformName Name of the variable.
  31428. * @param matrices matrices to be set.
  31429. * @returns this effect.
  31430. */
  31431. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31432. /**
  31433. * Sets matrix on a uniform variable.
  31434. * @param uniformName Name of the variable.
  31435. * @param matrix matrix to be set.
  31436. * @returns this effect.
  31437. */
  31438. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31439. /**
  31440. * 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)
  31441. * @param uniformName Name of the variable.
  31442. * @param matrix matrix to be set.
  31443. * @returns this effect.
  31444. */
  31445. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31446. /**
  31447. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31448. * @param uniformName Name of the variable.
  31449. * @param matrix matrix to be set.
  31450. * @returns this effect.
  31451. */
  31452. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31453. /**
  31454. * Sets a float on a uniform variable.
  31455. * @param uniformName Name of the variable.
  31456. * @param value value to be set.
  31457. * @returns this effect.
  31458. */
  31459. setFloat(uniformName: string, value: number): Effect;
  31460. /**
  31461. * Sets a boolean on a uniform variable.
  31462. * @param uniformName Name of the variable.
  31463. * @param bool value to be set.
  31464. * @returns this effect.
  31465. */
  31466. setBool(uniformName: string, bool: boolean): Effect;
  31467. /**
  31468. * Sets a Vector2 on a uniform variable.
  31469. * @param uniformName Name of the variable.
  31470. * @param vector2 vector2 to be set.
  31471. * @returns this effect.
  31472. */
  31473. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31474. /**
  31475. * Sets a float2 on a uniform variable.
  31476. * @param uniformName Name of the variable.
  31477. * @param x First float in float2.
  31478. * @param y Second float in float2.
  31479. * @returns this effect.
  31480. */
  31481. setFloat2(uniformName: string, x: number, y: number): Effect;
  31482. /**
  31483. * Sets a Vector3 on a uniform variable.
  31484. * @param uniformName Name of the variable.
  31485. * @param vector3 Value to be set.
  31486. * @returns this effect.
  31487. */
  31488. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31489. /**
  31490. * Sets a float3 on a uniform variable.
  31491. * @param uniformName Name of the variable.
  31492. * @param x First float in float3.
  31493. * @param y Second float in float3.
  31494. * @param z Third float in float3.
  31495. * @returns this effect.
  31496. */
  31497. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31498. /**
  31499. * Sets a Vector4 on a uniform variable.
  31500. * @param uniformName Name of the variable.
  31501. * @param vector4 Value to be set.
  31502. * @returns this effect.
  31503. */
  31504. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31505. /**
  31506. * Sets a float4 on a uniform variable.
  31507. * @param uniformName Name of the variable.
  31508. * @param x First float in float4.
  31509. * @param y Second float in float4.
  31510. * @param z Third float in float4.
  31511. * @param w Fourth float in float4.
  31512. * @returns this effect.
  31513. */
  31514. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31515. /**
  31516. * Sets a Color3 on a uniform variable.
  31517. * @param uniformName Name of the variable.
  31518. * @param color3 Value to be set.
  31519. * @returns this effect.
  31520. */
  31521. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31522. /**
  31523. * Sets a Color4 on a uniform variable.
  31524. * @param uniformName Name of the variable.
  31525. * @param color3 Value to be set.
  31526. * @param alpha Alpha value to be set.
  31527. * @returns this effect.
  31528. */
  31529. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31530. /**
  31531. * Sets a Color4 on a uniform variable
  31532. * @param uniformName defines the name of the variable
  31533. * @param color4 defines the value to be set
  31534. * @returns this effect.
  31535. */
  31536. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31537. /** Release all associated resources */
  31538. dispose(): void;
  31539. /**
  31540. * This function will add a new shader to the shader store
  31541. * @param name the name of the shader
  31542. * @param pixelShader optional pixel shader content
  31543. * @param vertexShader optional vertex shader content
  31544. */
  31545. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31546. /**
  31547. * Store of each shader (The can be looked up using effect.key)
  31548. */
  31549. static ShadersStore: {
  31550. [key: string]: string;
  31551. };
  31552. /**
  31553. * Store of each included file for a shader (The can be looked up using effect.key)
  31554. */
  31555. static IncludesShadersStore: {
  31556. [key: string]: string;
  31557. };
  31558. /**
  31559. * Resets the cache of effects.
  31560. */
  31561. static ResetCache(): void;
  31562. }
  31563. }
  31564. declare module "babylonjs/Engines/engineCapabilities" {
  31565. /**
  31566. * Interface used to describe the capabilities of the engine relatively to the current browser
  31567. */
  31568. export interface EngineCapabilities {
  31569. /** Maximum textures units per fragment shader */
  31570. maxTexturesImageUnits: number;
  31571. /** Maximum texture units per vertex shader */
  31572. maxVertexTextureImageUnits: number;
  31573. /** Maximum textures units in the entire pipeline */
  31574. maxCombinedTexturesImageUnits: number;
  31575. /** Maximum texture size */
  31576. maxTextureSize: number;
  31577. /** Maximum texture samples */
  31578. maxSamples?: number;
  31579. /** Maximum cube texture size */
  31580. maxCubemapTextureSize: number;
  31581. /** Maximum render texture size */
  31582. maxRenderTextureSize: number;
  31583. /** Maximum number of vertex attributes */
  31584. maxVertexAttribs: number;
  31585. /** Maximum number of varyings */
  31586. maxVaryingVectors: number;
  31587. /** Maximum number of uniforms per vertex shader */
  31588. maxVertexUniformVectors: number;
  31589. /** Maximum number of uniforms per fragment shader */
  31590. maxFragmentUniformVectors: number;
  31591. /** Defines if standard derivates (dx/dy) are supported */
  31592. standardDerivatives: boolean;
  31593. /** Defines if s3tc texture compression is supported */
  31594. s3tc?: WEBGL_compressed_texture_s3tc;
  31595. /** Defines if pvrtc texture compression is supported */
  31596. pvrtc: any;
  31597. /** Defines if etc1 texture compression is supported */
  31598. etc1: any;
  31599. /** Defines if etc2 texture compression is supported */
  31600. etc2: any;
  31601. /** Defines if astc texture compression is supported */
  31602. astc: any;
  31603. /** Defines if float textures are supported */
  31604. textureFloat: boolean;
  31605. /** Defines if vertex array objects are supported */
  31606. vertexArrayObject: boolean;
  31607. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31608. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31609. /** Gets the maximum level of anisotropy supported */
  31610. maxAnisotropy: number;
  31611. /** Defines if instancing is supported */
  31612. instancedArrays: boolean;
  31613. /** Defines if 32 bits indices are supported */
  31614. uintIndices: boolean;
  31615. /** Defines if high precision shaders are supported */
  31616. highPrecisionShaderSupported: boolean;
  31617. /** Defines if depth reading in the fragment shader is supported */
  31618. fragmentDepthSupported: boolean;
  31619. /** Defines if float texture linear filtering is supported*/
  31620. textureFloatLinearFiltering: boolean;
  31621. /** Defines if rendering to float textures is supported */
  31622. textureFloatRender: boolean;
  31623. /** Defines if half float textures are supported*/
  31624. textureHalfFloat: boolean;
  31625. /** Defines if half float texture linear filtering is supported*/
  31626. textureHalfFloatLinearFiltering: boolean;
  31627. /** Defines if rendering to half float textures is supported */
  31628. textureHalfFloatRender: boolean;
  31629. /** Defines if textureLOD shader command is supported */
  31630. textureLOD: boolean;
  31631. /** Defines if draw buffers extension is supported */
  31632. drawBuffersExtension: boolean;
  31633. /** Defines if depth textures are supported */
  31634. depthTextureExtension: boolean;
  31635. /** Defines if float color buffer are supported */
  31636. colorBufferFloat: boolean;
  31637. /** Gets disjoint timer query extension (null if not supported) */
  31638. timerQuery?: EXT_disjoint_timer_query;
  31639. /** Defines if timestamp can be used with timer query */
  31640. canUseTimestampForTimerQuery: boolean;
  31641. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31642. multiview?: any;
  31643. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31644. oculusMultiview?: any;
  31645. /** Function used to let the system compiles shaders in background */
  31646. parallelShaderCompile?: {
  31647. COMPLETION_STATUS_KHR: number;
  31648. };
  31649. /** Max number of texture samples for MSAA */
  31650. maxMSAASamples: number;
  31651. /** Defines if the blend min max extension is supported */
  31652. blendMinMax: boolean;
  31653. }
  31654. }
  31655. declare module "babylonjs/States/depthCullingState" {
  31656. import { Nullable } from "babylonjs/types";
  31657. /**
  31658. * @hidden
  31659. **/
  31660. export class DepthCullingState {
  31661. private _isDepthTestDirty;
  31662. private _isDepthMaskDirty;
  31663. private _isDepthFuncDirty;
  31664. private _isCullFaceDirty;
  31665. private _isCullDirty;
  31666. private _isZOffsetDirty;
  31667. private _isFrontFaceDirty;
  31668. private _depthTest;
  31669. private _depthMask;
  31670. private _depthFunc;
  31671. private _cull;
  31672. private _cullFace;
  31673. private _zOffset;
  31674. private _frontFace;
  31675. /**
  31676. * Initializes the state.
  31677. */
  31678. constructor();
  31679. get isDirty(): boolean;
  31680. get zOffset(): number;
  31681. set zOffset(value: number);
  31682. get cullFace(): Nullable<number>;
  31683. set cullFace(value: Nullable<number>);
  31684. get cull(): Nullable<boolean>;
  31685. set cull(value: Nullable<boolean>);
  31686. get depthFunc(): Nullable<number>;
  31687. set depthFunc(value: Nullable<number>);
  31688. get depthMask(): boolean;
  31689. set depthMask(value: boolean);
  31690. get depthTest(): boolean;
  31691. set depthTest(value: boolean);
  31692. get frontFace(): Nullable<number>;
  31693. set frontFace(value: Nullable<number>);
  31694. reset(): void;
  31695. apply(gl: WebGLRenderingContext): void;
  31696. }
  31697. }
  31698. declare module "babylonjs/States/stencilState" {
  31699. /**
  31700. * @hidden
  31701. **/
  31702. export class StencilState {
  31703. /** 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 */
  31704. static readonly ALWAYS: number;
  31705. /** Passed to stencilOperation to specify that stencil value must be kept */
  31706. static readonly KEEP: number;
  31707. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31708. static readonly REPLACE: number;
  31709. private _isStencilTestDirty;
  31710. private _isStencilMaskDirty;
  31711. private _isStencilFuncDirty;
  31712. private _isStencilOpDirty;
  31713. private _stencilTest;
  31714. private _stencilMask;
  31715. private _stencilFunc;
  31716. private _stencilFuncRef;
  31717. private _stencilFuncMask;
  31718. private _stencilOpStencilFail;
  31719. private _stencilOpDepthFail;
  31720. private _stencilOpStencilDepthPass;
  31721. get isDirty(): boolean;
  31722. get stencilFunc(): number;
  31723. set stencilFunc(value: number);
  31724. get stencilFuncRef(): number;
  31725. set stencilFuncRef(value: number);
  31726. get stencilFuncMask(): number;
  31727. set stencilFuncMask(value: number);
  31728. get stencilOpStencilFail(): number;
  31729. set stencilOpStencilFail(value: number);
  31730. get stencilOpDepthFail(): number;
  31731. set stencilOpDepthFail(value: number);
  31732. get stencilOpStencilDepthPass(): number;
  31733. set stencilOpStencilDepthPass(value: number);
  31734. get stencilMask(): number;
  31735. set stencilMask(value: number);
  31736. get stencilTest(): boolean;
  31737. set stencilTest(value: boolean);
  31738. constructor();
  31739. reset(): void;
  31740. apply(gl: WebGLRenderingContext): void;
  31741. }
  31742. }
  31743. declare module "babylonjs/States/alphaCullingState" {
  31744. /**
  31745. * @hidden
  31746. **/
  31747. export class AlphaState {
  31748. private _isAlphaBlendDirty;
  31749. private _isBlendFunctionParametersDirty;
  31750. private _isBlendEquationParametersDirty;
  31751. private _isBlendConstantsDirty;
  31752. private _alphaBlend;
  31753. private _blendFunctionParameters;
  31754. private _blendEquationParameters;
  31755. private _blendConstants;
  31756. /**
  31757. * Initializes the state.
  31758. */
  31759. constructor();
  31760. get isDirty(): boolean;
  31761. get alphaBlend(): boolean;
  31762. set alphaBlend(value: boolean);
  31763. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31764. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31765. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31766. reset(): void;
  31767. apply(gl: WebGLRenderingContext): void;
  31768. }
  31769. }
  31770. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31771. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31772. /** @hidden */
  31773. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31774. attributeProcessor(attribute: string): string;
  31775. varyingProcessor(varying: string, isFragment: boolean): string;
  31776. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31777. }
  31778. }
  31779. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31780. /**
  31781. * Interface for attribute information associated with buffer instanciation
  31782. */
  31783. export interface InstancingAttributeInfo {
  31784. /**
  31785. * Name of the GLSL attribute
  31786. * if attribute index is not specified, this is used to retrieve the index from the effect
  31787. */
  31788. attributeName: string;
  31789. /**
  31790. * Index/offset of the attribute in the vertex shader
  31791. * if not specified, this will be computes from the name.
  31792. */
  31793. index?: number;
  31794. /**
  31795. * size of the attribute, 1, 2, 3 or 4
  31796. */
  31797. attributeSize: number;
  31798. /**
  31799. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31800. */
  31801. offset: number;
  31802. /**
  31803. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31804. * default to 1
  31805. */
  31806. divisor?: number;
  31807. /**
  31808. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31809. * default is FLOAT
  31810. */
  31811. attributeType?: number;
  31812. /**
  31813. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31814. */
  31815. normalized?: boolean;
  31816. }
  31817. }
  31818. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31820. import { Nullable } from "babylonjs/types";
  31821. module "babylonjs/Engines/thinEngine" {
  31822. interface ThinEngine {
  31823. /**
  31824. * Update a video texture
  31825. * @param texture defines the texture to update
  31826. * @param video defines the video element to use
  31827. * @param invertY defines if data must be stored with Y axis inverted
  31828. */
  31829. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31830. }
  31831. }
  31832. }
  31833. declare module "babylonjs/Materials/Textures/videoTexture" {
  31834. import { Observable } from "babylonjs/Misc/observable";
  31835. import { Nullable } from "babylonjs/types";
  31836. import { Scene } from "babylonjs/scene";
  31837. import { Texture } from "babylonjs/Materials/Textures/texture";
  31838. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31839. /**
  31840. * Settings for finer control over video usage
  31841. */
  31842. export interface VideoTextureSettings {
  31843. /**
  31844. * Applies `autoplay` to video, if specified
  31845. */
  31846. autoPlay?: boolean;
  31847. /**
  31848. * Applies `loop` to video, if specified
  31849. */
  31850. loop?: boolean;
  31851. /**
  31852. * Automatically updates internal texture from video at every frame in the render loop
  31853. */
  31854. autoUpdateTexture: boolean;
  31855. /**
  31856. * Image src displayed during the video loading or until the user interacts with the video.
  31857. */
  31858. poster?: string;
  31859. }
  31860. /**
  31861. * If you want to display a video in your scene, this is the special texture for that.
  31862. * This special texture works similar to other textures, with the exception of a few parameters.
  31863. * @see https://doc.babylonjs.com/how_to/video_texture
  31864. */
  31865. export class VideoTexture extends Texture {
  31866. /**
  31867. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31868. */
  31869. readonly autoUpdateTexture: boolean;
  31870. /**
  31871. * The video instance used by the texture internally
  31872. */
  31873. readonly video: HTMLVideoElement;
  31874. private _onUserActionRequestedObservable;
  31875. /**
  31876. * Event triggerd when a dom action is required by the user to play the video.
  31877. * This happens due to recent changes in browser policies preventing video to auto start.
  31878. */
  31879. get onUserActionRequestedObservable(): Observable<Texture>;
  31880. private _generateMipMaps;
  31881. private _engine;
  31882. private _stillImageCaptured;
  31883. private _displayingPosterTexture;
  31884. private _settings;
  31885. private _createInternalTextureOnEvent;
  31886. private _frameId;
  31887. private _currentSrc;
  31888. /**
  31889. * Creates a video texture.
  31890. * If you want to display a video in your scene, this is the special texture for that.
  31891. * This special texture works similar to other textures, with the exception of a few parameters.
  31892. * @see https://doc.babylonjs.com/how_to/video_texture
  31893. * @param name optional name, will detect from video source, if not defined
  31894. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31895. * @param scene is obviously the current scene.
  31896. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31897. * @param invertY is false by default but can be used to invert video on Y axis
  31898. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31899. * @param settings allows finer control over video usage
  31900. */
  31901. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31902. private _getName;
  31903. private _getVideo;
  31904. private _createInternalTexture;
  31905. private reset;
  31906. /**
  31907. * @hidden Internal method to initiate `update`.
  31908. */
  31909. _rebuild(): void;
  31910. /**
  31911. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31912. */
  31913. update(): void;
  31914. /**
  31915. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31916. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31917. */
  31918. updateTexture(isVisible: boolean): void;
  31919. protected _updateInternalTexture: () => void;
  31920. /**
  31921. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31922. * @param url New url.
  31923. */
  31924. updateURL(url: string): void;
  31925. /**
  31926. * Clones the texture.
  31927. * @returns the cloned texture
  31928. */
  31929. clone(): VideoTexture;
  31930. /**
  31931. * Dispose the texture and release its associated resources.
  31932. */
  31933. dispose(): void;
  31934. /**
  31935. * Creates a video texture straight from a stream.
  31936. * @param scene Define the scene the texture should be created in
  31937. * @param stream Define the stream the texture should be created from
  31938. * @returns The created video texture as a promise
  31939. */
  31940. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31941. /**
  31942. * Creates a video texture straight from your WebCam video feed.
  31943. * @param scene Define the scene the texture should be created in
  31944. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31945. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31946. * @returns The created video texture as a promise
  31947. */
  31948. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31949. minWidth: number;
  31950. maxWidth: number;
  31951. minHeight: number;
  31952. maxHeight: number;
  31953. deviceId: string;
  31954. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31955. /**
  31956. * Creates a video texture straight from your WebCam video feed.
  31957. * @param scene Define the scene the texture should be created in
  31958. * @param onReady Define a callback to triggered once the texture will be ready
  31959. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31960. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31961. */
  31962. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31963. minWidth: number;
  31964. maxWidth: number;
  31965. minHeight: number;
  31966. maxHeight: number;
  31967. deviceId: string;
  31968. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31969. }
  31970. }
  31971. declare module "babylonjs/Engines/thinEngine" {
  31972. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31973. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31974. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31975. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31976. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31977. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31978. import { Observable } from "babylonjs/Misc/observable";
  31979. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31980. import { StencilState } from "babylonjs/States/stencilState";
  31981. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31983. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31984. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31985. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31986. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31987. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31988. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31989. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31991. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31992. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31993. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31994. import { WebRequest } from "babylonjs/Misc/webRequest";
  31995. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31996. /**
  31997. * Defines the interface used by objects working like Scene
  31998. * @hidden
  31999. */
  32000. export interface ISceneLike {
  32001. _addPendingData(data: any): void;
  32002. _removePendingData(data: any): void;
  32003. offlineProvider: IOfflineProvider;
  32004. }
  32005. /** Interface defining initialization parameters for Engine class */
  32006. export interface EngineOptions extends WebGLContextAttributes {
  32007. /**
  32008. * Defines if the engine should no exceed a specified device ratio
  32009. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32010. */
  32011. limitDeviceRatio?: number;
  32012. /**
  32013. * Defines if webvr should be enabled automatically
  32014. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32015. */
  32016. autoEnableWebVR?: boolean;
  32017. /**
  32018. * Defines if webgl2 should be turned off even if supported
  32019. * @see http://doc.babylonjs.com/features/webgl2
  32020. */
  32021. disableWebGL2Support?: boolean;
  32022. /**
  32023. * Defines if webaudio should be initialized as well
  32024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32025. */
  32026. audioEngine?: boolean;
  32027. /**
  32028. * Defines if animations should run using a deterministic lock step
  32029. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32030. */
  32031. deterministicLockstep?: boolean;
  32032. /** Defines the maximum steps to use with deterministic lock step mode */
  32033. lockstepMaxSteps?: number;
  32034. /** Defines the seconds between each deterministic lock step */
  32035. timeStep?: number;
  32036. /**
  32037. * Defines that engine should ignore context lost events
  32038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32039. */
  32040. doNotHandleContextLost?: boolean;
  32041. /**
  32042. * Defines that engine should ignore modifying touch action attribute and style
  32043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32044. */
  32045. doNotHandleTouchAction?: boolean;
  32046. /**
  32047. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32048. */
  32049. useHighPrecisionFloats?: boolean;
  32050. }
  32051. /**
  32052. * The base engine class (root of all engines)
  32053. */
  32054. export class ThinEngine {
  32055. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32056. static ExceptionList: ({
  32057. key: string;
  32058. capture: string;
  32059. captureConstraint: number;
  32060. targets: string[];
  32061. } | {
  32062. key: string;
  32063. capture: null;
  32064. captureConstraint: null;
  32065. targets: string[];
  32066. })[];
  32067. /** @hidden */
  32068. static _TextureLoaders: IInternalTextureLoader[];
  32069. /**
  32070. * Returns the current npm package of the sdk
  32071. */
  32072. static get NpmPackage(): string;
  32073. /**
  32074. * Returns the current version of the framework
  32075. */
  32076. static get Version(): string;
  32077. /**
  32078. * Returns a string describing the current engine
  32079. */
  32080. get description(): string;
  32081. /**
  32082. * Gets or sets the epsilon value used by collision engine
  32083. */
  32084. static CollisionsEpsilon: number;
  32085. /**
  32086. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32087. */
  32088. static get ShadersRepository(): string;
  32089. static set ShadersRepository(value: string);
  32090. /** @hidden */
  32091. _shaderProcessor: IShaderProcessor;
  32092. /**
  32093. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32094. */
  32095. forcePOTTextures: boolean;
  32096. /**
  32097. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32098. */
  32099. isFullscreen: boolean;
  32100. /**
  32101. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32102. */
  32103. cullBackFaces: boolean;
  32104. /**
  32105. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32106. */
  32107. renderEvenInBackground: boolean;
  32108. /**
  32109. * Gets or sets a boolean indicating that cache can be kept between frames
  32110. */
  32111. preventCacheWipeBetweenFrames: boolean;
  32112. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32113. validateShaderPrograms: boolean;
  32114. /**
  32115. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32116. * This can provide greater z depth for distant objects.
  32117. */
  32118. useReverseDepthBuffer: boolean;
  32119. /**
  32120. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32121. */
  32122. disableUniformBuffers: boolean;
  32123. /** @hidden */
  32124. _uniformBuffers: UniformBuffer[];
  32125. /**
  32126. * Gets a boolean indicating that the engine supports uniform buffers
  32127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32128. */
  32129. get supportsUniformBuffers(): boolean;
  32130. /** @hidden */
  32131. _gl: WebGLRenderingContext;
  32132. /** @hidden */
  32133. _webGLVersion: number;
  32134. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32135. protected _windowIsBackground: boolean;
  32136. protected _creationOptions: EngineOptions;
  32137. protected _highPrecisionShadersAllowed: boolean;
  32138. /** @hidden */
  32139. get _shouldUseHighPrecisionShader(): boolean;
  32140. /**
  32141. * Gets a boolean indicating that only power of 2 textures are supported
  32142. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32143. */
  32144. get needPOTTextures(): boolean;
  32145. /** @hidden */
  32146. _badOS: boolean;
  32147. /** @hidden */
  32148. _badDesktopOS: boolean;
  32149. private _hardwareScalingLevel;
  32150. /** @hidden */
  32151. _caps: EngineCapabilities;
  32152. private _isStencilEnable;
  32153. private _glVersion;
  32154. private _glRenderer;
  32155. private _glVendor;
  32156. /** @hidden */
  32157. _videoTextureSupported: boolean;
  32158. protected _renderingQueueLaunched: boolean;
  32159. protected _activeRenderLoops: (() => void)[];
  32160. /**
  32161. * Observable signaled when a context lost event is raised
  32162. */
  32163. onContextLostObservable: Observable<ThinEngine>;
  32164. /**
  32165. * Observable signaled when a context restored event is raised
  32166. */
  32167. onContextRestoredObservable: Observable<ThinEngine>;
  32168. private _onContextLost;
  32169. private _onContextRestored;
  32170. protected _contextWasLost: boolean;
  32171. /** @hidden */
  32172. _doNotHandleContextLost: boolean;
  32173. /**
  32174. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32176. */
  32177. get doNotHandleContextLost(): boolean;
  32178. set doNotHandleContextLost(value: boolean);
  32179. /**
  32180. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32181. */
  32182. disableVertexArrayObjects: boolean;
  32183. /** @hidden */
  32184. protected _colorWrite: boolean;
  32185. /** @hidden */
  32186. protected _colorWriteChanged: boolean;
  32187. /** @hidden */
  32188. protected _depthCullingState: DepthCullingState;
  32189. /** @hidden */
  32190. protected _stencilState: StencilState;
  32191. /** @hidden */
  32192. _alphaState: AlphaState;
  32193. /** @hidden */
  32194. _alphaMode: number;
  32195. /** @hidden */
  32196. _alphaEquation: number;
  32197. /** @hidden */
  32198. _internalTexturesCache: InternalTexture[];
  32199. /** @hidden */
  32200. protected _activeChannel: number;
  32201. private _currentTextureChannel;
  32202. /** @hidden */
  32203. protected _boundTexturesCache: {
  32204. [key: string]: Nullable<InternalTexture>;
  32205. };
  32206. /** @hidden */
  32207. protected _currentEffect: Nullable<Effect>;
  32208. /** @hidden */
  32209. protected _currentProgram: Nullable<WebGLProgram>;
  32210. private _compiledEffects;
  32211. private _vertexAttribArraysEnabled;
  32212. /** @hidden */
  32213. protected _cachedViewport: Nullable<IViewportLike>;
  32214. private _cachedVertexArrayObject;
  32215. /** @hidden */
  32216. protected _cachedVertexBuffers: any;
  32217. /** @hidden */
  32218. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32219. /** @hidden */
  32220. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32221. /** @hidden */
  32222. _currentRenderTarget: Nullable<InternalTexture>;
  32223. private _uintIndicesCurrentlySet;
  32224. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32225. /** @hidden */
  32226. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32227. private _currentBufferPointers;
  32228. private _currentInstanceLocations;
  32229. private _currentInstanceBuffers;
  32230. private _textureUnits;
  32231. /** @hidden */
  32232. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32233. /** @hidden */
  32234. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32235. /** @hidden */
  32236. _boundRenderFunction: any;
  32237. private _vaoRecordInProgress;
  32238. private _mustWipeVertexAttributes;
  32239. private _emptyTexture;
  32240. private _emptyCubeTexture;
  32241. private _emptyTexture3D;
  32242. private _emptyTexture2DArray;
  32243. /** @hidden */
  32244. _frameHandler: number;
  32245. private _nextFreeTextureSlots;
  32246. private _maxSimultaneousTextures;
  32247. private _activeRequests;
  32248. /** @hidden */
  32249. _transformTextureUrl: Nullable<(url: string) => string>;
  32250. protected get _supportsHardwareTextureRescaling(): boolean;
  32251. private _framebufferDimensionsObject;
  32252. /**
  32253. * sets the object from which width and height will be taken from when getting render width and height
  32254. * Will fallback to the gl object
  32255. * @param dimensions the framebuffer width and height that will be used.
  32256. */
  32257. set framebufferDimensionsObject(dimensions: Nullable<{
  32258. framebufferWidth: number;
  32259. framebufferHeight: number;
  32260. }>);
  32261. /**
  32262. * Gets the current viewport
  32263. */
  32264. get currentViewport(): Nullable<IViewportLike>;
  32265. /**
  32266. * Gets the default empty texture
  32267. */
  32268. get emptyTexture(): InternalTexture;
  32269. /**
  32270. * Gets the default empty 3D texture
  32271. */
  32272. get emptyTexture3D(): InternalTexture;
  32273. /**
  32274. * Gets the default empty 2D array texture
  32275. */
  32276. get emptyTexture2DArray(): InternalTexture;
  32277. /**
  32278. * Gets the default empty cube texture
  32279. */
  32280. get emptyCubeTexture(): InternalTexture;
  32281. /**
  32282. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32283. */
  32284. readonly premultipliedAlpha: boolean;
  32285. /**
  32286. * Observable event triggered before each texture is initialized
  32287. */
  32288. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32289. /**
  32290. * Creates a new engine
  32291. * @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
  32292. * @param antialias defines enable antialiasing (default: false)
  32293. * @param options defines further options to be sent to the getContext() function
  32294. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32295. */
  32296. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32297. private _rebuildInternalTextures;
  32298. private _rebuildEffects;
  32299. /**
  32300. * Gets a boolean indicating if all created effects are ready
  32301. * @returns true if all effects are ready
  32302. */
  32303. areAllEffectsReady(): boolean;
  32304. protected _rebuildBuffers(): void;
  32305. protected _initGLContext(): void;
  32306. /**
  32307. * Gets version of the current webGL context
  32308. */
  32309. get webGLVersion(): number;
  32310. /**
  32311. * Gets a string idenfifying the name of the class
  32312. * @returns "Engine" string
  32313. */
  32314. getClassName(): string;
  32315. /**
  32316. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32317. */
  32318. get isStencilEnable(): boolean;
  32319. /** @hidden */
  32320. _prepareWorkingCanvas(): void;
  32321. /**
  32322. * Reset the texture cache to empty state
  32323. */
  32324. resetTextureCache(): void;
  32325. /**
  32326. * Gets an object containing information about the current webGL context
  32327. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32328. */
  32329. getGlInfo(): {
  32330. vendor: string;
  32331. renderer: string;
  32332. version: string;
  32333. };
  32334. /**
  32335. * Defines the hardware scaling level.
  32336. * By default the hardware scaling level is computed from the window device ratio.
  32337. * 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.
  32338. * @param level defines the level to use
  32339. */
  32340. setHardwareScalingLevel(level: number): void;
  32341. /**
  32342. * Gets the current hardware scaling level.
  32343. * By default the hardware scaling level is computed from the window device ratio.
  32344. * 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.
  32345. * @returns a number indicating the current hardware scaling level
  32346. */
  32347. getHardwareScalingLevel(): number;
  32348. /**
  32349. * Gets the list of loaded textures
  32350. * @returns an array containing all loaded textures
  32351. */
  32352. getLoadedTexturesCache(): InternalTexture[];
  32353. /**
  32354. * Gets the object containing all engine capabilities
  32355. * @returns the EngineCapabilities object
  32356. */
  32357. getCaps(): EngineCapabilities;
  32358. /**
  32359. * stop executing a render loop function and remove it from the execution array
  32360. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32361. */
  32362. stopRenderLoop(renderFunction?: () => void): void;
  32363. /** @hidden */
  32364. _renderLoop(): void;
  32365. /**
  32366. * Gets the HTML canvas attached with the current webGL context
  32367. * @returns a HTML canvas
  32368. */
  32369. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32370. /**
  32371. * Gets host window
  32372. * @returns the host window object
  32373. */
  32374. getHostWindow(): Nullable<Window>;
  32375. /**
  32376. * Gets the current render width
  32377. * @param useScreen defines if screen size must be used (or the current render target if any)
  32378. * @returns a number defining the current render width
  32379. */
  32380. getRenderWidth(useScreen?: boolean): number;
  32381. /**
  32382. * Gets the current render height
  32383. * @param useScreen defines if screen size must be used (or the current render target if any)
  32384. * @returns a number defining the current render height
  32385. */
  32386. getRenderHeight(useScreen?: boolean): number;
  32387. /**
  32388. * Can be used to override the current requestAnimationFrame requester.
  32389. * @hidden
  32390. */
  32391. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32392. /**
  32393. * Register and execute a render loop. The engine can have more than one render function
  32394. * @param renderFunction defines the function to continuously execute
  32395. */
  32396. runRenderLoop(renderFunction: () => void): void;
  32397. /**
  32398. * Clear the current render buffer or the current render target (if any is set up)
  32399. * @param color defines the color to use
  32400. * @param backBuffer defines if the back buffer must be cleared
  32401. * @param depth defines if the depth buffer must be cleared
  32402. * @param stencil defines if the stencil buffer must be cleared
  32403. */
  32404. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32405. private _viewportCached;
  32406. /** @hidden */
  32407. _viewport(x: number, y: number, width: number, height: number): void;
  32408. /**
  32409. * Set the WebGL's viewport
  32410. * @param viewport defines the viewport element to be used
  32411. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32412. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32413. */
  32414. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32415. /**
  32416. * Begin a new frame
  32417. */
  32418. beginFrame(): void;
  32419. /**
  32420. * Enf the current frame
  32421. */
  32422. endFrame(): void;
  32423. /**
  32424. * Resize the view according to the canvas' size
  32425. */
  32426. resize(): void;
  32427. /**
  32428. * Force a specific size of the canvas
  32429. * @param width defines the new canvas' width
  32430. * @param height defines the new canvas' height
  32431. */
  32432. setSize(width: number, height: number): void;
  32433. /**
  32434. * Binds the frame buffer to the specified texture.
  32435. * @param texture The texture to render to or null for the default canvas
  32436. * @param faceIndex The face of the texture to render to in case of cube texture
  32437. * @param requiredWidth The width of the target to render to
  32438. * @param requiredHeight The height of the target to render to
  32439. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32440. * @param lodLevel defines the lod level to bind to the frame buffer
  32441. * @param layer defines the 2d array index to bind to frame buffer to
  32442. */
  32443. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32444. /** @hidden */
  32445. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32446. /**
  32447. * Unbind the current render target texture from the webGL context
  32448. * @param texture defines the render target texture to unbind
  32449. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32450. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32451. */
  32452. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32453. /**
  32454. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32455. */
  32456. flushFramebuffer(): void;
  32457. /**
  32458. * Unbind the current render target and bind the default framebuffer
  32459. */
  32460. restoreDefaultFramebuffer(): void;
  32461. /** @hidden */
  32462. protected _resetVertexBufferBinding(): void;
  32463. /**
  32464. * Creates a vertex buffer
  32465. * @param data the data for the vertex buffer
  32466. * @returns the new WebGL static buffer
  32467. */
  32468. createVertexBuffer(data: DataArray): DataBuffer;
  32469. private _createVertexBuffer;
  32470. /**
  32471. * Creates a dynamic vertex buffer
  32472. * @param data the data for the dynamic vertex buffer
  32473. * @returns the new WebGL dynamic buffer
  32474. */
  32475. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32476. protected _resetIndexBufferBinding(): void;
  32477. /**
  32478. * Creates a new index buffer
  32479. * @param indices defines the content of the index buffer
  32480. * @param updatable defines if the index buffer must be updatable
  32481. * @returns a new webGL buffer
  32482. */
  32483. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32484. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32485. /**
  32486. * Bind a webGL buffer to the webGL context
  32487. * @param buffer defines the buffer to bind
  32488. */
  32489. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32490. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32491. private bindBuffer;
  32492. /**
  32493. * update the bound buffer with the given data
  32494. * @param data defines the data to update
  32495. */
  32496. updateArrayBuffer(data: Float32Array): void;
  32497. private _vertexAttribPointer;
  32498. /** @hidden */
  32499. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32500. private _bindVertexBuffersAttributes;
  32501. /**
  32502. * Records a vertex array object
  32503. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32504. * @param vertexBuffers defines the list of vertex buffers to store
  32505. * @param indexBuffer defines the index buffer to store
  32506. * @param effect defines the effect to store
  32507. * @returns the new vertex array object
  32508. */
  32509. recordVertexArrayObject(vertexBuffers: {
  32510. [key: string]: VertexBuffer;
  32511. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32512. /**
  32513. * Bind a specific vertex array object
  32514. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32515. * @param vertexArrayObject defines the vertex array object to bind
  32516. * @param indexBuffer defines the index buffer to bind
  32517. */
  32518. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32519. /**
  32520. * Bind webGl buffers directly to the webGL context
  32521. * @param vertexBuffer defines the vertex buffer to bind
  32522. * @param indexBuffer defines the index buffer to bind
  32523. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32524. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32525. * @param effect defines the effect associated with the vertex buffer
  32526. */
  32527. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32528. private _unbindVertexArrayObject;
  32529. /**
  32530. * Bind a list of vertex buffers to the webGL context
  32531. * @param vertexBuffers defines the list of vertex buffers to bind
  32532. * @param indexBuffer defines the index buffer to bind
  32533. * @param effect defines the effect associated with the vertex buffers
  32534. */
  32535. bindBuffers(vertexBuffers: {
  32536. [key: string]: Nullable<VertexBuffer>;
  32537. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32538. /**
  32539. * Unbind all instance attributes
  32540. */
  32541. unbindInstanceAttributes(): void;
  32542. /**
  32543. * Release and free the memory of a vertex array object
  32544. * @param vao defines the vertex array object to delete
  32545. */
  32546. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32547. /** @hidden */
  32548. _releaseBuffer(buffer: DataBuffer): boolean;
  32549. protected _deleteBuffer(buffer: DataBuffer): void;
  32550. /**
  32551. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32552. * @param instancesBuffer defines the webGL buffer to update and bind
  32553. * @param data defines the data to store in the buffer
  32554. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32555. */
  32556. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32557. /**
  32558. * Bind the content of a webGL buffer used with instantiation
  32559. * @param instancesBuffer defines the webGL buffer to bind
  32560. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32561. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32562. */
  32563. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32564. /**
  32565. * Disable the instance attribute corresponding to the name in parameter
  32566. * @param name defines the name of the attribute to disable
  32567. */
  32568. disableInstanceAttributeByName(name: string): void;
  32569. /**
  32570. * Disable the instance attribute corresponding to the location in parameter
  32571. * @param attributeLocation defines the attribute location of the attribute to disable
  32572. */
  32573. disableInstanceAttribute(attributeLocation: number): void;
  32574. /**
  32575. * Disable the attribute corresponding to the location in parameter
  32576. * @param attributeLocation defines the attribute location of the attribute to disable
  32577. */
  32578. disableAttributeByIndex(attributeLocation: number): void;
  32579. /**
  32580. * Send a draw order
  32581. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32582. * @param indexStart defines the starting index
  32583. * @param indexCount defines the number of index to draw
  32584. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32585. */
  32586. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32587. /**
  32588. * Draw a list of points
  32589. * @param verticesStart defines the index of first vertex to draw
  32590. * @param verticesCount defines the count of vertices to draw
  32591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32592. */
  32593. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32594. /**
  32595. * Draw a list of unindexed primitives
  32596. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32597. * @param verticesStart defines the index of first vertex to draw
  32598. * @param verticesCount defines the count of vertices to draw
  32599. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32600. */
  32601. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32602. /**
  32603. * Draw a list of indexed primitives
  32604. * @param fillMode defines the primitive to use
  32605. * @param indexStart defines the starting index
  32606. * @param indexCount defines the number of index to draw
  32607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32608. */
  32609. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32610. /**
  32611. * Draw a list of unindexed primitives
  32612. * @param fillMode defines the primitive to use
  32613. * @param verticesStart defines the index of first vertex to draw
  32614. * @param verticesCount defines the count of vertices to draw
  32615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32616. */
  32617. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32618. private _drawMode;
  32619. /** @hidden */
  32620. protected _reportDrawCall(): void;
  32621. /** @hidden */
  32622. _releaseEffect(effect: Effect): void;
  32623. /** @hidden */
  32624. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32625. /**
  32626. * Create a new effect (used to store vertex/fragment shaders)
  32627. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32628. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32629. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32630. * @param samplers defines an array of string used to represent textures
  32631. * @param defines defines the string containing the defines to use to compile the shaders
  32632. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32633. * @param onCompiled defines a function to call when the effect creation is successful
  32634. * @param onError defines a function to call when the effect creation has failed
  32635. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32636. * @returns the new Effect
  32637. */
  32638. 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;
  32639. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32640. private _compileShader;
  32641. private _compileRawShader;
  32642. /** @hidden */
  32643. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32644. /**
  32645. * Directly creates a webGL program
  32646. * @param pipelineContext defines the pipeline context to attach to
  32647. * @param vertexCode defines the vertex shader code to use
  32648. * @param fragmentCode defines the fragment shader code to use
  32649. * @param context defines the webGL context to use (if not set, the current one will be used)
  32650. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32651. * @returns the new webGL program
  32652. */
  32653. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32654. /**
  32655. * Creates a webGL program
  32656. * @param pipelineContext defines the pipeline context to attach to
  32657. * @param vertexCode defines the vertex shader code to use
  32658. * @param fragmentCode defines the fragment shader code to use
  32659. * @param defines defines the string containing the defines to use to compile the shaders
  32660. * @param context defines the webGL context to use (if not set, the current one will be used)
  32661. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32662. * @returns the new webGL program
  32663. */
  32664. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32665. /**
  32666. * Creates a new pipeline context
  32667. * @returns the new pipeline
  32668. */
  32669. createPipelineContext(): IPipelineContext;
  32670. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32671. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32672. /** @hidden */
  32673. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32674. /** @hidden */
  32675. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32676. /** @hidden */
  32677. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32678. /**
  32679. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32680. * @param pipelineContext defines the pipeline context to use
  32681. * @param uniformsNames defines the list of uniform names
  32682. * @returns an array of webGL uniform locations
  32683. */
  32684. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32685. /**
  32686. * Gets the lsit of active attributes for a given webGL program
  32687. * @param pipelineContext defines the pipeline context to use
  32688. * @param attributesNames defines the list of attribute names to get
  32689. * @returns an array of indices indicating the offset of each attribute
  32690. */
  32691. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32692. /**
  32693. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32694. * @param effect defines the effect to activate
  32695. */
  32696. enableEffect(effect: Nullable<Effect>): void;
  32697. /**
  32698. * Set the value of an uniform to a number (int)
  32699. * @param uniform defines the webGL uniform location where to store the value
  32700. * @param value defines the int number to store
  32701. */
  32702. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32703. /**
  32704. * Set the value of an uniform to an array of int32
  32705. * @param uniform defines the webGL uniform location where to store the value
  32706. * @param array defines the array of int32 to store
  32707. */
  32708. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32709. /**
  32710. * Set the value of an uniform to an array of int32 (stored as vec2)
  32711. * @param uniform defines the webGL uniform location where to store the value
  32712. * @param array defines the array of int32 to store
  32713. */
  32714. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32715. /**
  32716. * Set the value of an uniform to an array of int32 (stored as vec3)
  32717. * @param uniform defines the webGL uniform location where to store the value
  32718. * @param array defines the array of int32 to store
  32719. */
  32720. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32721. /**
  32722. * Set the value of an uniform to an array of int32 (stored as vec4)
  32723. * @param uniform defines the webGL uniform location where to store the value
  32724. * @param array defines the array of int32 to store
  32725. */
  32726. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32727. /**
  32728. * Set the value of an uniform to an array of number
  32729. * @param uniform defines the webGL uniform location where to store the value
  32730. * @param array defines the array of number to store
  32731. */
  32732. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32733. /**
  32734. * Set the value of an uniform to an array of number (stored as vec2)
  32735. * @param uniform defines the webGL uniform location where to store the value
  32736. * @param array defines the array of number to store
  32737. */
  32738. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32739. /**
  32740. * Set the value of an uniform to an array of number (stored as vec3)
  32741. * @param uniform defines the webGL uniform location where to store the value
  32742. * @param array defines the array of number to store
  32743. */
  32744. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32745. /**
  32746. * Set the value of an uniform to an array of number (stored as vec4)
  32747. * @param uniform defines the webGL uniform location where to store the value
  32748. * @param array defines the array of number to store
  32749. */
  32750. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32751. /**
  32752. * Set the value of an uniform to an array of float32 (stored as matrices)
  32753. * @param uniform defines the webGL uniform location where to store the value
  32754. * @param matrices defines the array of float32 to store
  32755. */
  32756. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32757. /**
  32758. * Set the value of an uniform to a matrix (3x3)
  32759. * @param uniform defines the webGL uniform location where to store the value
  32760. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32761. */
  32762. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32763. /**
  32764. * Set the value of an uniform to a matrix (2x2)
  32765. * @param uniform defines the webGL uniform location where to store the value
  32766. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32767. */
  32768. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32769. /**
  32770. * Set the value of an uniform to a number (float)
  32771. * @param uniform defines the webGL uniform location where to store the value
  32772. * @param value defines the float number to store
  32773. */
  32774. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32775. /**
  32776. * Set the value of an uniform to a vec2
  32777. * @param uniform defines the webGL uniform location where to store the value
  32778. * @param x defines the 1st component of the value
  32779. * @param y defines the 2nd component of the value
  32780. */
  32781. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32782. /**
  32783. * Set the value of an uniform to a vec3
  32784. * @param uniform defines the webGL uniform location where to store the value
  32785. * @param x defines the 1st component of the value
  32786. * @param y defines the 2nd component of the value
  32787. * @param z defines the 3rd component of the value
  32788. */
  32789. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32790. /**
  32791. * Set the value of an uniform to a vec4
  32792. * @param uniform defines the webGL uniform location where to store the value
  32793. * @param x defines the 1st component of the value
  32794. * @param y defines the 2nd component of the value
  32795. * @param z defines the 3rd component of the value
  32796. * @param w defines the 4th component of the value
  32797. */
  32798. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32799. /**
  32800. * Apply all cached states (depth, culling, stencil and alpha)
  32801. */
  32802. applyStates(): void;
  32803. /**
  32804. * Enable or disable color writing
  32805. * @param enable defines the state to set
  32806. */
  32807. setColorWrite(enable: boolean): void;
  32808. /**
  32809. * Gets a boolean indicating if color writing is enabled
  32810. * @returns the current color writing state
  32811. */
  32812. getColorWrite(): boolean;
  32813. /**
  32814. * Gets the depth culling state manager
  32815. */
  32816. get depthCullingState(): DepthCullingState;
  32817. /**
  32818. * Gets the alpha state manager
  32819. */
  32820. get alphaState(): AlphaState;
  32821. /**
  32822. * Gets the stencil state manager
  32823. */
  32824. get stencilState(): StencilState;
  32825. /**
  32826. * Clears the list of texture accessible through engine.
  32827. * This can help preventing texture load conflict due to name collision.
  32828. */
  32829. clearInternalTexturesCache(): void;
  32830. /**
  32831. * Force the entire cache to be cleared
  32832. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32833. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32834. */
  32835. wipeCaches(bruteForce?: boolean): void;
  32836. /** @hidden */
  32837. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32838. min: number;
  32839. mag: number;
  32840. };
  32841. /** @hidden */
  32842. _createTexture(): WebGLTexture;
  32843. /**
  32844. * Usually called from Texture.ts.
  32845. * Passed information to create a WebGLTexture
  32846. * @param url defines a value which contains one of the following:
  32847. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32848. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32849. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32850. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32851. * @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)
  32852. * @param scene needed for loading to the correct scene
  32853. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32854. * @param onLoad optional callback to be called upon successful completion
  32855. * @param onError optional callback to be called upon failure
  32856. * @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
  32857. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32858. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32859. * @param forcedExtension defines the extension to use to pick the right loader
  32860. * @param mimeType defines an optional mime type
  32861. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32862. */
  32863. 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;
  32864. /**
  32865. * Loads an image as an HTMLImageElement.
  32866. * @param input url string, ArrayBuffer, or Blob to load
  32867. * @param onLoad callback called when the image successfully loads
  32868. * @param onError callback called when the image fails to load
  32869. * @param offlineProvider offline provider for caching
  32870. * @param mimeType optional mime type
  32871. * @returns the HTMLImageElement of the loaded image
  32872. * @hidden
  32873. */
  32874. 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>;
  32875. /**
  32876. * @hidden
  32877. */
  32878. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32879. /**
  32880. * Creates a raw texture
  32881. * @param data defines the data to store in the texture
  32882. * @param width defines the width of the texture
  32883. * @param height defines the height of the texture
  32884. * @param format defines the format of the data
  32885. * @param generateMipMaps defines if the engine should generate the mip levels
  32886. * @param invertY defines if data must be stored with Y axis inverted
  32887. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32888. * @param compression defines the compression used (null by default)
  32889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32890. * @returns the raw texture inside an InternalTexture
  32891. */
  32892. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32893. /**
  32894. * Creates a new raw cube texture
  32895. * @param data defines the array of data to use to create each face
  32896. * @param size defines the size of the textures
  32897. * @param format defines the format of the data
  32898. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32899. * @param generateMipMaps defines if the engine should generate the mip levels
  32900. * @param invertY defines if data must be stored with Y axis inverted
  32901. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32902. * @param compression defines the compression used (null by default)
  32903. * @returns the cube texture as an InternalTexture
  32904. */
  32905. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32906. /**
  32907. * Creates a new raw 3D texture
  32908. * @param data defines the data used to create the texture
  32909. * @param width defines the width of the texture
  32910. * @param height defines the height of the texture
  32911. * @param depth defines the depth of the texture
  32912. * @param format defines the format of the texture
  32913. * @param generateMipMaps defines if the engine must generate mip levels
  32914. * @param invertY defines if data must be stored with Y axis inverted
  32915. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32916. * @param compression defines the compressed used (can be null)
  32917. * @param textureType defines the compressed used (can be null)
  32918. * @returns a new raw 3D texture (stored in an InternalTexture)
  32919. */
  32920. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32921. /**
  32922. * Creates a new raw 2D array texture
  32923. * @param data defines the data used to create the texture
  32924. * @param width defines the width of the texture
  32925. * @param height defines the height of the texture
  32926. * @param depth defines the number of layers of the texture
  32927. * @param format defines the format of the texture
  32928. * @param generateMipMaps defines if the engine must generate mip levels
  32929. * @param invertY defines if data must be stored with Y axis inverted
  32930. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32931. * @param compression defines the compressed used (can be null)
  32932. * @param textureType defines the compressed used (can be null)
  32933. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32934. */
  32935. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32936. private _unpackFlipYCached;
  32937. /**
  32938. * In case you are sharing the context with other applications, it might
  32939. * be interested to not cache the unpack flip y state to ensure a consistent
  32940. * value would be set.
  32941. */
  32942. enableUnpackFlipYCached: boolean;
  32943. /** @hidden */
  32944. _unpackFlipY(value: boolean): void;
  32945. /** @hidden */
  32946. _getUnpackAlignement(): number;
  32947. private _getTextureTarget;
  32948. /**
  32949. * Update the sampling mode of a given texture
  32950. * @param samplingMode defines the required sampling mode
  32951. * @param texture defines the texture to update
  32952. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32953. */
  32954. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32955. /**
  32956. * Update the sampling mode of a given texture
  32957. * @param texture defines the texture to update
  32958. * @param wrapU defines the texture wrap mode of the u coordinates
  32959. * @param wrapV defines the texture wrap mode of the v coordinates
  32960. * @param wrapR defines the texture wrap mode of the r coordinates
  32961. */
  32962. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32963. /** @hidden */
  32964. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32965. width: number;
  32966. height: number;
  32967. layers?: number;
  32968. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32969. /** @hidden */
  32970. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32971. /** @hidden */
  32972. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32973. /**
  32974. * Update a portion of an internal texture
  32975. * @param texture defines the texture to update
  32976. * @param imageData defines the data to store into the texture
  32977. * @param xOffset defines the x coordinates of the update rectangle
  32978. * @param yOffset defines the y coordinates of the update rectangle
  32979. * @param width defines the width of the update rectangle
  32980. * @param height defines the height of the update rectangle
  32981. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32982. * @param lod defines the lod level to update (0 by default)
  32983. */
  32984. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32985. /** @hidden */
  32986. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32987. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32988. private _prepareWebGLTexture;
  32989. /** @hidden */
  32990. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32991. private _getDepthStencilBuffer;
  32992. /** @hidden */
  32993. _releaseFramebufferObjects(texture: InternalTexture): void;
  32994. /** @hidden */
  32995. _releaseTexture(texture: InternalTexture): void;
  32996. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32997. protected _setProgram(program: WebGLProgram): void;
  32998. protected _boundUniforms: {
  32999. [key: number]: WebGLUniformLocation;
  33000. };
  33001. /**
  33002. * Binds an effect to the webGL context
  33003. * @param effect defines the effect to bind
  33004. */
  33005. bindSamplers(effect: Effect): void;
  33006. private _activateCurrentTexture;
  33007. /** @hidden */
  33008. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33009. /** @hidden */
  33010. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33011. /**
  33012. * Unbind all textures from the webGL context
  33013. */
  33014. unbindAllTextures(): void;
  33015. /**
  33016. * Sets a texture to the according uniform.
  33017. * @param channel The texture channel
  33018. * @param uniform The uniform to set
  33019. * @param texture The texture to apply
  33020. */
  33021. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33022. private _bindSamplerUniformToChannel;
  33023. private _getTextureWrapMode;
  33024. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33025. /**
  33026. * Sets an array of texture to the webGL context
  33027. * @param channel defines the channel where the texture array must be set
  33028. * @param uniform defines the associated uniform location
  33029. * @param textures defines the array of textures to bind
  33030. */
  33031. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33032. /** @hidden */
  33033. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33034. private _setTextureParameterFloat;
  33035. private _setTextureParameterInteger;
  33036. /**
  33037. * Unbind all vertex attributes from the webGL context
  33038. */
  33039. unbindAllAttributes(): void;
  33040. /**
  33041. * 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
  33042. */
  33043. releaseEffects(): void;
  33044. /**
  33045. * Dispose and release all associated resources
  33046. */
  33047. dispose(): void;
  33048. /**
  33049. * Attach a new callback raised when context lost event is fired
  33050. * @param callback defines the callback to call
  33051. */
  33052. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33053. /**
  33054. * Attach a new callback raised when context restored event is fired
  33055. * @param callback defines the callback to call
  33056. */
  33057. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33058. /**
  33059. * Get the current error code of the webGL context
  33060. * @returns the error code
  33061. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33062. */
  33063. getError(): number;
  33064. private _canRenderToFloatFramebuffer;
  33065. private _canRenderToHalfFloatFramebuffer;
  33066. private _canRenderToFramebuffer;
  33067. /** @hidden */
  33068. _getWebGLTextureType(type: number): number;
  33069. /** @hidden */
  33070. _getInternalFormat(format: number): number;
  33071. /** @hidden */
  33072. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33073. /** @hidden */
  33074. _getRGBAMultiSampleBufferFormat(type: number): number;
  33075. /** @hidden */
  33076. _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;
  33077. /**
  33078. * Loads a file from a url
  33079. * @param url url to load
  33080. * @param onSuccess callback called when the file successfully loads
  33081. * @param onProgress callback called while file is loading (if the server supports this mode)
  33082. * @param offlineProvider defines the offline provider for caching
  33083. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33084. * @param onError callback called when the file fails to load
  33085. * @returns a file request object
  33086. * @hidden
  33087. */
  33088. 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;
  33089. /**
  33090. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33091. * @param x defines the x coordinate of the rectangle where pixels must be read
  33092. * @param y defines the y coordinate of the rectangle where pixels must be read
  33093. * @param width defines the width of the rectangle where pixels must be read
  33094. * @param height defines the height of the rectangle where pixels must be read
  33095. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33096. * @returns a Uint8Array containing RGBA colors
  33097. */
  33098. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33099. private static _isSupported;
  33100. /**
  33101. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33102. * @returns true if the engine can be created
  33103. * @ignorenaming
  33104. */
  33105. static isSupported(): boolean;
  33106. /**
  33107. * Find the next highest power of two.
  33108. * @param x Number to start search from.
  33109. * @return Next highest power of two.
  33110. */
  33111. static CeilingPOT(x: number): number;
  33112. /**
  33113. * Find the next lowest power of two.
  33114. * @param x Number to start search from.
  33115. * @return Next lowest power of two.
  33116. */
  33117. static FloorPOT(x: number): number;
  33118. /**
  33119. * Find the nearest power of two.
  33120. * @param x Number to start search from.
  33121. * @return Next nearest power of two.
  33122. */
  33123. static NearestPOT(x: number): number;
  33124. /**
  33125. * Get the closest exponent of two
  33126. * @param value defines the value to approximate
  33127. * @param max defines the maximum value to return
  33128. * @param mode defines how to define the closest value
  33129. * @returns closest exponent of two of the given value
  33130. */
  33131. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33132. /**
  33133. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33134. * @param func - the function to be called
  33135. * @param requester - the object that will request the next frame. Falls back to window.
  33136. * @returns frame number
  33137. */
  33138. static QueueNewFrame(func: () => void, requester?: any): number;
  33139. /**
  33140. * Gets host document
  33141. * @returns the host document object
  33142. */
  33143. getHostDocument(): Nullable<Document>;
  33144. }
  33145. }
  33146. declare module "babylonjs/Maths/sphericalPolynomial" {
  33147. import { Vector3 } from "babylonjs/Maths/math.vector";
  33148. import { Color3 } from "babylonjs/Maths/math.color";
  33149. /**
  33150. * Class representing spherical harmonics coefficients to the 3rd degree
  33151. */
  33152. export class SphericalHarmonics {
  33153. /**
  33154. * Defines whether or not the harmonics have been prescaled for rendering.
  33155. */
  33156. preScaled: boolean;
  33157. /**
  33158. * The l0,0 coefficients of the spherical harmonics
  33159. */
  33160. l00: Vector3;
  33161. /**
  33162. * The l1,-1 coefficients of the spherical harmonics
  33163. */
  33164. l1_1: Vector3;
  33165. /**
  33166. * The l1,0 coefficients of the spherical harmonics
  33167. */
  33168. l10: Vector3;
  33169. /**
  33170. * The l1,1 coefficients of the spherical harmonics
  33171. */
  33172. l11: Vector3;
  33173. /**
  33174. * The l2,-2 coefficients of the spherical harmonics
  33175. */
  33176. l2_2: Vector3;
  33177. /**
  33178. * The l2,-1 coefficients of the spherical harmonics
  33179. */
  33180. l2_1: Vector3;
  33181. /**
  33182. * The l2,0 coefficients of the spherical harmonics
  33183. */
  33184. l20: Vector3;
  33185. /**
  33186. * The l2,1 coefficients of the spherical harmonics
  33187. */
  33188. l21: Vector3;
  33189. /**
  33190. * The l2,2 coefficients of the spherical harmonics
  33191. */
  33192. l22: Vector3;
  33193. /**
  33194. * Adds a light to the spherical harmonics
  33195. * @param direction the direction of the light
  33196. * @param color the color of the light
  33197. * @param deltaSolidAngle the delta solid angle of the light
  33198. */
  33199. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33200. /**
  33201. * Scales the spherical harmonics by the given amount
  33202. * @param scale the amount to scale
  33203. */
  33204. scaleInPlace(scale: number): void;
  33205. /**
  33206. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33207. *
  33208. * ```
  33209. * E_lm = A_l * L_lm
  33210. * ```
  33211. *
  33212. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33213. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33214. * the scaling factors are given in equation 9.
  33215. */
  33216. convertIncidentRadianceToIrradiance(): void;
  33217. /**
  33218. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33219. *
  33220. * ```
  33221. * L = (1/pi) * E * rho
  33222. * ```
  33223. *
  33224. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33225. */
  33226. convertIrradianceToLambertianRadiance(): void;
  33227. /**
  33228. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33229. * required operations at run time.
  33230. *
  33231. * This is simply done by scaling back the SH with Ylm constants parameter.
  33232. * The trigonometric part being applied by the shader at run time.
  33233. */
  33234. preScaleForRendering(): void;
  33235. /**
  33236. * Constructs a spherical harmonics from an array.
  33237. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33238. * @returns the spherical harmonics
  33239. */
  33240. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33241. /**
  33242. * Gets the spherical harmonics from polynomial
  33243. * @param polynomial the spherical polynomial
  33244. * @returns the spherical harmonics
  33245. */
  33246. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33247. }
  33248. /**
  33249. * Class representing spherical polynomial coefficients to the 3rd degree
  33250. */
  33251. export class SphericalPolynomial {
  33252. private _harmonics;
  33253. /**
  33254. * The spherical harmonics used to create the polynomials.
  33255. */
  33256. get preScaledHarmonics(): SphericalHarmonics;
  33257. /**
  33258. * The x coefficients of the spherical polynomial
  33259. */
  33260. x: Vector3;
  33261. /**
  33262. * The y coefficients of the spherical polynomial
  33263. */
  33264. y: Vector3;
  33265. /**
  33266. * The z coefficients of the spherical polynomial
  33267. */
  33268. z: Vector3;
  33269. /**
  33270. * The xx coefficients of the spherical polynomial
  33271. */
  33272. xx: Vector3;
  33273. /**
  33274. * The yy coefficients of the spherical polynomial
  33275. */
  33276. yy: Vector3;
  33277. /**
  33278. * The zz coefficients of the spherical polynomial
  33279. */
  33280. zz: Vector3;
  33281. /**
  33282. * The xy coefficients of the spherical polynomial
  33283. */
  33284. xy: Vector3;
  33285. /**
  33286. * The yz coefficients of the spherical polynomial
  33287. */
  33288. yz: Vector3;
  33289. /**
  33290. * The zx coefficients of the spherical polynomial
  33291. */
  33292. zx: Vector3;
  33293. /**
  33294. * Adds an ambient color to the spherical polynomial
  33295. * @param color the color to add
  33296. */
  33297. addAmbient(color: Color3): void;
  33298. /**
  33299. * Scales the spherical polynomial by the given amount
  33300. * @param scale the amount to scale
  33301. */
  33302. scaleInPlace(scale: number): void;
  33303. /**
  33304. * Gets the spherical polynomial from harmonics
  33305. * @param harmonics the spherical harmonics
  33306. * @returns the spherical polynomial
  33307. */
  33308. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33309. /**
  33310. * Constructs a spherical polynomial from an array.
  33311. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33312. * @returns the spherical polynomial
  33313. */
  33314. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33315. }
  33316. }
  33317. declare module "babylonjs/Materials/Textures/internalTexture" {
  33318. import { Observable } from "babylonjs/Misc/observable";
  33319. import { Nullable, int } from "babylonjs/types";
  33320. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33322. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33323. /**
  33324. * Defines the source of the internal texture
  33325. */
  33326. export enum InternalTextureSource {
  33327. /**
  33328. * The source of the texture data is unknown
  33329. */
  33330. Unknown = 0,
  33331. /**
  33332. * Texture data comes from an URL
  33333. */
  33334. Url = 1,
  33335. /**
  33336. * Texture data is only used for temporary storage
  33337. */
  33338. Temp = 2,
  33339. /**
  33340. * Texture data comes from raw data (ArrayBuffer)
  33341. */
  33342. Raw = 3,
  33343. /**
  33344. * Texture content is dynamic (video or dynamic texture)
  33345. */
  33346. Dynamic = 4,
  33347. /**
  33348. * Texture content is generated by rendering to it
  33349. */
  33350. RenderTarget = 5,
  33351. /**
  33352. * Texture content is part of a multi render target process
  33353. */
  33354. MultiRenderTarget = 6,
  33355. /**
  33356. * Texture data comes from a cube data file
  33357. */
  33358. Cube = 7,
  33359. /**
  33360. * Texture data comes from a raw cube data
  33361. */
  33362. CubeRaw = 8,
  33363. /**
  33364. * Texture data come from a prefiltered cube data file
  33365. */
  33366. CubePrefiltered = 9,
  33367. /**
  33368. * Texture content is raw 3D data
  33369. */
  33370. Raw3D = 10,
  33371. /**
  33372. * Texture content is raw 2D array data
  33373. */
  33374. Raw2DArray = 11,
  33375. /**
  33376. * Texture content is a depth texture
  33377. */
  33378. Depth = 12,
  33379. /**
  33380. * Texture data comes from a raw cube data encoded with RGBD
  33381. */
  33382. CubeRawRGBD = 13
  33383. }
  33384. /**
  33385. * Class used to store data associated with WebGL texture data for the engine
  33386. * This class should not be used directly
  33387. */
  33388. export class InternalTexture {
  33389. /** @hidden */
  33390. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33391. /**
  33392. * Defines if the texture is ready
  33393. */
  33394. isReady: boolean;
  33395. /**
  33396. * Defines if the texture is a cube texture
  33397. */
  33398. isCube: boolean;
  33399. /**
  33400. * Defines if the texture contains 3D data
  33401. */
  33402. is3D: boolean;
  33403. /**
  33404. * Defines if the texture contains 2D array data
  33405. */
  33406. is2DArray: boolean;
  33407. /**
  33408. * Defines if the texture contains multiview data
  33409. */
  33410. isMultiview: boolean;
  33411. /**
  33412. * Gets the URL used to load this texture
  33413. */
  33414. url: string;
  33415. /**
  33416. * Gets the sampling mode of the texture
  33417. */
  33418. samplingMode: number;
  33419. /**
  33420. * Gets a boolean indicating if the texture needs mipmaps generation
  33421. */
  33422. generateMipMaps: boolean;
  33423. /**
  33424. * Gets the number of samples used by the texture (WebGL2+ only)
  33425. */
  33426. samples: number;
  33427. /**
  33428. * Gets the type of the texture (int, float...)
  33429. */
  33430. type: number;
  33431. /**
  33432. * Gets the format of the texture (RGB, RGBA...)
  33433. */
  33434. format: number;
  33435. /**
  33436. * Observable called when the texture is loaded
  33437. */
  33438. onLoadedObservable: Observable<InternalTexture>;
  33439. /**
  33440. * Gets the width of the texture
  33441. */
  33442. width: number;
  33443. /**
  33444. * Gets the height of the texture
  33445. */
  33446. height: number;
  33447. /**
  33448. * Gets the depth of the texture
  33449. */
  33450. depth: number;
  33451. /**
  33452. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33453. */
  33454. baseWidth: number;
  33455. /**
  33456. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33457. */
  33458. baseHeight: number;
  33459. /**
  33460. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33461. */
  33462. baseDepth: number;
  33463. /**
  33464. * Gets a boolean indicating if the texture is inverted on Y axis
  33465. */
  33466. invertY: boolean;
  33467. /** @hidden */
  33468. _invertVScale: boolean;
  33469. /** @hidden */
  33470. _associatedChannel: number;
  33471. /** @hidden */
  33472. _source: InternalTextureSource;
  33473. /** @hidden */
  33474. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33475. /** @hidden */
  33476. _bufferView: Nullable<ArrayBufferView>;
  33477. /** @hidden */
  33478. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33479. /** @hidden */
  33480. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33481. /** @hidden */
  33482. _size: number;
  33483. /** @hidden */
  33484. _extension: string;
  33485. /** @hidden */
  33486. _files: Nullable<string[]>;
  33487. /** @hidden */
  33488. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33489. /** @hidden */
  33490. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33491. /** @hidden */
  33492. _framebuffer: Nullable<WebGLFramebuffer>;
  33493. /** @hidden */
  33494. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33495. /** @hidden */
  33496. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33497. /** @hidden */
  33498. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33499. /** @hidden */
  33500. _attachments: Nullable<number[]>;
  33501. /** @hidden */
  33502. _cachedCoordinatesMode: Nullable<number>;
  33503. /** @hidden */
  33504. _cachedWrapU: Nullable<number>;
  33505. /** @hidden */
  33506. _cachedWrapV: Nullable<number>;
  33507. /** @hidden */
  33508. _cachedWrapR: Nullable<number>;
  33509. /** @hidden */
  33510. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33511. /** @hidden */
  33512. _isDisabled: boolean;
  33513. /** @hidden */
  33514. _compression: Nullable<string>;
  33515. /** @hidden */
  33516. _generateStencilBuffer: boolean;
  33517. /** @hidden */
  33518. _generateDepthBuffer: boolean;
  33519. /** @hidden */
  33520. _comparisonFunction: number;
  33521. /** @hidden */
  33522. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33523. /** @hidden */
  33524. _lodGenerationScale: number;
  33525. /** @hidden */
  33526. _lodGenerationOffset: number;
  33527. /** @hidden */
  33528. _depthStencilTexture: Nullable<InternalTexture>;
  33529. /** @hidden */
  33530. _colorTextureArray: Nullable<WebGLTexture>;
  33531. /** @hidden */
  33532. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33533. /** @hidden */
  33534. _lodTextureHigh: Nullable<BaseTexture>;
  33535. /** @hidden */
  33536. _lodTextureMid: Nullable<BaseTexture>;
  33537. /** @hidden */
  33538. _lodTextureLow: Nullable<BaseTexture>;
  33539. /** @hidden */
  33540. _isRGBD: boolean;
  33541. /** @hidden */
  33542. _linearSpecularLOD: boolean;
  33543. /** @hidden */
  33544. _irradianceTexture: Nullable<BaseTexture>;
  33545. /** @hidden */
  33546. _webGLTexture: Nullable<WebGLTexture>;
  33547. /** @hidden */
  33548. _references: number;
  33549. private _engine;
  33550. /**
  33551. * Gets the Engine the texture belongs to.
  33552. * @returns The babylon engine
  33553. */
  33554. getEngine(): ThinEngine;
  33555. /**
  33556. * Gets the data source type of the texture
  33557. */
  33558. get source(): InternalTextureSource;
  33559. /**
  33560. * Creates a new InternalTexture
  33561. * @param engine defines the engine to use
  33562. * @param source defines the type of data that will be used
  33563. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33564. */
  33565. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33566. /**
  33567. * Increments the number of references (ie. the number of Texture that point to it)
  33568. */
  33569. incrementReferences(): void;
  33570. /**
  33571. * Change the size of the texture (not the size of the content)
  33572. * @param width defines the new width
  33573. * @param height defines the new height
  33574. * @param depth defines the new depth (1 by default)
  33575. */
  33576. updateSize(width: int, height: int, depth?: int): void;
  33577. /** @hidden */
  33578. _rebuild(): void;
  33579. /** @hidden */
  33580. _swapAndDie(target: InternalTexture): void;
  33581. /**
  33582. * Dispose the current allocated resources
  33583. */
  33584. dispose(): void;
  33585. }
  33586. }
  33587. declare module "babylonjs/Audio/analyser" {
  33588. import { Scene } from "babylonjs/scene";
  33589. /**
  33590. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33592. */
  33593. export class Analyser {
  33594. /**
  33595. * Gets or sets the smoothing
  33596. * @ignorenaming
  33597. */
  33598. SMOOTHING: number;
  33599. /**
  33600. * Gets or sets the FFT table size
  33601. * @ignorenaming
  33602. */
  33603. FFT_SIZE: number;
  33604. /**
  33605. * Gets or sets the bar graph amplitude
  33606. * @ignorenaming
  33607. */
  33608. BARGRAPHAMPLITUDE: number;
  33609. /**
  33610. * Gets or sets the position of the debug canvas
  33611. * @ignorenaming
  33612. */
  33613. DEBUGCANVASPOS: {
  33614. x: number;
  33615. y: number;
  33616. };
  33617. /**
  33618. * Gets or sets the debug canvas size
  33619. * @ignorenaming
  33620. */
  33621. DEBUGCANVASSIZE: {
  33622. width: number;
  33623. height: number;
  33624. };
  33625. private _byteFreqs;
  33626. private _byteTime;
  33627. private _floatFreqs;
  33628. private _webAudioAnalyser;
  33629. private _debugCanvas;
  33630. private _debugCanvasContext;
  33631. private _scene;
  33632. private _registerFunc;
  33633. private _audioEngine;
  33634. /**
  33635. * Creates a new analyser
  33636. * @param scene defines hosting scene
  33637. */
  33638. constructor(scene: Scene);
  33639. /**
  33640. * Get the number of data values you will have to play with for the visualization
  33641. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33642. * @returns a number
  33643. */
  33644. getFrequencyBinCount(): number;
  33645. /**
  33646. * Gets the current frequency data as a byte array
  33647. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33648. * @returns a Uint8Array
  33649. */
  33650. getByteFrequencyData(): Uint8Array;
  33651. /**
  33652. * Gets the current waveform as a byte array
  33653. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33654. * @returns a Uint8Array
  33655. */
  33656. getByteTimeDomainData(): Uint8Array;
  33657. /**
  33658. * Gets the current frequency data as a float array
  33659. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33660. * @returns a Float32Array
  33661. */
  33662. getFloatFrequencyData(): Float32Array;
  33663. /**
  33664. * Renders the debug canvas
  33665. */
  33666. drawDebugCanvas(): void;
  33667. /**
  33668. * Stops rendering the debug canvas and removes it
  33669. */
  33670. stopDebugCanvas(): void;
  33671. /**
  33672. * Connects two audio nodes
  33673. * @param inputAudioNode defines first node to connect
  33674. * @param outputAudioNode defines second node to connect
  33675. */
  33676. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33677. /**
  33678. * Releases all associated resources
  33679. */
  33680. dispose(): void;
  33681. }
  33682. }
  33683. declare module "babylonjs/Audio/audioEngine" {
  33684. import { IDisposable } from "babylonjs/scene";
  33685. import { Analyser } from "babylonjs/Audio/analyser";
  33686. import { Nullable } from "babylonjs/types";
  33687. import { Observable } from "babylonjs/Misc/observable";
  33688. /**
  33689. * This represents an audio engine and it is responsible
  33690. * to play, synchronize and analyse sounds throughout the application.
  33691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33692. */
  33693. export interface IAudioEngine extends IDisposable {
  33694. /**
  33695. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33696. */
  33697. readonly canUseWebAudio: boolean;
  33698. /**
  33699. * Gets the current AudioContext if available.
  33700. */
  33701. readonly audioContext: Nullable<AudioContext>;
  33702. /**
  33703. * The master gain node defines the global audio volume of your audio engine.
  33704. */
  33705. readonly masterGain: GainNode;
  33706. /**
  33707. * Gets whether or not mp3 are supported by your browser.
  33708. */
  33709. readonly isMP3supported: boolean;
  33710. /**
  33711. * Gets whether or not ogg are supported by your browser.
  33712. */
  33713. readonly isOGGsupported: boolean;
  33714. /**
  33715. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33716. * @ignoreNaming
  33717. */
  33718. WarnedWebAudioUnsupported: boolean;
  33719. /**
  33720. * Defines if the audio engine relies on a custom unlocked button.
  33721. * In this case, the embedded button will not be displayed.
  33722. */
  33723. useCustomUnlockedButton: boolean;
  33724. /**
  33725. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33726. */
  33727. readonly unlocked: boolean;
  33728. /**
  33729. * Event raised when audio has been unlocked on the browser.
  33730. */
  33731. onAudioUnlockedObservable: Observable<AudioEngine>;
  33732. /**
  33733. * Event raised when audio has been locked on the browser.
  33734. */
  33735. onAudioLockedObservable: Observable<AudioEngine>;
  33736. /**
  33737. * Flags the audio engine in Locked state.
  33738. * This happens due to new browser policies preventing audio to autoplay.
  33739. */
  33740. lock(): void;
  33741. /**
  33742. * Unlocks the audio engine once a user action has been done on the dom.
  33743. * This is helpful to resume play once browser policies have been satisfied.
  33744. */
  33745. unlock(): void;
  33746. /**
  33747. * Gets the global volume sets on the master gain.
  33748. * @returns the global volume if set or -1 otherwise
  33749. */
  33750. getGlobalVolume(): number;
  33751. /**
  33752. * Sets the global volume of your experience (sets on the master gain).
  33753. * @param newVolume Defines the new global volume of the application
  33754. */
  33755. setGlobalVolume(newVolume: number): void;
  33756. /**
  33757. * Connect the audio engine to an audio analyser allowing some amazing
  33758. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33760. * @param analyser The analyser to connect to the engine
  33761. */
  33762. connectToAnalyser(analyser: Analyser): void;
  33763. }
  33764. /**
  33765. * This represents the default audio engine used in babylon.
  33766. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33768. */
  33769. export class AudioEngine implements IAudioEngine {
  33770. private _audioContext;
  33771. private _audioContextInitialized;
  33772. private _muteButton;
  33773. private _hostElement;
  33774. /**
  33775. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33776. */
  33777. canUseWebAudio: boolean;
  33778. /**
  33779. * The master gain node defines the global audio volume of your audio engine.
  33780. */
  33781. masterGain: GainNode;
  33782. /**
  33783. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33784. * @ignoreNaming
  33785. */
  33786. WarnedWebAudioUnsupported: boolean;
  33787. /**
  33788. * Gets whether or not mp3 are supported by your browser.
  33789. */
  33790. isMP3supported: boolean;
  33791. /**
  33792. * Gets whether or not ogg are supported by your browser.
  33793. */
  33794. isOGGsupported: boolean;
  33795. /**
  33796. * Gets whether audio has been unlocked on the device.
  33797. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33798. * a user interaction has happened.
  33799. */
  33800. unlocked: boolean;
  33801. /**
  33802. * Defines if the audio engine relies on a custom unlocked button.
  33803. * In this case, the embedded button will not be displayed.
  33804. */
  33805. useCustomUnlockedButton: boolean;
  33806. /**
  33807. * Event raised when audio has been unlocked on the browser.
  33808. */
  33809. onAudioUnlockedObservable: Observable<AudioEngine>;
  33810. /**
  33811. * Event raised when audio has been locked on the browser.
  33812. */
  33813. onAudioLockedObservable: Observable<AudioEngine>;
  33814. /**
  33815. * Gets the current AudioContext if available.
  33816. */
  33817. get audioContext(): Nullable<AudioContext>;
  33818. private _connectedAnalyser;
  33819. /**
  33820. * Instantiates a new audio engine.
  33821. *
  33822. * There should be only one per page as some browsers restrict the number
  33823. * of audio contexts you can create.
  33824. * @param hostElement defines the host element where to display the mute icon if necessary
  33825. */
  33826. constructor(hostElement?: Nullable<HTMLElement>);
  33827. /**
  33828. * Flags the audio engine in Locked state.
  33829. * This happens due to new browser policies preventing audio to autoplay.
  33830. */
  33831. lock(): void;
  33832. /**
  33833. * Unlocks the audio engine once a user action has been done on the dom.
  33834. * This is helpful to resume play once browser policies have been satisfied.
  33835. */
  33836. unlock(): void;
  33837. private _resumeAudioContext;
  33838. private _initializeAudioContext;
  33839. private _tryToRun;
  33840. private _triggerRunningState;
  33841. private _triggerSuspendedState;
  33842. private _displayMuteButton;
  33843. private _moveButtonToTopLeft;
  33844. private _onResize;
  33845. private _hideMuteButton;
  33846. /**
  33847. * Destroy and release the resources associated with the audio ccontext.
  33848. */
  33849. dispose(): void;
  33850. /**
  33851. * Gets the global volume sets on the master gain.
  33852. * @returns the global volume if set or -1 otherwise
  33853. */
  33854. getGlobalVolume(): number;
  33855. /**
  33856. * Sets the global volume of your experience (sets on the master gain).
  33857. * @param newVolume Defines the new global volume of the application
  33858. */
  33859. setGlobalVolume(newVolume: number): void;
  33860. /**
  33861. * Connect the audio engine to an audio analyser allowing some amazing
  33862. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33864. * @param analyser The analyser to connect to the engine
  33865. */
  33866. connectToAnalyser(analyser: Analyser): void;
  33867. }
  33868. }
  33869. declare module "babylonjs/Loading/loadingScreen" {
  33870. /**
  33871. * Interface used to present a loading screen while loading a scene
  33872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33873. */
  33874. export interface ILoadingScreen {
  33875. /**
  33876. * Function called to display the loading screen
  33877. */
  33878. displayLoadingUI: () => void;
  33879. /**
  33880. * Function called to hide the loading screen
  33881. */
  33882. hideLoadingUI: () => void;
  33883. /**
  33884. * Gets or sets the color to use for the background
  33885. */
  33886. loadingUIBackgroundColor: string;
  33887. /**
  33888. * Gets or sets the text to display while loading
  33889. */
  33890. loadingUIText: string;
  33891. }
  33892. /**
  33893. * Class used for the default loading screen
  33894. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33895. */
  33896. export class DefaultLoadingScreen implements ILoadingScreen {
  33897. private _renderingCanvas;
  33898. private _loadingText;
  33899. private _loadingDivBackgroundColor;
  33900. private _loadingDiv;
  33901. private _loadingTextDiv;
  33902. /** Gets or sets the logo url to use for the default loading screen */
  33903. static DefaultLogoUrl: string;
  33904. /** Gets or sets the spinner url to use for the default loading screen */
  33905. static DefaultSpinnerUrl: string;
  33906. /**
  33907. * Creates a new default loading screen
  33908. * @param _renderingCanvas defines the canvas used to render the scene
  33909. * @param _loadingText defines the default text to display
  33910. * @param _loadingDivBackgroundColor defines the default background color
  33911. */
  33912. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33913. /**
  33914. * Function called to display the loading screen
  33915. */
  33916. displayLoadingUI(): void;
  33917. /**
  33918. * Function called to hide the loading screen
  33919. */
  33920. hideLoadingUI(): void;
  33921. /**
  33922. * Gets or sets the text to display while loading
  33923. */
  33924. set loadingUIText(text: string);
  33925. get loadingUIText(): string;
  33926. /**
  33927. * Gets or sets the color to use for the background
  33928. */
  33929. get loadingUIBackgroundColor(): string;
  33930. set loadingUIBackgroundColor(color: string);
  33931. private _resizeLoadingUI;
  33932. }
  33933. }
  33934. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33935. /**
  33936. * Interface for any object that can request an animation frame
  33937. */
  33938. export interface ICustomAnimationFrameRequester {
  33939. /**
  33940. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33941. */
  33942. renderFunction?: Function;
  33943. /**
  33944. * Called to request the next frame to render to
  33945. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33946. */
  33947. requestAnimationFrame: Function;
  33948. /**
  33949. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33950. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33951. */
  33952. requestID?: number;
  33953. }
  33954. }
  33955. declare module "babylonjs/Misc/performanceMonitor" {
  33956. /**
  33957. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33958. */
  33959. export class PerformanceMonitor {
  33960. private _enabled;
  33961. private _rollingFrameTime;
  33962. private _lastFrameTimeMs;
  33963. /**
  33964. * constructor
  33965. * @param frameSampleSize The number of samples required to saturate the sliding window
  33966. */
  33967. constructor(frameSampleSize?: number);
  33968. /**
  33969. * Samples current frame
  33970. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33971. */
  33972. sampleFrame(timeMs?: number): void;
  33973. /**
  33974. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33975. */
  33976. get averageFrameTime(): number;
  33977. /**
  33978. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33979. */
  33980. get averageFrameTimeVariance(): number;
  33981. /**
  33982. * Returns the frame time of the most recent frame
  33983. */
  33984. get instantaneousFrameTime(): number;
  33985. /**
  33986. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33987. */
  33988. get averageFPS(): number;
  33989. /**
  33990. * Returns the average framerate in frames per second using the most recent frame time
  33991. */
  33992. get instantaneousFPS(): number;
  33993. /**
  33994. * Returns true if enough samples have been taken to completely fill the sliding window
  33995. */
  33996. get isSaturated(): boolean;
  33997. /**
  33998. * Enables contributions to the sliding window sample set
  33999. */
  34000. enable(): void;
  34001. /**
  34002. * Disables contributions to the sliding window sample set
  34003. * Samples will not be interpolated over the disabled period
  34004. */
  34005. disable(): void;
  34006. /**
  34007. * Returns true if sampling is enabled
  34008. */
  34009. get isEnabled(): boolean;
  34010. /**
  34011. * Resets performance monitor
  34012. */
  34013. reset(): void;
  34014. }
  34015. /**
  34016. * RollingAverage
  34017. *
  34018. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34019. */
  34020. export class RollingAverage {
  34021. /**
  34022. * Current average
  34023. */
  34024. average: number;
  34025. /**
  34026. * Current variance
  34027. */
  34028. variance: number;
  34029. protected _samples: Array<number>;
  34030. protected _sampleCount: number;
  34031. protected _pos: number;
  34032. protected _m2: number;
  34033. /**
  34034. * constructor
  34035. * @param length The number of samples required to saturate the sliding window
  34036. */
  34037. constructor(length: number);
  34038. /**
  34039. * Adds a sample to the sample set
  34040. * @param v The sample value
  34041. */
  34042. add(v: number): void;
  34043. /**
  34044. * Returns previously added values or null if outside of history or outside the sliding window domain
  34045. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34046. * @return Value previously recorded with add() or null if outside of range
  34047. */
  34048. history(i: number): number;
  34049. /**
  34050. * Returns true if enough samples have been taken to completely fill the sliding window
  34051. * @return true if sample-set saturated
  34052. */
  34053. isSaturated(): boolean;
  34054. /**
  34055. * Resets the rolling average (equivalent to 0 samples taken so far)
  34056. */
  34057. reset(): void;
  34058. /**
  34059. * Wraps a value around the sample range boundaries
  34060. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34061. * @return Wrapped position in sample range
  34062. */
  34063. protected _wrapPosition(i: number): number;
  34064. }
  34065. }
  34066. declare module "babylonjs/Misc/perfCounter" {
  34067. /**
  34068. * This class is used to track a performance counter which is number based.
  34069. * The user has access to many properties which give statistics of different nature.
  34070. *
  34071. * The implementer can track two kinds of Performance Counter: time and count.
  34072. * 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.
  34073. * 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.
  34074. */
  34075. export class PerfCounter {
  34076. /**
  34077. * Gets or sets a global boolean to turn on and off all the counters
  34078. */
  34079. static Enabled: boolean;
  34080. /**
  34081. * Returns the smallest value ever
  34082. */
  34083. get min(): number;
  34084. /**
  34085. * Returns the biggest value ever
  34086. */
  34087. get max(): number;
  34088. /**
  34089. * Returns the average value since the performance counter is running
  34090. */
  34091. get average(): number;
  34092. /**
  34093. * Returns the average value of the last second the counter was monitored
  34094. */
  34095. get lastSecAverage(): number;
  34096. /**
  34097. * Returns the current value
  34098. */
  34099. get current(): number;
  34100. /**
  34101. * Gets the accumulated total
  34102. */
  34103. get total(): number;
  34104. /**
  34105. * Gets the total value count
  34106. */
  34107. get count(): number;
  34108. /**
  34109. * Creates a new counter
  34110. */
  34111. constructor();
  34112. /**
  34113. * Call this method to start monitoring a new frame.
  34114. * 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.
  34115. */
  34116. fetchNewFrame(): void;
  34117. /**
  34118. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34119. * @param newCount the count value to add to the monitored count
  34120. * @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.
  34121. */
  34122. addCount(newCount: number, fetchResult: boolean): void;
  34123. /**
  34124. * Start monitoring this performance counter
  34125. */
  34126. beginMonitoring(): void;
  34127. /**
  34128. * Compute the time lapsed since the previous beginMonitoring() call.
  34129. * @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
  34130. */
  34131. endMonitoring(newFrame?: boolean): void;
  34132. private _fetchResult;
  34133. private _startMonitoringTime;
  34134. private _min;
  34135. private _max;
  34136. private _average;
  34137. private _current;
  34138. private _totalValueCount;
  34139. private _totalAccumulated;
  34140. private _lastSecAverage;
  34141. private _lastSecAccumulated;
  34142. private _lastSecTime;
  34143. private _lastSecValueCount;
  34144. }
  34145. }
  34146. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34147. module "babylonjs/Engines/thinEngine" {
  34148. interface ThinEngine {
  34149. /**
  34150. * Sets alpha constants used by some alpha blending modes
  34151. * @param r defines the red component
  34152. * @param g defines the green component
  34153. * @param b defines the blue component
  34154. * @param a defines the alpha component
  34155. */
  34156. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34157. /**
  34158. * Sets the current alpha mode
  34159. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34160. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34161. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34162. */
  34163. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34164. /**
  34165. * Gets the current alpha mode
  34166. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34167. * @returns the current alpha mode
  34168. */
  34169. getAlphaMode(): number;
  34170. /**
  34171. * Sets the current alpha equation
  34172. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34173. */
  34174. setAlphaEquation(equation: number): void;
  34175. /**
  34176. * Gets the current alpha equation.
  34177. * @returns the current alpha equation
  34178. */
  34179. getAlphaEquation(): number;
  34180. }
  34181. }
  34182. }
  34183. declare module "babylonjs/Engines/engine" {
  34184. import { Observable } from "babylonjs/Misc/observable";
  34185. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34186. import { Scene } from "babylonjs/scene";
  34187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34188. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34189. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34190. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34191. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34192. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34193. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34194. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34195. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34196. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34197. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34198. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34199. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34200. import "babylonjs/Engines/Extensions/engine.alpha";
  34201. import { Material } from "babylonjs/Materials/material";
  34202. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34203. /**
  34204. * Defines the interface used by display changed events
  34205. */
  34206. export interface IDisplayChangedEventArgs {
  34207. /** Gets the vrDisplay object (if any) */
  34208. vrDisplay: Nullable<any>;
  34209. /** Gets a boolean indicating if webVR is supported */
  34210. vrSupported: boolean;
  34211. }
  34212. /**
  34213. * Defines the interface used by objects containing a viewport (like a camera)
  34214. */
  34215. interface IViewportOwnerLike {
  34216. /**
  34217. * Gets or sets the viewport
  34218. */
  34219. viewport: IViewportLike;
  34220. }
  34221. /**
  34222. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34223. */
  34224. export class Engine extends ThinEngine {
  34225. /** Defines that alpha blending is disabled */
  34226. static readonly ALPHA_DISABLE: number;
  34227. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34228. static readonly ALPHA_ADD: number;
  34229. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34230. static readonly ALPHA_COMBINE: number;
  34231. /** Defines that alpha blending to DEST - SRC * DEST */
  34232. static readonly ALPHA_SUBTRACT: number;
  34233. /** Defines that alpha blending to SRC * DEST */
  34234. static readonly ALPHA_MULTIPLY: number;
  34235. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34236. static readonly ALPHA_MAXIMIZED: number;
  34237. /** Defines that alpha blending to SRC + DEST */
  34238. static readonly ALPHA_ONEONE: number;
  34239. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34240. static readonly ALPHA_PREMULTIPLIED: number;
  34241. /**
  34242. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34243. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34244. */
  34245. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34246. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34247. static readonly ALPHA_INTERPOLATE: number;
  34248. /**
  34249. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34250. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34251. */
  34252. static readonly ALPHA_SCREENMODE: number;
  34253. /** Defines that the ressource is not delayed*/
  34254. static readonly DELAYLOADSTATE_NONE: number;
  34255. /** Defines that the ressource was successfully delay loaded */
  34256. static readonly DELAYLOADSTATE_LOADED: number;
  34257. /** Defines that the ressource is currently delay loading */
  34258. static readonly DELAYLOADSTATE_LOADING: number;
  34259. /** Defines that the ressource is delayed and has not started loading */
  34260. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34261. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34262. static readonly NEVER: number;
  34263. /** 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 */
  34264. static readonly ALWAYS: number;
  34265. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34266. static readonly LESS: number;
  34267. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34268. static readonly EQUAL: number;
  34269. /** 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 */
  34270. static readonly LEQUAL: number;
  34271. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34272. static readonly GREATER: number;
  34273. /** 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 */
  34274. static readonly GEQUAL: number;
  34275. /** 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 */
  34276. static readonly NOTEQUAL: number;
  34277. /** Passed to stencilOperation to specify that stencil value must be kept */
  34278. static readonly KEEP: number;
  34279. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34280. static readonly REPLACE: number;
  34281. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34282. static readonly INCR: number;
  34283. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34284. static readonly DECR: number;
  34285. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34286. static readonly INVERT: number;
  34287. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34288. static readonly INCR_WRAP: number;
  34289. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34290. static readonly DECR_WRAP: number;
  34291. /** Texture is not repeating outside of 0..1 UVs */
  34292. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34293. /** Texture is repeating outside of 0..1 UVs */
  34294. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34295. /** Texture is repeating and mirrored */
  34296. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34297. /** ALPHA */
  34298. static readonly TEXTUREFORMAT_ALPHA: number;
  34299. /** LUMINANCE */
  34300. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34301. /** LUMINANCE_ALPHA */
  34302. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34303. /** RGB */
  34304. static readonly TEXTUREFORMAT_RGB: number;
  34305. /** RGBA */
  34306. static readonly TEXTUREFORMAT_RGBA: number;
  34307. /** RED */
  34308. static readonly TEXTUREFORMAT_RED: number;
  34309. /** RED (2nd reference) */
  34310. static readonly TEXTUREFORMAT_R: number;
  34311. /** RG */
  34312. static readonly TEXTUREFORMAT_RG: number;
  34313. /** RED_INTEGER */
  34314. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34315. /** RED_INTEGER (2nd reference) */
  34316. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34317. /** RG_INTEGER */
  34318. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34319. /** RGB_INTEGER */
  34320. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34321. /** RGBA_INTEGER */
  34322. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34323. /** UNSIGNED_BYTE */
  34324. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34325. /** UNSIGNED_BYTE (2nd reference) */
  34326. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34327. /** FLOAT */
  34328. static readonly TEXTURETYPE_FLOAT: number;
  34329. /** HALF_FLOAT */
  34330. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34331. /** BYTE */
  34332. static readonly TEXTURETYPE_BYTE: number;
  34333. /** SHORT */
  34334. static readonly TEXTURETYPE_SHORT: number;
  34335. /** UNSIGNED_SHORT */
  34336. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34337. /** INT */
  34338. static readonly TEXTURETYPE_INT: number;
  34339. /** UNSIGNED_INT */
  34340. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34341. /** UNSIGNED_SHORT_4_4_4_4 */
  34342. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34343. /** UNSIGNED_SHORT_5_5_5_1 */
  34344. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34345. /** UNSIGNED_SHORT_5_6_5 */
  34346. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34347. /** UNSIGNED_INT_2_10_10_10_REV */
  34348. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34349. /** UNSIGNED_INT_24_8 */
  34350. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34351. /** UNSIGNED_INT_10F_11F_11F_REV */
  34352. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34353. /** UNSIGNED_INT_5_9_9_9_REV */
  34354. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34355. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34356. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34357. /** nearest is mag = nearest and min = nearest and mip = linear */
  34358. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34359. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34360. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34361. /** Trilinear is mag = linear and min = linear and mip = linear */
  34362. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34363. /** nearest is mag = nearest and min = nearest and mip = linear */
  34364. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34365. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34366. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34367. /** Trilinear is mag = linear and min = linear and mip = linear */
  34368. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34369. /** mag = nearest and min = nearest and mip = nearest */
  34370. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34371. /** mag = nearest and min = linear and mip = nearest */
  34372. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34373. /** mag = nearest and min = linear and mip = linear */
  34374. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34375. /** mag = nearest and min = linear and mip = none */
  34376. static readonly TEXTURE_NEAREST_LINEAR: number;
  34377. /** mag = nearest and min = nearest and mip = none */
  34378. static readonly TEXTURE_NEAREST_NEAREST: number;
  34379. /** mag = linear and min = nearest and mip = nearest */
  34380. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34381. /** mag = linear and min = nearest and mip = linear */
  34382. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34383. /** mag = linear and min = linear and mip = none */
  34384. static readonly TEXTURE_LINEAR_LINEAR: number;
  34385. /** mag = linear and min = nearest and mip = none */
  34386. static readonly TEXTURE_LINEAR_NEAREST: number;
  34387. /** Explicit coordinates mode */
  34388. static readonly TEXTURE_EXPLICIT_MODE: number;
  34389. /** Spherical coordinates mode */
  34390. static readonly TEXTURE_SPHERICAL_MODE: number;
  34391. /** Planar coordinates mode */
  34392. static readonly TEXTURE_PLANAR_MODE: number;
  34393. /** Cubic coordinates mode */
  34394. static readonly TEXTURE_CUBIC_MODE: number;
  34395. /** Projection coordinates mode */
  34396. static readonly TEXTURE_PROJECTION_MODE: number;
  34397. /** Skybox coordinates mode */
  34398. static readonly TEXTURE_SKYBOX_MODE: number;
  34399. /** Inverse Cubic coordinates mode */
  34400. static readonly TEXTURE_INVCUBIC_MODE: number;
  34401. /** Equirectangular coordinates mode */
  34402. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34403. /** Equirectangular Fixed coordinates mode */
  34404. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34405. /** Equirectangular Fixed Mirrored coordinates mode */
  34406. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34407. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34408. static readonly SCALEMODE_FLOOR: number;
  34409. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34410. static readonly SCALEMODE_NEAREST: number;
  34411. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34412. static readonly SCALEMODE_CEILING: number;
  34413. /**
  34414. * Returns the current npm package of the sdk
  34415. */
  34416. static get NpmPackage(): string;
  34417. /**
  34418. * Returns the current version of the framework
  34419. */
  34420. static get Version(): string;
  34421. /** Gets the list of created engines */
  34422. static get Instances(): Engine[];
  34423. /**
  34424. * Gets the latest created engine
  34425. */
  34426. static get LastCreatedEngine(): Nullable<Engine>;
  34427. /**
  34428. * Gets the latest created scene
  34429. */
  34430. static get LastCreatedScene(): Nullable<Scene>;
  34431. /**
  34432. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34433. * @param flag defines which part of the materials must be marked as dirty
  34434. * @param predicate defines a predicate used to filter which materials should be affected
  34435. */
  34436. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34437. /**
  34438. * Method called to create the default loading screen.
  34439. * This can be overriden in your own app.
  34440. * @param canvas The rendering canvas element
  34441. * @returns The loading screen
  34442. */
  34443. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34444. /**
  34445. * Method called to create the default rescale post process on each engine.
  34446. */
  34447. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34448. /**
  34449. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34450. **/
  34451. enableOfflineSupport: boolean;
  34452. /**
  34453. * 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)
  34454. **/
  34455. disableManifestCheck: boolean;
  34456. /**
  34457. * Gets the list of created scenes
  34458. */
  34459. scenes: Scene[];
  34460. /**
  34461. * Event raised when a new scene is created
  34462. */
  34463. onNewSceneAddedObservable: Observable<Scene>;
  34464. /**
  34465. * Gets the list of created postprocesses
  34466. */
  34467. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34468. /**
  34469. * Gets a boolean indicating if the pointer is currently locked
  34470. */
  34471. isPointerLock: boolean;
  34472. /**
  34473. * Observable event triggered each time the rendering canvas is resized
  34474. */
  34475. onResizeObservable: Observable<Engine>;
  34476. /**
  34477. * Observable event triggered each time the canvas loses focus
  34478. */
  34479. onCanvasBlurObservable: Observable<Engine>;
  34480. /**
  34481. * Observable event triggered each time the canvas gains focus
  34482. */
  34483. onCanvasFocusObservable: Observable<Engine>;
  34484. /**
  34485. * Observable event triggered each time the canvas receives pointerout event
  34486. */
  34487. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34488. /**
  34489. * Observable raised when the engine begins a new frame
  34490. */
  34491. onBeginFrameObservable: Observable<Engine>;
  34492. /**
  34493. * If set, will be used to request the next animation frame for the render loop
  34494. */
  34495. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34496. /**
  34497. * Observable raised when the engine ends the current frame
  34498. */
  34499. onEndFrameObservable: Observable<Engine>;
  34500. /**
  34501. * Observable raised when the engine is about to compile a shader
  34502. */
  34503. onBeforeShaderCompilationObservable: Observable<Engine>;
  34504. /**
  34505. * Observable raised when the engine has jsut compiled a shader
  34506. */
  34507. onAfterShaderCompilationObservable: Observable<Engine>;
  34508. /**
  34509. * Gets the audio engine
  34510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34511. * @ignorenaming
  34512. */
  34513. static audioEngine: IAudioEngine;
  34514. /**
  34515. * Default AudioEngine factory responsible of creating the Audio Engine.
  34516. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34517. */
  34518. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34519. /**
  34520. * Default offline support factory responsible of creating a tool used to store data locally.
  34521. * By default, this will create a Database object if the workload has been embedded.
  34522. */
  34523. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34524. private _loadingScreen;
  34525. private _pointerLockRequested;
  34526. private _dummyFramebuffer;
  34527. private _rescalePostProcess;
  34528. private _deterministicLockstep;
  34529. private _lockstepMaxSteps;
  34530. private _timeStep;
  34531. protected get _supportsHardwareTextureRescaling(): boolean;
  34532. private _fps;
  34533. private _deltaTime;
  34534. /** @hidden */
  34535. _drawCalls: PerfCounter;
  34536. /** 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 */
  34537. canvasTabIndex: number;
  34538. /**
  34539. * Turn this value on if you want to pause FPS computation when in background
  34540. */
  34541. disablePerformanceMonitorInBackground: boolean;
  34542. private _performanceMonitor;
  34543. /**
  34544. * Gets the performance monitor attached to this engine
  34545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34546. */
  34547. get performanceMonitor(): PerformanceMonitor;
  34548. private _onFocus;
  34549. private _onBlur;
  34550. private _onCanvasPointerOut;
  34551. private _onCanvasBlur;
  34552. private _onCanvasFocus;
  34553. private _onFullscreenChange;
  34554. private _onPointerLockChange;
  34555. /**
  34556. * Gets the HTML element used to attach event listeners
  34557. * @returns a HTML element
  34558. */
  34559. getInputElement(): Nullable<HTMLElement>;
  34560. /**
  34561. * Creates a new engine
  34562. * @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
  34563. * @param antialias defines enable antialiasing (default: false)
  34564. * @param options defines further options to be sent to the getContext() function
  34565. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34566. */
  34567. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34568. /**
  34569. * Gets current aspect ratio
  34570. * @param viewportOwner defines the camera to use to get the aspect ratio
  34571. * @param useScreen defines if screen size must be used (or the current render target if any)
  34572. * @returns a number defining the aspect ratio
  34573. */
  34574. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34575. /**
  34576. * Gets current screen aspect ratio
  34577. * @returns a number defining the aspect ratio
  34578. */
  34579. getScreenAspectRatio(): number;
  34580. /**
  34581. * Gets the client rect of the HTML canvas attached with the current webGL context
  34582. * @returns a client rectanglee
  34583. */
  34584. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34585. /**
  34586. * Gets the client rect of the HTML element used for events
  34587. * @returns a client rectanglee
  34588. */
  34589. getInputElementClientRect(): Nullable<ClientRect>;
  34590. /**
  34591. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34593. * @returns true if engine is in deterministic lock step mode
  34594. */
  34595. isDeterministicLockStep(): boolean;
  34596. /**
  34597. * Gets the max steps when engine is running in deterministic lock step
  34598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34599. * @returns the max steps
  34600. */
  34601. getLockstepMaxSteps(): number;
  34602. /**
  34603. * Returns the time in ms between steps when using deterministic lock step.
  34604. * @returns time step in (ms)
  34605. */
  34606. getTimeStep(): number;
  34607. /**
  34608. * Force the mipmap generation for the given render target texture
  34609. * @param texture defines the render target texture to use
  34610. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34611. */
  34612. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34613. /** States */
  34614. /**
  34615. * Set various states to the webGL context
  34616. * @param culling defines backface culling state
  34617. * @param zOffset defines the value to apply to zOffset (0 by default)
  34618. * @param force defines if states must be applied even if cache is up to date
  34619. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34620. */
  34621. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34622. /**
  34623. * Set the z offset to apply to current rendering
  34624. * @param value defines the offset to apply
  34625. */
  34626. setZOffset(value: number): void;
  34627. /**
  34628. * Gets the current value of the zOffset
  34629. * @returns the current zOffset state
  34630. */
  34631. getZOffset(): number;
  34632. /**
  34633. * Enable or disable depth buffering
  34634. * @param enable defines the state to set
  34635. */
  34636. setDepthBuffer(enable: boolean): void;
  34637. /**
  34638. * Gets a boolean indicating if depth writing is enabled
  34639. * @returns the current depth writing state
  34640. */
  34641. getDepthWrite(): boolean;
  34642. /**
  34643. * Enable or disable depth writing
  34644. * @param enable defines the state to set
  34645. */
  34646. setDepthWrite(enable: boolean): void;
  34647. /**
  34648. * Gets a boolean indicating if stencil buffer is enabled
  34649. * @returns the current stencil buffer state
  34650. */
  34651. getStencilBuffer(): boolean;
  34652. /**
  34653. * Enable or disable the stencil buffer
  34654. * @param enable defines if the stencil buffer must be enabled or disabled
  34655. */
  34656. setStencilBuffer(enable: boolean): void;
  34657. /**
  34658. * Gets the current stencil mask
  34659. * @returns a number defining the new stencil mask to use
  34660. */
  34661. getStencilMask(): number;
  34662. /**
  34663. * Sets the current stencil mask
  34664. * @param mask defines the new stencil mask to use
  34665. */
  34666. setStencilMask(mask: number): void;
  34667. /**
  34668. * Gets the current stencil function
  34669. * @returns a number defining the stencil function to use
  34670. */
  34671. getStencilFunction(): number;
  34672. /**
  34673. * Gets the current stencil reference value
  34674. * @returns a number defining the stencil reference value to use
  34675. */
  34676. getStencilFunctionReference(): number;
  34677. /**
  34678. * Gets the current stencil mask
  34679. * @returns a number defining the stencil mask to use
  34680. */
  34681. getStencilFunctionMask(): number;
  34682. /**
  34683. * Sets the current stencil function
  34684. * @param stencilFunc defines the new stencil function to use
  34685. */
  34686. setStencilFunction(stencilFunc: number): void;
  34687. /**
  34688. * Sets the current stencil reference
  34689. * @param reference defines the new stencil reference to use
  34690. */
  34691. setStencilFunctionReference(reference: number): void;
  34692. /**
  34693. * Sets the current stencil mask
  34694. * @param mask defines the new stencil mask to use
  34695. */
  34696. setStencilFunctionMask(mask: number): void;
  34697. /**
  34698. * Gets the current stencil operation when stencil fails
  34699. * @returns a number defining stencil operation to use when stencil fails
  34700. */
  34701. getStencilOperationFail(): number;
  34702. /**
  34703. * Gets the current stencil operation when depth fails
  34704. * @returns a number defining stencil operation to use when depth fails
  34705. */
  34706. getStencilOperationDepthFail(): number;
  34707. /**
  34708. * Gets the current stencil operation when stencil passes
  34709. * @returns a number defining stencil operation to use when stencil passes
  34710. */
  34711. getStencilOperationPass(): number;
  34712. /**
  34713. * Sets the stencil operation to use when stencil fails
  34714. * @param operation defines the stencil operation to use when stencil fails
  34715. */
  34716. setStencilOperationFail(operation: number): void;
  34717. /**
  34718. * Sets the stencil operation to use when depth fails
  34719. * @param operation defines the stencil operation to use when depth fails
  34720. */
  34721. setStencilOperationDepthFail(operation: number): void;
  34722. /**
  34723. * Sets the stencil operation to use when stencil passes
  34724. * @param operation defines the stencil operation to use when stencil passes
  34725. */
  34726. setStencilOperationPass(operation: number): void;
  34727. /**
  34728. * Sets a boolean indicating if the dithering state is enabled or disabled
  34729. * @param value defines the dithering state
  34730. */
  34731. setDitheringState(value: boolean): void;
  34732. /**
  34733. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34734. * @param value defines the rasterizer state
  34735. */
  34736. setRasterizerState(value: boolean): void;
  34737. /**
  34738. * Gets the current depth function
  34739. * @returns a number defining the depth function
  34740. */
  34741. getDepthFunction(): Nullable<number>;
  34742. /**
  34743. * Sets the current depth function
  34744. * @param depthFunc defines the function to use
  34745. */
  34746. setDepthFunction(depthFunc: number): void;
  34747. /**
  34748. * Sets the current depth function to GREATER
  34749. */
  34750. setDepthFunctionToGreater(): void;
  34751. /**
  34752. * Sets the current depth function to GEQUAL
  34753. */
  34754. setDepthFunctionToGreaterOrEqual(): void;
  34755. /**
  34756. * Sets the current depth function to LESS
  34757. */
  34758. setDepthFunctionToLess(): void;
  34759. /**
  34760. * Sets the current depth function to LEQUAL
  34761. */
  34762. setDepthFunctionToLessOrEqual(): void;
  34763. private _cachedStencilBuffer;
  34764. private _cachedStencilFunction;
  34765. private _cachedStencilMask;
  34766. private _cachedStencilOperationPass;
  34767. private _cachedStencilOperationFail;
  34768. private _cachedStencilOperationDepthFail;
  34769. private _cachedStencilReference;
  34770. /**
  34771. * Caches the the state of the stencil buffer
  34772. */
  34773. cacheStencilState(): void;
  34774. /**
  34775. * Restores the state of the stencil buffer
  34776. */
  34777. restoreStencilState(): void;
  34778. /**
  34779. * Directly set the WebGL Viewport
  34780. * @param x defines the x coordinate of the viewport (in screen space)
  34781. * @param y defines the y coordinate of the viewport (in screen space)
  34782. * @param width defines the width of the viewport (in screen space)
  34783. * @param height defines the height of the viewport (in screen space)
  34784. * @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
  34785. */
  34786. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34787. /**
  34788. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34789. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34790. * @param y defines the y-coordinate of the corner of the clear rectangle
  34791. * @param width defines the width of the clear rectangle
  34792. * @param height defines the height of the clear rectangle
  34793. * @param clearColor defines the clear color
  34794. */
  34795. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34796. /**
  34797. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34798. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34799. * @param y defines the y-coordinate of the corner of the clear rectangle
  34800. * @param width defines the width of the clear rectangle
  34801. * @param height defines the height of the clear rectangle
  34802. */
  34803. enableScissor(x: number, y: number, width: number, height: number): void;
  34804. /**
  34805. * Disable previously set scissor test rectangle
  34806. */
  34807. disableScissor(): void;
  34808. protected _reportDrawCall(): void;
  34809. /**
  34810. * Initializes a webVR display and starts listening to display change events
  34811. * The onVRDisplayChangedObservable will be notified upon these changes
  34812. * @returns The onVRDisplayChangedObservable
  34813. */
  34814. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34815. /** @hidden */
  34816. _prepareVRComponent(): void;
  34817. /** @hidden */
  34818. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34819. /** @hidden */
  34820. _submitVRFrame(): void;
  34821. /**
  34822. * Call this function to leave webVR mode
  34823. * Will do nothing if webVR is not supported or if there is no webVR device
  34824. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34825. */
  34826. disableVR(): void;
  34827. /**
  34828. * Gets a boolean indicating that the system is in VR mode and is presenting
  34829. * @returns true if VR mode is engaged
  34830. */
  34831. isVRPresenting(): boolean;
  34832. /** @hidden */
  34833. _requestVRFrame(): void;
  34834. /** @hidden */
  34835. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34836. /**
  34837. * Gets the source code of the vertex shader associated with a specific webGL program
  34838. * @param program defines the program to use
  34839. * @returns a string containing the source code of the vertex shader associated with the program
  34840. */
  34841. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34842. /**
  34843. * Gets the source code of the fragment shader associated with a specific webGL program
  34844. * @param program defines the program to use
  34845. * @returns a string containing the source code of the fragment shader associated with the program
  34846. */
  34847. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34848. /**
  34849. * Sets a depth stencil texture from a render target to the according uniform.
  34850. * @param channel The texture channel
  34851. * @param uniform The uniform to set
  34852. * @param texture The render target texture containing the depth stencil texture to apply
  34853. */
  34854. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34855. /**
  34856. * Sets a texture to the webGL context from a postprocess
  34857. * @param channel defines the channel to use
  34858. * @param postProcess defines the source postprocess
  34859. */
  34860. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34861. /**
  34862. * Binds the output of the passed in post process to the texture channel specified
  34863. * @param channel The channel the texture should be bound to
  34864. * @param postProcess The post process which's output should be bound
  34865. */
  34866. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34867. /** @hidden */
  34868. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34869. protected _rebuildBuffers(): void;
  34870. /** @hidden */
  34871. _renderFrame(): void;
  34872. _renderLoop(): void;
  34873. /** @hidden */
  34874. _renderViews(): boolean;
  34875. /**
  34876. * Toggle full screen mode
  34877. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34878. */
  34879. switchFullscreen(requestPointerLock: boolean): void;
  34880. /**
  34881. * Enters full screen mode
  34882. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34883. */
  34884. enterFullscreen(requestPointerLock: boolean): void;
  34885. /**
  34886. * Exits full screen mode
  34887. */
  34888. exitFullscreen(): void;
  34889. /**
  34890. * Enters Pointerlock mode
  34891. */
  34892. enterPointerlock(): void;
  34893. /**
  34894. * Exits Pointerlock mode
  34895. */
  34896. exitPointerlock(): void;
  34897. /**
  34898. * Begin a new frame
  34899. */
  34900. beginFrame(): void;
  34901. /**
  34902. * Enf the current frame
  34903. */
  34904. endFrame(): void;
  34905. resize(): void;
  34906. /**
  34907. * Force a specific size of the canvas
  34908. * @param width defines the new canvas' width
  34909. * @param height defines the new canvas' height
  34910. */
  34911. setSize(width: number, height: number): void;
  34912. /**
  34913. * Updates a dynamic vertex buffer.
  34914. * @param vertexBuffer the vertex buffer to update
  34915. * @param data the data used to update the vertex buffer
  34916. * @param byteOffset the byte offset of the data
  34917. * @param byteLength the byte length of the data
  34918. */
  34919. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34920. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34921. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34922. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34923. _releaseTexture(texture: InternalTexture): void;
  34924. /**
  34925. * @hidden
  34926. * Rescales a texture
  34927. * @param source input texutre
  34928. * @param destination destination texture
  34929. * @param scene scene to use to render the resize
  34930. * @param internalFormat format to use when resizing
  34931. * @param onComplete callback to be called when resize has completed
  34932. */
  34933. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34934. /**
  34935. * Gets the current framerate
  34936. * @returns a number representing the framerate
  34937. */
  34938. getFps(): number;
  34939. /**
  34940. * Gets the time spent between current and previous frame
  34941. * @returns a number representing the delta time in ms
  34942. */
  34943. getDeltaTime(): number;
  34944. private _measureFps;
  34945. /** @hidden */
  34946. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34947. /**
  34948. * Update a dynamic index buffer
  34949. * @param indexBuffer defines the target index buffer
  34950. * @param indices defines the data to update
  34951. * @param offset defines the offset in the target index buffer where update should start
  34952. */
  34953. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34954. /**
  34955. * Updates the sample count of a render target texture
  34956. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34957. * @param texture defines the texture to update
  34958. * @param samples defines the sample count to set
  34959. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34960. */
  34961. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34962. /**
  34963. * Updates a depth texture Comparison Mode and Function.
  34964. * If the comparison Function is equal to 0, the mode will be set to none.
  34965. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34966. * @param texture The texture to set the comparison function for
  34967. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34968. */
  34969. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34970. /**
  34971. * Creates a webGL buffer to use with instanciation
  34972. * @param capacity defines the size of the buffer
  34973. * @returns the webGL buffer
  34974. */
  34975. createInstancesBuffer(capacity: number): DataBuffer;
  34976. /**
  34977. * Delete a webGL buffer used with instanciation
  34978. * @param buffer defines the webGL buffer to delete
  34979. */
  34980. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34981. private _clientWaitAsync;
  34982. /** @hidden */
  34983. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34984. /** @hidden */
  34985. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34986. dispose(): void;
  34987. private _disableTouchAction;
  34988. /**
  34989. * Display the loading screen
  34990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34991. */
  34992. displayLoadingUI(): void;
  34993. /**
  34994. * Hide the loading screen
  34995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34996. */
  34997. hideLoadingUI(): void;
  34998. /**
  34999. * Gets the current loading screen object
  35000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35001. */
  35002. get loadingScreen(): ILoadingScreen;
  35003. /**
  35004. * Sets the current loading screen object
  35005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35006. */
  35007. set loadingScreen(loadingScreen: ILoadingScreen);
  35008. /**
  35009. * Sets the current loading screen text
  35010. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35011. */
  35012. set loadingUIText(text: string);
  35013. /**
  35014. * Sets the current loading screen background color
  35015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35016. */
  35017. set loadingUIBackgroundColor(color: string);
  35018. /** Pointerlock and fullscreen */
  35019. /**
  35020. * Ask the browser to promote the current element to pointerlock mode
  35021. * @param element defines the DOM element to promote
  35022. */
  35023. static _RequestPointerlock(element: HTMLElement): void;
  35024. /**
  35025. * Asks the browser to exit pointerlock mode
  35026. */
  35027. static _ExitPointerlock(): void;
  35028. /**
  35029. * Ask the browser to promote the current element to fullscreen rendering mode
  35030. * @param element defines the DOM element to promote
  35031. */
  35032. static _RequestFullscreen(element: HTMLElement): void;
  35033. /**
  35034. * Asks the browser to exit fullscreen mode
  35035. */
  35036. static _ExitFullscreen(): void;
  35037. }
  35038. }
  35039. declare module "babylonjs/Engines/engineStore" {
  35040. import { Nullable } from "babylonjs/types";
  35041. import { Engine } from "babylonjs/Engines/engine";
  35042. import { Scene } from "babylonjs/scene";
  35043. /**
  35044. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35045. * during the life time of the application.
  35046. */
  35047. export class EngineStore {
  35048. /** Gets the list of created engines */
  35049. static Instances: import("babylonjs/Engines/engine").Engine[];
  35050. /** @hidden */
  35051. static _LastCreatedScene: Nullable<Scene>;
  35052. /**
  35053. * Gets the latest created engine
  35054. */
  35055. static get LastCreatedEngine(): Nullable<Engine>;
  35056. /**
  35057. * Gets the latest created scene
  35058. */
  35059. static get LastCreatedScene(): Nullable<Scene>;
  35060. /**
  35061. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35062. * @ignorenaming
  35063. */
  35064. static UseFallbackTexture: boolean;
  35065. /**
  35066. * Texture content used if a texture cannot loaded
  35067. * @ignorenaming
  35068. */
  35069. static FallbackTexture: string;
  35070. }
  35071. }
  35072. declare module "babylonjs/Misc/promise" {
  35073. /**
  35074. * Helper class that provides a small promise polyfill
  35075. */
  35076. export class PromisePolyfill {
  35077. /**
  35078. * Static function used to check if the polyfill is required
  35079. * If this is the case then the function will inject the polyfill to window.Promise
  35080. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35081. */
  35082. static Apply(force?: boolean): void;
  35083. }
  35084. }
  35085. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35086. /**
  35087. * Interface for screenshot methods with describe argument called `size` as object with options
  35088. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35089. */
  35090. export interface IScreenshotSize {
  35091. /**
  35092. * number in pixels for canvas height
  35093. */
  35094. height?: number;
  35095. /**
  35096. * multiplier allowing render at a higher or lower resolution
  35097. * If value is defined then height and width will be ignored and taken from camera
  35098. */
  35099. precision?: number;
  35100. /**
  35101. * number in pixels for canvas width
  35102. */
  35103. width?: number;
  35104. }
  35105. }
  35106. declare module "babylonjs/Misc/tools" {
  35107. import { Nullable, float } from "babylonjs/types";
  35108. import { DomManagement } from "babylonjs/Misc/domManagement";
  35109. import { WebRequest } from "babylonjs/Misc/webRequest";
  35110. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35111. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35112. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35113. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35114. import { Camera } from "babylonjs/Cameras/camera";
  35115. import { Engine } from "babylonjs/Engines/engine";
  35116. interface IColor4Like {
  35117. r: float;
  35118. g: float;
  35119. b: float;
  35120. a: float;
  35121. }
  35122. /**
  35123. * Class containing a set of static utilities functions
  35124. */
  35125. export class Tools {
  35126. /**
  35127. * Gets or sets the base URL to use to load assets
  35128. */
  35129. static get BaseUrl(): string;
  35130. static set BaseUrl(value: string);
  35131. /**
  35132. * Enable/Disable Custom HTTP Request Headers globally.
  35133. * default = false
  35134. * @see CustomRequestHeaders
  35135. */
  35136. static UseCustomRequestHeaders: boolean;
  35137. /**
  35138. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35139. * i.e. when loading files, where the server/service expects an Authorization header
  35140. */
  35141. static CustomRequestHeaders: {
  35142. [key: string]: string;
  35143. };
  35144. /**
  35145. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35146. */
  35147. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35148. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35149. /**
  35150. * Default behaviour for cors in the application.
  35151. * It can be a string if the expected behavior is identical in the entire app.
  35152. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35153. */
  35154. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35155. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35156. /**
  35157. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35158. * @ignorenaming
  35159. */
  35160. static get UseFallbackTexture(): boolean;
  35161. static set UseFallbackTexture(value: boolean);
  35162. /**
  35163. * Use this object to register external classes like custom textures or material
  35164. * to allow the laoders to instantiate them
  35165. */
  35166. static get RegisteredExternalClasses(): {
  35167. [key: string]: Object;
  35168. };
  35169. static set RegisteredExternalClasses(classes: {
  35170. [key: string]: Object;
  35171. });
  35172. /**
  35173. * Texture content used if a texture cannot loaded
  35174. * @ignorenaming
  35175. */
  35176. static get fallbackTexture(): string;
  35177. static set fallbackTexture(value: string);
  35178. /**
  35179. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35180. * @param u defines the coordinate on X axis
  35181. * @param v defines the coordinate on Y axis
  35182. * @param width defines the width of the source data
  35183. * @param height defines the height of the source data
  35184. * @param pixels defines the source byte array
  35185. * @param color defines the output color
  35186. */
  35187. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35188. /**
  35189. * Interpolates between a and b via alpha
  35190. * @param a The lower value (returned when alpha = 0)
  35191. * @param b The upper value (returned when alpha = 1)
  35192. * @param alpha The interpolation-factor
  35193. * @return The mixed value
  35194. */
  35195. static Mix(a: number, b: number, alpha: number): number;
  35196. /**
  35197. * Tries to instantiate a new object from a given class name
  35198. * @param className defines the class name to instantiate
  35199. * @returns the new object or null if the system was not able to do the instantiation
  35200. */
  35201. static Instantiate(className: string): any;
  35202. /**
  35203. * Provides a slice function that will work even on IE
  35204. * @param data defines the array to slice
  35205. * @param start defines the start of the data (optional)
  35206. * @param end defines the end of the data (optional)
  35207. * @returns the new sliced array
  35208. */
  35209. static Slice<T>(data: T, start?: number, end?: number): T;
  35210. /**
  35211. * Polyfill for setImmediate
  35212. * @param action defines the action to execute after the current execution block
  35213. */
  35214. static SetImmediate(action: () => void): void;
  35215. /**
  35216. * Function indicating if a number is an exponent of 2
  35217. * @param value defines the value to test
  35218. * @returns true if the value is an exponent of 2
  35219. */
  35220. static IsExponentOfTwo(value: number): boolean;
  35221. private static _tmpFloatArray;
  35222. /**
  35223. * Returns the nearest 32-bit single precision float representation of a Number
  35224. * @param value A Number. If the parameter is of a different type, it will get converted
  35225. * to a number or to NaN if it cannot be converted
  35226. * @returns number
  35227. */
  35228. static FloatRound(value: number): number;
  35229. /**
  35230. * Extracts the filename from a path
  35231. * @param path defines the path to use
  35232. * @returns the filename
  35233. */
  35234. static GetFilename(path: string): string;
  35235. /**
  35236. * Extracts the "folder" part of a path (everything before the filename).
  35237. * @param uri The URI to extract the info from
  35238. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35239. * @returns The "folder" part of the path
  35240. */
  35241. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35242. /**
  35243. * Extracts text content from a DOM element hierarchy
  35244. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35245. */
  35246. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35247. /**
  35248. * Convert an angle in radians to degrees
  35249. * @param angle defines the angle to convert
  35250. * @returns the angle in degrees
  35251. */
  35252. static ToDegrees(angle: number): number;
  35253. /**
  35254. * Convert an angle in degrees to radians
  35255. * @param angle defines the angle to convert
  35256. * @returns the angle in radians
  35257. */
  35258. static ToRadians(angle: number): number;
  35259. /**
  35260. * Returns an array if obj is not an array
  35261. * @param obj defines the object to evaluate as an array
  35262. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35263. * @returns either obj directly if obj is an array or a new array containing obj
  35264. */
  35265. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35266. /**
  35267. * Gets the pointer prefix to use
  35268. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35269. */
  35270. static GetPointerPrefix(): string;
  35271. /**
  35272. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35273. * @param url define the url we are trying
  35274. * @param element define the dom element where to configure the cors policy
  35275. */
  35276. static SetCorsBehavior(url: string | string[], element: {
  35277. crossOrigin: string | null;
  35278. }): void;
  35279. /**
  35280. * Removes unwanted characters from an url
  35281. * @param url defines the url to clean
  35282. * @returns the cleaned url
  35283. */
  35284. static CleanUrl(url: string): string;
  35285. /**
  35286. * Gets or sets a function used to pre-process url before using them to load assets
  35287. */
  35288. static get PreprocessUrl(): (url: string) => string;
  35289. static set PreprocessUrl(processor: (url: string) => string);
  35290. /**
  35291. * Loads an image as an HTMLImageElement.
  35292. * @param input url string, ArrayBuffer, or Blob to load
  35293. * @param onLoad callback called when the image successfully loads
  35294. * @param onError callback called when the image fails to load
  35295. * @param offlineProvider offline provider for caching
  35296. * @param mimeType optional mime type
  35297. * @returns the HTMLImageElement of the loaded image
  35298. */
  35299. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35300. /**
  35301. * Loads a file from a url
  35302. * @param url url string, ArrayBuffer, or Blob to load
  35303. * @param onSuccess callback called when the file successfully loads
  35304. * @param onProgress callback called while file is loading (if the server supports this mode)
  35305. * @param offlineProvider defines the offline provider for caching
  35306. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35307. * @param onError callback called when the file fails to load
  35308. * @returns a file request object
  35309. */
  35310. 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;
  35311. /**
  35312. * Loads a file from a url
  35313. * @param url the file url to load
  35314. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35315. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35316. */
  35317. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35318. /**
  35319. * Load a script (identified by an url). When the url returns, the
  35320. * content of this file is added into a new script element, attached to the DOM (body element)
  35321. * @param scriptUrl defines the url of the script to laod
  35322. * @param onSuccess defines the callback called when the script is loaded
  35323. * @param onError defines the callback to call if an error occurs
  35324. * @param scriptId defines the id of the script element
  35325. */
  35326. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35327. /**
  35328. * Load an asynchronous script (identified by an url). When the url returns, the
  35329. * content of this file is added into a new script element, attached to the DOM (body element)
  35330. * @param scriptUrl defines the url of the script to laod
  35331. * @param scriptId defines the id of the script element
  35332. * @returns a promise request object
  35333. */
  35334. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35335. /**
  35336. * Loads a file from a blob
  35337. * @param fileToLoad defines the blob to use
  35338. * @param callback defines the callback to call when data is loaded
  35339. * @param progressCallback defines the callback to call during loading process
  35340. * @returns a file request object
  35341. */
  35342. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35343. /**
  35344. * Reads a file from a File object
  35345. * @param file defines the file to load
  35346. * @param onSuccess defines the callback to call when data is loaded
  35347. * @param onProgress defines the callback to call during loading process
  35348. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35349. * @param onError defines the callback to call when an error occurs
  35350. * @returns a file request object
  35351. */
  35352. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35353. /**
  35354. * Creates a data url from a given string content
  35355. * @param content defines the content to convert
  35356. * @returns the new data url link
  35357. */
  35358. static FileAsURL(content: string): string;
  35359. /**
  35360. * Format the given number to a specific decimal format
  35361. * @param value defines the number to format
  35362. * @param decimals defines the number of decimals to use
  35363. * @returns the formatted string
  35364. */
  35365. static Format(value: number, decimals?: number): string;
  35366. /**
  35367. * Tries to copy an object by duplicating every property
  35368. * @param source defines the source object
  35369. * @param destination defines the target object
  35370. * @param doNotCopyList defines a list of properties to avoid
  35371. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35372. */
  35373. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35374. /**
  35375. * Gets a boolean indicating if the given object has no own property
  35376. * @param obj defines the object to test
  35377. * @returns true if object has no own property
  35378. */
  35379. static IsEmpty(obj: any): boolean;
  35380. /**
  35381. * Function used to register events at window level
  35382. * @param windowElement defines the Window object to use
  35383. * @param events defines the events to register
  35384. */
  35385. static RegisterTopRootEvents(windowElement: Window, events: {
  35386. name: string;
  35387. handler: Nullable<(e: FocusEvent) => any>;
  35388. }[]): void;
  35389. /**
  35390. * Function used to unregister events from window level
  35391. * @param windowElement defines the Window object to use
  35392. * @param events defines the events to unregister
  35393. */
  35394. static UnregisterTopRootEvents(windowElement: Window, events: {
  35395. name: string;
  35396. handler: Nullable<(e: FocusEvent) => any>;
  35397. }[]): void;
  35398. /**
  35399. * @ignore
  35400. */
  35401. static _ScreenshotCanvas: HTMLCanvasElement;
  35402. /**
  35403. * Dumps the current bound framebuffer
  35404. * @param width defines the rendering width
  35405. * @param height defines the rendering height
  35406. * @param engine defines the hosting engine
  35407. * @param successCallback defines the callback triggered once the data are available
  35408. * @param mimeType defines the mime type of the result
  35409. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35410. */
  35411. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35412. /**
  35413. * Converts the canvas data to blob.
  35414. * This acts as a polyfill for browsers not supporting the to blob function.
  35415. * @param canvas Defines the canvas to extract the data from
  35416. * @param successCallback Defines the callback triggered once the data are available
  35417. * @param mimeType Defines the mime type of the result
  35418. */
  35419. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35420. /**
  35421. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35422. * @param successCallback defines the callback triggered once the data are available
  35423. * @param mimeType defines the mime type of the result
  35424. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35425. */
  35426. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35427. /**
  35428. * Downloads a blob in the browser
  35429. * @param blob defines the blob to download
  35430. * @param fileName defines the name of the downloaded file
  35431. */
  35432. static Download(blob: Blob, fileName: string): void;
  35433. /**
  35434. * Captures a screenshot of the current rendering
  35435. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35436. * @param engine defines the rendering engine
  35437. * @param camera defines the source camera
  35438. * @param size This parameter can be set to a single number or to an object with the
  35439. * following (optional) properties: precision, width, height. If a single number is passed,
  35440. * it will be used for both width and height. If an object is passed, the screenshot size
  35441. * will be derived from the parameters. The precision property is a multiplier allowing
  35442. * rendering at a higher or lower resolution
  35443. * @param successCallback defines the callback receives a single parameter which contains the
  35444. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35445. * src parameter of an <img> to display it
  35446. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35447. * Check your browser for supported MIME types
  35448. */
  35449. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35450. /**
  35451. * Captures a screenshot of the current rendering
  35452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35453. * @param engine defines the rendering engine
  35454. * @param camera defines the source camera
  35455. * @param size This parameter can be set to a single number or to an object with the
  35456. * following (optional) properties: precision, width, height. If a single number is passed,
  35457. * it will be used for both width and height. If an object is passed, the screenshot size
  35458. * will be derived from the parameters. The precision property is a multiplier allowing
  35459. * rendering at a higher or lower resolution
  35460. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35461. * Check your browser for supported MIME types
  35462. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35463. * to the src parameter of an <img> to display it
  35464. */
  35465. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35466. /**
  35467. * Generates an image screenshot from the specified camera.
  35468. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35469. * @param engine The engine to use for rendering
  35470. * @param camera The camera to use for rendering
  35471. * @param size This parameter can be set to a single number or to an object with the
  35472. * following (optional) properties: precision, width, height. If a single number is passed,
  35473. * it will be used for both width and height. If an object is passed, the screenshot size
  35474. * will be derived from the parameters. The precision property is a multiplier allowing
  35475. * rendering at a higher or lower resolution
  35476. * @param successCallback The callback receives a single parameter which contains the
  35477. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35478. * src parameter of an <img> to display it
  35479. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35480. * Check your browser for supported MIME types
  35481. * @param samples Texture samples (default: 1)
  35482. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35483. * @param fileName A name for for the downloaded file.
  35484. */
  35485. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35486. /**
  35487. * Generates an image screenshot from the specified camera.
  35488. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35489. * @param engine The engine to use for rendering
  35490. * @param camera The camera to use for rendering
  35491. * @param size This parameter can be set to a single number or to an object with the
  35492. * following (optional) properties: precision, width, height. If a single number is passed,
  35493. * it will be used for both width and height. If an object is passed, the screenshot size
  35494. * will be derived from the parameters. The precision property is a multiplier allowing
  35495. * rendering at a higher or lower resolution
  35496. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35497. * Check your browser for supported MIME types
  35498. * @param samples Texture samples (default: 1)
  35499. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35500. * @param fileName A name for for the downloaded file.
  35501. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35502. * to the src parameter of an <img> to display it
  35503. */
  35504. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35505. /**
  35506. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35507. * Be aware Math.random() could cause collisions, but:
  35508. * "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"
  35509. * @returns a pseudo random id
  35510. */
  35511. static RandomId(): string;
  35512. /**
  35513. * Test if the given uri is a base64 string
  35514. * @param uri The uri to test
  35515. * @return True if the uri is a base64 string or false otherwise
  35516. */
  35517. static IsBase64(uri: string): boolean;
  35518. /**
  35519. * Decode the given base64 uri.
  35520. * @param uri The uri to decode
  35521. * @return The decoded base64 data.
  35522. */
  35523. static DecodeBase64(uri: string): ArrayBuffer;
  35524. /**
  35525. * Gets the absolute url.
  35526. * @param url the input url
  35527. * @return the absolute url
  35528. */
  35529. static GetAbsoluteUrl(url: string): string;
  35530. /**
  35531. * No log
  35532. */
  35533. static readonly NoneLogLevel: number;
  35534. /**
  35535. * Only message logs
  35536. */
  35537. static readonly MessageLogLevel: number;
  35538. /**
  35539. * Only warning logs
  35540. */
  35541. static readonly WarningLogLevel: number;
  35542. /**
  35543. * Only error logs
  35544. */
  35545. static readonly ErrorLogLevel: number;
  35546. /**
  35547. * All logs
  35548. */
  35549. static readonly AllLogLevel: number;
  35550. /**
  35551. * Gets a value indicating the number of loading errors
  35552. * @ignorenaming
  35553. */
  35554. static get errorsCount(): number;
  35555. /**
  35556. * Callback called when a new log is added
  35557. */
  35558. static OnNewCacheEntry: (entry: string) => void;
  35559. /**
  35560. * Log a message to the console
  35561. * @param message defines the message to log
  35562. */
  35563. static Log(message: string): void;
  35564. /**
  35565. * Write a warning message to the console
  35566. * @param message defines the message to log
  35567. */
  35568. static Warn(message: string): void;
  35569. /**
  35570. * Write an error message to the console
  35571. * @param message defines the message to log
  35572. */
  35573. static Error(message: string): void;
  35574. /**
  35575. * Gets current log cache (list of logs)
  35576. */
  35577. static get LogCache(): string;
  35578. /**
  35579. * Clears the log cache
  35580. */
  35581. static ClearLogCache(): void;
  35582. /**
  35583. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35584. */
  35585. static set LogLevels(level: number);
  35586. /**
  35587. * Checks if the window object exists
  35588. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35589. */
  35590. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35591. /**
  35592. * No performance log
  35593. */
  35594. static readonly PerformanceNoneLogLevel: number;
  35595. /**
  35596. * Use user marks to log performance
  35597. */
  35598. static readonly PerformanceUserMarkLogLevel: number;
  35599. /**
  35600. * Log performance to the console
  35601. */
  35602. static readonly PerformanceConsoleLogLevel: number;
  35603. private static _performance;
  35604. /**
  35605. * Sets the current performance log level
  35606. */
  35607. static set PerformanceLogLevel(level: number);
  35608. private static _StartPerformanceCounterDisabled;
  35609. private static _EndPerformanceCounterDisabled;
  35610. private static _StartUserMark;
  35611. private static _EndUserMark;
  35612. private static _StartPerformanceConsole;
  35613. private static _EndPerformanceConsole;
  35614. /**
  35615. * Starts a performance counter
  35616. */
  35617. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35618. /**
  35619. * Ends a specific performance coutner
  35620. */
  35621. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35622. /**
  35623. * Gets either window.performance.now() if supported or Date.now() else
  35624. */
  35625. static get Now(): number;
  35626. /**
  35627. * This method will return the name of the class used to create the instance of the given object.
  35628. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35629. * @param object the object to get the class name from
  35630. * @param isType defines if the object is actually a type
  35631. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35632. */
  35633. static GetClassName(object: any, isType?: boolean): string;
  35634. /**
  35635. * Gets the first element of an array satisfying a given predicate
  35636. * @param array defines the array to browse
  35637. * @param predicate defines the predicate to use
  35638. * @returns null if not found or the element
  35639. */
  35640. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35641. /**
  35642. * This method will return the name of the full name of the class, including its owning module (if any).
  35643. * 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).
  35644. * @param object the object to get the class name from
  35645. * @param isType defines if the object is actually a type
  35646. * @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.
  35647. * @ignorenaming
  35648. */
  35649. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35650. /**
  35651. * Returns a promise that resolves after the given amount of time.
  35652. * @param delay Number of milliseconds to delay
  35653. * @returns Promise that resolves after the given amount of time
  35654. */
  35655. static DelayAsync(delay: number): Promise<void>;
  35656. /**
  35657. * Utility function to detect if the current user agent is Safari
  35658. * @returns whether or not the current user agent is safari
  35659. */
  35660. static IsSafari(): boolean;
  35661. }
  35662. /**
  35663. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35664. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35665. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35666. * @param name The name of the class, case should be preserved
  35667. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35668. */
  35669. export function className(name: string, module?: string): (target: Object) => void;
  35670. /**
  35671. * An implementation of a loop for asynchronous functions.
  35672. */
  35673. export class AsyncLoop {
  35674. /**
  35675. * Defines the number of iterations for the loop
  35676. */
  35677. iterations: number;
  35678. /**
  35679. * Defines the current index of the loop.
  35680. */
  35681. index: number;
  35682. private _done;
  35683. private _fn;
  35684. private _successCallback;
  35685. /**
  35686. * Constructor.
  35687. * @param iterations the number of iterations.
  35688. * @param func the function to run each iteration
  35689. * @param successCallback the callback that will be called upon succesful execution
  35690. * @param offset starting offset.
  35691. */
  35692. constructor(
  35693. /**
  35694. * Defines the number of iterations for the loop
  35695. */
  35696. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35697. /**
  35698. * Execute the next iteration. Must be called after the last iteration was finished.
  35699. */
  35700. executeNext(): void;
  35701. /**
  35702. * Break the loop and run the success callback.
  35703. */
  35704. breakLoop(): void;
  35705. /**
  35706. * Create and run an async loop.
  35707. * @param iterations the number of iterations.
  35708. * @param fn the function to run each iteration
  35709. * @param successCallback the callback that will be called upon succesful execution
  35710. * @param offset starting offset.
  35711. * @returns the created async loop object
  35712. */
  35713. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35714. /**
  35715. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35716. * @param iterations total number of iterations
  35717. * @param syncedIterations number of synchronous iterations in each async iteration.
  35718. * @param fn the function to call each iteration.
  35719. * @param callback a success call back that will be called when iterating stops.
  35720. * @param breakFunction a break condition (optional)
  35721. * @param timeout timeout settings for the setTimeout function. default - 0.
  35722. * @returns the created async loop object
  35723. */
  35724. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35725. }
  35726. }
  35727. declare module "babylonjs/Misc/stringDictionary" {
  35728. import { Nullable } from "babylonjs/types";
  35729. /**
  35730. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35731. * The underlying implementation relies on an associative array to ensure the best performances.
  35732. * The value can be anything including 'null' but except 'undefined'
  35733. */
  35734. export class StringDictionary<T> {
  35735. /**
  35736. * This will clear this dictionary and copy the content from the 'source' one.
  35737. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35738. * @param source the dictionary to take the content from and copy to this dictionary
  35739. */
  35740. copyFrom(source: StringDictionary<T>): void;
  35741. /**
  35742. * Get a value based from its key
  35743. * @param key the given key to get the matching value from
  35744. * @return the value if found, otherwise undefined is returned
  35745. */
  35746. get(key: string): T | undefined;
  35747. /**
  35748. * Get a value from its key or add it if it doesn't exist.
  35749. * This method will ensure you that a given key/data will be present in the dictionary.
  35750. * @param key the given key to get the matching value from
  35751. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35752. * The factory will only be invoked if there's no data for the given key.
  35753. * @return the value corresponding to the key.
  35754. */
  35755. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35756. /**
  35757. * Get a value from its key if present in the dictionary otherwise add it
  35758. * @param key the key to get the value from
  35759. * @param val if there's no such key/value pair in the dictionary add it with this value
  35760. * @return the value corresponding to the key
  35761. */
  35762. getOrAdd(key: string, val: T): T;
  35763. /**
  35764. * Check if there's a given key in the dictionary
  35765. * @param key the key to check for
  35766. * @return true if the key is present, false otherwise
  35767. */
  35768. contains(key: string): boolean;
  35769. /**
  35770. * Add a new key and its corresponding value
  35771. * @param key the key to add
  35772. * @param value the value corresponding to the key
  35773. * @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
  35774. */
  35775. add(key: string, value: T): boolean;
  35776. /**
  35777. * Update a specific value associated to a key
  35778. * @param key defines the key to use
  35779. * @param value defines the value to store
  35780. * @returns true if the value was updated (or false if the key was not found)
  35781. */
  35782. set(key: string, value: T): boolean;
  35783. /**
  35784. * Get the element of the given key and remove it from the dictionary
  35785. * @param key defines the key to search
  35786. * @returns the value associated with the key or null if not found
  35787. */
  35788. getAndRemove(key: string): Nullable<T>;
  35789. /**
  35790. * Remove a key/value from the dictionary.
  35791. * @param key the key to remove
  35792. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35793. */
  35794. remove(key: string): boolean;
  35795. /**
  35796. * Clear the whole content of the dictionary
  35797. */
  35798. clear(): void;
  35799. /**
  35800. * Gets the current count
  35801. */
  35802. get count(): number;
  35803. /**
  35804. * Execute a callback on each key/val of the dictionary.
  35805. * Note that you can remove any element in this dictionary in the callback implementation
  35806. * @param callback the callback to execute on a given key/value pair
  35807. */
  35808. forEach(callback: (key: string, val: T) => void): void;
  35809. /**
  35810. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35811. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35812. * Note that you can remove any element in this dictionary in the callback implementation
  35813. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35814. * @returns the first item
  35815. */
  35816. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35817. private _count;
  35818. private _data;
  35819. }
  35820. }
  35821. declare module "babylonjs/Collisions/collisionCoordinator" {
  35822. import { Nullable } from "babylonjs/types";
  35823. import { Scene } from "babylonjs/scene";
  35824. import { Vector3 } from "babylonjs/Maths/math.vector";
  35825. import { Collider } from "babylonjs/Collisions/collider";
  35826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35827. /** @hidden */
  35828. export interface ICollisionCoordinator {
  35829. createCollider(): Collider;
  35830. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35831. init(scene: Scene): void;
  35832. }
  35833. /** @hidden */
  35834. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35835. private _scene;
  35836. private _scaledPosition;
  35837. private _scaledVelocity;
  35838. private _finalPosition;
  35839. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35840. createCollider(): Collider;
  35841. init(scene: Scene): void;
  35842. private _collideWithWorld;
  35843. }
  35844. }
  35845. declare module "babylonjs/Inputs/scene.inputManager" {
  35846. import { Nullable } from "babylonjs/types";
  35847. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35848. import { Vector2 } from "babylonjs/Maths/math.vector";
  35849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35850. import { Scene } from "babylonjs/scene";
  35851. /**
  35852. * Class used to manage all inputs for the scene.
  35853. */
  35854. export class InputManager {
  35855. /** The distance in pixel that you have to move to prevent some events */
  35856. static DragMovementThreshold: number;
  35857. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35858. static LongPressDelay: number;
  35859. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35860. static DoubleClickDelay: number;
  35861. /** If you need to check double click without raising a single click at first click, enable this flag */
  35862. static ExclusiveDoubleClickMode: boolean;
  35863. private _wheelEventName;
  35864. private _onPointerMove;
  35865. private _onPointerDown;
  35866. private _onPointerUp;
  35867. private _initClickEvent;
  35868. private _initActionManager;
  35869. private _delayedSimpleClick;
  35870. private _delayedSimpleClickTimeout;
  35871. private _previousDelayedSimpleClickTimeout;
  35872. private _meshPickProceed;
  35873. private _previousButtonPressed;
  35874. private _currentPickResult;
  35875. private _previousPickResult;
  35876. private _totalPointersPressed;
  35877. private _doubleClickOccured;
  35878. private _pointerOverMesh;
  35879. private _pickedDownMesh;
  35880. private _pickedUpMesh;
  35881. private _pointerX;
  35882. private _pointerY;
  35883. private _unTranslatedPointerX;
  35884. private _unTranslatedPointerY;
  35885. private _startingPointerPosition;
  35886. private _previousStartingPointerPosition;
  35887. private _startingPointerTime;
  35888. private _previousStartingPointerTime;
  35889. private _pointerCaptures;
  35890. private _onKeyDown;
  35891. private _onKeyUp;
  35892. private _onCanvasFocusObserver;
  35893. private _onCanvasBlurObserver;
  35894. private _scene;
  35895. /**
  35896. * Creates a new InputManager
  35897. * @param scene defines the hosting scene
  35898. */
  35899. constructor(scene: Scene);
  35900. /**
  35901. * Gets the mesh that is currently under the pointer
  35902. */
  35903. get meshUnderPointer(): Nullable<AbstractMesh>;
  35904. /**
  35905. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35906. */
  35907. get unTranslatedPointer(): Vector2;
  35908. /**
  35909. * Gets or sets the current on-screen X position of the pointer
  35910. */
  35911. get pointerX(): number;
  35912. set pointerX(value: number);
  35913. /**
  35914. * Gets or sets the current on-screen Y position of the pointer
  35915. */
  35916. get pointerY(): number;
  35917. set pointerY(value: number);
  35918. private _updatePointerPosition;
  35919. private _processPointerMove;
  35920. private _setRayOnPointerInfo;
  35921. private _checkPrePointerObservable;
  35922. /**
  35923. * Use this method to simulate a pointer move on a mesh
  35924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35927. */
  35928. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35929. /**
  35930. * Use this method to simulate a pointer down on a mesh
  35931. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35932. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35933. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35934. */
  35935. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35936. private _processPointerDown;
  35937. /** @hidden */
  35938. _isPointerSwiping(): boolean;
  35939. /**
  35940. * Use this method to simulate a pointer up on a mesh
  35941. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35942. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35943. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35944. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35945. */
  35946. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35947. private _processPointerUp;
  35948. /**
  35949. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35950. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35951. * @returns true if the pointer was captured
  35952. */
  35953. isPointerCaptured(pointerId?: number): boolean;
  35954. /**
  35955. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35956. * @param attachUp defines if you want to attach events to pointerup
  35957. * @param attachDown defines if you want to attach events to pointerdown
  35958. * @param attachMove defines if you want to attach events to pointermove
  35959. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35960. */
  35961. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35962. /**
  35963. * Detaches all event handlers
  35964. */
  35965. detachControl(): void;
  35966. /**
  35967. * Force the value of meshUnderPointer
  35968. * @param mesh defines the mesh to use
  35969. */
  35970. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35971. /**
  35972. * Gets the mesh under the pointer
  35973. * @returns a Mesh or null if no mesh is under the pointer
  35974. */
  35975. getPointerOverMesh(): Nullable<AbstractMesh>;
  35976. }
  35977. }
  35978. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35979. /**
  35980. * Helper class used to generate session unique ID
  35981. */
  35982. export class UniqueIdGenerator {
  35983. private static _UniqueIdCounter;
  35984. /**
  35985. * Gets an unique (relatively to the current scene) Id
  35986. */
  35987. static get UniqueId(): number;
  35988. }
  35989. }
  35990. declare module "babylonjs/Animations/animationGroup" {
  35991. import { Animatable } from "babylonjs/Animations/animatable";
  35992. import { Animation } from "babylonjs/Animations/animation";
  35993. import { Scene, IDisposable } from "babylonjs/scene";
  35994. import { Observable } from "babylonjs/Misc/observable";
  35995. import { Nullable } from "babylonjs/types";
  35996. import "babylonjs/Animations/animatable";
  35997. /**
  35998. * This class defines the direct association between an animation and a target
  35999. */
  36000. export class TargetedAnimation {
  36001. /**
  36002. * Animation to perform
  36003. */
  36004. animation: Animation;
  36005. /**
  36006. * Target to animate
  36007. */
  36008. target: any;
  36009. /**
  36010. * Serialize the object
  36011. * @returns the JSON object representing the current entity
  36012. */
  36013. serialize(): any;
  36014. }
  36015. /**
  36016. * Use this class to create coordinated animations on multiple targets
  36017. */
  36018. export class AnimationGroup implements IDisposable {
  36019. /** The name of the animation group */
  36020. name: string;
  36021. private _scene;
  36022. private _targetedAnimations;
  36023. private _animatables;
  36024. private _from;
  36025. private _to;
  36026. private _isStarted;
  36027. private _isPaused;
  36028. private _speedRatio;
  36029. private _loopAnimation;
  36030. /**
  36031. * Gets or sets the unique id of the node
  36032. */
  36033. uniqueId: number;
  36034. /**
  36035. * This observable will notify when one animation have ended
  36036. */
  36037. onAnimationEndObservable: Observable<TargetedAnimation>;
  36038. /**
  36039. * Observer raised when one animation loops
  36040. */
  36041. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36042. /**
  36043. * Observer raised when all animations have looped
  36044. */
  36045. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36046. /**
  36047. * This observable will notify when all animations have ended.
  36048. */
  36049. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36050. /**
  36051. * This observable will notify when all animations have paused.
  36052. */
  36053. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36054. /**
  36055. * This observable will notify when all animations are playing.
  36056. */
  36057. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36058. /**
  36059. * Gets the first frame
  36060. */
  36061. get from(): number;
  36062. /**
  36063. * Gets the last frame
  36064. */
  36065. get to(): number;
  36066. /**
  36067. * Define if the animations are started
  36068. */
  36069. get isStarted(): boolean;
  36070. /**
  36071. * Gets a value indicating that the current group is playing
  36072. */
  36073. get isPlaying(): boolean;
  36074. /**
  36075. * Gets or sets the speed ratio to use for all animations
  36076. */
  36077. get speedRatio(): number;
  36078. /**
  36079. * Gets or sets the speed ratio to use for all animations
  36080. */
  36081. set speedRatio(value: number);
  36082. /**
  36083. * Gets or sets if all animations should loop or not
  36084. */
  36085. get loopAnimation(): boolean;
  36086. set loopAnimation(value: boolean);
  36087. /**
  36088. * Gets the targeted animations for this animation group
  36089. */
  36090. get targetedAnimations(): Array<TargetedAnimation>;
  36091. /**
  36092. * returning the list of animatables controlled by this animation group.
  36093. */
  36094. get animatables(): Array<Animatable>;
  36095. /**
  36096. * Instantiates a new Animation Group.
  36097. * This helps managing several animations at once.
  36098. * @see http://doc.babylonjs.com/how_to/group
  36099. * @param name Defines the name of the group
  36100. * @param scene Defines the scene the group belongs to
  36101. */
  36102. constructor(
  36103. /** The name of the animation group */
  36104. name: string, scene?: Nullable<Scene>);
  36105. /**
  36106. * Add an animation (with its target) in the group
  36107. * @param animation defines the animation we want to add
  36108. * @param target defines the target of the animation
  36109. * @returns the TargetedAnimation object
  36110. */
  36111. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36112. /**
  36113. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36114. * It can add constant keys at begin or end
  36115. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36116. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36117. * @returns the animation group
  36118. */
  36119. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36120. private _animationLoopCount;
  36121. private _animationLoopFlags;
  36122. private _processLoop;
  36123. /**
  36124. * Start all animations on given targets
  36125. * @param loop defines if animations must loop
  36126. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36127. * @param from defines the from key (optional)
  36128. * @param to defines the to key (optional)
  36129. * @returns the current animation group
  36130. */
  36131. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  36132. /**
  36133. * Pause all animations
  36134. * @returns the animation group
  36135. */
  36136. pause(): AnimationGroup;
  36137. /**
  36138. * Play all animations to initial state
  36139. * This function will start() the animations if they were not started or will restart() them if they were paused
  36140. * @param loop defines if animations must loop
  36141. * @returns the animation group
  36142. */
  36143. play(loop?: boolean): AnimationGroup;
  36144. /**
  36145. * Reset all animations to initial state
  36146. * @returns the animation group
  36147. */
  36148. reset(): AnimationGroup;
  36149. /**
  36150. * Restart animations from key 0
  36151. * @returns the animation group
  36152. */
  36153. restart(): AnimationGroup;
  36154. /**
  36155. * Stop all animations
  36156. * @returns the animation group
  36157. */
  36158. stop(): AnimationGroup;
  36159. /**
  36160. * Set animation weight for all animatables
  36161. * @param weight defines the weight to use
  36162. * @return the animationGroup
  36163. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36164. */
  36165. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36166. /**
  36167. * Synchronize and normalize all animatables with a source animatable
  36168. * @param root defines the root animatable to synchronize with
  36169. * @return the animationGroup
  36170. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36171. */
  36172. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36173. /**
  36174. * Goes to a specific frame in this animation group
  36175. * @param frame the frame number to go to
  36176. * @return the animationGroup
  36177. */
  36178. goToFrame(frame: number): AnimationGroup;
  36179. /**
  36180. * Dispose all associated resources
  36181. */
  36182. dispose(): void;
  36183. private _checkAnimationGroupEnded;
  36184. /**
  36185. * Clone the current animation group and returns a copy
  36186. * @param newName defines the name of the new group
  36187. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36188. * @returns the new aniamtion group
  36189. */
  36190. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36191. /**
  36192. * Serializes the animationGroup to an object
  36193. * @returns Serialized object
  36194. */
  36195. serialize(): any;
  36196. /**
  36197. * Returns a new AnimationGroup object parsed from the source provided.
  36198. * @param parsedAnimationGroup defines the source
  36199. * @param scene defines the scene that will receive the animationGroup
  36200. * @returns a new AnimationGroup
  36201. */
  36202. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36203. /**
  36204. * Returns the string "AnimationGroup"
  36205. * @returns "AnimationGroup"
  36206. */
  36207. getClassName(): string;
  36208. /**
  36209. * Creates a detailled string about the object
  36210. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36211. * @returns a string representing the object
  36212. */
  36213. toString(fullDetails?: boolean): string;
  36214. }
  36215. }
  36216. declare module "babylonjs/scene" {
  36217. import { Nullable } from "babylonjs/types";
  36218. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36219. import { Observable } from "babylonjs/Misc/observable";
  36220. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36221. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36222. import { Geometry } from "babylonjs/Meshes/geometry";
  36223. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36226. import { Mesh } from "babylonjs/Meshes/mesh";
  36227. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36228. import { Bone } from "babylonjs/Bones/bone";
  36229. import { Skeleton } from "babylonjs/Bones/skeleton";
  36230. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36231. import { Camera } from "babylonjs/Cameras/camera";
  36232. import { AbstractScene } from "babylonjs/abstractScene";
  36233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36235. import { Material } from "babylonjs/Materials/material";
  36236. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36237. import { Effect } from "babylonjs/Materials/effect";
  36238. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36239. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36240. import { Light } from "babylonjs/Lights/light";
  36241. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36242. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36243. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36244. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36245. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36246. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36247. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36248. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36249. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36250. import { Engine } from "babylonjs/Engines/engine";
  36251. import { Node } from "babylonjs/node";
  36252. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36253. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36254. import { WebRequest } from "babylonjs/Misc/webRequest";
  36255. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36256. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36257. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36258. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36259. import { Plane } from "babylonjs/Maths/math.plane";
  36260. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36261. import { Ray } from "babylonjs/Culling/ray";
  36262. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36263. import { Animation } from "babylonjs/Animations/animation";
  36264. import { Animatable } from "babylonjs/Animations/animatable";
  36265. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36266. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36267. import { Collider } from "babylonjs/Collisions/collider";
  36268. /**
  36269. * Define an interface for all classes that will hold resources
  36270. */
  36271. export interface IDisposable {
  36272. /**
  36273. * Releases all held resources
  36274. */
  36275. dispose(): void;
  36276. }
  36277. /** Interface defining initialization parameters for Scene class */
  36278. export interface SceneOptions {
  36279. /**
  36280. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36281. * It will improve performance when the number of geometries becomes important.
  36282. */
  36283. useGeometryUniqueIdsMap?: boolean;
  36284. /**
  36285. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36286. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36287. */
  36288. useMaterialMeshMap?: boolean;
  36289. /**
  36290. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36291. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36292. */
  36293. useClonedMeshMap?: boolean;
  36294. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36295. virtual?: boolean;
  36296. }
  36297. /**
  36298. * Represents a scene to be rendered by the engine.
  36299. * @see http://doc.babylonjs.com/features/scene
  36300. */
  36301. export class Scene extends AbstractScene implements IAnimatable {
  36302. /** The fog is deactivated */
  36303. static readonly FOGMODE_NONE: number;
  36304. /** The fog density is following an exponential function */
  36305. static readonly FOGMODE_EXP: number;
  36306. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36307. static readonly FOGMODE_EXP2: number;
  36308. /** The fog density is following a linear function. */
  36309. static readonly FOGMODE_LINEAR: number;
  36310. /**
  36311. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36313. */
  36314. static MinDeltaTime: number;
  36315. /**
  36316. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36318. */
  36319. static MaxDeltaTime: number;
  36320. /**
  36321. * Factory used to create the default material.
  36322. * @param name The name of the material to create
  36323. * @param scene The scene to create the material for
  36324. * @returns The default material
  36325. */
  36326. static DefaultMaterialFactory(scene: Scene): Material;
  36327. /**
  36328. * Factory used to create the a collision coordinator.
  36329. * @returns The collision coordinator
  36330. */
  36331. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36332. /** @hidden */
  36333. _inputManager: InputManager;
  36334. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36335. cameraToUseForPointers: Nullable<Camera>;
  36336. /** @hidden */
  36337. readonly _isScene: boolean;
  36338. /** @hidden */
  36339. _blockEntityCollection: boolean;
  36340. /**
  36341. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36342. */
  36343. autoClear: boolean;
  36344. /**
  36345. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36346. */
  36347. autoClearDepthAndStencil: boolean;
  36348. /**
  36349. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36350. */
  36351. clearColor: Color4;
  36352. /**
  36353. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36354. */
  36355. ambientColor: Color3;
  36356. /**
  36357. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36358. * It should only be one of the following (if not the default embedded one):
  36359. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36360. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36361. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36362. * The material properties need to be setup according to the type of texture in use.
  36363. */
  36364. environmentBRDFTexture: BaseTexture;
  36365. /** @hidden */
  36366. protected _environmentTexture: Nullable<BaseTexture>;
  36367. /**
  36368. * Texture used in all pbr material as the reflection texture.
  36369. * As in the majority of the scene they are the same (exception for multi room and so on),
  36370. * this is easier to reference from here than from all the materials.
  36371. */
  36372. get environmentTexture(): Nullable<BaseTexture>;
  36373. /**
  36374. * Texture used in all pbr material as the reflection texture.
  36375. * As in the majority of the scene they are the same (exception for multi room and so on),
  36376. * this is easier to set here than in all the materials.
  36377. */
  36378. set environmentTexture(value: Nullable<BaseTexture>);
  36379. /** @hidden */
  36380. protected _environmentIntensity: number;
  36381. /**
  36382. * Intensity of the environment in all pbr material.
  36383. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36384. * As in the majority of the scene they are the same (exception for multi room and so on),
  36385. * this is easier to reference from here than from all the materials.
  36386. */
  36387. get environmentIntensity(): number;
  36388. /**
  36389. * Intensity of the environment in all pbr material.
  36390. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36391. * As in the majority of the scene they are the same (exception for multi room and so on),
  36392. * this is easier to set here than in all the materials.
  36393. */
  36394. set environmentIntensity(value: number);
  36395. /** @hidden */
  36396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36397. /**
  36398. * Default image processing configuration used either in the rendering
  36399. * Forward main pass or through the imageProcessingPostProcess if present.
  36400. * As in the majority of the scene they are the same (exception for multi camera),
  36401. * this is easier to reference from here than from all the materials and post process.
  36402. *
  36403. * No setter as we it is a shared configuration, you can set the values instead.
  36404. */
  36405. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36406. private _forceWireframe;
  36407. /**
  36408. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36409. */
  36410. set forceWireframe(value: boolean);
  36411. get forceWireframe(): boolean;
  36412. private _skipFrustumClipping;
  36413. /**
  36414. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36415. */
  36416. set skipFrustumClipping(value: boolean);
  36417. get skipFrustumClipping(): boolean;
  36418. private _forcePointsCloud;
  36419. /**
  36420. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36421. */
  36422. set forcePointsCloud(value: boolean);
  36423. get forcePointsCloud(): boolean;
  36424. /**
  36425. * Gets or sets the active clipplane 1
  36426. */
  36427. clipPlane: Nullable<Plane>;
  36428. /**
  36429. * Gets or sets the active clipplane 2
  36430. */
  36431. clipPlane2: Nullable<Plane>;
  36432. /**
  36433. * Gets or sets the active clipplane 3
  36434. */
  36435. clipPlane3: Nullable<Plane>;
  36436. /**
  36437. * Gets or sets the active clipplane 4
  36438. */
  36439. clipPlane4: Nullable<Plane>;
  36440. /**
  36441. * Gets or sets the active clipplane 5
  36442. */
  36443. clipPlane5: Nullable<Plane>;
  36444. /**
  36445. * Gets or sets the active clipplane 6
  36446. */
  36447. clipPlane6: Nullable<Plane>;
  36448. /**
  36449. * Gets or sets a boolean indicating if animations are enabled
  36450. */
  36451. animationsEnabled: boolean;
  36452. private _animationPropertiesOverride;
  36453. /**
  36454. * Gets or sets the animation properties override
  36455. */
  36456. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36457. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36458. /**
  36459. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36460. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36461. */
  36462. useConstantAnimationDeltaTime: boolean;
  36463. /**
  36464. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36465. * Please note that it requires to run a ray cast through the scene on every frame
  36466. */
  36467. constantlyUpdateMeshUnderPointer: boolean;
  36468. /**
  36469. * Defines the HTML cursor to use when hovering over interactive elements
  36470. */
  36471. hoverCursor: string;
  36472. /**
  36473. * Defines the HTML default cursor to use (empty by default)
  36474. */
  36475. defaultCursor: string;
  36476. /**
  36477. * Defines whether cursors are handled by the scene.
  36478. */
  36479. doNotHandleCursors: boolean;
  36480. /**
  36481. * This is used to call preventDefault() on pointer down
  36482. * in order to block unwanted artifacts like system double clicks
  36483. */
  36484. preventDefaultOnPointerDown: boolean;
  36485. /**
  36486. * This is used to call preventDefault() on pointer up
  36487. * in order to block unwanted artifacts like system double clicks
  36488. */
  36489. preventDefaultOnPointerUp: boolean;
  36490. /**
  36491. * Gets or sets user defined metadata
  36492. */
  36493. metadata: any;
  36494. /**
  36495. * For internal use only. Please do not use.
  36496. */
  36497. reservedDataStore: any;
  36498. /**
  36499. * Gets the name of the plugin used to load this scene (null by default)
  36500. */
  36501. loadingPluginName: string;
  36502. /**
  36503. * Use this array to add regular expressions used to disable offline support for specific urls
  36504. */
  36505. disableOfflineSupportExceptionRules: RegExp[];
  36506. /**
  36507. * An event triggered when the scene is disposed.
  36508. */
  36509. onDisposeObservable: Observable<Scene>;
  36510. private _onDisposeObserver;
  36511. /** Sets a function to be executed when this scene is disposed. */
  36512. set onDispose(callback: () => void);
  36513. /**
  36514. * An event triggered before rendering the scene (right after animations and physics)
  36515. */
  36516. onBeforeRenderObservable: Observable<Scene>;
  36517. private _onBeforeRenderObserver;
  36518. /** Sets a function to be executed before rendering this scene */
  36519. set beforeRender(callback: Nullable<() => void>);
  36520. /**
  36521. * An event triggered after rendering the scene
  36522. */
  36523. onAfterRenderObservable: Observable<Scene>;
  36524. /**
  36525. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36526. */
  36527. onAfterRenderCameraObservable: Observable<Camera>;
  36528. private _onAfterRenderObserver;
  36529. /** Sets a function to be executed after rendering this scene */
  36530. set afterRender(callback: Nullable<() => void>);
  36531. /**
  36532. * An event triggered before animating the scene
  36533. */
  36534. onBeforeAnimationsObservable: Observable<Scene>;
  36535. /**
  36536. * An event triggered after animations processing
  36537. */
  36538. onAfterAnimationsObservable: Observable<Scene>;
  36539. /**
  36540. * An event triggered before draw calls are ready to be sent
  36541. */
  36542. onBeforeDrawPhaseObservable: Observable<Scene>;
  36543. /**
  36544. * An event triggered after draw calls have been sent
  36545. */
  36546. onAfterDrawPhaseObservable: Observable<Scene>;
  36547. /**
  36548. * An event triggered when the scene is ready
  36549. */
  36550. onReadyObservable: Observable<Scene>;
  36551. /**
  36552. * An event triggered before rendering a camera
  36553. */
  36554. onBeforeCameraRenderObservable: Observable<Camera>;
  36555. private _onBeforeCameraRenderObserver;
  36556. /** Sets a function to be executed before rendering a camera*/
  36557. set beforeCameraRender(callback: () => void);
  36558. /**
  36559. * An event triggered after rendering a camera
  36560. */
  36561. onAfterCameraRenderObservable: Observable<Camera>;
  36562. private _onAfterCameraRenderObserver;
  36563. /** Sets a function to be executed after rendering a camera*/
  36564. set afterCameraRender(callback: () => void);
  36565. /**
  36566. * An event triggered when active meshes evaluation is about to start
  36567. */
  36568. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36569. /**
  36570. * An event triggered when active meshes evaluation is done
  36571. */
  36572. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36573. /**
  36574. * An event triggered when particles rendering is about to start
  36575. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36576. */
  36577. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36578. /**
  36579. * An event triggered when particles rendering is done
  36580. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36581. */
  36582. onAfterParticlesRenderingObservable: Observable<Scene>;
  36583. /**
  36584. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36585. */
  36586. onDataLoadedObservable: Observable<Scene>;
  36587. /**
  36588. * An event triggered when a camera is created
  36589. */
  36590. onNewCameraAddedObservable: Observable<Camera>;
  36591. /**
  36592. * An event triggered when a camera is removed
  36593. */
  36594. onCameraRemovedObservable: Observable<Camera>;
  36595. /**
  36596. * An event triggered when a light is created
  36597. */
  36598. onNewLightAddedObservable: Observable<Light>;
  36599. /**
  36600. * An event triggered when a light is removed
  36601. */
  36602. onLightRemovedObservable: Observable<Light>;
  36603. /**
  36604. * An event triggered when a geometry is created
  36605. */
  36606. onNewGeometryAddedObservable: Observable<Geometry>;
  36607. /**
  36608. * An event triggered when a geometry is removed
  36609. */
  36610. onGeometryRemovedObservable: Observable<Geometry>;
  36611. /**
  36612. * An event triggered when a transform node is created
  36613. */
  36614. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36615. /**
  36616. * An event triggered when a transform node is removed
  36617. */
  36618. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36619. /**
  36620. * An event triggered when a mesh is created
  36621. */
  36622. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36623. /**
  36624. * An event triggered when a mesh is removed
  36625. */
  36626. onMeshRemovedObservable: Observable<AbstractMesh>;
  36627. /**
  36628. * An event triggered when a skeleton is created
  36629. */
  36630. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36631. /**
  36632. * An event triggered when a skeleton is removed
  36633. */
  36634. onSkeletonRemovedObservable: Observable<Skeleton>;
  36635. /**
  36636. * An event triggered when a material is created
  36637. */
  36638. onNewMaterialAddedObservable: Observable<Material>;
  36639. /**
  36640. * An event triggered when a material is removed
  36641. */
  36642. onMaterialRemovedObservable: Observable<Material>;
  36643. /**
  36644. * An event triggered when a texture is created
  36645. */
  36646. onNewTextureAddedObservable: Observable<BaseTexture>;
  36647. /**
  36648. * An event triggered when a texture is removed
  36649. */
  36650. onTextureRemovedObservable: Observable<BaseTexture>;
  36651. /**
  36652. * An event triggered when render targets are about to be rendered
  36653. * Can happen multiple times per frame.
  36654. */
  36655. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36656. /**
  36657. * An event triggered when render targets were rendered.
  36658. * Can happen multiple times per frame.
  36659. */
  36660. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36661. /**
  36662. * An event triggered before calculating deterministic simulation step
  36663. */
  36664. onBeforeStepObservable: Observable<Scene>;
  36665. /**
  36666. * An event triggered after calculating deterministic simulation step
  36667. */
  36668. onAfterStepObservable: Observable<Scene>;
  36669. /**
  36670. * An event triggered when the activeCamera property is updated
  36671. */
  36672. onActiveCameraChanged: Observable<Scene>;
  36673. /**
  36674. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36675. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36676. * 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)
  36677. */
  36678. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36679. /**
  36680. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36681. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36682. * 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)
  36683. */
  36684. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36685. /**
  36686. * This Observable will when a mesh has been imported into the scene.
  36687. */
  36688. onMeshImportedObservable: Observable<AbstractMesh>;
  36689. /**
  36690. * This Observable will when an animation file has been imported into the scene.
  36691. */
  36692. onAnimationFileImportedObservable: Observable<Scene>;
  36693. /**
  36694. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36695. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36696. */
  36697. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36698. /** @hidden */
  36699. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36700. /**
  36701. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36702. */
  36703. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36704. /**
  36705. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36706. */
  36707. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36708. /**
  36709. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36710. */
  36711. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36712. /** Callback called when a pointer move is detected */
  36713. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36714. /** Callback called when a pointer down is detected */
  36715. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36716. /** Callback called when a pointer up is detected */
  36717. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36718. /** Callback called when a pointer pick is detected */
  36719. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36720. /**
  36721. * 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).
  36722. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36723. */
  36724. onPrePointerObservable: Observable<PointerInfoPre>;
  36725. /**
  36726. * Observable event triggered each time an input event is received from the rendering canvas
  36727. */
  36728. onPointerObservable: Observable<PointerInfo>;
  36729. /**
  36730. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36731. */
  36732. get unTranslatedPointer(): Vector2;
  36733. /**
  36734. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36735. */
  36736. static get DragMovementThreshold(): number;
  36737. static set DragMovementThreshold(value: number);
  36738. /**
  36739. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36740. */
  36741. static get LongPressDelay(): number;
  36742. static set LongPressDelay(value: number);
  36743. /**
  36744. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36745. */
  36746. static get DoubleClickDelay(): number;
  36747. static set DoubleClickDelay(value: number);
  36748. /** If you need to check double click without raising a single click at first click, enable this flag */
  36749. static get ExclusiveDoubleClickMode(): boolean;
  36750. static set ExclusiveDoubleClickMode(value: boolean);
  36751. /** @hidden */
  36752. _mirroredCameraPosition: Nullable<Vector3>;
  36753. /**
  36754. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36755. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36756. */
  36757. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36758. /**
  36759. * Observable event triggered each time an keyboard event is received from the hosting window
  36760. */
  36761. onKeyboardObservable: Observable<KeyboardInfo>;
  36762. private _useRightHandedSystem;
  36763. /**
  36764. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36765. */
  36766. set useRightHandedSystem(value: boolean);
  36767. get useRightHandedSystem(): boolean;
  36768. private _timeAccumulator;
  36769. private _currentStepId;
  36770. private _currentInternalStep;
  36771. /**
  36772. * Sets the step Id used by deterministic lock step
  36773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36774. * @param newStepId defines the step Id
  36775. */
  36776. setStepId(newStepId: number): void;
  36777. /**
  36778. * Gets the step Id used by deterministic lock step
  36779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36780. * @returns the step Id
  36781. */
  36782. getStepId(): number;
  36783. /**
  36784. * Gets the internal step used by deterministic lock step
  36785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36786. * @returns the internal step
  36787. */
  36788. getInternalStep(): number;
  36789. private _fogEnabled;
  36790. /**
  36791. * Gets or sets a boolean indicating if fog is enabled on this scene
  36792. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36793. * (Default is true)
  36794. */
  36795. set fogEnabled(value: boolean);
  36796. get fogEnabled(): boolean;
  36797. private _fogMode;
  36798. /**
  36799. * Gets or sets the fog mode to use
  36800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36801. * | mode | value |
  36802. * | --- | --- |
  36803. * | FOGMODE_NONE | 0 |
  36804. * | FOGMODE_EXP | 1 |
  36805. * | FOGMODE_EXP2 | 2 |
  36806. * | FOGMODE_LINEAR | 3 |
  36807. */
  36808. set fogMode(value: number);
  36809. get fogMode(): number;
  36810. /**
  36811. * Gets or sets the fog color to use
  36812. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36813. * (Default is Color3(0.2, 0.2, 0.3))
  36814. */
  36815. fogColor: Color3;
  36816. /**
  36817. * Gets or sets the fog density to use
  36818. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36819. * (Default is 0.1)
  36820. */
  36821. fogDensity: number;
  36822. /**
  36823. * Gets or sets the fog start distance to use
  36824. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36825. * (Default is 0)
  36826. */
  36827. fogStart: number;
  36828. /**
  36829. * Gets or sets the fog end distance to use
  36830. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36831. * (Default is 1000)
  36832. */
  36833. fogEnd: number;
  36834. private _shadowsEnabled;
  36835. /**
  36836. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36837. */
  36838. set shadowsEnabled(value: boolean);
  36839. get shadowsEnabled(): boolean;
  36840. private _lightsEnabled;
  36841. /**
  36842. * Gets or sets a boolean indicating if lights are enabled on this scene
  36843. */
  36844. set lightsEnabled(value: boolean);
  36845. get lightsEnabled(): boolean;
  36846. /** All of the active cameras added to this scene. */
  36847. activeCameras: Camera[];
  36848. /** @hidden */
  36849. _activeCamera: Nullable<Camera>;
  36850. /** Gets or sets the current active camera */
  36851. get activeCamera(): Nullable<Camera>;
  36852. set activeCamera(value: Nullable<Camera>);
  36853. private _defaultMaterial;
  36854. /** The default material used on meshes when no material is affected */
  36855. get defaultMaterial(): Material;
  36856. /** The default material used on meshes when no material is affected */
  36857. set defaultMaterial(value: Material);
  36858. private _texturesEnabled;
  36859. /**
  36860. * Gets or sets a boolean indicating if textures are enabled on this scene
  36861. */
  36862. set texturesEnabled(value: boolean);
  36863. get texturesEnabled(): boolean;
  36864. /**
  36865. * Gets or sets a boolean indicating if particles are enabled on this scene
  36866. */
  36867. particlesEnabled: boolean;
  36868. /**
  36869. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36870. */
  36871. spritesEnabled: boolean;
  36872. private _skeletonsEnabled;
  36873. /**
  36874. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36875. */
  36876. set skeletonsEnabled(value: boolean);
  36877. get skeletonsEnabled(): boolean;
  36878. /**
  36879. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36880. */
  36881. lensFlaresEnabled: boolean;
  36882. /**
  36883. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36885. */
  36886. collisionsEnabled: boolean;
  36887. private _collisionCoordinator;
  36888. /** @hidden */
  36889. get collisionCoordinator(): ICollisionCoordinator;
  36890. /**
  36891. * Defines the gravity applied to this scene (used only for collisions)
  36892. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36893. */
  36894. gravity: Vector3;
  36895. /**
  36896. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36897. */
  36898. postProcessesEnabled: boolean;
  36899. /**
  36900. * The list of postprocesses added to the scene
  36901. */
  36902. postProcesses: PostProcess[];
  36903. /**
  36904. * Gets the current postprocess manager
  36905. */
  36906. postProcessManager: PostProcessManager;
  36907. /**
  36908. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36909. */
  36910. renderTargetsEnabled: boolean;
  36911. /**
  36912. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36913. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36914. */
  36915. dumpNextRenderTargets: boolean;
  36916. /**
  36917. * The list of user defined render targets added to the scene
  36918. */
  36919. customRenderTargets: RenderTargetTexture[];
  36920. /**
  36921. * Defines if texture loading must be delayed
  36922. * If true, textures will only be loaded when they need to be rendered
  36923. */
  36924. useDelayedTextureLoading: boolean;
  36925. /**
  36926. * Gets the list of meshes imported to the scene through SceneLoader
  36927. */
  36928. importedMeshesFiles: String[];
  36929. /**
  36930. * Gets or sets a boolean indicating if probes are enabled on this scene
  36931. */
  36932. probesEnabled: boolean;
  36933. /**
  36934. * Gets or sets the current offline provider to use to store scene data
  36935. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36936. */
  36937. offlineProvider: IOfflineProvider;
  36938. /**
  36939. * Gets or sets the action manager associated with the scene
  36940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36941. */
  36942. actionManager: AbstractActionManager;
  36943. private _meshesForIntersections;
  36944. /**
  36945. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36946. */
  36947. proceduralTexturesEnabled: boolean;
  36948. private _engine;
  36949. private _totalVertices;
  36950. /** @hidden */
  36951. _activeIndices: PerfCounter;
  36952. /** @hidden */
  36953. _activeParticles: PerfCounter;
  36954. /** @hidden */
  36955. _activeBones: PerfCounter;
  36956. private _animationRatio;
  36957. /** @hidden */
  36958. _animationTimeLast: number;
  36959. /** @hidden */
  36960. _animationTime: number;
  36961. /**
  36962. * Gets or sets a general scale for animation speed
  36963. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36964. */
  36965. animationTimeScale: number;
  36966. /** @hidden */
  36967. _cachedMaterial: Nullable<Material>;
  36968. /** @hidden */
  36969. _cachedEffect: Nullable<Effect>;
  36970. /** @hidden */
  36971. _cachedVisibility: Nullable<number>;
  36972. private _renderId;
  36973. private _frameId;
  36974. private _executeWhenReadyTimeoutId;
  36975. private _intermediateRendering;
  36976. private _viewUpdateFlag;
  36977. private _projectionUpdateFlag;
  36978. /** @hidden */
  36979. _toBeDisposed: Nullable<IDisposable>[];
  36980. private _activeRequests;
  36981. /** @hidden */
  36982. _pendingData: any[];
  36983. private _isDisposed;
  36984. /**
  36985. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36986. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36987. */
  36988. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36989. private _activeMeshes;
  36990. private _processedMaterials;
  36991. private _renderTargets;
  36992. /** @hidden */
  36993. _activeParticleSystems: SmartArray<IParticleSystem>;
  36994. private _activeSkeletons;
  36995. private _softwareSkinnedMeshes;
  36996. private _renderingManager;
  36997. /** @hidden */
  36998. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36999. private _transformMatrix;
  37000. private _sceneUbo;
  37001. /** @hidden */
  37002. _viewMatrix: Matrix;
  37003. private _projectionMatrix;
  37004. /** @hidden */
  37005. _forcedViewPosition: Nullable<Vector3>;
  37006. /** @hidden */
  37007. _frustumPlanes: Plane[];
  37008. /**
  37009. * Gets the list of frustum planes (built from the active camera)
  37010. */
  37011. get frustumPlanes(): Plane[];
  37012. /**
  37013. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37014. * This is useful if there are more lights that the maximum simulteanous authorized
  37015. */
  37016. requireLightSorting: boolean;
  37017. /** @hidden */
  37018. readonly useMaterialMeshMap: boolean;
  37019. /** @hidden */
  37020. readonly useClonedMeshMap: boolean;
  37021. private _externalData;
  37022. private _uid;
  37023. /**
  37024. * @hidden
  37025. * Backing store of defined scene components.
  37026. */
  37027. _components: ISceneComponent[];
  37028. /**
  37029. * @hidden
  37030. * Backing store of defined scene components.
  37031. */
  37032. _serializableComponents: ISceneSerializableComponent[];
  37033. /**
  37034. * List of components to register on the next registration step.
  37035. */
  37036. private _transientComponents;
  37037. /**
  37038. * Registers the transient components if needed.
  37039. */
  37040. private _registerTransientComponents;
  37041. /**
  37042. * @hidden
  37043. * Add a component to the scene.
  37044. * Note that the ccomponent could be registered on th next frame if this is called after
  37045. * the register component stage.
  37046. * @param component Defines the component to add to the scene
  37047. */
  37048. _addComponent(component: ISceneComponent): void;
  37049. /**
  37050. * @hidden
  37051. * Gets a component from the scene.
  37052. * @param name defines the name of the component to retrieve
  37053. * @returns the component or null if not present
  37054. */
  37055. _getComponent(name: string): Nullable<ISceneComponent>;
  37056. /**
  37057. * @hidden
  37058. * Defines the actions happening before camera updates.
  37059. */
  37060. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37061. /**
  37062. * @hidden
  37063. * Defines the actions happening before clear the canvas.
  37064. */
  37065. _beforeClearStage: Stage<SimpleStageAction>;
  37066. /**
  37067. * @hidden
  37068. * Defines the actions when collecting render targets for the frame.
  37069. */
  37070. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37071. /**
  37072. * @hidden
  37073. * Defines the actions happening for one camera in the frame.
  37074. */
  37075. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37076. /**
  37077. * @hidden
  37078. * Defines the actions happening during the per mesh ready checks.
  37079. */
  37080. _isReadyForMeshStage: Stage<MeshStageAction>;
  37081. /**
  37082. * @hidden
  37083. * Defines the actions happening before evaluate active mesh checks.
  37084. */
  37085. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37086. /**
  37087. * @hidden
  37088. * Defines the actions happening during the evaluate sub mesh checks.
  37089. */
  37090. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37091. /**
  37092. * @hidden
  37093. * Defines the actions happening during the active mesh stage.
  37094. */
  37095. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37096. /**
  37097. * @hidden
  37098. * Defines the actions happening during the per camera render target step.
  37099. */
  37100. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37101. /**
  37102. * @hidden
  37103. * Defines the actions happening just before the active camera is drawing.
  37104. */
  37105. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37106. /**
  37107. * @hidden
  37108. * Defines the actions happening just before a render target is drawing.
  37109. */
  37110. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37111. /**
  37112. * @hidden
  37113. * Defines the actions happening just before a rendering group is drawing.
  37114. */
  37115. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37116. /**
  37117. * @hidden
  37118. * Defines the actions happening just before a mesh is drawing.
  37119. */
  37120. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37121. /**
  37122. * @hidden
  37123. * Defines the actions happening just after a mesh has been drawn.
  37124. */
  37125. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37126. /**
  37127. * @hidden
  37128. * Defines the actions happening just after a rendering group has been drawn.
  37129. */
  37130. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37131. /**
  37132. * @hidden
  37133. * Defines the actions happening just after the active camera has been drawn.
  37134. */
  37135. _afterCameraDrawStage: Stage<CameraStageAction>;
  37136. /**
  37137. * @hidden
  37138. * Defines the actions happening just after a render target has been drawn.
  37139. */
  37140. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37141. /**
  37142. * @hidden
  37143. * Defines the actions happening just after rendering all cameras and computing intersections.
  37144. */
  37145. _afterRenderStage: Stage<SimpleStageAction>;
  37146. /**
  37147. * @hidden
  37148. * Defines the actions happening when a pointer move event happens.
  37149. */
  37150. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37151. /**
  37152. * @hidden
  37153. * Defines the actions happening when a pointer down event happens.
  37154. */
  37155. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37156. /**
  37157. * @hidden
  37158. * Defines the actions happening when a pointer up event happens.
  37159. */
  37160. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37161. /**
  37162. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37163. */
  37164. private geometriesByUniqueId;
  37165. /**
  37166. * Creates a new Scene
  37167. * @param engine defines the engine to use to render this scene
  37168. * @param options defines the scene options
  37169. */
  37170. constructor(engine: Engine, options?: SceneOptions);
  37171. /**
  37172. * Gets a string idenfifying the name of the class
  37173. * @returns "Scene" string
  37174. */
  37175. getClassName(): string;
  37176. private _defaultMeshCandidates;
  37177. /**
  37178. * @hidden
  37179. */
  37180. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37181. private _defaultSubMeshCandidates;
  37182. /**
  37183. * @hidden
  37184. */
  37185. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37186. /**
  37187. * Sets the default candidate providers for the scene.
  37188. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37189. * and getCollidingSubMeshCandidates to their default function
  37190. */
  37191. setDefaultCandidateProviders(): void;
  37192. /**
  37193. * Gets the mesh that is currently under the pointer
  37194. */
  37195. get meshUnderPointer(): Nullable<AbstractMesh>;
  37196. /**
  37197. * Gets or sets the current on-screen X position of the pointer
  37198. */
  37199. get pointerX(): number;
  37200. set pointerX(value: number);
  37201. /**
  37202. * Gets or sets the current on-screen Y position of the pointer
  37203. */
  37204. get pointerY(): number;
  37205. set pointerY(value: number);
  37206. /**
  37207. * Gets the cached material (ie. the latest rendered one)
  37208. * @returns the cached material
  37209. */
  37210. getCachedMaterial(): Nullable<Material>;
  37211. /**
  37212. * Gets the cached effect (ie. the latest rendered one)
  37213. * @returns the cached effect
  37214. */
  37215. getCachedEffect(): Nullable<Effect>;
  37216. /**
  37217. * Gets the cached visibility state (ie. the latest rendered one)
  37218. * @returns the cached visibility state
  37219. */
  37220. getCachedVisibility(): Nullable<number>;
  37221. /**
  37222. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37223. * @param material defines the current material
  37224. * @param effect defines the current effect
  37225. * @param visibility defines the current visibility state
  37226. * @returns true if one parameter is not cached
  37227. */
  37228. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37229. /**
  37230. * Gets the engine associated with the scene
  37231. * @returns an Engine
  37232. */
  37233. getEngine(): Engine;
  37234. /**
  37235. * Gets the total number of vertices rendered per frame
  37236. * @returns the total number of vertices rendered per frame
  37237. */
  37238. getTotalVertices(): number;
  37239. /**
  37240. * Gets the performance counter for total vertices
  37241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37242. */
  37243. get totalVerticesPerfCounter(): PerfCounter;
  37244. /**
  37245. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37246. * @returns the total number of active indices rendered per frame
  37247. */
  37248. getActiveIndices(): number;
  37249. /**
  37250. * Gets the performance counter for active indices
  37251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37252. */
  37253. get totalActiveIndicesPerfCounter(): PerfCounter;
  37254. /**
  37255. * Gets the total number of active particles rendered per frame
  37256. * @returns the total number of active particles rendered per frame
  37257. */
  37258. getActiveParticles(): number;
  37259. /**
  37260. * Gets the performance counter for active particles
  37261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37262. */
  37263. get activeParticlesPerfCounter(): PerfCounter;
  37264. /**
  37265. * Gets the total number of active bones rendered per frame
  37266. * @returns the total number of active bones rendered per frame
  37267. */
  37268. getActiveBones(): number;
  37269. /**
  37270. * Gets the performance counter for active bones
  37271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37272. */
  37273. get activeBonesPerfCounter(): PerfCounter;
  37274. /**
  37275. * Gets the array of active meshes
  37276. * @returns an array of AbstractMesh
  37277. */
  37278. getActiveMeshes(): SmartArray<AbstractMesh>;
  37279. /**
  37280. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37281. * @returns a number
  37282. */
  37283. getAnimationRatio(): number;
  37284. /**
  37285. * Gets an unique Id for the current render phase
  37286. * @returns a number
  37287. */
  37288. getRenderId(): number;
  37289. /**
  37290. * Gets an unique Id for the current frame
  37291. * @returns a number
  37292. */
  37293. getFrameId(): number;
  37294. /** Call this function if you want to manually increment the render Id*/
  37295. incrementRenderId(): void;
  37296. private _createUbo;
  37297. /**
  37298. * Use this method to simulate a pointer move on a mesh
  37299. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37300. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37301. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37302. * @returns the current scene
  37303. */
  37304. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37305. /**
  37306. * Use this method to simulate a pointer down on a mesh
  37307. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37308. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37309. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37310. * @returns the current scene
  37311. */
  37312. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37313. /**
  37314. * Use this method to simulate a pointer up on a mesh
  37315. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37316. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37317. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37318. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37319. * @returns the current scene
  37320. */
  37321. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37322. /**
  37323. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37324. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37325. * @returns true if the pointer was captured
  37326. */
  37327. isPointerCaptured(pointerId?: number): boolean;
  37328. /**
  37329. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37330. * @param attachUp defines if you want to attach events to pointerup
  37331. * @param attachDown defines if you want to attach events to pointerdown
  37332. * @param attachMove defines if you want to attach events to pointermove
  37333. */
  37334. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37335. /** Detaches all event handlers*/
  37336. detachControl(): void;
  37337. /**
  37338. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37339. * Delay loaded resources are not taking in account
  37340. * @return true if all required resources are ready
  37341. */
  37342. isReady(): boolean;
  37343. /** Resets all cached information relative to material (including effect and visibility) */
  37344. resetCachedMaterial(): void;
  37345. /**
  37346. * Registers a function to be called before every frame render
  37347. * @param func defines the function to register
  37348. */
  37349. registerBeforeRender(func: () => void): void;
  37350. /**
  37351. * Unregisters a function called before every frame render
  37352. * @param func defines the function to unregister
  37353. */
  37354. unregisterBeforeRender(func: () => void): void;
  37355. /**
  37356. * Registers a function to be called after every frame render
  37357. * @param func defines the function to register
  37358. */
  37359. registerAfterRender(func: () => void): void;
  37360. /**
  37361. * Unregisters a function called after every frame render
  37362. * @param func defines the function to unregister
  37363. */
  37364. unregisterAfterRender(func: () => void): void;
  37365. private _executeOnceBeforeRender;
  37366. /**
  37367. * The provided function will run before render once and will be disposed afterwards.
  37368. * A timeout delay can be provided so that the function will be executed in N ms.
  37369. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37370. * @param func The function to be executed.
  37371. * @param timeout optional delay in ms
  37372. */
  37373. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37374. /** @hidden */
  37375. _addPendingData(data: any): void;
  37376. /** @hidden */
  37377. _removePendingData(data: any): void;
  37378. /**
  37379. * Returns the number of items waiting to be loaded
  37380. * @returns the number of items waiting to be loaded
  37381. */
  37382. getWaitingItemsCount(): number;
  37383. /**
  37384. * Returns a boolean indicating if the scene is still loading data
  37385. */
  37386. get isLoading(): boolean;
  37387. /**
  37388. * Registers a function to be executed when the scene is ready
  37389. * @param {Function} func - the function to be executed
  37390. */
  37391. executeWhenReady(func: () => void): void;
  37392. /**
  37393. * Returns a promise that resolves when the scene is ready
  37394. * @returns A promise that resolves when the scene is ready
  37395. */
  37396. whenReadyAsync(): Promise<void>;
  37397. /** @hidden */
  37398. _checkIsReady(): void;
  37399. /**
  37400. * Gets all animatable attached to the scene
  37401. */
  37402. get animatables(): Animatable[];
  37403. /**
  37404. * Resets the last animation time frame.
  37405. * Useful to override when animations start running when loading a scene for the first time.
  37406. */
  37407. resetLastAnimationTimeFrame(): void;
  37408. /**
  37409. * Gets the current view matrix
  37410. * @returns a Matrix
  37411. */
  37412. getViewMatrix(): Matrix;
  37413. /**
  37414. * Gets the current projection matrix
  37415. * @returns a Matrix
  37416. */
  37417. getProjectionMatrix(): Matrix;
  37418. /**
  37419. * Gets the current transform matrix
  37420. * @returns a Matrix made of View * Projection
  37421. */
  37422. getTransformMatrix(): Matrix;
  37423. /**
  37424. * Sets the current transform matrix
  37425. * @param viewL defines the View matrix to use
  37426. * @param projectionL defines the Projection matrix to use
  37427. * @param viewR defines the right View matrix to use (if provided)
  37428. * @param projectionR defines the right Projection matrix to use (if provided)
  37429. */
  37430. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37431. /**
  37432. * Gets the uniform buffer used to store scene data
  37433. * @returns a UniformBuffer
  37434. */
  37435. getSceneUniformBuffer(): UniformBuffer;
  37436. /**
  37437. * Gets an unique (relatively to the current scene) Id
  37438. * @returns an unique number for the scene
  37439. */
  37440. getUniqueId(): number;
  37441. /**
  37442. * Add a mesh to the list of scene's meshes
  37443. * @param newMesh defines the mesh to add
  37444. * @param recursive if all child meshes should also be added to the scene
  37445. */
  37446. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37447. /**
  37448. * Remove a mesh for the list of scene's meshes
  37449. * @param toRemove defines the mesh to remove
  37450. * @param recursive if all child meshes should also be removed from the scene
  37451. * @returns the index where the mesh was in the mesh list
  37452. */
  37453. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37454. /**
  37455. * Add a transform node to the list of scene's transform nodes
  37456. * @param newTransformNode defines the transform node to add
  37457. */
  37458. addTransformNode(newTransformNode: TransformNode): void;
  37459. /**
  37460. * Remove a transform node for the list of scene's transform nodes
  37461. * @param toRemove defines the transform node to remove
  37462. * @returns the index where the transform node was in the transform node list
  37463. */
  37464. removeTransformNode(toRemove: TransformNode): number;
  37465. /**
  37466. * Remove a skeleton for the list of scene's skeletons
  37467. * @param toRemove defines the skeleton to remove
  37468. * @returns the index where the skeleton was in the skeleton list
  37469. */
  37470. removeSkeleton(toRemove: Skeleton): number;
  37471. /**
  37472. * Remove a morph target for the list of scene's morph targets
  37473. * @param toRemove defines the morph target to remove
  37474. * @returns the index where the morph target was in the morph target list
  37475. */
  37476. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37477. /**
  37478. * Remove a light for the list of scene's lights
  37479. * @param toRemove defines the light to remove
  37480. * @returns the index where the light was in the light list
  37481. */
  37482. removeLight(toRemove: Light): number;
  37483. /**
  37484. * Remove a camera for the list of scene's cameras
  37485. * @param toRemove defines the camera to remove
  37486. * @returns the index where the camera was in the camera list
  37487. */
  37488. removeCamera(toRemove: Camera): number;
  37489. /**
  37490. * Remove a particle system for the list of scene's particle systems
  37491. * @param toRemove defines the particle system to remove
  37492. * @returns the index where the particle system was in the particle system list
  37493. */
  37494. removeParticleSystem(toRemove: IParticleSystem): number;
  37495. /**
  37496. * Remove a animation for the list of scene's animations
  37497. * @param toRemove defines the animation to remove
  37498. * @returns the index where the animation was in the animation list
  37499. */
  37500. removeAnimation(toRemove: Animation): number;
  37501. /**
  37502. * Will stop the animation of the given target
  37503. * @param target - the target
  37504. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37505. * @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)
  37506. */
  37507. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37508. /**
  37509. * Removes the given animation group from this scene.
  37510. * @param toRemove The animation group to remove
  37511. * @returns The index of the removed animation group
  37512. */
  37513. removeAnimationGroup(toRemove: AnimationGroup): number;
  37514. /**
  37515. * Removes the given multi-material from this scene.
  37516. * @param toRemove The multi-material to remove
  37517. * @returns The index of the removed multi-material
  37518. */
  37519. removeMultiMaterial(toRemove: MultiMaterial): number;
  37520. /**
  37521. * Removes the given material from this scene.
  37522. * @param toRemove The material to remove
  37523. * @returns The index of the removed material
  37524. */
  37525. removeMaterial(toRemove: Material): number;
  37526. /**
  37527. * Removes the given action manager from this scene.
  37528. * @param toRemove The action manager to remove
  37529. * @returns The index of the removed action manager
  37530. */
  37531. removeActionManager(toRemove: AbstractActionManager): number;
  37532. /**
  37533. * Removes the given texture from this scene.
  37534. * @param toRemove The texture to remove
  37535. * @returns The index of the removed texture
  37536. */
  37537. removeTexture(toRemove: BaseTexture): number;
  37538. /**
  37539. * Adds the given light to this scene
  37540. * @param newLight The light to add
  37541. */
  37542. addLight(newLight: Light): void;
  37543. /**
  37544. * Sorts the list list based on light priorities
  37545. */
  37546. sortLightsByPriority(): void;
  37547. /**
  37548. * Adds the given camera to this scene
  37549. * @param newCamera The camera to add
  37550. */
  37551. addCamera(newCamera: Camera): void;
  37552. /**
  37553. * Adds the given skeleton to this scene
  37554. * @param newSkeleton The skeleton to add
  37555. */
  37556. addSkeleton(newSkeleton: Skeleton): void;
  37557. /**
  37558. * Adds the given particle system to this scene
  37559. * @param newParticleSystem The particle system to add
  37560. */
  37561. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37562. /**
  37563. * Adds the given animation to this scene
  37564. * @param newAnimation The animation to add
  37565. */
  37566. addAnimation(newAnimation: Animation): void;
  37567. /**
  37568. * Adds the given animation group to this scene.
  37569. * @param newAnimationGroup The animation group to add
  37570. */
  37571. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37572. /**
  37573. * Adds the given multi-material to this scene
  37574. * @param newMultiMaterial The multi-material to add
  37575. */
  37576. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37577. /**
  37578. * Adds the given material to this scene
  37579. * @param newMaterial The material to add
  37580. */
  37581. addMaterial(newMaterial: Material): void;
  37582. /**
  37583. * Adds the given morph target to this scene
  37584. * @param newMorphTargetManager The morph target to add
  37585. */
  37586. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37587. /**
  37588. * Adds the given geometry to this scene
  37589. * @param newGeometry The geometry to add
  37590. */
  37591. addGeometry(newGeometry: Geometry): void;
  37592. /**
  37593. * Adds the given action manager to this scene
  37594. * @param newActionManager The action manager to add
  37595. */
  37596. addActionManager(newActionManager: AbstractActionManager): void;
  37597. /**
  37598. * Adds the given texture to this scene.
  37599. * @param newTexture The texture to add
  37600. */
  37601. addTexture(newTexture: BaseTexture): void;
  37602. /**
  37603. * Switch active camera
  37604. * @param newCamera defines the new active camera
  37605. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37606. */
  37607. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37608. /**
  37609. * sets the active camera of the scene using its ID
  37610. * @param id defines the camera's ID
  37611. * @return the new active camera or null if none found.
  37612. */
  37613. setActiveCameraByID(id: string): Nullable<Camera>;
  37614. /**
  37615. * sets the active camera of the scene using its name
  37616. * @param name defines the camera's name
  37617. * @returns the new active camera or null if none found.
  37618. */
  37619. setActiveCameraByName(name: string): Nullable<Camera>;
  37620. /**
  37621. * get an animation group using its name
  37622. * @param name defines the material's name
  37623. * @return the animation group or null if none found.
  37624. */
  37625. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37626. /**
  37627. * Get a material using its unique id
  37628. * @param uniqueId defines the material's unique id
  37629. * @return the material or null if none found.
  37630. */
  37631. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37632. /**
  37633. * get a material using its id
  37634. * @param id defines the material's ID
  37635. * @return the material or null if none found.
  37636. */
  37637. getMaterialByID(id: string): Nullable<Material>;
  37638. /**
  37639. * Gets a the last added material using a given id
  37640. * @param id defines the material's ID
  37641. * @return the last material with the given id or null if none found.
  37642. */
  37643. getLastMaterialByID(id: string): Nullable<Material>;
  37644. /**
  37645. * Gets a material using its name
  37646. * @param name defines the material's name
  37647. * @return the material or null if none found.
  37648. */
  37649. getMaterialByName(name: string): Nullable<Material>;
  37650. /**
  37651. * Get a texture using its unique id
  37652. * @param uniqueId defines the texture's unique id
  37653. * @return the texture or null if none found.
  37654. */
  37655. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37656. /**
  37657. * Gets a camera using its id
  37658. * @param id defines the id to look for
  37659. * @returns the camera or null if not found
  37660. */
  37661. getCameraByID(id: string): Nullable<Camera>;
  37662. /**
  37663. * Gets a camera using its unique id
  37664. * @param uniqueId defines the unique id to look for
  37665. * @returns the camera or null if not found
  37666. */
  37667. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37668. /**
  37669. * Gets a camera using its name
  37670. * @param name defines the camera's name
  37671. * @return the camera or null if none found.
  37672. */
  37673. getCameraByName(name: string): Nullable<Camera>;
  37674. /**
  37675. * Gets a bone using its id
  37676. * @param id defines the bone's id
  37677. * @return the bone or null if not found
  37678. */
  37679. getBoneByID(id: string): Nullable<Bone>;
  37680. /**
  37681. * Gets a bone using its id
  37682. * @param name defines the bone's name
  37683. * @return the bone or null if not found
  37684. */
  37685. getBoneByName(name: string): Nullable<Bone>;
  37686. /**
  37687. * Gets a light node using its name
  37688. * @param name defines the the light's name
  37689. * @return the light or null if none found.
  37690. */
  37691. getLightByName(name: string): Nullable<Light>;
  37692. /**
  37693. * Gets a light node using its id
  37694. * @param id defines the light's id
  37695. * @return the light or null if none found.
  37696. */
  37697. getLightByID(id: string): Nullable<Light>;
  37698. /**
  37699. * Gets a light node using its scene-generated unique ID
  37700. * @param uniqueId defines the light's unique id
  37701. * @return the light or null if none found.
  37702. */
  37703. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37704. /**
  37705. * Gets a particle system by id
  37706. * @param id defines the particle system id
  37707. * @return the corresponding system or null if none found
  37708. */
  37709. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37710. /**
  37711. * Gets a geometry using its ID
  37712. * @param id defines the geometry's id
  37713. * @return the geometry or null if none found.
  37714. */
  37715. getGeometryByID(id: string): Nullable<Geometry>;
  37716. private _getGeometryByUniqueID;
  37717. /**
  37718. * Add a new geometry to this scene
  37719. * @param geometry defines the geometry to be added to the scene.
  37720. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37721. * @return a boolean defining if the geometry was added or not
  37722. */
  37723. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37724. /**
  37725. * Removes an existing geometry
  37726. * @param geometry defines the geometry to be removed from the scene
  37727. * @return a boolean defining if the geometry was removed or not
  37728. */
  37729. removeGeometry(geometry: Geometry): boolean;
  37730. /**
  37731. * Gets the list of geometries attached to the scene
  37732. * @returns an array of Geometry
  37733. */
  37734. getGeometries(): Geometry[];
  37735. /**
  37736. * Gets the first added mesh found of a given ID
  37737. * @param id defines the id to search for
  37738. * @return the mesh found or null if not found at all
  37739. */
  37740. getMeshByID(id: string): Nullable<AbstractMesh>;
  37741. /**
  37742. * Gets a list of meshes using their id
  37743. * @param id defines the id to search for
  37744. * @returns a list of meshes
  37745. */
  37746. getMeshesByID(id: string): Array<AbstractMesh>;
  37747. /**
  37748. * Gets the first added transform node found of a given ID
  37749. * @param id defines the id to search for
  37750. * @return the found transform node or null if not found at all.
  37751. */
  37752. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37753. /**
  37754. * Gets a transform node with its auto-generated unique id
  37755. * @param uniqueId efines the unique id to search for
  37756. * @return the found transform node or null if not found at all.
  37757. */
  37758. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37759. /**
  37760. * Gets a list of transform nodes using their id
  37761. * @param id defines the id to search for
  37762. * @returns a list of transform nodes
  37763. */
  37764. getTransformNodesByID(id: string): Array<TransformNode>;
  37765. /**
  37766. * Gets a mesh with its auto-generated unique id
  37767. * @param uniqueId defines the unique id to search for
  37768. * @return the found mesh or null if not found at all.
  37769. */
  37770. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37771. /**
  37772. * Gets a the last added mesh using a given id
  37773. * @param id defines the id to search for
  37774. * @return the found mesh or null if not found at all.
  37775. */
  37776. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37777. /**
  37778. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37779. * @param id defines the id to search for
  37780. * @return the found node or null if not found at all
  37781. */
  37782. getLastEntryByID(id: string): Nullable<Node>;
  37783. /**
  37784. * Gets a node (Mesh, Camera, Light) using a given id
  37785. * @param id defines the id to search for
  37786. * @return the found node or null if not found at all
  37787. */
  37788. getNodeByID(id: string): Nullable<Node>;
  37789. /**
  37790. * Gets a node (Mesh, Camera, Light) using a given name
  37791. * @param name defines the name to search for
  37792. * @return the found node or null if not found at all.
  37793. */
  37794. getNodeByName(name: string): Nullable<Node>;
  37795. /**
  37796. * Gets a mesh using a given name
  37797. * @param name defines the name to search for
  37798. * @return the found mesh or null if not found at all.
  37799. */
  37800. getMeshByName(name: string): Nullable<AbstractMesh>;
  37801. /**
  37802. * Gets a transform node using a given name
  37803. * @param name defines the name to search for
  37804. * @return the found transform node or null if not found at all.
  37805. */
  37806. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37807. /**
  37808. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37809. * @param id defines the id to search for
  37810. * @return the found skeleton or null if not found at all.
  37811. */
  37812. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37813. /**
  37814. * Gets a skeleton using a given auto generated unique id
  37815. * @param uniqueId defines the unique id to search for
  37816. * @return the found skeleton or null if not found at all.
  37817. */
  37818. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37819. /**
  37820. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37821. * @param id defines the id to search for
  37822. * @return the found skeleton or null if not found at all.
  37823. */
  37824. getSkeletonById(id: string): Nullable<Skeleton>;
  37825. /**
  37826. * Gets a skeleton using a given name
  37827. * @param name defines the name to search for
  37828. * @return the found skeleton or null if not found at all.
  37829. */
  37830. getSkeletonByName(name: string): Nullable<Skeleton>;
  37831. /**
  37832. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37833. * @param id defines the id to search for
  37834. * @return the found morph target manager or null if not found at all.
  37835. */
  37836. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37837. /**
  37838. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37839. * @param id defines the id to search for
  37840. * @return the found morph target or null if not found at all.
  37841. */
  37842. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37843. /**
  37844. * Gets a boolean indicating if the given mesh is active
  37845. * @param mesh defines the mesh to look for
  37846. * @returns true if the mesh is in the active list
  37847. */
  37848. isActiveMesh(mesh: AbstractMesh): boolean;
  37849. /**
  37850. * Return a unique id as a string which can serve as an identifier for the scene
  37851. */
  37852. get uid(): string;
  37853. /**
  37854. * Add an externaly attached data from its key.
  37855. * This method call will fail and return false, if such key already exists.
  37856. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37857. * @param key the unique key that identifies the data
  37858. * @param data the data object to associate to the key for this Engine instance
  37859. * @return true if no such key were already present and the data was added successfully, false otherwise
  37860. */
  37861. addExternalData<T>(key: string, data: T): boolean;
  37862. /**
  37863. * Get an externaly attached data from its key
  37864. * @param key the unique key that identifies the data
  37865. * @return the associated data, if present (can be null), or undefined if not present
  37866. */
  37867. getExternalData<T>(key: string): Nullable<T>;
  37868. /**
  37869. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37870. * @param key the unique key that identifies the data
  37871. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37872. * @return the associated data, can be null if the factory returned null.
  37873. */
  37874. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37875. /**
  37876. * Remove an externaly attached data from the Engine instance
  37877. * @param key the unique key that identifies the data
  37878. * @return true if the data was successfully removed, false if it doesn't exist
  37879. */
  37880. removeExternalData(key: string): boolean;
  37881. private _evaluateSubMesh;
  37882. /**
  37883. * Clear the processed materials smart array preventing retention point in material dispose.
  37884. */
  37885. freeProcessedMaterials(): void;
  37886. private _preventFreeActiveMeshesAndRenderingGroups;
  37887. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37888. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37889. * when disposing several meshes in a row or a hierarchy of meshes.
  37890. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37891. */
  37892. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37893. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37894. /**
  37895. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37896. */
  37897. freeActiveMeshes(): void;
  37898. /**
  37899. * Clear the info related to rendering groups preventing retention points during dispose.
  37900. */
  37901. freeRenderingGroups(): void;
  37902. /** @hidden */
  37903. _isInIntermediateRendering(): boolean;
  37904. /**
  37905. * Lambda returning the list of potentially active meshes.
  37906. */
  37907. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37908. /**
  37909. * Lambda returning the list of potentially active sub meshes.
  37910. */
  37911. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37912. /**
  37913. * Lambda returning the list of potentially intersecting sub meshes.
  37914. */
  37915. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37916. /**
  37917. * Lambda returning the list of potentially colliding sub meshes.
  37918. */
  37919. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37920. private _activeMeshesFrozen;
  37921. private _skipEvaluateActiveMeshesCompletely;
  37922. /**
  37923. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37924. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37925. * @returns the current scene
  37926. */
  37927. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37928. /**
  37929. * Use this function to restart evaluating active meshes on every frame
  37930. * @returns the current scene
  37931. */
  37932. unfreezeActiveMeshes(): Scene;
  37933. private _evaluateActiveMeshes;
  37934. private _activeMesh;
  37935. /**
  37936. * Update the transform matrix to update from the current active camera
  37937. * @param force defines a boolean used to force the update even if cache is up to date
  37938. */
  37939. updateTransformMatrix(force?: boolean): void;
  37940. private _bindFrameBuffer;
  37941. /** @hidden */
  37942. _allowPostProcessClearColor: boolean;
  37943. /** @hidden */
  37944. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37945. private _processSubCameras;
  37946. private _checkIntersections;
  37947. /** @hidden */
  37948. _advancePhysicsEngineStep(step: number): void;
  37949. /**
  37950. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37951. */
  37952. getDeterministicFrameTime: () => number;
  37953. /** @hidden */
  37954. _animate(): void;
  37955. /** Execute all animations (for a frame) */
  37956. animate(): void;
  37957. /**
  37958. * Render the scene
  37959. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37960. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37961. */
  37962. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37963. /**
  37964. * Freeze all materials
  37965. * A frozen material will not be updatable but should be faster to render
  37966. */
  37967. freezeMaterials(): void;
  37968. /**
  37969. * Unfreeze all materials
  37970. * A frozen material will not be updatable but should be faster to render
  37971. */
  37972. unfreezeMaterials(): void;
  37973. /**
  37974. * Releases all held ressources
  37975. */
  37976. dispose(): void;
  37977. /**
  37978. * Gets if the scene is already disposed
  37979. */
  37980. get isDisposed(): boolean;
  37981. /**
  37982. * Call this function to reduce memory footprint of the scene.
  37983. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37984. */
  37985. clearCachedVertexData(): void;
  37986. /**
  37987. * This function will remove the local cached buffer data from texture.
  37988. * It will save memory but will prevent the texture from being rebuilt
  37989. */
  37990. cleanCachedTextureBuffer(): void;
  37991. /**
  37992. * Get the world extend vectors with an optional filter
  37993. *
  37994. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37995. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37996. */
  37997. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37998. min: Vector3;
  37999. max: Vector3;
  38000. };
  38001. /**
  38002. * Creates a ray that can be used to pick in the scene
  38003. * @param x defines the x coordinate of the origin (on-screen)
  38004. * @param y defines the y coordinate of the origin (on-screen)
  38005. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38006. * @param camera defines the camera to use for the picking
  38007. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38008. * @returns a Ray
  38009. */
  38010. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38011. /**
  38012. * Creates a ray that can be used to pick in the scene
  38013. * @param x defines the x coordinate of the origin (on-screen)
  38014. * @param y defines the y coordinate of the origin (on-screen)
  38015. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38016. * @param result defines the ray where to store the picking ray
  38017. * @param camera defines the camera to use for the picking
  38018. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38019. * @returns the current scene
  38020. */
  38021. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38022. /**
  38023. * Creates a ray that can be used to pick in the scene
  38024. * @param x defines the x coordinate of the origin (on-screen)
  38025. * @param y defines the y coordinate of the origin (on-screen)
  38026. * @param camera defines the camera to use for the picking
  38027. * @returns a Ray
  38028. */
  38029. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38030. /**
  38031. * Creates a ray that can be used to pick in the scene
  38032. * @param x defines the x coordinate of the origin (on-screen)
  38033. * @param y defines the y coordinate of the origin (on-screen)
  38034. * @param result defines the ray where to store the picking ray
  38035. * @param camera defines the camera to use for the picking
  38036. * @returns the current scene
  38037. */
  38038. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38039. /** Launch a ray to try to pick a mesh in the scene
  38040. * @param x position on screen
  38041. * @param y position on screen
  38042. * @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
  38043. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38044. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38045. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38046. * @returns a PickingInfo
  38047. */
  38048. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38049. /** Use the given ray to pick a mesh in the scene
  38050. * @param ray The ray to use to pick meshes
  38051. * @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
  38052. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38053. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38054. * @returns a PickingInfo
  38055. */
  38056. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38057. /**
  38058. * Launch a ray to try to pick a mesh in the scene
  38059. * @param x X position on screen
  38060. * @param y Y position on screen
  38061. * @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
  38062. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38063. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38064. * @returns an array of PickingInfo
  38065. */
  38066. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38067. /**
  38068. * Launch a ray to try to pick a mesh in the scene
  38069. * @param ray Ray to use
  38070. * @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
  38071. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38072. * @returns an array of PickingInfo
  38073. */
  38074. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38075. /**
  38076. * Force the value of meshUnderPointer
  38077. * @param mesh defines the mesh to use
  38078. */
  38079. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38080. /**
  38081. * Gets the mesh under the pointer
  38082. * @returns a Mesh or null if no mesh is under the pointer
  38083. */
  38084. getPointerOverMesh(): Nullable<AbstractMesh>;
  38085. /** @hidden */
  38086. _rebuildGeometries(): void;
  38087. /** @hidden */
  38088. _rebuildTextures(): void;
  38089. private _getByTags;
  38090. /**
  38091. * Get a list of meshes by tags
  38092. * @param tagsQuery defines the tags query to use
  38093. * @param forEach defines a predicate used to filter results
  38094. * @returns an array of Mesh
  38095. */
  38096. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38097. /**
  38098. * Get a list of cameras by tags
  38099. * @param tagsQuery defines the tags query to use
  38100. * @param forEach defines a predicate used to filter results
  38101. * @returns an array of Camera
  38102. */
  38103. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38104. /**
  38105. * Get a list of lights by tags
  38106. * @param tagsQuery defines the tags query to use
  38107. * @param forEach defines a predicate used to filter results
  38108. * @returns an array of Light
  38109. */
  38110. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38111. /**
  38112. * Get a list of materials by tags
  38113. * @param tagsQuery defines the tags query to use
  38114. * @param forEach defines a predicate used to filter results
  38115. * @returns an array of Material
  38116. */
  38117. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38118. /**
  38119. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38120. * This allowed control for front to back rendering or reversly depending of the special needs.
  38121. *
  38122. * @param renderingGroupId The rendering group id corresponding to its index
  38123. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38124. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38125. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38126. */
  38127. 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;
  38128. /**
  38129. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38130. *
  38131. * @param renderingGroupId The rendering group id corresponding to its index
  38132. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38133. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38134. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38135. */
  38136. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38137. /**
  38138. * Gets the current auto clear configuration for one rendering group of the rendering
  38139. * manager.
  38140. * @param index the rendering group index to get the information for
  38141. * @returns The auto clear setup for the requested rendering group
  38142. */
  38143. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38144. private _blockMaterialDirtyMechanism;
  38145. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38146. get blockMaterialDirtyMechanism(): boolean;
  38147. set blockMaterialDirtyMechanism(value: boolean);
  38148. /**
  38149. * Will flag all materials as dirty to trigger new shader compilation
  38150. * @param flag defines the flag used to specify which material part must be marked as dirty
  38151. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38152. */
  38153. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38154. /** @hidden */
  38155. _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;
  38156. /** @hidden */
  38157. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38158. /** @hidden */
  38159. _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;
  38160. /** @hidden */
  38161. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38162. /** @hidden */
  38163. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38164. /** @hidden */
  38165. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38166. }
  38167. }
  38168. declare module "babylonjs/assetContainer" {
  38169. import { AbstractScene } from "babylonjs/abstractScene";
  38170. import { Scene } from "babylonjs/scene";
  38171. import { Mesh } from "babylonjs/Meshes/mesh";
  38172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38173. import { Skeleton } from "babylonjs/Bones/skeleton";
  38174. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38175. import { Animatable } from "babylonjs/Animations/animatable";
  38176. import { Nullable } from "babylonjs/types";
  38177. import { Node } from "babylonjs/node";
  38178. /**
  38179. * Set of assets to keep when moving a scene into an asset container.
  38180. */
  38181. export class KeepAssets extends AbstractScene {
  38182. }
  38183. /**
  38184. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38185. */
  38186. export class InstantiatedEntries {
  38187. /**
  38188. * List of new root nodes (eg. nodes with no parent)
  38189. */
  38190. rootNodes: TransformNode[];
  38191. /**
  38192. * List of new skeletons
  38193. */
  38194. skeletons: Skeleton[];
  38195. /**
  38196. * List of new animation groups
  38197. */
  38198. animationGroups: AnimationGroup[];
  38199. }
  38200. /**
  38201. * Container with a set of assets that can be added or removed from a scene.
  38202. */
  38203. export class AssetContainer extends AbstractScene {
  38204. private _wasAddedToScene;
  38205. /**
  38206. * The scene the AssetContainer belongs to.
  38207. */
  38208. scene: Scene;
  38209. /**
  38210. * Instantiates an AssetContainer.
  38211. * @param scene The scene the AssetContainer belongs to.
  38212. */
  38213. constructor(scene: Scene);
  38214. /**
  38215. * Instantiate or clone all meshes and add the new ones to the scene.
  38216. * Skeletons and animation groups will all be cloned
  38217. * @param nameFunction defines an optional function used to get new names for clones
  38218. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38219. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38220. */
  38221. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38222. /**
  38223. * Adds all the assets from the container to the scene.
  38224. */
  38225. addAllToScene(): void;
  38226. /**
  38227. * Removes all the assets in the container from the scene
  38228. */
  38229. removeAllFromScene(): void;
  38230. /**
  38231. * Disposes all the assets in the container
  38232. */
  38233. dispose(): void;
  38234. private _moveAssets;
  38235. /**
  38236. * Removes all the assets contained in the scene and adds them to the container.
  38237. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38238. */
  38239. moveAllFromScene(keepAssets?: KeepAssets): void;
  38240. /**
  38241. * 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.
  38242. * @returns the root mesh
  38243. */
  38244. createRootMesh(): Mesh;
  38245. /**
  38246. * Merge animations from this asset container into a scene
  38247. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38248. * @param animatables set of animatables to retarget to a node from the scene
  38249. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38250. */
  38251. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38252. }
  38253. }
  38254. declare module "babylonjs/abstractScene" {
  38255. import { Scene } from "babylonjs/scene";
  38256. import { Nullable } from "babylonjs/types";
  38257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38258. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38259. import { Geometry } from "babylonjs/Meshes/geometry";
  38260. import { Skeleton } from "babylonjs/Bones/skeleton";
  38261. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38262. import { AssetContainer } from "babylonjs/assetContainer";
  38263. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38264. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38266. import { Material } from "babylonjs/Materials/material";
  38267. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38268. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38269. import { Camera } from "babylonjs/Cameras/camera";
  38270. import { Light } from "babylonjs/Lights/light";
  38271. import { Node } from "babylonjs/node";
  38272. import { Animation } from "babylonjs/Animations/animation";
  38273. /**
  38274. * Defines how the parser contract is defined.
  38275. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38276. */
  38277. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38278. /**
  38279. * Defines how the individual parser contract is defined.
  38280. * These parser can parse an individual asset
  38281. */
  38282. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38283. /**
  38284. * Base class of the scene acting as a container for the different elements composing a scene.
  38285. * This class is dynamically extended by the different components of the scene increasing
  38286. * flexibility and reducing coupling
  38287. */
  38288. export abstract class AbstractScene {
  38289. /**
  38290. * Stores the list of available parsers in the application.
  38291. */
  38292. private static _BabylonFileParsers;
  38293. /**
  38294. * Stores the list of available individual parsers in the application.
  38295. */
  38296. private static _IndividualBabylonFileParsers;
  38297. /**
  38298. * Adds a parser in the list of available ones
  38299. * @param name Defines the name of the parser
  38300. * @param parser Defines the parser to add
  38301. */
  38302. static AddParser(name: string, parser: BabylonFileParser): void;
  38303. /**
  38304. * Gets a general parser from the list of avaialble ones
  38305. * @param name Defines the name of the parser
  38306. * @returns the requested parser or null
  38307. */
  38308. static GetParser(name: string): Nullable<BabylonFileParser>;
  38309. /**
  38310. * Adds n individual parser in the list of available ones
  38311. * @param name Defines the name of the parser
  38312. * @param parser Defines the parser to add
  38313. */
  38314. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38315. /**
  38316. * Gets an individual parser from the list of avaialble ones
  38317. * @param name Defines the name of the parser
  38318. * @returns the requested parser or null
  38319. */
  38320. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38321. /**
  38322. * Parser json data and populate both a scene and its associated container object
  38323. * @param jsonData Defines the data to parse
  38324. * @param scene Defines the scene to parse the data for
  38325. * @param container Defines the container attached to the parsing sequence
  38326. * @param rootUrl Defines the root url of the data
  38327. */
  38328. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38329. /**
  38330. * Gets the list of root nodes (ie. nodes with no parent)
  38331. */
  38332. rootNodes: Node[];
  38333. /** All of the cameras added to this scene
  38334. * @see http://doc.babylonjs.com/babylon101/cameras
  38335. */
  38336. cameras: Camera[];
  38337. /**
  38338. * All of the lights added to this scene
  38339. * @see http://doc.babylonjs.com/babylon101/lights
  38340. */
  38341. lights: Light[];
  38342. /**
  38343. * All of the (abstract) meshes added to this scene
  38344. */
  38345. meshes: AbstractMesh[];
  38346. /**
  38347. * The list of skeletons added to the scene
  38348. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38349. */
  38350. skeletons: Skeleton[];
  38351. /**
  38352. * All of the particle systems added to this scene
  38353. * @see http://doc.babylonjs.com/babylon101/particles
  38354. */
  38355. particleSystems: IParticleSystem[];
  38356. /**
  38357. * Gets a list of Animations associated with the scene
  38358. */
  38359. animations: Animation[];
  38360. /**
  38361. * All of the animation groups added to this scene
  38362. * @see http://doc.babylonjs.com/how_to/group
  38363. */
  38364. animationGroups: AnimationGroup[];
  38365. /**
  38366. * All of the multi-materials added to this scene
  38367. * @see http://doc.babylonjs.com/how_to/multi_materials
  38368. */
  38369. multiMaterials: MultiMaterial[];
  38370. /**
  38371. * All of the materials added to this scene
  38372. * In the context of a Scene, it is not supposed to be modified manually.
  38373. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38374. * Note also that the order of the Material within the array is not significant and might change.
  38375. * @see http://doc.babylonjs.com/babylon101/materials
  38376. */
  38377. materials: Material[];
  38378. /**
  38379. * The list of morph target managers added to the scene
  38380. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38381. */
  38382. morphTargetManagers: MorphTargetManager[];
  38383. /**
  38384. * The list of geometries used in the scene.
  38385. */
  38386. geometries: Geometry[];
  38387. /**
  38388. * All of the tranform nodes added to this scene
  38389. * In the context of a Scene, it is not supposed to be modified manually.
  38390. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38391. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38392. * @see http://doc.babylonjs.com/how_to/transformnode
  38393. */
  38394. transformNodes: TransformNode[];
  38395. /**
  38396. * ActionManagers available on the scene.
  38397. */
  38398. actionManagers: AbstractActionManager[];
  38399. /**
  38400. * Textures to keep.
  38401. */
  38402. textures: BaseTexture[];
  38403. /**
  38404. * Environment texture for the scene
  38405. */
  38406. environmentTexture: Nullable<BaseTexture>;
  38407. /**
  38408. * @returns all meshes, lights, cameras, transformNodes and bones
  38409. */
  38410. getNodes(): Array<Node>;
  38411. }
  38412. }
  38413. declare module "babylonjs/Audio/sound" {
  38414. import { Observable } from "babylonjs/Misc/observable";
  38415. import { Vector3 } from "babylonjs/Maths/math.vector";
  38416. import { Nullable } from "babylonjs/types";
  38417. import { Scene } from "babylonjs/scene";
  38418. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38419. /**
  38420. * Interface used to define options for Sound class
  38421. */
  38422. export interface ISoundOptions {
  38423. /**
  38424. * Does the sound autoplay once loaded.
  38425. */
  38426. autoplay?: boolean;
  38427. /**
  38428. * Does the sound loop after it finishes playing once.
  38429. */
  38430. loop?: boolean;
  38431. /**
  38432. * Sound's volume
  38433. */
  38434. volume?: number;
  38435. /**
  38436. * Is it a spatial sound?
  38437. */
  38438. spatialSound?: boolean;
  38439. /**
  38440. * Maximum distance to hear that sound
  38441. */
  38442. maxDistance?: number;
  38443. /**
  38444. * Uses user defined attenuation function
  38445. */
  38446. useCustomAttenuation?: boolean;
  38447. /**
  38448. * Define the roll off factor of spatial sounds.
  38449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38450. */
  38451. rolloffFactor?: number;
  38452. /**
  38453. * Define the reference distance the sound should be heard perfectly.
  38454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38455. */
  38456. refDistance?: number;
  38457. /**
  38458. * Define the distance attenuation model the sound will follow.
  38459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38460. */
  38461. distanceModel?: string;
  38462. /**
  38463. * Defines the playback speed (1 by default)
  38464. */
  38465. playbackRate?: number;
  38466. /**
  38467. * Defines if the sound is from a streaming source
  38468. */
  38469. streaming?: boolean;
  38470. /**
  38471. * Defines an optional length (in seconds) inside the sound file
  38472. */
  38473. length?: number;
  38474. /**
  38475. * Defines an optional offset (in seconds) inside the sound file
  38476. */
  38477. offset?: number;
  38478. /**
  38479. * If true, URLs will not be required to state the audio file codec to use.
  38480. */
  38481. skipCodecCheck?: boolean;
  38482. }
  38483. /**
  38484. * Defines a sound that can be played in the application.
  38485. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38487. */
  38488. export class Sound {
  38489. /**
  38490. * The name of the sound in the scene.
  38491. */
  38492. name: string;
  38493. /**
  38494. * Does the sound autoplay once loaded.
  38495. */
  38496. autoplay: boolean;
  38497. /**
  38498. * Does the sound loop after it finishes playing once.
  38499. */
  38500. loop: boolean;
  38501. /**
  38502. * Does the sound use a custom attenuation curve to simulate the falloff
  38503. * happening when the source gets further away from the camera.
  38504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38505. */
  38506. useCustomAttenuation: boolean;
  38507. /**
  38508. * The sound track id this sound belongs to.
  38509. */
  38510. soundTrackId: number;
  38511. /**
  38512. * Is this sound currently played.
  38513. */
  38514. isPlaying: boolean;
  38515. /**
  38516. * Is this sound currently paused.
  38517. */
  38518. isPaused: boolean;
  38519. /**
  38520. * Does this sound enables spatial sound.
  38521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38522. */
  38523. spatialSound: boolean;
  38524. /**
  38525. * Define the reference distance the sound should be heard perfectly.
  38526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38527. */
  38528. refDistance: number;
  38529. /**
  38530. * Define the roll off factor of spatial sounds.
  38531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38532. */
  38533. rolloffFactor: number;
  38534. /**
  38535. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38537. */
  38538. maxDistance: number;
  38539. /**
  38540. * Define the distance attenuation model the sound will follow.
  38541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38542. */
  38543. distanceModel: string;
  38544. /**
  38545. * @hidden
  38546. * Back Compat
  38547. **/
  38548. onended: () => any;
  38549. /**
  38550. * Observable event when the current playing sound finishes.
  38551. */
  38552. onEndedObservable: Observable<Sound>;
  38553. private _panningModel;
  38554. private _playbackRate;
  38555. private _streaming;
  38556. private _startTime;
  38557. private _startOffset;
  38558. private _position;
  38559. /** @hidden */
  38560. _positionInEmitterSpace: boolean;
  38561. private _localDirection;
  38562. private _volume;
  38563. private _isReadyToPlay;
  38564. private _isDirectional;
  38565. private _readyToPlayCallback;
  38566. private _audioBuffer;
  38567. private _soundSource;
  38568. private _streamingSource;
  38569. private _soundPanner;
  38570. private _soundGain;
  38571. private _inputAudioNode;
  38572. private _outputAudioNode;
  38573. private _coneInnerAngle;
  38574. private _coneOuterAngle;
  38575. private _coneOuterGain;
  38576. private _scene;
  38577. private _connectedTransformNode;
  38578. private _customAttenuationFunction;
  38579. private _registerFunc;
  38580. private _isOutputConnected;
  38581. private _htmlAudioElement;
  38582. private _urlType;
  38583. private _length?;
  38584. private _offset?;
  38585. /** @hidden */
  38586. static _SceneComponentInitialization: (scene: Scene) => void;
  38587. /**
  38588. * Create a sound and attach it to a scene
  38589. * @param name Name of your sound
  38590. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38591. * @param scene defines the scene the sound belongs to
  38592. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38593. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38594. */
  38595. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38596. /**
  38597. * Release the sound and its associated resources
  38598. */
  38599. dispose(): void;
  38600. /**
  38601. * Gets if the sounds is ready to be played or not.
  38602. * @returns true if ready, otherwise false
  38603. */
  38604. isReady(): boolean;
  38605. private _soundLoaded;
  38606. /**
  38607. * Sets the data of the sound from an audiobuffer
  38608. * @param audioBuffer The audioBuffer containing the data
  38609. */
  38610. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38611. /**
  38612. * Updates the current sounds options such as maxdistance, loop...
  38613. * @param options A JSON object containing values named as the object properties
  38614. */
  38615. updateOptions(options: ISoundOptions): void;
  38616. private _createSpatialParameters;
  38617. private _updateSpatialParameters;
  38618. /**
  38619. * Switch the panning model to HRTF:
  38620. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38622. */
  38623. switchPanningModelToHRTF(): void;
  38624. /**
  38625. * Switch the panning model to Equal Power:
  38626. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38628. */
  38629. switchPanningModelToEqualPower(): void;
  38630. private _switchPanningModel;
  38631. /**
  38632. * Connect this sound to a sound track audio node like gain...
  38633. * @param soundTrackAudioNode the sound track audio node to connect to
  38634. */
  38635. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38636. /**
  38637. * Transform this sound into a directional source
  38638. * @param coneInnerAngle Size of the inner cone in degree
  38639. * @param coneOuterAngle Size of the outer cone in degree
  38640. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38641. */
  38642. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38643. /**
  38644. * Gets or sets the inner angle for the directional cone.
  38645. */
  38646. get directionalConeInnerAngle(): number;
  38647. /**
  38648. * Gets or sets the inner angle for the directional cone.
  38649. */
  38650. set directionalConeInnerAngle(value: number);
  38651. /**
  38652. * Gets or sets the outer angle for the directional cone.
  38653. */
  38654. get directionalConeOuterAngle(): number;
  38655. /**
  38656. * Gets or sets the outer angle for the directional cone.
  38657. */
  38658. set directionalConeOuterAngle(value: number);
  38659. /**
  38660. * Sets the position of the emitter if spatial sound is enabled
  38661. * @param newPosition Defines the new posisiton
  38662. */
  38663. setPosition(newPosition: Vector3): void;
  38664. /**
  38665. * Sets the local direction of the emitter if spatial sound is enabled
  38666. * @param newLocalDirection Defines the new local direction
  38667. */
  38668. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38669. private _updateDirection;
  38670. /** @hidden */
  38671. updateDistanceFromListener(): void;
  38672. /**
  38673. * Sets a new custom attenuation function for the sound.
  38674. * @param callback Defines the function used for the attenuation
  38675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38676. */
  38677. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38678. /**
  38679. * Play the sound
  38680. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38681. * @param offset (optional) Start the sound at a specific time in seconds
  38682. * @param length (optional) Sound duration (in seconds)
  38683. */
  38684. play(time?: number, offset?: number, length?: number): void;
  38685. private _onended;
  38686. /**
  38687. * Stop the sound
  38688. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38689. */
  38690. stop(time?: number): void;
  38691. /**
  38692. * Put the sound in pause
  38693. */
  38694. pause(): void;
  38695. /**
  38696. * Sets a dedicated volume for this sounds
  38697. * @param newVolume Define the new volume of the sound
  38698. * @param time Define time for gradual change to new volume
  38699. */
  38700. setVolume(newVolume: number, time?: number): void;
  38701. /**
  38702. * Set the sound play back rate
  38703. * @param newPlaybackRate Define the playback rate the sound should be played at
  38704. */
  38705. setPlaybackRate(newPlaybackRate: number): void;
  38706. /**
  38707. * Gets the volume of the sound.
  38708. * @returns the volume of the sound
  38709. */
  38710. getVolume(): number;
  38711. /**
  38712. * Attach the sound to a dedicated mesh
  38713. * @param transformNode The transform node to connect the sound with
  38714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38715. */
  38716. attachToMesh(transformNode: TransformNode): void;
  38717. /**
  38718. * Detach the sound from the previously attached mesh
  38719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38720. */
  38721. detachFromMesh(): void;
  38722. private _onRegisterAfterWorldMatrixUpdate;
  38723. /**
  38724. * Clone the current sound in the scene.
  38725. * @returns the new sound clone
  38726. */
  38727. clone(): Nullable<Sound>;
  38728. /**
  38729. * Gets the current underlying audio buffer containing the data
  38730. * @returns the audio buffer
  38731. */
  38732. getAudioBuffer(): Nullable<AudioBuffer>;
  38733. /**
  38734. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38735. * @returns the source node
  38736. */
  38737. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38738. /**
  38739. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38740. * @returns the gain node
  38741. */
  38742. getSoundGain(): Nullable<GainNode>;
  38743. /**
  38744. * Serializes the Sound in a JSON representation
  38745. * @returns the JSON representation of the sound
  38746. */
  38747. serialize(): any;
  38748. /**
  38749. * Parse a JSON representation of a sound to innstantiate in a given scene
  38750. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38751. * @param scene Define the scene the new parsed sound should be created in
  38752. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38753. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38754. * @returns the newly parsed sound
  38755. */
  38756. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38757. }
  38758. }
  38759. declare module "babylonjs/Actions/directAudioActions" {
  38760. import { Action } from "babylonjs/Actions/action";
  38761. import { Condition } from "babylonjs/Actions/condition";
  38762. import { Sound } from "babylonjs/Audio/sound";
  38763. /**
  38764. * This defines an action helpful to play a defined sound on a triggered action.
  38765. */
  38766. export class PlaySoundAction extends Action {
  38767. private _sound;
  38768. /**
  38769. * Instantiate the action
  38770. * @param triggerOptions defines the trigger options
  38771. * @param sound defines the sound to play
  38772. * @param condition defines the trigger related conditions
  38773. */
  38774. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38775. /** @hidden */
  38776. _prepare(): void;
  38777. /**
  38778. * Execute the action and play the sound.
  38779. */
  38780. execute(): void;
  38781. /**
  38782. * Serializes the actions and its related information.
  38783. * @param parent defines the object to serialize in
  38784. * @returns the serialized object
  38785. */
  38786. serialize(parent: any): any;
  38787. }
  38788. /**
  38789. * This defines an action helpful to stop a defined sound on a triggered action.
  38790. */
  38791. export class StopSoundAction extends Action {
  38792. private _sound;
  38793. /**
  38794. * Instantiate the action
  38795. * @param triggerOptions defines the trigger options
  38796. * @param sound defines the sound to stop
  38797. * @param condition defines the trigger related conditions
  38798. */
  38799. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38800. /** @hidden */
  38801. _prepare(): void;
  38802. /**
  38803. * Execute the action and stop the sound.
  38804. */
  38805. execute(): void;
  38806. /**
  38807. * Serializes the actions and its related information.
  38808. * @param parent defines the object to serialize in
  38809. * @returns the serialized object
  38810. */
  38811. serialize(parent: any): any;
  38812. }
  38813. }
  38814. declare module "babylonjs/Actions/interpolateValueAction" {
  38815. import { Action } from "babylonjs/Actions/action";
  38816. import { Condition } from "babylonjs/Actions/condition";
  38817. import { Observable } from "babylonjs/Misc/observable";
  38818. /**
  38819. * This defines an action responsible to change the value of a property
  38820. * by interpolating between its current value and the newly set one once triggered.
  38821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38822. */
  38823. export class InterpolateValueAction extends Action {
  38824. /**
  38825. * Defines the path of the property where the value should be interpolated
  38826. */
  38827. propertyPath: string;
  38828. /**
  38829. * Defines the target value at the end of the interpolation.
  38830. */
  38831. value: any;
  38832. /**
  38833. * Defines the time it will take for the property to interpolate to the value.
  38834. */
  38835. duration: number;
  38836. /**
  38837. * Defines if the other scene animations should be stopped when the action has been triggered
  38838. */
  38839. stopOtherAnimations?: boolean;
  38840. /**
  38841. * Defines a callback raised once the interpolation animation has been done.
  38842. */
  38843. onInterpolationDone?: () => void;
  38844. /**
  38845. * Observable triggered once the interpolation animation has been done.
  38846. */
  38847. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38848. private _target;
  38849. private _effectiveTarget;
  38850. private _property;
  38851. /**
  38852. * Instantiate the action
  38853. * @param triggerOptions defines the trigger options
  38854. * @param target defines the object containing the value to interpolate
  38855. * @param propertyPath defines the path to the property in the target object
  38856. * @param value defines the target value at the end of the interpolation
  38857. * @param duration deines the time it will take for the property to interpolate to the value.
  38858. * @param condition defines the trigger related conditions
  38859. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38860. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38861. */
  38862. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38863. /** @hidden */
  38864. _prepare(): void;
  38865. /**
  38866. * Execute the action starts the value interpolation.
  38867. */
  38868. execute(): void;
  38869. /**
  38870. * Serializes the actions and its related information.
  38871. * @param parent defines the object to serialize in
  38872. * @returns the serialized object
  38873. */
  38874. serialize(parent: any): any;
  38875. }
  38876. }
  38877. declare module "babylonjs/Actions/index" {
  38878. export * from "babylonjs/Actions/abstractActionManager";
  38879. export * from "babylonjs/Actions/action";
  38880. export * from "babylonjs/Actions/actionEvent";
  38881. export * from "babylonjs/Actions/actionManager";
  38882. export * from "babylonjs/Actions/condition";
  38883. export * from "babylonjs/Actions/directActions";
  38884. export * from "babylonjs/Actions/directAudioActions";
  38885. export * from "babylonjs/Actions/interpolateValueAction";
  38886. }
  38887. declare module "babylonjs/Animations/index" {
  38888. export * from "babylonjs/Animations/animatable";
  38889. export * from "babylonjs/Animations/animation";
  38890. export * from "babylonjs/Animations/animationGroup";
  38891. export * from "babylonjs/Animations/animationPropertiesOverride";
  38892. export * from "babylonjs/Animations/easing";
  38893. export * from "babylonjs/Animations/runtimeAnimation";
  38894. export * from "babylonjs/Animations/animationEvent";
  38895. export * from "babylonjs/Animations/animationGroup";
  38896. export * from "babylonjs/Animations/animationKey";
  38897. export * from "babylonjs/Animations/animationRange";
  38898. export * from "babylonjs/Animations/animatable.interface";
  38899. }
  38900. declare module "babylonjs/Audio/soundTrack" {
  38901. import { Sound } from "babylonjs/Audio/sound";
  38902. import { Analyser } from "babylonjs/Audio/analyser";
  38903. import { Scene } from "babylonjs/scene";
  38904. /**
  38905. * Options allowed during the creation of a sound track.
  38906. */
  38907. export interface ISoundTrackOptions {
  38908. /**
  38909. * The volume the sound track should take during creation
  38910. */
  38911. volume?: number;
  38912. /**
  38913. * Define if the sound track is the main sound track of the scene
  38914. */
  38915. mainTrack?: boolean;
  38916. }
  38917. /**
  38918. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38919. * It will be also used in a future release to apply effects on a specific track.
  38920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38921. */
  38922. export class SoundTrack {
  38923. /**
  38924. * The unique identifier of the sound track in the scene.
  38925. */
  38926. id: number;
  38927. /**
  38928. * The list of sounds included in the sound track.
  38929. */
  38930. soundCollection: Array<Sound>;
  38931. private _outputAudioNode;
  38932. private _scene;
  38933. private _connectedAnalyser;
  38934. private _options;
  38935. private _isInitialized;
  38936. /**
  38937. * Creates a new sound track.
  38938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38939. * @param scene Define the scene the sound track belongs to
  38940. * @param options
  38941. */
  38942. constructor(scene: Scene, options?: ISoundTrackOptions);
  38943. private _initializeSoundTrackAudioGraph;
  38944. /**
  38945. * Release the sound track and its associated resources
  38946. */
  38947. dispose(): void;
  38948. /**
  38949. * Adds a sound to this sound track
  38950. * @param sound define the cound to add
  38951. * @ignoreNaming
  38952. */
  38953. AddSound(sound: Sound): void;
  38954. /**
  38955. * Removes a sound to this sound track
  38956. * @param sound define the cound to remove
  38957. * @ignoreNaming
  38958. */
  38959. RemoveSound(sound: Sound): void;
  38960. /**
  38961. * Set a global volume for the full sound track.
  38962. * @param newVolume Define the new volume of the sound track
  38963. */
  38964. setVolume(newVolume: number): void;
  38965. /**
  38966. * Switch the panning model to HRTF:
  38967. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38969. */
  38970. switchPanningModelToHRTF(): void;
  38971. /**
  38972. * Switch the panning model to Equal Power:
  38973. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38975. */
  38976. switchPanningModelToEqualPower(): void;
  38977. /**
  38978. * Connect the sound track to an audio analyser allowing some amazing
  38979. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38981. * @param analyser The analyser to connect to the engine
  38982. */
  38983. connectToAnalyser(analyser: Analyser): void;
  38984. }
  38985. }
  38986. declare module "babylonjs/Audio/audioSceneComponent" {
  38987. import { Sound } from "babylonjs/Audio/sound";
  38988. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38989. import { Nullable } from "babylonjs/types";
  38990. import { Vector3 } from "babylonjs/Maths/math.vector";
  38991. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38992. import { Scene } from "babylonjs/scene";
  38993. import { AbstractScene } from "babylonjs/abstractScene";
  38994. import "babylonjs/Audio/audioEngine";
  38995. module "babylonjs/abstractScene" {
  38996. interface AbstractScene {
  38997. /**
  38998. * The list of sounds used in the scene.
  38999. */
  39000. sounds: Nullable<Array<Sound>>;
  39001. }
  39002. }
  39003. module "babylonjs/scene" {
  39004. interface Scene {
  39005. /**
  39006. * @hidden
  39007. * Backing field
  39008. */
  39009. _mainSoundTrack: SoundTrack;
  39010. /**
  39011. * The main sound track played by the scene.
  39012. * It cotains your primary collection of sounds.
  39013. */
  39014. mainSoundTrack: SoundTrack;
  39015. /**
  39016. * The list of sound tracks added to the scene
  39017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39018. */
  39019. soundTracks: Nullable<Array<SoundTrack>>;
  39020. /**
  39021. * Gets a sound using a given name
  39022. * @param name defines the name to search for
  39023. * @return the found sound or null if not found at all.
  39024. */
  39025. getSoundByName(name: string): Nullable<Sound>;
  39026. /**
  39027. * Gets or sets if audio support is enabled
  39028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39029. */
  39030. audioEnabled: boolean;
  39031. /**
  39032. * Gets or sets if audio will be output to headphones
  39033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39034. */
  39035. headphone: boolean;
  39036. /**
  39037. * Gets or sets custom audio listener position provider
  39038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39039. */
  39040. audioListenerPositionProvider: Nullable<() => Vector3>;
  39041. /**
  39042. * Gets or sets a refresh rate when using 3D audio positioning
  39043. */
  39044. audioPositioningRefreshRate: number;
  39045. }
  39046. }
  39047. /**
  39048. * Defines the sound scene component responsible to manage any sounds
  39049. * in a given scene.
  39050. */
  39051. export class AudioSceneComponent implements ISceneSerializableComponent {
  39052. /**
  39053. * The component name helpfull to identify the component in the list of scene components.
  39054. */
  39055. readonly name: string;
  39056. /**
  39057. * The scene the component belongs to.
  39058. */
  39059. scene: Scene;
  39060. private _audioEnabled;
  39061. /**
  39062. * Gets whether audio is enabled or not.
  39063. * Please use related enable/disable method to switch state.
  39064. */
  39065. get audioEnabled(): boolean;
  39066. private _headphone;
  39067. /**
  39068. * Gets whether audio is outputing to headphone or not.
  39069. * Please use the according Switch methods to change output.
  39070. */
  39071. get headphone(): boolean;
  39072. /**
  39073. * Gets or sets a refresh rate when using 3D audio positioning
  39074. */
  39075. audioPositioningRefreshRate: number;
  39076. private _audioListenerPositionProvider;
  39077. /**
  39078. * Gets the current audio listener position provider
  39079. */
  39080. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39081. /**
  39082. * Sets a custom listener position for all sounds in the scene
  39083. * By default, this is the position of the first active camera
  39084. */
  39085. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39086. /**
  39087. * Creates a new instance of the component for the given scene
  39088. * @param scene Defines the scene to register the component in
  39089. */
  39090. constructor(scene: Scene);
  39091. /**
  39092. * Registers the component in a given scene
  39093. */
  39094. register(): void;
  39095. /**
  39096. * Rebuilds the elements related to this component in case of
  39097. * context lost for instance.
  39098. */
  39099. rebuild(): void;
  39100. /**
  39101. * Serializes the component data to the specified json object
  39102. * @param serializationObject The object to serialize to
  39103. */
  39104. serialize(serializationObject: any): void;
  39105. /**
  39106. * Adds all the elements from the container to the scene
  39107. * @param container the container holding the elements
  39108. */
  39109. addFromContainer(container: AbstractScene): void;
  39110. /**
  39111. * Removes all the elements in the container from the scene
  39112. * @param container contains the elements to remove
  39113. * @param dispose if the removed element should be disposed (default: false)
  39114. */
  39115. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39116. /**
  39117. * Disposes the component and the associated ressources.
  39118. */
  39119. dispose(): void;
  39120. /**
  39121. * Disables audio in the associated scene.
  39122. */
  39123. disableAudio(): void;
  39124. /**
  39125. * Enables audio in the associated scene.
  39126. */
  39127. enableAudio(): void;
  39128. /**
  39129. * Switch audio to headphone output.
  39130. */
  39131. switchAudioModeForHeadphones(): void;
  39132. /**
  39133. * Switch audio to normal speakers.
  39134. */
  39135. switchAudioModeForNormalSpeakers(): void;
  39136. private _cachedCameraDirection;
  39137. private _cachedCameraPosition;
  39138. private _lastCheck;
  39139. private _afterRender;
  39140. }
  39141. }
  39142. declare module "babylonjs/Audio/weightedsound" {
  39143. import { Sound } from "babylonjs/Audio/sound";
  39144. /**
  39145. * Wraps one or more Sound objects and selects one with random weight for playback.
  39146. */
  39147. export class WeightedSound {
  39148. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39149. loop: boolean;
  39150. private _coneInnerAngle;
  39151. private _coneOuterAngle;
  39152. private _volume;
  39153. /** A Sound is currently playing. */
  39154. isPlaying: boolean;
  39155. /** A Sound is currently paused. */
  39156. isPaused: boolean;
  39157. private _sounds;
  39158. private _weights;
  39159. private _currentIndex?;
  39160. /**
  39161. * Creates a new WeightedSound from the list of sounds given.
  39162. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39163. * @param sounds Array of Sounds that will be selected from.
  39164. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39165. */
  39166. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39167. /**
  39168. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39169. */
  39170. get directionalConeInnerAngle(): number;
  39171. /**
  39172. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39173. */
  39174. set directionalConeInnerAngle(value: number);
  39175. /**
  39176. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39177. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39178. */
  39179. get directionalConeOuterAngle(): number;
  39180. /**
  39181. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39182. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39183. */
  39184. set directionalConeOuterAngle(value: number);
  39185. /**
  39186. * Playback volume.
  39187. */
  39188. get volume(): number;
  39189. /**
  39190. * Playback volume.
  39191. */
  39192. set volume(value: number);
  39193. private _onended;
  39194. /**
  39195. * Suspend playback
  39196. */
  39197. pause(): void;
  39198. /**
  39199. * Stop playback
  39200. */
  39201. stop(): void;
  39202. /**
  39203. * Start playback.
  39204. * @param startOffset Position the clip head at a specific time in seconds.
  39205. */
  39206. play(startOffset?: number): void;
  39207. }
  39208. }
  39209. declare module "babylonjs/Audio/index" {
  39210. export * from "babylonjs/Audio/analyser";
  39211. export * from "babylonjs/Audio/audioEngine";
  39212. export * from "babylonjs/Audio/audioSceneComponent";
  39213. export * from "babylonjs/Audio/sound";
  39214. export * from "babylonjs/Audio/soundTrack";
  39215. export * from "babylonjs/Audio/weightedsound";
  39216. }
  39217. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39218. import { Behavior } from "babylonjs/Behaviors/behavior";
  39219. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39220. import { BackEase } from "babylonjs/Animations/easing";
  39221. /**
  39222. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39223. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39224. */
  39225. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39226. /**
  39227. * Gets the name of the behavior.
  39228. */
  39229. get name(): string;
  39230. /**
  39231. * The easing function used by animations
  39232. */
  39233. static EasingFunction: BackEase;
  39234. /**
  39235. * The easing mode used by animations
  39236. */
  39237. static EasingMode: number;
  39238. /**
  39239. * The duration of the animation, in milliseconds
  39240. */
  39241. transitionDuration: number;
  39242. /**
  39243. * Length of the distance animated by the transition when lower radius is reached
  39244. */
  39245. lowerRadiusTransitionRange: number;
  39246. /**
  39247. * Length of the distance animated by the transition when upper radius is reached
  39248. */
  39249. upperRadiusTransitionRange: number;
  39250. private _autoTransitionRange;
  39251. /**
  39252. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39253. */
  39254. get autoTransitionRange(): boolean;
  39255. /**
  39256. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39257. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39258. */
  39259. set autoTransitionRange(value: boolean);
  39260. private _attachedCamera;
  39261. private _onAfterCheckInputsObserver;
  39262. private _onMeshTargetChangedObserver;
  39263. /**
  39264. * Initializes the behavior.
  39265. */
  39266. init(): void;
  39267. /**
  39268. * Attaches the behavior to its arc rotate camera.
  39269. * @param camera Defines the camera to attach the behavior to
  39270. */
  39271. attach(camera: ArcRotateCamera): void;
  39272. /**
  39273. * Detaches the behavior from its current arc rotate camera.
  39274. */
  39275. detach(): void;
  39276. private _radiusIsAnimating;
  39277. private _radiusBounceTransition;
  39278. private _animatables;
  39279. private _cachedWheelPrecision;
  39280. /**
  39281. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39282. * @param radiusLimit The limit to check against.
  39283. * @return Bool to indicate if at limit.
  39284. */
  39285. private _isRadiusAtLimit;
  39286. /**
  39287. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39288. * @param radiusDelta The delta by which to animate to. Can be negative.
  39289. */
  39290. private _applyBoundRadiusAnimation;
  39291. /**
  39292. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39293. */
  39294. protected _clearAnimationLocks(): void;
  39295. /**
  39296. * Stops and removes all animations that have been applied to the camera
  39297. */
  39298. stopAllAnimations(): void;
  39299. }
  39300. }
  39301. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39302. import { Behavior } from "babylonjs/Behaviors/behavior";
  39303. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39304. import { ExponentialEase } from "babylonjs/Animations/easing";
  39305. import { Nullable } from "babylonjs/types";
  39306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39307. import { Vector3 } from "babylonjs/Maths/math.vector";
  39308. /**
  39309. * 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.
  39310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39311. */
  39312. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39313. /**
  39314. * Gets the name of the behavior.
  39315. */
  39316. get name(): string;
  39317. private _mode;
  39318. private _radiusScale;
  39319. private _positionScale;
  39320. private _defaultElevation;
  39321. private _elevationReturnTime;
  39322. private _elevationReturnWaitTime;
  39323. private _zoomStopsAnimation;
  39324. private _framingTime;
  39325. /**
  39326. * The easing function used by animations
  39327. */
  39328. static EasingFunction: ExponentialEase;
  39329. /**
  39330. * The easing mode used by animations
  39331. */
  39332. static EasingMode: number;
  39333. /**
  39334. * Sets the current mode used by the behavior
  39335. */
  39336. set mode(mode: number);
  39337. /**
  39338. * Gets current mode used by the behavior.
  39339. */
  39340. get mode(): number;
  39341. /**
  39342. * Sets the scale applied to the radius (1 by default)
  39343. */
  39344. set radiusScale(radius: number);
  39345. /**
  39346. * Gets the scale applied to the radius
  39347. */
  39348. get radiusScale(): number;
  39349. /**
  39350. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39351. */
  39352. set positionScale(scale: number);
  39353. /**
  39354. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39355. */
  39356. get positionScale(): number;
  39357. /**
  39358. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39359. * behaviour is triggered, in radians.
  39360. */
  39361. set defaultElevation(elevation: number);
  39362. /**
  39363. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39364. * behaviour is triggered, in radians.
  39365. */
  39366. get defaultElevation(): number;
  39367. /**
  39368. * Sets the time (in milliseconds) taken to return to the default beta position.
  39369. * Negative value indicates camera should not return to default.
  39370. */
  39371. set elevationReturnTime(speed: number);
  39372. /**
  39373. * Gets the time (in milliseconds) taken to return to the default beta position.
  39374. * Negative value indicates camera should not return to default.
  39375. */
  39376. get elevationReturnTime(): number;
  39377. /**
  39378. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39379. */
  39380. set elevationReturnWaitTime(time: number);
  39381. /**
  39382. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39383. */
  39384. get elevationReturnWaitTime(): number;
  39385. /**
  39386. * Sets the flag that indicates if user zooming should stop animation.
  39387. */
  39388. set zoomStopsAnimation(flag: boolean);
  39389. /**
  39390. * Gets the flag that indicates if user zooming should stop animation.
  39391. */
  39392. get zoomStopsAnimation(): boolean;
  39393. /**
  39394. * Sets the transition time when framing the mesh, in milliseconds
  39395. */
  39396. set framingTime(time: number);
  39397. /**
  39398. * Gets the transition time when framing the mesh, in milliseconds
  39399. */
  39400. get framingTime(): number;
  39401. /**
  39402. * Define if the behavior should automatically change the configured
  39403. * camera limits and sensibilities.
  39404. */
  39405. autoCorrectCameraLimitsAndSensibility: boolean;
  39406. private _onPrePointerObservableObserver;
  39407. private _onAfterCheckInputsObserver;
  39408. private _onMeshTargetChangedObserver;
  39409. private _attachedCamera;
  39410. private _isPointerDown;
  39411. private _lastInteractionTime;
  39412. /**
  39413. * Initializes the behavior.
  39414. */
  39415. init(): void;
  39416. /**
  39417. * Attaches the behavior to its arc rotate camera.
  39418. * @param camera Defines the camera to attach the behavior to
  39419. */
  39420. attach(camera: ArcRotateCamera): void;
  39421. /**
  39422. * Detaches the behavior from its current arc rotate camera.
  39423. */
  39424. detach(): void;
  39425. private _animatables;
  39426. private _betaIsAnimating;
  39427. private _betaTransition;
  39428. private _radiusTransition;
  39429. private _vectorTransition;
  39430. /**
  39431. * Targets the given mesh and updates zoom level accordingly.
  39432. * @param mesh The mesh to target.
  39433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39435. */
  39436. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39437. /**
  39438. * Targets the given mesh with its children and updates zoom level accordingly.
  39439. * @param mesh The mesh to target.
  39440. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39441. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39442. */
  39443. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39444. /**
  39445. * Targets the given meshes with their children and updates zoom level accordingly.
  39446. * @param meshes The mesh to target.
  39447. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39448. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39449. */
  39450. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39451. /**
  39452. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39453. * @param minimumWorld Determines the smaller position of the bounding box extend
  39454. * @param maximumWorld Determines the bigger position of the bounding box extend
  39455. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39456. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39457. */
  39458. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39459. /**
  39460. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39461. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39462. * frustum width.
  39463. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39464. * to fully enclose the mesh in the viewing frustum.
  39465. */
  39466. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39467. /**
  39468. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39469. * is automatically returned to its default position (expected to be above ground plane).
  39470. */
  39471. private _maintainCameraAboveGround;
  39472. /**
  39473. * Returns the frustum slope based on the canvas ratio and camera FOV
  39474. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39475. */
  39476. private _getFrustumSlope;
  39477. /**
  39478. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39479. */
  39480. private _clearAnimationLocks;
  39481. /**
  39482. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39483. */
  39484. private _applyUserInteraction;
  39485. /**
  39486. * Stops and removes all animations that have been applied to the camera
  39487. */
  39488. stopAllAnimations(): void;
  39489. /**
  39490. * Gets a value indicating if the user is moving the camera
  39491. */
  39492. get isUserIsMoving(): boolean;
  39493. /**
  39494. * The camera can move all the way towards the mesh.
  39495. */
  39496. static IgnoreBoundsSizeMode: number;
  39497. /**
  39498. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39499. */
  39500. static FitFrustumSidesMode: number;
  39501. }
  39502. }
  39503. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39504. import { Nullable } from "babylonjs/types";
  39505. import { Camera } from "babylonjs/Cameras/camera";
  39506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39507. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39508. /**
  39509. * Base class for Camera Pointer Inputs.
  39510. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39511. * for example usage.
  39512. */
  39513. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39514. /**
  39515. * Defines the camera the input is attached to.
  39516. */
  39517. abstract camera: Camera;
  39518. /**
  39519. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39520. */
  39521. protected _altKey: boolean;
  39522. protected _ctrlKey: boolean;
  39523. protected _metaKey: boolean;
  39524. protected _shiftKey: boolean;
  39525. /**
  39526. * Which mouse buttons were pressed at time of last mouse event.
  39527. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39528. */
  39529. protected _buttonsPressed: number;
  39530. /**
  39531. * Defines the buttons associated with the input to handle camera move.
  39532. */
  39533. buttons: number[];
  39534. /**
  39535. * Attach the input controls to a specific dom element to get the input from.
  39536. * @param element Defines the element the controls should be listened from
  39537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39538. */
  39539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39540. /**
  39541. * Detach the current controls from the specified dom element.
  39542. * @param element Defines the element to stop listening the inputs from
  39543. */
  39544. detachControl(element: Nullable<HTMLElement>): void;
  39545. /**
  39546. * Gets the class name of the current input.
  39547. * @returns the class name
  39548. */
  39549. getClassName(): string;
  39550. /**
  39551. * Get the friendly name associated with the input class.
  39552. * @returns the input friendly name
  39553. */
  39554. getSimpleName(): string;
  39555. /**
  39556. * Called on pointer POINTERDOUBLETAP event.
  39557. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39558. */
  39559. protected onDoubleTap(type: string): void;
  39560. /**
  39561. * Called on pointer POINTERMOVE event if only a single touch is active.
  39562. * Override this method to provide functionality.
  39563. */
  39564. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39565. /**
  39566. * Called on pointer POINTERMOVE event if multiple touches are active.
  39567. * Override this method to provide functionality.
  39568. */
  39569. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39570. /**
  39571. * Called on JS contextmenu event.
  39572. * Override this method to provide functionality.
  39573. */
  39574. protected onContextMenu(evt: PointerEvent): void;
  39575. /**
  39576. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39577. * press.
  39578. * Override this method to provide functionality.
  39579. */
  39580. protected onButtonDown(evt: PointerEvent): void;
  39581. /**
  39582. * Called each time a new POINTERUP event occurs. Ie, for each button
  39583. * release.
  39584. * Override this method to provide functionality.
  39585. */
  39586. protected onButtonUp(evt: PointerEvent): void;
  39587. /**
  39588. * Called when window becomes inactive.
  39589. * Override this method to provide functionality.
  39590. */
  39591. protected onLostFocus(): void;
  39592. private _pointerInput;
  39593. private _observer;
  39594. private _onLostFocus;
  39595. private pointA;
  39596. private pointB;
  39597. }
  39598. }
  39599. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39600. import { Nullable } from "babylonjs/types";
  39601. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39602. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39603. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39604. /**
  39605. * Manage the pointers inputs to control an arc rotate camera.
  39606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39607. */
  39608. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39609. /**
  39610. * Defines the camera the input is attached to.
  39611. */
  39612. camera: ArcRotateCamera;
  39613. /**
  39614. * Gets the class name of the current input.
  39615. * @returns the class name
  39616. */
  39617. getClassName(): string;
  39618. /**
  39619. * Defines the buttons associated with the input to handle camera move.
  39620. */
  39621. buttons: number[];
  39622. /**
  39623. * Defines the pointer angular sensibility along the X axis or how fast is
  39624. * the camera rotating.
  39625. */
  39626. angularSensibilityX: number;
  39627. /**
  39628. * Defines the pointer angular sensibility along the Y axis or how fast is
  39629. * the camera rotating.
  39630. */
  39631. angularSensibilityY: number;
  39632. /**
  39633. * Defines the pointer pinch precision or how fast is the camera zooming.
  39634. */
  39635. pinchPrecision: number;
  39636. /**
  39637. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39638. * from 0.
  39639. * It defines the percentage of current camera.radius to use as delta when
  39640. * pinch zoom is used.
  39641. */
  39642. pinchDeltaPercentage: number;
  39643. /**
  39644. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39645. * that any object in the plane at the camera's target point will scale
  39646. * perfectly with finger motion.
  39647. * Overrides pinchDeltaPercentage and pinchPrecision.
  39648. */
  39649. useNaturalPinchZoom: boolean;
  39650. /**
  39651. * Defines the pointer panning sensibility or how fast is the camera moving.
  39652. */
  39653. panningSensibility: number;
  39654. /**
  39655. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39656. */
  39657. multiTouchPanning: boolean;
  39658. /**
  39659. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39660. * zoom (pinch) through multitouch.
  39661. */
  39662. multiTouchPanAndZoom: boolean;
  39663. /**
  39664. * Revers pinch action direction.
  39665. */
  39666. pinchInwards: boolean;
  39667. private _isPanClick;
  39668. private _twoFingerActivityCount;
  39669. private _isPinching;
  39670. /**
  39671. * Called on pointer POINTERMOVE event if only a single touch is active.
  39672. */
  39673. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39674. /**
  39675. * Called on pointer POINTERDOUBLETAP event.
  39676. */
  39677. protected onDoubleTap(type: string): void;
  39678. /**
  39679. * Called on pointer POINTERMOVE event if multiple touches are active.
  39680. */
  39681. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39682. /**
  39683. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39684. * press.
  39685. */
  39686. protected onButtonDown(evt: PointerEvent): void;
  39687. /**
  39688. * Called each time a new POINTERUP event occurs. Ie, for each button
  39689. * release.
  39690. */
  39691. protected onButtonUp(evt: PointerEvent): void;
  39692. /**
  39693. * Called when window becomes inactive.
  39694. */
  39695. protected onLostFocus(): void;
  39696. }
  39697. }
  39698. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39699. import { Nullable } from "babylonjs/types";
  39700. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39701. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39702. /**
  39703. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39705. */
  39706. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39707. /**
  39708. * Defines the camera the input is attached to.
  39709. */
  39710. camera: ArcRotateCamera;
  39711. /**
  39712. * Defines the list of key codes associated with the up action (increase alpha)
  39713. */
  39714. keysUp: number[];
  39715. /**
  39716. * Defines the list of key codes associated with the down action (decrease alpha)
  39717. */
  39718. keysDown: number[];
  39719. /**
  39720. * Defines the list of key codes associated with the left action (increase beta)
  39721. */
  39722. keysLeft: number[];
  39723. /**
  39724. * Defines the list of key codes associated with the right action (decrease beta)
  39725. */
  39726. keysRight: number[];
  39727. /**
  39728. * Defines the list of key codes associated with the reset action.
  39729. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39730. */
  39731. keysReset: number[];
  39732. /**
  39733. * Defines the panning sensibility of the inputs.
  39734. * (How fast is the camera panning)
  39735. */
  39736. panningSensibility: number;
  39737. /**
  39738. * Defines the zooming sensibility of the inputs.
  39739. * (How fast is the camera zooming)
  39740. */
  39741. zoomingSensibility: number;
  39742. /**
  39743. * Defines whether maintaining the alt key down switch the movement mode from
  39744. * orientation to zoom.
  39745. */
  39746. useAltToZoom: boolean;
  39747. /**
  39748. * Rotation speed of the camera
  39749. */
  39750. angularSpeed: number;
  39751. private _keys;
  39752. private _ctrlPressed;
  39753. private _altPressed;
  39754. private _onCanvasBlurObserver;
  39755. private _onKeyboardObserver;
  39756. private _engine;
  39757. private _scene;
  39758. /**
  39759. * Attach the input controls to a specific dom element to get the input from.
  39760. * @param element Defines the element the controls should be listened from
  39761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39762. */
  39763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39764. /**
  39765. * Detach the current controls from the specified dom element.
  39766. * @param element Defines the element to stop listening the inputs from
  39767. */
  39768. detachControl(element: Nullable<HTMLElement>): void;
  39769. /**
  39770. * Update the current camera state depending on the inputs that have been used this frame.
  39771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39772. */
  39773. checkInputs(): void;
  39774. /**
  39775. * Gets the class name of the current intput.
  39776. * @returns the class name
  39777. */
  39778. getClassName(): string;
  39779. /**
  39780. * Get the friendly name associated with the input class.
  39781. * @returns the input friendly name
  39782. */
  39783. getSimpleName(): string;
  39784. }
  39785. }
  39786. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39787. import { Nullable } from "babylonjs/types";
  39788. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39789. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39790. /**
  39791. * Manage the mouse wheel inputs to control an arc rotate camera.
  39792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39793. */
  39794. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39795. /**
  39796. * Defines the camera the input is attached to.
  39797. */
  39798. camera: ArcRotateCamera;
  39799. /**
  39800. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39801. */
  39802. wheelPrecision: number;
  39803. /**
  39804. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39805. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39806. */
  39807. wheelDeltaPercentage: number;
  39808. private _wheel;
  39809. private _observer;
  39810. private computeDeltaFromMouseWheelLegacyEvent;
  39811. /**
  39812. * Attach the input controls to a specific dom element to get the input from.
  39813. * @param element Defines the element the controls should be listened from
  39814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39815. */
  39816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39817. /**
  39818. * Detach the current controls from the specified dom element.
  39819. * @param element Defines the element to stop listening the inputs from
  39820. */
  39821. detachControl(element: Nullable<HTMLElement>): void;
  39822. /**
  39823. * Gets the class name of the current intput.
  39824. * @returns the class name
  39825. */
  39826. getClassName(): string;
  39827. /**
  39828. * Get the friendly name associated with the input class.
  39829. * @returns the input friendly name
  39830. */
  39831. getSimpleName(): string;
  39832. }
  39833. }
  39834. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39836. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39837. /**
  39838. * Default Inputs manager for the ArcRotateCamera.
  39839. * It groups all the default supported inputs for ease of use.
  39840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39841. */
  39842. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39843. /**
  39844. * Instantiates a new ArcRotateCameraInputsManager.
  39845. * @param camera Defines the camera the inputs belong to
  39846. */
  39847. constructor(camera: ArcRotateCamera);
  39848. /**
  39849. * Add mouse wheel input support to the input manager.
  39850. * @returns the current input manager
  39851. */
  39852. addMouseWheel(): ArcRotateCameraInputsManager;
  39853. /**
  39854. * Add pointers input support to the input manager.
  39855. * @returns the current input manager
  39856. */
  39857. addPointers(): ArcRotateCameraInputsManager;
  39858. /**
  39859. * Add keyboard input support to the input manager.
  39860. * @returns the current input manager
  39861. */
  39862. addKeyboard(): ArcRotateCameraInputsManager;
  39863. }
  39864. }
  39865. declare module "babylonjs/Cameras/arcRotateCamera" {
  39866. import { Observable } from "babylonjs/Misc/observable";
  39867. import { Nullable } from "babylonjs/types";
  39868. import { Scene } from "babylonjs/scene";
  39869. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39871. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39872. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39873. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39874. import { Camera } from "babylonjs/Cameras/camera";
  39875. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39876. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39877. import { Collider } from "babylonjs/Collisions/collider";
  39878. /**
  39879. * This represents an orbital type of camera.
  39880. *
  39881. * 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.
  39882. * 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.
  39883. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39884. */
  39885. export class ArcRotateCamera extends TargetCamera {
  39886. /**
  39887. * Defines the rotation angle of the camera along the longitudinal axis.
  39888. */
  39889. alpha: number;
  39890. /**
  39891. * Defines the rotation angle of the camera along the latitudinal axis.
  39892. */
  39893. beta: number;
  39894. /**
  39895. * Defines the radius of the camera from it s target point.
  39896. */
  39897. radius: number;
  39898. protected _target: Vector3;
  39899. protected _targetHost: Nullable<AbstractMesh>;
  39900. /**
  39901. * Defines the target point of the camera.
  39902. * The camera looks towards it form the radius distance.
  39903. */
  39904. get target(): Vector3;
  39905. set target(value: Vector3);
  39906. /**
  39907. * Define the current local position of the camera in the scene
  39908. */
  39909. get position(): Vector3;
  39910. set position(newPosition: Vector3);
  39911. protected _upVector: Vector3;
  39912. protected _upToYMatrix: Matrix;
  39913. protected _YToUpMatrix: Matrix;
  39914. /**
  39915. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39916. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39917. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39918. */
  39919. set upVector(vec: Vector3);
  39920. get upVector(): Vector3;
  39921. /**
  39922. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39923. */
  39924. setMatUp(): void;
  39925. /**
  39926. * Current inertia value on the longitudinal axis.
  39927. * The bigger this number the longer it will take for the camera to stop.
  39928. */
  39929. inertialAlphaOffset: number;
  39930. /**
  39931. * Current inertia value on the latitudinal axis.
  39932. * The bigger this number the longer it will take for the camera to stop.
  39933. */
  39934. inertialBetaOffset: number;
  39935. /**
  39936. * Current inertia value on the radius axis.
  39937. * The bigger this number the longer it will take for the camera to stop.
  39938. */
  39939. inertialRadiusOffset: number;
  39940. /**
  39941. * Minimum allowed angle on the longitudinal axis.
  39942. * This can help limiting how the Camera is able to move in the scene.
  39943. */
  39944. lowerAlphaLimit: Nullable<number>;
  39945. /**
  39946. * Maximum allowed angle on the longitudinal axis.
  39947. * This can help limiting how the Camera is able to move in the scene.
  39948. */
  39949. upperAlphaLimit: Nullable<number>;
  39950. /**
  39951. * Minimum allowed angle on the latitudinal axis.
  39952. * This can help limiting how the Camera is able to move in the scene.
  39953. */
  39954. lowerBetaLimit: number;
  39955. /**
  39956. * Maximum allowed angle on the latitudinal axis.
  39957. * This can help limiting how the Camera is able to move in the scene.
  39958. */
  39959. upperBetaLimit: number;
  39960. /**
  39961. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39962. * This can help limiting how the Camera is able to move in the scene.
  39963. */
  39964. lowerRadiusLimit: Nullable<number>;
  39965. /**
  39966. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39967. * This can help limiting how the Camera is able to move in the scene.
  39968. */
  39969. upperRadiusLimit: Nullable<number>;
  39970. /**
  39971. * Defines the current inertia value used during panning of the camera along the X axis.
  39972. */
  39973. inertialPanningX: number;
  39974. /**
  39975. * Defines the current inertia value used during panning of the camera along the Y axis.
  39976. */
  39977. inertialPanningY: number;
  39978. /**
  39979. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39980. * Basically if your fingers moves away from more than this distance you will be considered
  39981. * in pinch mode.
  39982. */
  39983. pinchToPanMaxDistance: number;
  39984. /**
  39985. * Defines the maximum distance the camera can pan.
  39986. * This could help keeping the cammera always in your scene.
  39987. */
  39988. panningDistanceLimit: Nullable<number>;
  39989. /**
  39990. * Defines the target of the camera before paning.
  39991. */
  39992. panningOriginTarget: Vector3;
  39993. /**
  39994. * Defines the value of the inertia used during panning.
  39995. * 0 would mean stop inertia and one would mean no decelleration at all.
  39996. */
  39997. panningInertia: number;
  39998. /**
  39999. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40000. */
  40001. get angularSensibilityX(): number;
  40002. set angularSensibilityX(value: number);
  40003. /**
  40004. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40005. */
  40006. get angularSensibilityY(): number;
  40007. set angularSensibilityY(value: number);
  40008. /**
  40009. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40010. */
  40011. get pinchPrecision(): number;
  40012. set pinchPrecision(value: number);
  40013. /**
  40014. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40015. * It will be used instead of pinchDeltaPrecision if different from 0.
  40016. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40017. */
  40018. get pinchDeltaPercentage(): number;
  40019. set pinchDeltaPercentage(value: number);
  40020. /**
  40021. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40022. * and pinch delta percentage.
  40023. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40024. * that any object in the plane at the camera's target point will scale
  40025. * perfectly with finger motion.
  40026. */
  40027. get useNaturalPinchZoom(): boolean;
  40028. set useNaturalPinchZoom(value: boolean);
  40029. /**
  40030. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40031. */
  40032. get panningSensibility(): number;
  40033. set panningSensibility(value: number);
  40034. /**
  40035. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40036. */
  40037. get keysUp(): number[];
  40038. set keysUp(value: number[]);
  40039. /**
  40040. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40041. */
  40042. get keysDown(): number[];
  40043. set keysDown(value: number[]);
  40044. /**
  40045. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40046. */
  40047. get keysLeft(): number[];
  40048. set keysLeft(value: number[]);
  40049. /**
  40050. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40051. */
  40052. get keysRight(): number[];
  40053. set keysRight(value: number[]);
  40054. /**
  40055. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40056. */
  40057. get wheelPrecision(): number;
  40058. set wheelPrecision(value: number);
  40059. /**
  40060. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40061. * It will be used instead of pinchDeltaPrecision if different from 0.
  40062. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40063. */
  40064. get wheelDeltaPercentage(): number;
  40065. set wheelDeltaPercentage(value: number);
  40066. /**
  40067. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40068. */
  40069. zoomOnFactor: number;
  40070. /**
  40071. * Defines a screen offset for the camera position.
  40072. */
  40073. targetScreenOffset: Vector2;
  40074. /**
  40075. * Allows the camera to be completely reversed.
  40076. * If false the camera can not arrive upside down.
  40077. */
  40078. allowUpsideDown: boolean;
  40079. /**
  40080. * Define if double tap/click is used to restore the previously saved state of the camera.
  40081. */
  40082. useInputToRestoreState: boolean;
  40083. /** @hidden */
  40084. _viewMatrix: Matrix;
  40085. /** @hidden */
  40086. _useCtrlForPanning: boolean;
  40087. /** @hidden */
  40088. _panningMouseButton: number;
  40089. /**
  40090. * Defines the input associated to the camera.
  40091. */
  40092. inputs: ArcRotateCameraInputsManager;
  40093. /** @hidden */
  40094. _reset: () => void;
  40095. /**
  40096. * Defines the allowed panning axis.
  40097. */
  40098. panningAxis: Vector3;
  40099. protected _localDirection: Vector3;
  40100. protected _transformedDirection: Vector3;
  40101. private _bouncingBehavior;
  40102. /**
  40103. * Gets the bouncing behavior of the camera if it has been enabled.
  40104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40105. */
  40106. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40107. /**
  40108. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40110. */
  40111. get useBouncingBehavior(): boolean;
  40112. set useBouncingBehavior(value: boolean);
  40113. private _framingBehavior;
  40114. /**
  40115. * Gets the framing behavior of the camera if it has been enabled.
  40116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40117. */
  40118. get framingBehavior(): Nullable<FramingBehavior>;
  40119. /**
  40120. * Defines if the framing behavior of the camera is enabled on the camera.
  40121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40122. */
  40123. get useFramingBehavior(): boolean;
  40124. set useFramingBehavior(value: boolean);
  40125. private _autoRotationBehavior;
  40126. /**
  40127. * Gets the auto rotation behavior of the camera if it has been enabled.
  40128. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40129. */
  40130. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40131. /**
  40132. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40134. */
  40135. get useAutoRotationBehavior(): boolean;
  40136. set useAutoRotationBehavior(value: boolean);
  40137. /**
  40138. * Observable triggered when the mesh target has been changed on the camera.
  40139. */
  40140. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40141. /**
  40142. * Event raised when the camera is colliding with a mesh.
  40143. */
  40144. onCollide: (collidedMesh: AbstractMesh) => void;
  40145. /**
  40146. * Defines whether the camera should check collision with the objects oh the scene.
  40147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40148. */
  40149. checkCollisions: boolean;
  40150. /**
  40151. * Defines the collision radius of the camera.
  40152. * This simulates a sphere around the camera.
  40153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40154. */
  40155. collisionRadius: Vector3;
  40156. protected _collider: Collider;
  40157. protected _previousPosition: Vector3;
  40158. protected _collisionVelocity: Vector3;
  40159. protected _newPosition: Vector3;
  40160. protected _previousAlpha: number;
  40161. protected _previousBeta: number;
  40162. protected _previousRadius: number;
  40163. protected _collisionTriggered: boolean;
  40164. protected _targetBoundingCenter: Nullable<Vector3>;
  40165. private _computationVector;
  40166. /**
  40167. * Instantiates a new ArcRotateCamera in a given scene
  40168. * @param name Defines the name of the camera
  40169. * @param alpha Defines the camera rotation along the logitudinal axis
  40170. * @param beta Defines the camera rotation along the latitudinal axis
  40171. * @param radius Defines the camera distance from its target
  40172. * @param target Defines the camera target
  40173. * @param scene Defines the scene the camera belongs to
  40174. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40175. */
  40176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40177. /** @hidden */
  40178. _initCache(): void;
  40179. /** @hidden */
  40180. _updateCache(ignoreParentClass?: boolean): void;
  40181. protected _getTargetPosition(): Vector3;
  40182. private _storedAlpha;
  40183. private _storedBeta;
  40184. private _storedRadius;
  40185. private _storedTarget;
  40186. private _storedTargetScreenOffset;
  40187. /**
  40188. * Stores the current state of the camera (alpha, beta, radius and target)
  40189. * @returns the camera itself
  40190. */
  40191. storeState(): Camera;
  40192. /**
  40193. * @hidden
  40194. * Restored camera state. You must call storeState() first
  40195. */
  40196. _restoreStateValues(): boolean;
  40197. /** @hidden */
  40198. _isSynchronizedViewMatrix(): boolean;
  40199. /**
  40200. * Attached controls to the current camera.
  40201. * @param element Defines the element the controls should be listened from
  40202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40203. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40204. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40205. */
  40206. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40207. /**
  40208. * Detach the current controls from the camera.
  40209. * The camera will stop reacting to inputs.
  40210. * @param element Defines the element to stop listening the inputs from
  40211. */
  40212. detachControl(element: HTMLElement): void;
  40213. /** @hidden */
  40214. _checkInputs(): void;
  40215. protected _checkLimits(): void;
  40216. /**
  40217. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40218. */
  40219. rebuildAnglesAndRadius(): void;
  40220. /**
  40221. * Use a position to define the current camera related information like alpha, beta and radius
  40222. * @param position Defines the position to set the camera at
  40223. */
  40224. setPosition(position: Vector3): void;
  40225. /**
  40226. * Defines the target the camera should look at.
  40227. * This will automatically adapt alpha beta and radius to fit within the new target.
  40228. * @param target Defines the new target as a Vector or a mesh
  40229. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40230. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40231. */
  40232. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40233. /** @hidden */
  40234. _getViewMatrix(): Matrix;
  40235. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40236. /**
  40237. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40238. * @param meshes Defines the mesh to zoom on
  40239. * @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)
  40240. */
  40241. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40242. /**
  40243. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40244. * The target will be changed but the radius
  40245. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40246. * @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)
  40247. */
  40248. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40249. min: Vector3;
  40250. max: Vector3;
  40251. distance: number;
  40252. }, doNotUpdateMaxZ?: boolean): void;
  40253. /**
  40254. * @override
  40255. * Override Camera.createRigCamera
  40256. */
  40257. createRigCamera(name: string, cameraIndex: number): Camera;
  40258. /**
  40259. * @hidden
  40260. * @override
  40261. * Override Camera._updateRigCameras
  40262. */
  40263. _updateRigCameras(): void;
  40264. /**
  40265. * Destroy the camera and release the current resources hold by it.
  40266. */
  40267. dispose(): void;
  40268. /**
  40269. * Gets the current object class name.
  40270. * @return the class name
  40271. */
  40272. getClassName(): string;
  40273. }
  40274. }
  40275. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40276. import { Behavior } from "babylonjs/Behaviors/behavior";
  40277. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40278. /**
  40279. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40280. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40281. */
  40282. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40283. /**
  40284. * Gets the name of the behavior.
  40285. */
  40286. get name(): string;
  40287. private _zoomStopsAnimation;
  40288. private _idleRotationSpeed;
  40289. private _idleRotationWaitTime;
  40290. private _idleRotationSpinupTime;
  40291. /**
  40292. * Sets the flag that indicates if user zooming should stop animation.
  40293. */
  40294. set zoomStopsAnimation(flag: boolean);
  40295. /**
  40296. * Gets the flag that indicates if user zooming should stop animation.
  40297. */
  40298. get zoomStopsAnimation(): boolean;
  40299. /**
  40300. * Sets the default speed at which the camera rotates around the model.
  40301. */
  40302. set idleRotationSpeed(speed: number);
  40303. /**
  40304. * Gets the default speed at which the camera rotates around the model.
  40305. */
  40306. get idleRotationSpeed(): number;
  40307. /**
  40308. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40309. */
  40310. set idleRotationWaitTime(time: number);
  40311. /**
  40312. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40313. */
  40314. get idleRotationWaitTime(): number;
  40315. /**
  40316. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40317. */
  40318. set idleRotationSpinupTime(time: number);
  40319. /**
  40320. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40321. */
  40322. get idleRotationSpinupTime(): number;
  40323. /**
  40324. * Gets a value indicating if the camera is currently rotating because of this behavior
  40325. */
  40326. get rotationInProgress(): boolean;
  40327. private _onPrePointerObservableObserver;
  40328. private _onAfterCheckInputsObserver;
  40329. private _attachedCamera;
  40330. private _isPointerDown;
  40331. private _lastFrameTime;
  40332. private _lastInteractionTime;
  40333. private _cameraRotationSpeed;
  40334. /**
  40335. * Initializes the behavior.
  40336. */
  40337. init(): void;
  40338. /**
  40339. * Attaches the behavior to its arc rotate camera.
  40340. * @param camera Defines the camera to attach the behavior to
  40341. */
  40342. attach(camera: ArcRotateCamera): void;
  40343. /**
  40344. * Detaches the behavior from its current arc rotate camera.
  40345. */
  40346. detach(): void;
  40347. /**
  40348. * Returns true if user is scrolling.
  40349. * @return true if user is scrolling.
  40350. */
  40351. private _userIsZooming;
  40352. private _lastFrameRadius;
  40353. private _shouldAnimationStopForInteraction;
  40354. /**
  40355. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40356. */
  40357. private _applyUserInteraction;
  40358. private _userIsMoving;
  40359. }
  40360. }
  40361. declare module "babylonjs/Behaviors/Cameras/index" {
  40362. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40363. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40364. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40365. }
  40366. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40367. import { Mesh } from "babylonjs/Meshes/mesh";
  40368. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40369. import { Behavior } from "babylonjs/Behaviors/behavior";
  40370. /**
  40371. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40372. */
  40373. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40374. private ui;
  40375. /**
  40376. * The name of the behavior
  40377. */
  40378. name: string;
  40379. /**
  40380. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40381. */
  40382. distanceAwayFromFace: number;
  40383. /**
  40384. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40385. */
  40386. distanceAwayFromBottomOfFace: number;
  40387. private _faceVectors;
  40388. private _target;
  40389. private _scene;
  40390. private _onRenderObserver;
  40391. private _tmpMatrix;
  40392. private _tmpVector;
  40393. /**
  40394. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40395. * @param ui The transform node that should be attched to the mesh
  40396. */
  40397. constructor(ui: TransformNode);
  40398. /**
  40399. * Initializes the behavior
  40400. */
  40401. init(): void;
  40402. private _closestFace;
  40403. private _zeroVector;
  40404. private _lookAtTmpMatrix;
  40405. private _lookAtToRef;
  40406. /**
  40407. * Attaches the AttachToBoxBehavior to the passed in mesh
  40408. * @param target The mesh that the specified node will be attached to
  40409. */
  40410. attach(target: Mesh): void;
  40411. /**
  40412. * Detaches the behavior from the mesh
  40413. */
  40414. detach(): void;
  40415. }
  40416. }
  40417. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40418. import { Behavior } from "babylonjs/Behaviors/behavior";
  40419. import { Mesh } from "babylonjs/Meshes/mesh";
  40420. /**
  40421. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40422. */
  40423. export class FadeInOutBehavior implements Behavior<Mesh> {
  40424. /**
  40425. * Time in milliseconds to delay before fading in (Default: 0)
  40426. */
  40427. delay: number;
  40428. /**
  40429. * Time in milliseconds for the mesh to fade in (Default: 300)
  40430. */
  40431. fadeInTime: number;
  40432. private _millisecondsPerFrame;
  40433. private _hovered;
  40434. private _hoverValue;
  40435. private _ownerNode;
  40436. /**
  40437. * Instatiates the FadeInOutBehavior
  40438. */
  40439. constructor();
  40440. /**
  40441. * The name of the behavior
  40442. */
  40443. get name(): string;
  40444. /**
  40445. * Initializes the behavior
  40446. */
  40447. init(): void;
  40448. /**
  40449. * Attaches the fade behavior on the passed in mesh
  40450. * @param ownerNode The mesh that will be faded in/out once attached
  40451. */
  40452. attach(ownerNode: Mesh): void;
  40453. /**
  40454. * Detaches the behavior from the mesh
  40455. */
  40456. detach(): void;
  40457. /**
  40458. * Triggers the mesh to begin fading in or out
  40459. * @param value if the object should fade in or out (true to fade in)
  40460. */
  40461. fadeIn(value: boolean): void;
  40462. private _update;
  40463. private _setAllVisibility;
  40464. }
  40465. }
  40466. declare module "babylonjs/Misc/pivotTools" {
  40467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40468. /**
  40469. * Class containing a set of static utilities functions for managing Pivots
  40470. * @hidden
  40471. */
  40472. export class PivotTools {
  40473. private static _PivotCached;
  40474. private static _OldPivotPoint;
  40475. private static _PivotTranslation;
  40476. private static _PivotTmpVector;
  40477. /** @hidden */
  40478. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40479. /** @hidden */
  40480. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40481. }
  40482. }
  40483. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40484. import { Scene } from "babylonjs/scene";
  40485. import { Vector4 } from "babylonjs/Maths/math.vector";
  40486. import { Mesh } from "babylonjs/Meshes/mesh";
  40487. import { Nullable } from "babylonjs/types";
  40488. import { Plane } from "babylonjs/Maths/math.plane";
  40489. /**
  40490. * Class containing static functions to help procedurally build meshes
  40491. */
  40492. export class PlaneBuilder {
  40493. /**
  40494. * Creates a plane mesh
  40495. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40496. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40497. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40501. * @param name defines the name of the mesh
  40502. * @param options defines the options used to create the mesh
  40503. * @param scene defines the hosting scene
  40504. * @returns the plane mesh
  40505. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40506. */
  40507. static CreatePlane(name: string, options: {
  40508. size?: number;
  40509. width?: number;
  40510. height?: number;
  40511. sideOrientation?: number;
  40512. frontUVs?: Vector4;
  40513. backUVs?: Vector4;
  40514. updatable?: boolean;
  40515. sourcePlane?: Plane;
  40516. }, scene?: Nullable<Scene>): Mesh;
  40517. }
  40518. }
  40519. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40520. import { Behavior } from "babylonjs/Behaviors/behavior";
  40521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40522. import { Observable } from "babylonjs/Misc/observable";
  40523. import { Vector3 } from "babylonjs/Maths/math.vector";
  40524. import { Ray } from "babylonjs/Culling/ray";
  40525. import "babylonjs/Meshes/Builders/planeBuilder";
  40526. /**
  40527. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40528. */
  40529. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40530. private static _AnyMouseID;
  40531. /**
  40532. * Abstract mesh the behavior is set on
  40533. */
  40534. attachedNode: AbstractMesh;
  40535. private _dragPlane;
  40536. private _scene;
  40537. private _pointerObserver;
  40538. private _beforeRenderObserver;
  40539. private static _planeScene;
  40540. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40541. /**
  40542. * 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)
  40543. */
  40544. maxDragAngle: number;
  40545. /**
  40546. * @hidden
  40547. */
  40548. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40549. /**
  40550. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40551. */
  40552. currentDraggingPointerID: number;
  40553. /**
  40554. * The last position where the pointer hit the drag plane in world space
  40555. */
  40556. lastDragPosition: Vector3;
  40557. /**
  40558. * If the behavior is currently in a dragging state
  40559. */
  40560. dragging: boolean;
  40561. /**
  40562. * 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)
  40563. */
  40564. dragDeltaRatio: number;
  40565. /**
  40566. * If the drag plane orientation should be updated during the dragging (Default: true)
  40567. */
  40568. updateDragPlane: boolean;
  40569. private _debugMode;
  40570. private _moving;
  40571. /**
  40572. * Fires each time the attached mesh is dragged with the pointer
  40573. * * delta between last drag position and current drag position in world space
  40574. * * dragDistance along the drag axis
  40575. * * dragPlaneNormal normal of the current drag plane used during the drag
  40576. * * dragPlanePoint in world space where the drag intersects the drag plane
  40577. */
  40578. onDragObservable: Observable<{
  40579. delta: Vector3;
  40580. dragPlanePoint: Vector3;
  40581. dragPlaneNormal: Vector3;
  40582. dragDistance: number;
  40583. pointerId: number;
  40584. }>;
  40585. /**
  40586. * Fires each time a drag begins (eg. mouse down on mesh)
  40587. */
  40588. onDragStartObservable: Observable<{
  40589. dragPlanePoint: Vector3;
  40590. pointerId: number;
  40591. }>;
  40592. /**
  40593. * Fires each time a drag ends (eg. mouse release after drag)
  40594. */
  40595. onDragEndObservable: Observable<{
  40596. dragPlanePoint: Vector3;
  40597. pointerId: number;
  40598. }>;
  40599. /**
  40600. * If the attached mesh should be moved when dragged
  40601. */
  40602. moveAttached: boolean;
  40603. /**
  40604. * If the drag behavior will react to drag events (Default: true)
  40605. */
  40606. enabled: boolean;
  40607. /**
  40608. * If pointer events should start and release the drag (Default: true)
  40609. */
  40610. startAndReleaseDragOnPointerEvents: boolean;
  40611. /**
  40612. * If camera controls should be detached during the drag
  40613. */
  40614. detachCameraControls: boolean;
  40615. /**
  40616. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40617. */
  40618. useObjectOrientationForDragging: boolean;
  40619. private _options;
  40620. /**
  40621. * Gets the options used by the behavior
  40622. */
  40623. get options(): {
  40624. dragAxis?: Vector3;
  40625. dragPlaneNormal?: Vector3;
  40626. };
  40627. /**
  40628. * Sets the options used by the behavior
  40629. */
  40630. set options(options: {
  40631. dragAxis?: Vector3;
  40632. dragPlaneNormal?: Vector3;
  40633. });
  40634. /**
  40635. * Creates a pointer drag behavior that can be attached to a mesh
  40636. * @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)
  40637. */
  40638. constructor(options?: {
  40639. dragAxis?: Vector3;
  40640. dragPlaneNormal?: Vector3;
  40641. });
  40642. /**
  40643. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40644. */
  40645. validateDrag: (targetPosition: Vector3) => boolean;
  40646. /**
  40647. * The name of the behavior
  40648. */
  40649. get name(): string;
  40650. /**
  40651. * Initializes the behavior
  40652. */
  40653. init(): void;
  40654. private _tmpVector;
  40655. private _alternatePickedPoint;
  40656. private _worldDragAxis;
  40657. private _targetPosition;
  40658. private _attachedElement;
  40659. /**
  40660. * Attaches the drag behavior the passed in mesh
  40661. * @param ownerNode The mesh that will be dragged around once attached
  40662. * @param predicate Predicate to use for pick filtering
  40663. */
  40664. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40665. /**
  40666. * Force relase the drag action by code.
  40667. */
  40668. releaseDrag(): void;
  40669. private _startDragRay;
  40670. private _lastPointerRay;
  40671. /**
  40672. * Simulates the start of a pointer drag event on the behavior
  40673. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40674. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40675. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40676. */
  40677. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40678. private _startDrag;
  40679. private _dragDelta;
  40680. private _moveDrag;
  40681. private _pickWithRayOnDragPlane;
  40682. private _pointA;
  40683. private _pointB;
  40684. private _pointC;
  40685. private _lineA;
  40686. private _lineB;
  40687. private _localAxis;
  40688. private _lookAt;
  40689. private _updateDragPlanePosition;
  40690. /**
  40691. * Detaches the behavior from the mesh
  40692. */
  40693. detach(): void;
  40694. }
  40695. }
  40696. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40697. import { Mesh } from "babylonjs/Meshes/mesh";
  40698. import { Behavior } from "babylonjs/Behaviors/behavior";
  40699. /**
  40700. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40701. */
  40702. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40703. private _dragBehaviorA;
  40704. private _dragBehaviorB;
  40705. private _startDistance;
  40706. private _initialScale;
  40707. private _targetScale;
  40708. private _ownerNode;
  40709. private _sceneRenderObserver;
  40710. /**
  40711. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40712. */
  40713. constructor();
  40714. /**
  40715. * The name of the behavior
  40716. */
  40717. get name(): string;
  40718. /**
  40719. * Initializes the behavior
  40720. */
  40721. init(): void;
  40722. private _getCurrentDistance;
  40723. /**
  40724. * Attaches the scale behavior the passed in mesh
  40725. * @param ownerNode The mesh that will be scaled around once attached
  40726. */
  40727. attach(ownerNode: Mesh): void;
  40728. /**
  40729. * Detaches the behavior from the mesh
  40730. */
  40731. detach(): void;
  40732. }
  40733. }
  40734. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40735. import { Behavior } from "babylonjs/Behaviors/behavior";
  40736. import { Mesh } from "babylonjs/Meshes/mesh";
  40737. import { Observable } from "babylonjs/Misc/observable";
  40738. /**
  40739. * 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
  40740. */
  40741. export class SixDofDragBehavior implements Behavior<Mesh> {
  40742. private static _virtualScene;
  40743. private _ownerNode;
  40744. private _sceneRenderObserver;
  40745. private _scene;
  40746. private _targetPosition;
  40747. private _virtualOriginMesh;
  40748. private _virtualDragMesh;
  40749. private _pointerObserver;
  40750. private _moving;
  40751. private _startingOrientation;
  40752. /**
  40753. * 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)
  40754. */
  40755. private zDragFactor;
  40756. /**
  40757. * If the object should rotate to face the drag origin
  40758. */
  40759. rotateDraggedObject: boolean;
  40760. /**
  40761. * If the behavior is currently in a dragging state
  40762. */
  40763. dragging: boolean;
  40764. /**
  40765. * 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)
  40766. */
  40767. dragDeltaRatio: number;
  40768. /**
  40769. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40770. */
  40771. currentDraggingPointerID: number;
  40772. /**
  40773. * If camera controls should be detached during the drag
  40774. */
  40775. detachCameraControls: boolean;
  40776. /**
  40777. * Fires each time a drag starts
  40778. */
  40779. onDragStartObservable: Observable<{}>;
  40780. /**
  40781. * Fires each time a drag ends (eg. mouse release after drag)
  40782. */
  40783. onDragEndObservable: Observable<{}>;
  40784. /**
  40785. * 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
  40786. */
  40787. constructor();
  40788. /**
  40789. * The name of the behavior
  40790. */
  40791. get name(): string;
  40792. /**
  40793. * Initializes the behavior
  40794. */
  40795. init(): void;
  40796. /**
  40797. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40798. */
  40799. private get _pointerCamera();
  40800. /**
  40801. * Attaches the scale behavior the passed in mesh
  40802. * @param ownerNode The mesh that will be scaled around once attached
  40803. */
  40804. attach(ownerNode: Mesh): void;
  40805. /**
  40806. * Detaches the behavior from the mesh
  40807. */
  40808. detach(): void;
  40809. }
  40810. }
  40811. declare module "babylonjs/Behaviors/Meshes/index" {
  40812. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40813. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40814. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40815. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40816. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40817. }
  40818. declare module "babylonjs/Behaviors/index" {
  40819. export * from "babylonjs/Behaviors/behavior";
  40820. export * from "babylonjs/Behaviors/Cameras/index";
  40821. export * from "babylonjs/Behaviors/Meshes/index";
  40822. }
  40823. declare module "babylonjs/Bones/boneIKController" {
  40824. import { Bone } from "babylonjs/Bones/bone";
  40825. import { Vector3 } from "babylonjs/Maths/math.vector";
  40826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40827. import { Nullable } from "babylonjs/types";
  40828. /**
  40829. * Class used to apply inverse kinematics to bones
  40830. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40831. */
  40832. export class BoneIKController {
  40833. private static _tmpVecs;
  40834. private static _tmpQuat;
  40835. private static _tmpMats;
  40836. /**
  40837. * Gets or sets the target mesh
  40838. */
  40839. targetMesh: AbstractMesh;
  40840. /** Gets or sets the mesh used as pole */
  40841. poleTargetMesh: AbstractMesh;
  40842. /**
  40843. * Gets or sets the bone used as pole
  40844. */
  40845. poleTargetBone: Nullable<Bone>;
  40846. /**
  40847. * Gets or sets the target position
  40848. */
  40849. targetPosition: Vector3;
  40850. /**
  40851. * Gets or sets the pole target position
  40852. */
  40853. poleTargetPosition: Vector3;
  40854. /**
  40855. * Gets or sets the pole target local offset
  40856. */
  40857. poleTargetLocalOffset: Vector3;
  40858. /**
  40859. * Gets or sets the pole angle
  40860. */
  40861. poleAngle: number;
  40862. /**
  40863. * Gets or sets the mesh associated with the controller
  40864. */
  40865. mesh: AbstractMesh;
  40866. /**
  40867. * 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)
  40868. */
  40869. slerpAmount: number;
  40870. private _bone1Quat;
  40871. private _bone1Mat;
  40872. private _bone2Ang;
  40873. private _bone1;
  40874. private _bone2;
  40875. private _bone1Length;
  40876. private _bone2Length;
  40877. private _maxAngle;
  40878. private _maxReach;
  40879. private _rightHandedSystem;
  40880. private _bendAxis;
  40881. private _slerping;
  40882. private _adjustRoll;
  40883. /**
  40884. * Gets or sets maximum allowed angle
  40885. */
  40886. get maxAngle(): number;
  40887. set maxAngle(value: number);
  40888. /**
  40889. * Creates a new BoneIKController
  40890. * @param mesh defines the mesh to control
  40891. * @param bone defines the bone to control
  40892. * @param options defines options to set up the controller
  40893. */
  40894. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40895. targetMesh?: AbstractMesh;
  40896. poleTargetMesh?: AbstractMesh;
  40897. poleTargetBone?: Bone;
  40898. poleTargetLocalOffset?: Vector3;
  40899. poleAngle?: number;
  40900. bendAxis?: Vector3;
  40901. maxAngle?: number;
  40902. slerpAmount?: number;
  40903. });
  40904. private _setMaxAngle;
  40905. /**
  40906. * Force the controller to update the bones
  40907. */
  40908. update(): void;
  40909. }
  40910. }
  40911. declare module "babylonjs/Bones/boneLookController" {
  40912. import { Vector3 } from "babylonjs/Maths/math.vector";
  40913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40914. import { Bone } from "babylonjs/Bones/bone";
  40915. import { Space } from "babylonjs/Maths/math.axis";
  40916. /**
  40917. * Class used to make a bone look toward a point in space
  40918. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40919. */
  40920. export class BoneLookController {
  40921. private static _tmpVecs;
  40922. private static _tmpQuat;
  40923. private static _tmpMats;
  40924. /**
  40925. * The target Vector3 that the bone will look at
  40926. */
  40927. target: Vector3;
  40928. /**
  40929. * The mesh that the bone is attached to
  40930. */
  40931. mesh: AbstractMesh;
  40932. /**
  40933. * The bone that will be looking to the target
  40934. */
  40935. bone: Bone;
  40936. /**
  40937. * The up axis of the coordinate system that is used when the bone is rotated
  40938. */
  40939. upAxis: Vector3;
  40940. /**
  40941. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40942. */
  40943. upAxisSpace: Space;
  40944. /**
  40945. * Used to make an adjustment to the yaw of the bone
  40946. */
  40947. adjustYaw: number;
  40948. /**
  40949. * Used to make an adjustment to the pitch of the bone
  40950. */
  40951. adjustPitch: number;
  40952. /**
  40953. * Used to make an adjustment to the roll of the bone
  40954. */
  40955. adjustRoll: number;
  40956. /**
  40957. * 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)
  40958. */
  40959. slerpAmount: number;
  40960. private _minYaw;
  40961. private _maxYaw;
  40962. private _minPitch;
  40963. private _maxPitch;
  40964. private _minYawSin;
  40965. private _minYawCos;
  40966. private _maxYawSin;
  40967. private _maxYawCos;
  40968. private _midYawConstraint;
  40969. private _minPitchTan;
  40970. private _maxPitchTan;
  40971. private _boneQuat;
  40972. private _slerping;
  40973. private _transformYawPitch;
  40974. private _transformYawPitchInv;
  40975. private _firstFrameSkipped;
  40976. private _yawRange;
  40977. private _fowardAxis;
  40978. /**
  40979. * Gets or sets the minimum yaw angle that the bone can look to
  40980. */
  40981. get minYaw(): number;
  40982. set minYaw(value: number);
  40983. /**
  40984. * Gets or sets the maximum yaw angle that the bone can look to
  40985. */
  40986. get maxYaw(): number;
  40987. set maxYaw(value: number);
  40988. /**
  40989. * Gets or sets the minimum pitch angle that the bone can look to
  40990. */
  40991. get minPitch(): number;
  40992. set minPitch(value: number);
  40993. /**
  40994. * Gets or sets the maximum pitch angle that the bone can look to
  40995. */
  40996. get maxPitch(): number;
  40997. set maxPitch(value: number);
  40998. /**
  40999. * Create a BoneLookController
  41000. * @param mesh the mesh that the bone belongs to
  41001. * @param bone the bone that will be looking to the target
  41002. * @param target the target Vector3 to look at
  41003. * @param options optional settings:
  41004. * * maxYaw: the maximum angle the bone will yaw to
  41005. * * minYaw: the minimum angle the bone will yaw to
  41006. * * maxPitch: the maximum angle the bone will pitch to
  41007. * * minPitch: the minimum angle the bone will yaw to
  41008. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41009. * * upAxis: the up axis of the coordinate system
  41010. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41011. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41012. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41013. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41014. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41015. * * adjustRoll: used to make an adjustment to the roll of the bone
  41016. **/
  41017. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41018. maxYaw?: number;
  41019. minYaw?: number;
  41020. maxPitch?: number;
  41021. minPitch?: number;
  41022. slerpAmount?: number;
  41023. upAxis?: Vector3;
  41024. upAxisSpace?: Space;
  41025. yawAxis?: Vector3;
  41026. pitchAxis?: Vector3;
  41027. adjustYaw?: number;
  41028. adjustPitch?: number;
  41029. adjustRoll?: number;
  41030. });
  41031. /**
  41032. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41033. */
  41034. update(): void;
  41035. private _getAngleDiff;
  41036. private _getAngleBetween;
  41037. private _isAngleBetween;
  41038. }
  41039. }
  41040. declare module "babylonjs/Bones/index" {
  41041. export * from "babylonjs/Bones/bone";
  41042. export * from "babylonjs/Bones/boneIKController";
  41043. export * from "babylonjs/Bones/boneLookController";
  41044. export * from "babylonjs/Bones/skeleton";
  41045. }
  41046. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41047. import { Nullable } from "babylonjs/types";
  41048. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41050. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41051. /**
  41052. * Manage the gamepad inputs to control an arc rotate camera.
  41053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41054. */
  41055. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41056. /**
  41057. * Defines the camera the input is attached to.
  41058. */
  41059. camera: ArcRotateCamera;
  41060. /**
  41061. * Defines the gamepad the input is gathering event from.
  41062. */
  41063. gamepad: Nullable<Gamepad>;
  41064. /**
  41065. * Defines the gamepad rotation sensiblity.
  41066. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41067. */
  41068. gamepadRotationSensibility: number;
  41069. /**
  41070. * Defines the gamepad move sensiblity.
  41071. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41072. */
  41073. gamepadMoveSensibility: number;
  41074. private _yAxisScale;
  41075. /**
  41076. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41077. */
  41078. get invertYAxis(): boolean;
  41079. set invertYAxis(value: boolean);
  41080. private _onGamepadConnectedObserver;
  41081. private _onGamepadDisconnectedObserver;
  41082. /**
  41083. * Attach the input controls to a specific dom element to get the input from.
  41084. * @param element Defines the element the controls should be listened from
  41085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41086. */
  41087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41088. /**
  41089. * Detach the current controls from the specified dom element.
  41090. * @param element Defines the element to stop listening the inputs from
  41091. */
  41092. detachControl(element: Nullable<HTMLElement>): void;
  41093. /**
  41094. * Update the current camera state depending on the inputs that have been used this frame.
  41095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41096. */
  41097. checkInputs(): void;
  41098. /**
  41099. * Gets the class name of the current intput.
  41100. * @returns the class name
  41101. */
  41102. getClassName(): string;
  41103. /**
  41104. * Get the friendly name associated with the input class.
  41105. * @returns the input friendly name
  41106. */
  41107. getSimpleName(): string;
  41108. }
  41109. }
  41110. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41111. import { Nullable } from "babylonjs/types";
  41112. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41114. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41115. interface ArcRotateCameraInputsManager {
  41116. /**
  41117. * Add orientation input support to the input manager.
  41118. * @returns the current input manager
  41119. */
  41120. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41121. }
  41122. }
  41123. /**
  41124. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41126. */
  41127. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41128. /**
  41129. * Defines the camera the input is attached to.
  41130. */
  41131. camera: ArcRotateCamera;
  41132. /**
  41133. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41134. */
  41135. alphaCorrection: number;
  41136. /**
  41137. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41138. */
  41139. gammaCorrection: number;
  41140. private _alpha;
  41141. private _gamma;
  41142. private _dirty;
  41143. private _deviceOrientationHandler;
  41144. /**
  41145. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41146. */
  41147. constructor();
  41148. /**
  41149. * Attach the input controls to a specific dom element to get the input from.
  41150. * @param element Defines the element the controls should be listened from
  41151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41152. */
  41153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41154. /** @hidden */
  41155. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41156. /**
  41157. * Update the current camera state depending on the inputs that have been used this frame.
  41158. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41159. */
  41160. checkInputs(): void;
  41161. /**
  41162. * Detach the current controls from the specified dom element.
  41163. * @param element Defines the element to stop listening the inputs from
  41164. */
  41165. detachControl(element: Nullable<HTMLElement>): void;
  41166. /**
  41167. * Gets the class name of the current intput.
  41168. * @returns the class name
  41169. */
  41170. getClassName(): string;
  41171. /**
  41172. * Get the friendly name associated with the input class.
  41173. * @returns the input friendly name
  41174. */
  41175. getSimpleName(): string;
  41176. }
  41177. }
  41178. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41179. import { Nullable } from "babylonjs/types";
  41180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41181. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41182. /**
  41183. * Listen to mouse events to control the camera.
  41184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41185. */
  41186. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41187. /**
  41188. * Defines the camera the input is attached to.
  41189. */
  41190. camera: FlyCamera;
  41191. /**
  41192. * Defines if touch is enabled. (Default is true.)
  41193. */
  41194. touchEnabled: boolean;
  41195. /**
  41196. * Defines the buttons associated with the input to handle camera rotation.
  41197. */
  41198. buttons: number[];
  41199. /**
  41200. * Assign buttons for Yaw control.
  41201. */
  41202. buttonsYaw: number[];
  41203. /**
  41204. * Assign buttons for Pitch control.
  41205. */
  41206. buttonsPitch: number[];
  41207. /**
  41208. * Assign buttons for Roll control.
  41209. */
  41210. buttonsRoll: number[];
  41211. /**
  41212. * Detect if any button is being pressed while mouse is moved.
  41213. * -1 = Mouse locked.
  41214. * 0 = Left button.
  41215. * 1 = Middle Button.
  41216. * 2 = Right Button.
  41217. */
  41218. activeButton: number;
  41219. /**
  41220. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41221. * Higher values reduce its sensitivity.
  41222. */
  41223. angularSensibility: number;
  41224. private _mousemoveCallback;
  41225. private _observer;
  41226. private _rollObserver;
  41227. private previousPosition;
  41228. private noPreventDefault;
  41229. private element;
  41230. /**
  41231. * Listen to mouse events to control the camera.
  41232. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41234. */
  41235. constructor(touchEnabled?: boolean);
  41236. /**
  41237. * Attach the mouse control to the HTML DOM element.
  41238. * @param element Defines the element that listens to the input events.
  41239. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41240. */
  41241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41242. /**
  41243. * Detach the current controls from the specified dom element.
  41244. * @param element Defines the element to stop listening the inputs from
  41245. */
  41246. detachControl(element: Nullable<HTMLElement>): void;
  41247. /**
  41248. * Gets the class name of the current input.
  41249. * @returns the class name.
  41250. */
  41251. getClassName(): string;
  41252. /**
  41253. * Get the friendly name associated with the input class.
  41254. * @returns the input's friendly name.
  41255. */
  41256. getSimpleName(): string;
  41257. private _pointerInput;
  41258. private _onMouseMove;
  41259. /**
  41260. * Rotate camera by mouse offset.
  41261. */
  41262. private rotateCamera;
  41263. }
  41264. }
  41265. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41266. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41267. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41268. /**
  41269. * Default Inputs manager for the FlyCamera.
  41270. * It groups all the default supported inputs for ease of use.
  41271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41272. */
  41273. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41274. /**
  41275. * Instantiates a new FlyCameraInputsManager.
  41276. * @param camera Defines the camera the inputs belong to.
  41277. */
  41278. constructor(camera: FlyCamera);
  41279. /**
  41280. * Add keyboard input support to the input manager.
  41281. * @returns the new FlyCameraKeyboardMoveInput().
  41282. */
  41283. addKeyboard(): FlyCameraInputsManager;
  41284. /**
  41285. * Add mouse input support to the input manager.
  41286. * @param touchEnabled Enable touch screen support.
  41287. * @returns the new FlyCameraMouseInput().
  41288. */
  41289. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41290. }
  41291. }
  41292. declare module "babylonjs/Cameras/flyCamera" {
  41293. import { Scene } from "babylonjs/scene";
  41294. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41296. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41297. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41298. /**
  41299. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41300. * such as in a 3D Space Shooter or a Flight Simulator.
  41301. */
  41302. export class FlyCamera extends TargetCamera {
  41303. /**
  41304. * Define the collision ellipsoid of the camera.
  41305. * This is helpful for simulating a camera body, like a player's body.
  41306. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41307. */
  41308. ellipsoid: Vector3;
  41309. /**
  41310. * Define an offset for the position of the ellipsoid around the camera.
  41311. * This can be helpful if the camera is attached away from the player's body center,
  41312. * such as at its head.
  41313. */
  41314. ellipsoidOffset: Vector3;
  41315. /**
  41316. * Enable or disable collisions of the camera with the rest of the scene objects.
  41317. */
  41318. checkCollisions: boolean;
  41319. /**
  41320. * Enable or disable gravity on the camera.
  41321. */
  41322. applyGravity: boolean;
  41323. /**
  41324. * Define the current direction the camera is moving to.
  41325. */
  41326. cameraDirection: Vector3;
  41327. /**
  41328. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41329. * This overrides and empties cameraRotation.
  41330. */
  41331. rotationQuaternion: Quaternion;
  41332. /**
  41333. * Track Roll to maintain the wanted Rolling when looking around.
  41334. */
  41335. _trackRoll: number;
  41336. /**
  41337. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41338. */
  41339. rollCorrect: number;
  41340. /**
  41341. * Mimic a banked turn, Rolling the camera when Yawing.
  41342. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41343. */
  41344. bankedTurn: boolean;
  41345. /**
  41346. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41347. */
  41348. bankedTurnLimit: number;
  41349. /**
  41350. * Value of 0 disables the banked Roll.
  41351. * Value of 1 is equal to the Yaw angle in radians.
  41352. */
  41353. bankedTurnMultiplier: number;
  41354. /**
  41355. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41356. */
  41357. inputs: FlyCameraInputsManager;
  41358. /**
  41359. * Gets the input sensibility for mouse input.
  41360. * Higher values reduce sensitivity.
  41361. */
  41362. get angularSensibility(): number;
  41363. /**
  41364. * Sets the input sensibility for a mouse input.
  41365. * Higher values reduce sensitivity.
  41366. */
  41367. set angularSensibility(value: number);
  41368. /**
  41369. * Get the keys for camera movement forward.
  41370. */
  41371. get keysForward(): number[];
  41372. /**
  41373. * Set the keys for camera movement forward.
  41374. */
  41375. set keysForward(value: number[]);
  41376. /**
  41377. * Get the keys for camera movement backward.
  41378. */
  41379. get keysBackward(): number[];
  41380. set keysBackward(value: number[]);
  41381. /**
  41382. * Get the keys for camera movement up.
  41383. */
  41384. get keysUp(): number[];
  41385. /**
  41386. * Set the keys for camera movement up.
  41387. */
  41388. set keysUp(value: number[]);
  41389. /**
  41390. * Get the keys for camera movement down.
  41391. */
  41392. get keysDown(): number[];
  41393. /**
  41394. * Set the keys for camera movement down.
  41395. */
  41396. set keysDown(value: number[]);
  41397. /**
  41398. * Get the keys for camera movement left.
  41399. */
  41400. get keysLeft(): number[];
  41401. /**
  41402. * Set the keys for camera movement left.
  41403. */
  41404. set keysLeft(value: number[]);
  41405. /**
  41406. * Set the keys for camera movement right.
  41407. */
  41408. get keysRight(): number[];
  41409. /**
  41410. * Set the keys for camera movement right.
  41411. */
  41412. set keysRight(value: number[]);
  41413. /**
  41414. * Event raised when the camera collides with a mesh in the scene.
  41415. */
  41416. onCollide: (collidedMesh: AbstractMesh) => void;
  41417. private _collider;
  41418. private _needMoveForGravity;
  41419. private _oldPosition;
  41420. private _diffPosition;
  41421. private _newPosition;
  41422. /** @hidden */
  41423. _localDirection: Vector3;
  41424. /** @hidden */
  41425. _transformedDirection: Vector3;
  41426. /**
  41427. * Instantiates a FlyCamera.
  41428. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41429. * such as in a 3D Space Shooter or a Flight Simulator.
  41430. * @param name Define the name of the camera in the scene.
  41431. * @param position Define the starting position of the camera in the scene.
  41432. * @param scene Define the scene the camera belongs to.
  41433. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41434. */
  41435. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41436. /**
  41437. * Attach a control to the HTML DOM element.
  41438. * @param element Defines the element that listens to the input events.
  41439. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41440. */
  41441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41442. /**
  41443. * Detach a control from the HTML DOM element.
  41444. * The camera will stop reacting to that input.
  41445. * @param element Defines the element that listens to the input events.
  41446. */
  41447. detachControl(element: HTMLElement): void;
  41448. private _collisionMask;
  41449. /**
  41450. * Get the mask that the camera ignores in collision events.
  41451. */
  41452. get collisionMask(): number;
  41453. /**
  41454. * Set the mask that the camera ignores in collision events.
  41455. */
  41456. set collisionMask(mask: number);
  41457. /** @hidden */
  41458. _collideWithWorld(displacement: Vector3): void;
  41459. /** @hidden */
  41460. private _onCollisionPositionChange;
  41461. /** @hidden */
  41462. _checkInputs(): void;
  41463. /** @hidden */
  41464. _decideIfNeedsToMove(): boolean;
  41465. /** @hidden */
  41466. _updatePosition(): void;
  41467. /**
  41468. * Restore the Roll to its target value at the rate specified.
  41469. * @param rate - Higher means slower restoring.
  41470. * @hidden
  41471. */
  41472. restoreRoll(rate: number): void;
  41473. /**
  41474. * Destroy the camera and release the current resources held by it.
  41475. */
  41476. dispose(): void;
  41477. /**
  41478. * Get the current object class name.
  41479. * @returns the class name.
  41480. */
  41481. getClassName(): string;
  41482. }
  41483. }
  41484. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41485. import { Nullable } from "babylonjs/types";
  41486. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41487. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41488. /**
  41489. * Listen to keyboard events to control the camera.
  41490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41491. */
  41492. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41493. /**
  41494. * Defines the camera the input is attached to.
  41495. */
  41496. camera: FlyCamera;
  41497. /**
  41498. * The list of keyboard keys used to control the forward move of the camera.
  41499. */
  41500. keysForward: number[];
  41501. /**
  41502. * The list of keyboard keys used to control the backward move of the camera.
  41503. */
  41504. keysBackward: number[];
  41505. /**
  41506. * The list of keyboard keys used to control the forward move of the camera.
  41507. */
  41508. keysUp: number[];
  41509. /**
  41510. * The list of keyboard keys used to control the backward move of the camera.
  41511. */
  41512. keysDown: number[];
  41513. /**
  41514. * The list of keyboard keys used to control the right strafe move of the camera.
  41515. */
  41516. keysRight: number[];
  41517. /**
  41518. * The list of keyboard keys used to control the left strafe move of the camera.
  41519. */
  41520. keysLeft: number[];
  41521. private _keys;
  41522. private _onCanvasBlurObserver;
  41523. private _onKeyboardObserver;
  41524. private _engine;
  41525. private _scene;
  41526. /**
  41527. * Attach the input controls to a specific dom element to get the input from.
  41528. * @param element Defines the element the controls should be listened from
  41529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41530. */
  41531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41532. /**
  41533. * Detach the current controls from the specified dom element.
  41534. * @param element Defines the element to stop listening the inputs from
  41535. */
  41536. detachControl(element: Nullable<HTMLElement>): void;
  41537. /**
  41538. * Gets the class name of the current intput.
  41539. * @returns the class name
  41540. */
  41541. getClassName(): string;
  41542. /** @hidden */
  41543. _onLostFocus(e: FocusEvent): void;
  41544. /**
  41545. * Get the friendly name associated with the input class.
  41546. * @returns the input friendly name
  41547. */
  41548. getSimpleName(): string;
  41549. /**
  41550. * Update the current camera state depending on the inputs that have been used this frame.
  41551. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41552. */
  41553. checkInputs(): void;
  41554. }
  41555. }
  41556. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41557. import { Nullable } from "babylonjs/types";
  41558. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41559. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41560. /**
  41561. * Manage the mouse wheel inputs to control a follow camera.
  41562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41563. */
  41564. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41565. /**
  41566. * Defines the camera the input is attached to.
  41567. */
  41568. camera: FollowCamera;
  41569. /**
  41570. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41571. */
  41572. axisControlRadius: boolean;
  41573. /**
  41574. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41575. */
  41576. axisControlHeight: boolean;
  41577. /**
  41578. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41579. */
  41580. axisControlRotation: boolean;
  41581. /**
  41582. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41583. * relation to mouseWheel events.
  41584. */
  41585. wheelPrecision: number;
  41586. /**
  41587. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41588. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41589. */
  41590. wheelDeltaPercentage: number;
  41591. private _wheel;
  41592. private _observer;
  41593. /**
  41594. * Attach the input controls to a specific dom element to get the input from.
  41595. * @param element Defines the element the controls should be listened from
  41596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41597. */
  41598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41599. /**
  41600. * Detach the current controls from the specified dom element.
  41601. * @param element Defines the element to stop listening the inputs from
  41602. */
  41603. detachControl(element: Nullable<HTMLElement>): void;
  41604. /**
  41605. * Gets the class name of the current intput.
  41606. * @returns the class name
  41607. */
  41608. getClassName(): string;
  41609. /**
  41610. * Get the friendly name associated with the input class.
  41611. * @returns the input friendly name
  41612. */
  41613. getSimpleName(): string;
  41614. }
  41615. }
  41616. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41617. import { Nullable } from "babylonjs/types";
  41618. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41619. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41620. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41621. /**
  41622. * Manage the pointers inputs to control an follow camera.
  41623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41624. */
  41625. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41626. /**
  41627. * Defines the camera the input is attached to.
  41628. */
  41629. camera: FollowCamera;
  41630. /**
  41631. * Gets the class name of the current input.
  41632. * @returns the class name
  41633. */
  41634. getClassName(): string;
  41635. /**
  41636. * Defines the pointer angular sensibility along the X axis or how fast is
  41637. * the camera rotating.
  41638. * A negative number will reverse the axis direction.
  41639. */
  41640. angularSensibilityX: number;
  41641. /**
  41642. * Defines the pointer angular sensibility along the Y axis or how fast is
  41643. * the camera rotating.
  41644. * A negative number will reverse the axis direction.
  41645. */
  41646. angularSensibilityY: number;
  41647. /**
  41648. * Defines the pointer pinch precision or how fast is the camera zooming.
  41649. * A negative number will reverse the axis direction.
  41650. */
  41651. pinchPrecision: number;
  41652. /**
  41653. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41654. * from 0.
  41655. * It defines the percentage of current camera.radius to use as delta when
  41656. * pinch zoom is used.
  41657. */
  41658. pinchDeltaPercentage: number;
  41659. /**
  41660. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41661. */
  41662. axisXControlRadius: boolean;
  41663. /**
  41664. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41665. */
  41666. axisXControlHeight: boolean;
  41667. /**
  41668. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41669. */
  41670. axisXControlRotation: boolean;
  41671. /**
  41672. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41673. */
  41674. axisYControlRadius: boolean;
  41675. /**
  41676. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41677. */
  41678. axisYControlHeight: boolean;
  41679. /**
  41680. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41681. */
  41682. axisYControlRotation: boolean;
  41683. /**
  41684. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41685. */
  41686. axisPinchControlRadius: boolean;
  41687. /**
  41688. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41689. */
  41690. axisPinchControlHeight: boolean;
  41691. /**
  41692. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41693. */
  41694. axisPinchControlRotation: boolean;
  41695. /**
  41696. * Log error messages if basic misconfiguration has occurred.
  41697. */
  41698. warningEnable: boolean;
  41699. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41700. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41701. private _warningCounter;
  41702. private _warning;
  41703. }
  41704. }
  41705. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41706. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41707. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41708. /**
  41709. * Default Inputs manager for the FollowCamera.
  41710. * It groups all the default supported inputs for ease of use.
  41711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41712. */
  41713. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41714. /**
  41715. * Instantiates a new FollowCameraInputsManager.
  41716. * @param camera Defines the camera the inputs belong to
  41717. */
  41718. constructor(camera: FollowCamera);
  41719. /**
  41720. * Add keyboard input support to the input manager.
  41721. * @returns the current input manager
  41722. */
  41723. addKeyboard(): FollowCameraInputsManager;
  41724. /**
  41725. * Add mouse wheel input support to the input manager.
  41726. * @returns the current input manager
  41727. */
  41728. addMouseWheel(): FollowCameraInputsManager;
  41729. /**
  41730. * Add pointers input support to the input manager.
  41731. * @returns the current input manager
  41732. */
  41733. addPointers(): FollowCameraInputsManager;
  41734. /**
  41735. * Add orientation input support to the input manager.
  41736. * @returns the current input manager
  41737. */
  41738. addVRDeviceOrientation(): FollowCameraInputsManager;
  41739. }
  41740. }
  41741. declare module "babylonjs/Cameras/followCamera" {
  41742. import { Nullable } from "babylonjs/types";
  41743. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41744. import { Scene } from "babylonjs/scene";
  41745. import { Vector3 } from "babylonjs/Maths/math.vector";
  41746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41747. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41748. /**
  41749. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41750. * an arc rotate version arcFollowCamera are available.
  41751. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41752. */
  41753. export class FollowCamera extends TargetCamera {
  41754. /**
  41755. * Distance the follow camera should follow an object at
  41756. */
  41757. radius: number;
  41758. /**
  41759. * Minimum allowed distance of the camera to the axis of rotation
  41760. * (The camera can not get closer).
  41761. * This can help limiting how the Camera is able to move in the scene.
  41762. */
  41763. lowerRadiusLimit: Nullable<number>;
  41764. /**
  41765. * Maximum allowed distance of the camera to the axis of rotation
  41766. * (The camera can not get further).
  41767. * This can help limiting how the Camera is able to move in the scene.
  41768. */
  41769. upperRadiusLimit: Nullable<number>;
  41770. /**
  41771. * Define a rotation offset between the camera and the object it follows
  41772. */
  41773. rotationOffset: number;
  41774. /**
  41775. * Minimum allowed angle to camera position relative to target object.
  41776. * This can help limiting how the Camera is able to move in the scene.
  41777. */
  41778. lowerRotationOffsetLimit: Nullable<number>;
  41779. /**
  41780. * Maximum allowed angle to camera position relative to target object.
  41781. * This can help limiting how the Camera is able to move in the scene.
  41782. */
  41783. upperRotationOffsetLimit: Nullable<number>;
  41784. /**
  41785. * Define a height offset between the camera and the object it follows.
  41786. * It can help following an object from the top (like a car chaing a plane)
  41787. */
  41788. heightOffset: number;
  41789. /**
  41790. * Minimum allowed height of camera position relative to target object.
  41791. * This can help limiting how the Camera is able to move in the scene.
  41792. */
  41793. lowerHeightOffsetLimit: Nullable<number>;
  41794. /**
  41795. * Maximum allowed height of camera position relative to target object.
  41796. * This can help limiting how the Camera is able to move in the scene.
  41797. */
  41798. upperHeightOffsetLimit: Nullable<number>;
  41799. /**
  41800. * Define how fast the camera can accelerate to follow it s target.
  41801. */
  41802. cameraAcceleration: number;
  41803. /**
  41804. * Define the speed limit of the camera following an object.
  41805. */
  41806. maxCameraSpeed: number;
  41807. /**
  41808. * Define the target of the camera.
  41809. */
  41810. lockedTarget: Nullable<AbstractMesh>;
  41811. /**
  41812. * Defines the input associated with the camera.
  41813. */
  41814. inputs: FollowCameraInputsManager;
  41815. /**
  41816. * Instantiates the follow camera.
  41817. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41818. * @param name Define the name of the camera in the scene
  41819. * @param position Define the position of the camera
  41820. * @param scene Define the scene the camera belong to
  41821. * @param lockedTarget Define the target of the camera
  41822. */
  41823. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41824. private _follow;
  41825. /**
  41826. * Attached controls to the current camera.
  41827. * @param element Defines the element the controls should be listened from
  41828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41829. */
  41830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41831. /**
  41832. * Detach the current controls from the camera.
  41833. * The camera will stop reacting to inputs.
  41834. * @param element Defines the element to stop listening the inputs from
  41835. */
  41836. detachControl(element: HTMLElement): void;
  41837. /** @hidden */
  41838. _checkInputs(): void;
  41839. private _checkLimits;
  41840. /**
  41841. * Gets the camera class name.
  41842. * @returns the class name
  41843. */
  41844. getClassName(): string;
  41845. }
  41846. /**
  41847. * Arc Rotate version of the follow camera.
  41848. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41849. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41850. */
  41851. export class ArcFollowCamera extends TargetCamera {
  41852. /** The longitudinal angle of the camera */
  41853. alpha: number;
  41854. /** The latitudinal angle of the camera */
  41855. beta: number;
  41856. /** The radius of the camera from its target */
  41857. radius: number;
  41858. /** Define the camera target (the messh it should follow) */
  41859. target: Nullable<AbstractMesh>;
  41860. private _cartesianCoordinates;
  41861. /**
  41862. * Instantiates a new ArcFollowCamera
  41863. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41864. * @param name Define the name of the camera
  41865. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41866. * @param beta Define the rotation angle of the camera around the elevation axis
  41867. * @param radius Define the radius of the camera from its target point
  41868. * @param target Define the target of the camera
  41869. * @param scene Define the scene the camera belongs to
  41870. */
  41871. constructor(name: string,
  41872. /** The longitudinal angle of the camera */
  41873. alpha: number,
  41874. /** The latitudinal angle of the camera */
  41875. beta: number,
  41876. /** The radius of the camera from its target */
  41877. radius: number,
  41878. /** Define the camera target (the messh it should follow) */
  41879. target: Nullable<AbstractMesh>, scene: Scene);
  41880. private _follow;
  41881. /** @hidden */
  41882. _checkInputs(): void;
  41883. /**
  41884. * Returns the class name of the object.
  41885. * It is mostly used internally for serialization purposes.
  41886. */
  41887. getClassName(): string;
  41888. }
  41889. }
  41890. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41892. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41893. import { Nullable } from "babylonjs/types";
  41894. /**
  41895. * Manage the keyboard inputs to control the movement of a follow camera.
  41896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41897. */
  41898. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41899. /**
  41900. * Defines the camera the input is attached to.
  41901. */
  41902. camera: FollowCamera;
  41903. /**
  41904. * Defines the list of key codes associated with the up action (increase heightOffset)
  41905. */
  41906. keysHeightOffsetIncr: number[];
  41907. /**
  41908. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41909. */
  41910. keysHeightOffsetDecr: number[];
  41911. /**
  41912. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41913. */
  41914. keysHeightOffsetModifierAlt: boolean;
  41915. /**
  41916. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41917. */
  41918. keysHeightOffsetModifierCtrl: boolean;
  41919. /**
  41920. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41921. */
  41922. keysHeightOffsetModifierShift: boolean;
  41923. /**
  41924. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41925. */
  41926. keysRotationOffsetIncr: number[];
  41927. /**
  41928. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41929. */
  41930. keysRotationOffsetDecr: number[];
  41931. /**
  41932. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41933. */
  41934. keysRotationOffsetModifierAlt: boolean;
  41935. /**
  41936. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41937. */
  41938. keysRotationOffsetModifierCtrl: boolean;
  41939. /**
  41940. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41941. */
  41942. keysRotationOffsetModifierShift: boolean;
  41943. /**
  41944. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41945. */
  41946. keysRadiusIncr: number[];
  41947. /**
  41948. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41949. */
  41950. keysRadiusDecr: number[];
  41951. /**
  41952. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41953. */
  41954. keysRadiusModifierAlt: boolean;
  41955. /**
  41956. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41957. */
  41958. keysRadiusModifierCtrl: boolean;
  41959. /**
  41960. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41961. */
  41962. keysRadiusModifierShift: boolean;
  41963. /**
  41964. * Defines the rate of change of heightOffset.
  41965. */
  41966. heightSensibility: number;
  41967. /**
  41968. * Defines the rate of change of rotationOffset.
  41969. */
  41970. rotationSensibility: number;
  41971. /**
  41972. * Defines the rate of change of radius.
  41973. */
  41974. radiusSensibility: number;
  41975. private _keys;
  41976. private _ctrlPressed;
  41977. private _altPressed;
  41978. private _shiftPressed;
  41979. private _onCanvasBlurObserver;
  41980. private _onKeyboardObserver;
  41981. private _engine;
  41982. private _scene;
  41983. /**
  41984. * Attach the input controls to a specific dom element to get the input from.
  41985. * @param element Defines the element the controls should be listened from
  41986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41987. */
  41988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41989. /**
  41990. * Detach the current controls from the specified dom element.
  41991. * @param element Defines the element to stop listening the inputs from
  41992. */
  41993. detachControl(element: Nullable<HTMLElement>): void;
  41994. /**
  41995. * Update the current camera state depending on the inputs that have been used this frame.
  41996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41997. */
  41998. checkInputs(): void;
  41999. /**
  42000. * Gets the class name of the current input.
  42001. * @returns the class name
  42002. */
  42003. getClassName(): string;
  42004. /**
  42005. * Get the friendly name associated with the input class.
  42006. * @returns the input friendly name
  42007. */
  42008. getSimpleName(): string;
  42009. /**
  42010. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42011. * allow modification of the heightOffset value.
  42012. */
  42013. private _modifierHeightOffset;
  42014. /**
  42015. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42016. * allow modification of the rotationOffset value.
  42017. */
  42018. private _modifierRotationOffset;
  42019. /**
  42020. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42021. * allow modification of the radius value.
  42022. */
  42023. private _modifierRadius;
  42024. }
  42025. }
  42026. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42027. import { Nullable } from "babylonjs/types";
  42028. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42029. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42030. import { Observable } from "babylonjs/Misc/observable";
  42031. module "babylonjs/Cameras/freeCameraInputsManager" {
  42032. interface FreeCameraInputsManager {
  42033. /**
  42034. * @hidden
  42035. */
  42036. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42037. /**
  42038. * Add orientation input support to the input manager.
  42039. * @returns the current input manager
  42040. */
  42041. addDeviceOrientation(): FreeCameraInputsManager;
  42042. }
  42043. }
  42044. /**
  42045. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42046. * Screen rotation is taken into account.
  42047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42048. */
  42049. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42050. private _camera;
  42051. private _screenOrientationAngle;
  42052. private _constantTranform;
  42053. private _screenQuaternion;
  42054. private _alpha;
  42055. private _beta;
  42056. private _gamma;
  42057. /**
  42058. * Can be used to detect if a device orientation sensor is available on a device
  42059. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42060. * @returns a promise that will resolve on orientation change
  42061. */
  42062. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42063. /**
  42064. * @hidden
  42065. */
  42066. _onDeviceOrientationChangedObservable: Observable<void>;
  42067. /**
  42068. * Instantiates a new input
  42069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42070. */
  42071. constructor();
  42072. /**
  42073. * Define the camera controlled by the input.
  42074. */
  42075. get camera(): FreeCamera;
  42076. set camera(camera: FreeCamera);
  42077. /**
  42078. * Attach the input controls to a specific dom element to get the input from.
  42079. * @param element Defines the element the controls should be listened from
  42080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42081. */
  42082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42083. private _orientationChanged;
  42084. private _deviceOrientation;
  42085. /**
  42086. * Detach the current controls from the specified dom element.
  42087. * @param element Defines the element to stop listening the inputs from
  42088. */
  42089. detachControl(element: Nullable<HTMLElement>): void;
  42090. /**
  42091. * Update the current camera state depending on the inputs that have been used this frame.
  42092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42093. */
  42094. checkInputs(): void;
  42095. /**
  42096. * Gets the class name of the current intput.
  42097. * @returns the class name
  42098. */
  42099. getClassName(): string;
  42100. /**
  42101. * Get the friendly name associated with the input class.
  42102. * @returns the input friendly name
  42103. */
  42104. getSimpleName(): string;
  42105. }
  42106. }
  42107. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42108. import { Nullable } from "babylonjs/types";
  42109. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42110. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42111. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42112. /**
  42113. * Manage the gamepad inputs to control a free camera.
  42114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42115. */
  42116. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42117. /**
  42118. * Define the camera the input is attached to.
  42119. */
  42120. camera: FreeCamera;
  42121. /**
  42122. * Define the Gamepad controlling the input
  42123. */
  42124. gamepad: Nullable<Gamepad>;
  42125. /**
  42126. * Defines the gamepad rotation sensiblity.
  42127. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42128. */
  42129. gamepadAngularSensibility: number;
  42130. /**
  42131. * Defines the gamepad move sensiblity.
  42132. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42133. */
  42134. gamepadMoveSensibility: number;
  42135. private _yAxisScale;
  42136. /**
  42137. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42138. */
  42139. get invertYAxis(): boolean;
  42140. set invertYAxis(value: boolean);
  42141. private _onGamepadConnectedObserver;
  42142. private _onGamepadDisconnectedObserver;
  42143. private _cameraTransform;
  42144. private _deltaTransform;
  42145. private _vector3;
  42146. private _vector2;
  42147. /**
  42148. * Attach the input controls to a specific dom element to get the input from.
  42149. * @param element Defines the element the controls should be listened from
  42150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42151. */
  42152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42153. /**
  42154. * Detach the current controls from the specified dom element.
  42155. * @param element Defines the element to stop listening the inputs from
  42156. */
  42157. detachControl(element: Nullable<HTMLElement>): void;
  42158. /**
  42159. * Update the current camera state depending on the inputs that have been used this frame.
  42160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42161. */
  42162. checkInputs(): void;
  42163. /**
  42164. * Gets the class name of the current intput.
  42165. * @returns the class name
  42166. */
  42167. getClassName(): string;
  42168. /**
  42169. * Get the friendly name associated with the input class.
  42170. * @returns the input friendly name
  42171. */
  42172. getSimpleName(): string;
  42173. }
  42174. }
  42175. declare module "babylonjs/Misc/virtualJoystick" {
  42176. import { Nullable } from "babylonjs/types";
  42177. import { Vector3 } from "babylonjs/Maths/math.vector";
  42178. /**
  42179. * Defines the potential axis of a Joystick
  42180. */
  42181. export enum JoystickAxis {
  42182. /** X axis */
  42183. X = 0,
  42184. /** Y axis */
  42185. Y = 1,
  42186. /** Z axis */
  42187. Z = 2
  42188. }
  42189. /**
  42190. * Class used to define virtual joystick (used in touch mode)
  42191. */
  42192. export class VirtualJoystick {
  42193. /**
  42194. * Gets or sets a boolean indicating that left and right values must be inverted
  42195. */
  42196. reverseLeftRight: boolean;
  42197. /**
  42198. * Gets or sets a boolean indicating that up and down values must be inverted
  42199. */
  42200. reverseUpDown: boolean;
  42201. /**
  42202. * Gets the offset value for the position (ie. the change of the position value)
  42203. */
  42204. deltaPosition: Vector3;
  42205. /**
  42206. * Gets a boolean indicating if the virtual joystick was pressed
  42207. */
  42208. pressed: boolean;
  42209. /**
  42210. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42211. */
  42212. static Canvas: Nullable<HTMLCanvasElement>;
  42213. private static _globalJoystickIndex;
  42214. private static vjCanvasContext;
  42215. private static vjCanvasWidth;
  42216. private static vjCanvasHeight;
  42217. private static halfWidth;
  42218. private _action;
  42219. private _axisTargetedByLeftAndRight;
  42220. private _axisTargetedByUpAndDown;
  42221. private _joystickSensibility;
  42222. private _inversedSensibility;
  42223. private _joystickPointerID;
  42224. private _joystickColor;
  42225. private _joystickPointerPos;
  42226. private _joystickPreviousPointerPos;
  42227. private _joystickPointerStartPos;
  42228. private _deltaJoystickVector;
  42229. private _leftJoystick;
  42230. private _touches;
  42231. private _onPointerDownHandlerRef;
  42232. private _onPointerMoveHandlerRef;
  42233. private _onPointerUpHandlerRef;
  42234. private _onResize;
  42235. /**
  42236. * Creates a new virtual joystick
  42237. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42238. */
  42239. constructor(leftJoystick?: boolean);
  42240. /**
  42241. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42242. * @param newJoystickSensibility defines the new sensibility
  42243. */
  42244. setJoystickSensibility(newJoystickSensibility: number): void;
  42245. private _onPointerDown;
  42246. private _onPointerMove;
  42247. private _onPointerUp;
  42248. /**
  42249. * Change the color of the virtual joystick
  42250. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42251. */
  42252. setJoystickColor(newColor: string): void;
  42253. /**
  42254. * Defines a callback to call when the joystick is touched
  42255. * @param action defines the callback
  42256. */
  42257. setActionOnTouch(action: () => any): void;
  42258. /**
  42259. * Defines which axis you'd like to control for left & right
  42260. * @param axis defines the axis to use
  42261. */
  42262. setAxisForLeftRight(axis: JoystickAxis): void;
  42263. /**
  42264. * Defines which axis you'd like to control for up & down
  42265. * @param axis defines the axis to use
  42266. */
  42267. setAxisForUpDown(axis: JoystickAxis): void;
  42268. private _drawVirtualJoystick;
  42269. /**
  42270. * Release internal HTML canvas
  42271. */
  42272. releaseCanvas(): void;
  42273. }
  42274. }
  42275. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42276. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42277. import { Nullable } from "babylonjs/types";
  42278. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42279. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42280. module "babylonjs/Cameras/freeCameraInputsManager" {
  42281. interface FreeCameraInputsManager {
  42282. /**
  42283. * Add virtual joystick input support to the input manager.
  42284. * @returns the current input manager
  42285. */
  42286. addVirtualJoystick(): FreeCameraInputsManager;
  42287. }
  42288. }
  42289. /**
  42290. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42292. */
  42293. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42294. /**
  42295. * Defines the camera the input is attached to.
  42296. */
  42297. camera: FreeCamera;
  42298. private _leftjoystick;
  42299. private _rightjoystick;
  42300. /**
  42301. * Gets the left stick of the virtual joystick.
  42302. * @returns The virtual Joystick
  42303. */
  42304. getLeftJoystick(): VirtualJoystick;
  42305. /**
  42306. * Gets the right stick of the virtual joystick.
  42307. * @returns The virtual Joystick
  42308. */
  42309. getRightJoystick(): VirtualJoystick;
  42310. /**
  42311. * Update the current camera state depending on the inputs that have been used this frame.
  42312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42313. */
  42314. checkInputs(): void;
  42315. /**
  42316. * Attach the input controls to a specific dom element to get the input from.
  42317. * @param element Defines the element the controls should be listened from
  42318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42319. */
  42320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42321. /**
  42322. * Detach the current controls from the specified dom element.
  42323. * @param element Defines the element to stop listening the inputs from
  42324. */
  42325. detachControl(element: Nullable<HTMLElement>): void;
  42326. /**
  42327. * Gets the class name of the current intput.
  42328. * @returns the class name
  42329. */
  42330. getClassName(): string;
  42331. /**
  42332. * Get the friendly name associated with the input class.
  42333. * @returns the input friendly name
  42334. */
  42335. getSimpleName(): string;
  42336. }
  42337. }
  42338. declare module "babylonjs/Cameras/Inputs/index" {
  42339. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42340. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42341. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42342. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42343. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42344. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42345. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42346. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42347. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42348. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42349. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42350. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42351. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42352. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42353. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42354. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42355. }
  42356. declare module "babylonjs/Cameras/touchCamera" {
  42357. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42358. import { Scene } from "babylonjs/scene";
  42359. import { Vector3 } from "babylonjs/Maths/math.vector";
  42360. /**
  42361. * This represents a FPS type of camera controlled by touch.
  42362. * This is like a universal camera minus the Gamepad controls.
  42363. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42364. */
  42365. export class TouchCamera extends FreeCamera {
  42366. /**
  42367. * Defines the touch sensibility for rotation.
  42368. * The higher the faster.
  42369. */
  42370. get touchAngularSensibility(): number;
  42371. set touchAngularSensibility(value: number);
  42372. /**
  42373. * Defines the touch sensibility for move.
  42374. * The higher the faster.
  42375. */
  42376. get touchMoveSensibility(): number;
  42377. set touchMoveSensibility(value: number);
  42378. /**
  42379. * Instantiates a new touch camera.
  42380. * This represents a FPS type of camera controlled by touch.
  42381. * This is like a universal camera minus the Gamepad controls.
  42382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42383. * @param name Define the name of the camera in the scene
  42384. * @param position Define the start position of the camera in the scene
  42385. * @param scene Define the scene the camera belongs to
  42386. */
  42387. constructor(name: string, position: Vector3, scene: Scene);
  42388. /**
  42389. * Gets the current object class name.
  42390. * @return the class name
  42391. */
  42392. getClassName(): string;
  42393. /** @hidden */
  42394. _setupInputs(): void;
  42395. }
  42396. }
  42397. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42398. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42399. import { Scene } from "babylonjs/scene";
  42400. import { Vector3 } from "babylonjs/Maths/math.vector";
  42401. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42402. import { Axis } from "babylonjs/Maths/math.axis";
  42403. /**
  42404. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42405. * being tilted forward or back and left or right.
  42406. */
  42407. export class DeviceOrientationCamera extends FreeCamera {
  42408. private _initialQuaternion;
  42409. private _quaternionCache;
  42410. private _tmpDragQuaternion;
  42411. private _disablePointerInputWhenUsingDeviceOrientation;
  42412. /**
  42413. * Creates a new device orientation camera
  42414. * @param name The name of the camera
  42415. * @param position The start position camera
  42416. * @param scene The scene the camera belongs to
  42417. */
  42418. constructor(name: string, position: Vector3, scene: Scene);
  42419. /**
  42420. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42421. */
  42422. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42423. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42424. private _dragFactor;
  42425. /**
  42426. * Enabled turning on the y axis when the orientation sensor is active
  42427. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42428. */
  42429. enableHorizontalDragging(dragFactor?: number): void;
  42430. /**
  42431. * Gets the current instance class name ("DeviceOrientationCamera").
  42432. * This helps avoiding instanceof at run time.
  42433. * @returns the class name
  42434. */
  42435. getClassName(): string;
  42436. /**
  42437. * @hidden
  42438. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42439. */
  42440. _checkInputs(): void;
  42441. /**
  42442. * Reset the camera to its default orientation on the specified axis only.
  42443. * @param axis The axis to reset
  42444. */
  42445. resetToCurrentRotation(axis?: Axis): void;
  42446. }
  42447. }
  42448. declare module "babylonjs/Gamepads/xboxGamepad" {
  42449. import { Observable } from "babylonjs/Misc/observable";
  42450. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42451. /**
  42452. * Defines supported buttons for XBox360 compatible gamepads
  42453. */
  42454. export enum Xbox360Button {
  42455. /** A */
  42456. A = 0,
  42457. /** B */
  42458. B = 1,
  42459. /** X */
  42460. X = 2,
  42461. /** Y */
  42462. Y = 3,
  42463. /** Left button */
  42464. LB = 4,
  42465. /** Right button */
  42466. RB = 5,
  42467. /** Back */
  42468. Back = 8,
  42469. /** Start */
  42470. Start = 9,
  42471. /** Left stick */
  42472. LeftStick = 10,
  42473. /** Right stick */
  42474. RightStick = 11
  42475. }
  42476. /** Defines values for XBox360 DPad */
  42477. export enum Xbox360Dpad {
  42478. /** Up */
  42479. Up = 12,
  42480. /** Down */
  42481. Down = 13,
  42482. /** Left */
  42483. Left = 14,
  42484. /** Right */
  42485. Right = 15
  42486. }
  42487. /**
  42488. * Defines a XBox360 gamepad
  42489. */
  42490. export class Xbox360Pad extends Gamepad {
  42491. private _leftTrigger;
  42492. private _rightTrigger;
  42493. private _onlefttriggerchanged;
  42494. private _onrighttriggerchanged;
  42495. private _onbuttondown;
  42496. private _onbuttonup;
  42497. private _ondpaddown;
  42498. private _ondpadup;
  42499. /** Observable raised when a button is pressed */
  42500. onButtonDownObservable: Observable<Xbox360Button>;
  42501. /** Observable raised when a button is released */
  42502. onButtonUpObservable: Observable<Xbox360Button>;
  42503. /** Observable raised when a pad is pressed */
  42504. onPadDownObservable: Observable<Xbox360Dpad>;
  42505. /** Observable raised when a pad is released */
  42506. onPadUpObservable: Observable<Xbox360Dpad>;
  42507. private _buttonA;
  42508. private _buttonB;
  42509. private _buttonX;
  42510. private _buttonY;
  42511. private _buttonBack;
  42512. private _buttonStart;
  42513. private _buttonLB;
  42514. private _buttonRB;
  42515. private _buttonLeftStick;
  42516. private _buttonRightStick;
  42517. private _dPadUp;
  42518. private _dPadDown;
  42519. private _dPadLeft;
  42520. private _dPadRight;
  42521. private _isXboxOnePad;
  42522. /**
  42523. * Creates a new XBox360 gamepad object
  42524. * @param id defines the id of this gamepad
  42525. * @param index defines its index
  42526. * @param gamepad defines the internal HTML gamepad object
  42527. * @param xboxOne defines if it is a XBox One gamepad
  42528. */
  42529. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42530. /**
  42531. * Defines the callback to call when left trigger is pressed
  42532. * @param callback defines the callback to use
  42533. */
  42534. onlefttriggerchanged(callback: (value: number) => void): void;
  42535. /**
  42536. * Defines the callback to call when right trigger is pressed
  42537. * @param callback defines the callback to use
  42538. */
  42539. onrighttriggerchanged(callback: (value: number) => void): void;
  42540. /**
  42541. * Gets the left trigger value
  42542. */
  42543. get leftTrigger(): number;
  42544. /**
  42545. * Sets the left trigger value
  42546. */
  42547. set leftTrigger(newValue: number);
  42548. /**
  42549. * Gets the right trigger value
  42550. */
  42551. get rightTrigger(): number;
  42552. /**
  42553. * Sets the right trigger value
  42554. */
  42555. set rightTrigger(newValue: number);
  42556. /**
  42557. * Defines the callback to call when a button is pressed
  42558. * @param callback defines the callback to use
  42559. */
  42560. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42561. /**
  42562. * Defines the callback to call when a button is released
  42563. * @param callback defines the callback to use
  42564. */
  42565. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42566. /**
  42567. * Defines the callback to call when a pad is pressed
  42568. * @param callback defines the callback to use
  42569. */
  42570. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42571. /**
  42572. * Defines the callback to call when a pad is released
  42573. * @param callback defines the callback to use
  42574. */
  42575. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42576. private _setButtonValue;
  42577. private _setDPadValue;
  42578. /**
  42579. * Gets the value of the `A` button
  42580. */
  42581. get buttonA(): number;
  42582. /**
  42583. * Sets the value of the `A` button
  42584. */
  42585. set buttonA(value: number);
  42586. /**
  42587. * Gets the value of the `B` button
  42588. */
  42589. get buttonB(): number;
  42590. /**
  42591. * Sets the value of the `B` button
  42592. */
  42593. set buttonB(value: number);
  42594. /**
  42595. * Gets the value of the `X` button
  42596. */
  42597. get buttonX(): number;
  42598. /**
  42599. * Sets the value of the `X` button
  42600. */
  42601. set buttonX(value: number);
  42602. /**
  42603. * Gets the value of the `Y` button
  42604. */
  42605. get buttonY(): number;
  42606. /**
  42607. * Sets the value of the `Y` button
  42608. */
  42609. set buttonY(value: number);
  42610. /**
  42611. * Gets the value of the `Start` button
  42612. */
  42613. get buttonStart(): number;
  42614. /**
  42615. * Sets the value of the `Start` button
  42616. */
  42617. set buttonStart(value: number);
  42618. /**
  42619. * Gets the value of the `Back` button
  42620. */
  42621. get buttonBack(): number;
  42622. /**
  42623. * Sets the value of the `Back` button
  42624. */
  42625. set buttonBack(value: number);
  42626. /**
  42627. * Gets the value of the `Left` button
  42628. */
  42629. get buttonLB(): number;
  42630. /**
  42631. * Sets the value of the `Left` button
  42632. */
  42633. set buttonLB(value: number);
  42634. /**
  42635. * Gets the value of the `Right` button
  42636. */
  42637. get buttonRB(): number;
  42638. /**
  42639. * Sets the value of the `Right` button
  42640. */
  42641. set buttonRB(value: number);
  42642. /**
  42643. * Gets the value of the Left joystick
  42644. */
  42645. get buttonLeftStick(): number;
  42646. /**
  42647. * Sets the value of the Left joystick
  42648. */
  42649. set buttonLeftStick(value: number);
  42650. /**
  42651. * Gets the value of the Right joystick
  42652. */
  42653. get buttonRightStick(): number;
  42654. /**
  42655. * Sets the value of the Right joystick
  42656. */
  42657. set buttonRightStick(value: number);
  42658. /**
  42659. * Gets the value of D-pad up
  42660. */
  42661. get dPadUp(): number;
  42662. /**
  42663. * Sets the value of D-pad up
  42664. */
  42665. set dPadUp(value: number);
  42666. /**
  42667. * Gets the value of D-pad down
  42668. */
  42669. get dPadDown(): number;
  42670. /**
  42671. * Sets the value of D-pad down
  42672. */
  42673. set dPadDown(value: number);
  42674. /**
  42675. * Gets the value of D-pad left
  42676. */
  42677. get dPadLeft(): number;
  42678. /**
  42679. * Sets the value of D-pad left
  42680. */
  42681. set dPadLeft(value: number);
  42682. /**
  42683. * Gets the value of D-pad right
  42684. */
  42685. get dPadRight(): number;
  42686. /**
  42687. * Sets the value of D-pad right
  42688. */
  42689. set dPadRight(value: number);
  42690. /**
  42691. * Force the gamepad to synchronize with device values
  42692. */
  42693. update(): void;
  42694. /**
  42695. * Disposes the gamepad
  42696. */
  42697. dispose(): void;
  42698. }
  42699. }
  42700. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42701. import { Observable } from "babylonjs/Misc/observable";
  42702. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42703. /**
  42704. * Defines supported buttons for DualShock compatible gamepads
  42705. */
  42706. export enum DualShockButton {
  42707. /** Cross */
  42708. Cross = 0,
  42709. /** Circle */
  42710. Circle = 1,
  42711. /** Square */
  42712. Square = 2,
  42713. /** Triangle */
  42714. Triangle = 3,
  42715. /** L1 */
  42716. L1 = 4,
  42717. /** R1 */
  42718. R1 = 5,
  42719. /** Share */
  42720. Share = 8,
  42721. /** Options */
  42722. Options = 9,
  42723. /** Left stick */
  42724. LeftStick = 10,
  42725. /** Right stick */
  42726. RightStick = 11
  42727. }
  42728. /** Defines values for DualShock DPad */
  42729. export enum DualShockDpad {
  42730. /** Up */
  42731. Up = 12,
  42732. /** Down */
  42733. Down = 13,
  42734. /** Left */
  42735. Left = 14,
  42736. /** Right */
  42737. Right = 15
  42738. }
  42739. /**
  42740. * Defines a DualShock gamepad
  42741. */
  42742. export class DualShockPad extends Gamepad {
  42743. private _leftTrigger;
  42744. private _rightTrigger;
  42745. private _onlefttriggerchanged;
  42746. private _onrighttriggerchanged;
  42747. private _onbuttondown;
  42748. private _onbuttonup;
  42749. private _ondpaddown;
  42750. private _ondpadup;
  42751. /** Observable raised when a button is pressed */
  42752. onButtonDownObservable: Observable<DualShockButton>;
  42753. /** Observable raised when a button is released */
  42754. onButtonUpObservable: Observable<DualShockButton>;
  42755. /** Observable raised when a pad is pressed */
  42756. onPadDownObservable: Observable<DualShockDpad>;
  42757. /** Observable raised when a pad is released */
  42758. onPadUpObservable: Observable<DualShockDpad>;
  42759. private _buttonCross;
  42760. private _buttonCircle;
  42761. private _buttonSquare;
  42762. private _buttonTriangle;
  42763. private _buttonShare;
  42764. private _buttonOptions;
  42765. private _buttonL1;
  42766. private _buttonR1;
  42767. private _buttonLeftStick;
  42768. private _buttonRightStick;
  42769. private _dPadUp;
  42770. private _dPadDown;
  42771. private _dPadLeft;
  42772. private _dPadRight;
  42773. /**
  42774. * Creates a new DualShock gamepad object
  42775. * @param id defines the id of this gamepad
  42776. * @param index defines its index
  42777. * @param gamepad defines the internal HTML gamepad object
  42778. */
  42779. constructor(id: string, index: number, gamepad: any);
  42780. /**
  42781. * Defines the callback to call when left trigger is pressed
  42782. * @param callback defines the callback to use
  42783. */
  42784. onlefttriggerchanged(callback: (value: number) => void): void;
  42785. /**
  42786. * Defines the callback to call when right trigger is pressed
  42787. * @param callback defines the callback to use
  42788. */
  42789. onrighttriggerchanged(callback: (value: number) => void): void;
  42790. /**
  42791. * Gets the left trigger value
  42792. */
  42793. get leftTrigger(): number;
  42794. /**
  42795. * Sets the left trigger value
  42796. */
  42797. set leftTrigger(newValue: number);
  42798. /**
  42799. * Gets the right trigger value
  42800. */
  42801. get rightTrigger(): number;
  42802. /**
  42803. * Sets the right trigger value
  42804. */
  42805. set rightTrigger(newValue: number);
  42806. /**
  42807. * Defines the callback to call when a button is pressed
  42808. * @param callback defines the callback to use
  42809. */
  42810. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42811. /**
  42812. * Defines the callback to call when a button is released
  42813. * @param callback defines the callback to use
  42814. */
  42815. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42816. /**
  42817. * Defines the callback to call when a pad is pressed
  42818. * @param callback defines the callback to use
  42819. */
  42820. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42821. /**
  42822. * Defines the callback to call when a pad is released
  42823. * @param callback defines the callback to use
  42824. */
  42825. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42826. private _setButtonValue;
  42827. private _setDPadValue;
  42828. /**
  42829. * Gets the value of the `Cross` button
  42830. */
  42831. get buttonCross(): number;
  42832. /**
  42833. * Sets the value of the `Cross` button
  42834. */
  42835. set buttonCross(value: number);
  42836. /**
  42837. * Gets the value of the `Circle` button
  42838. */
  42839. get buttonCircle(): number;
  42840. /**
  42841. * Sets the value of the `Circle` button
  42842. */
  42843. set buttonCircle(value: number);
  42844. /**
  42845. * Gets the value of the `Square` button
  42846. */
  42847. get buttonSquare(): number;
  42848. /**
  42849. * Sets the value of the `Square` button
  42850. */
  42851. set buttonSquare(value: number);
  42852. /**
  42853. * Gets the value of the `Triangle` button
  42854. */
  42855. get buttonTriangle(): number;
  42856. /**
  42857. * Sets the value of the `Triangle` button
  42858. */
  42859. set buttonTriangle(value: number);
  42860. /**
  42861. * Gets the value of the `Options` button
  42862. */
  42863. get buttonOptions(): number;
  42864. /**
  42865. * Sets the value of the `Options` button
  42866. */
  42867. set buttonOptions(value: number);
  42868. /**
  42869. * Gets the value of the `Share` button
  42870. */
  42871. get buttonShare(): number;
  42872. /**
  42873. * Sets the value of the `Share` button
  42874. */
  42875. set buttonShare(value: number);
  42876. /**
  42877. * Gets the value of the `L1` button
  42878. */
  42879. get buttonL1(): number;
  42880. /**
  42881. * Sets the value of the `L1` button
  42882. */
  42883. set buttonL1(value: number);
  42884. /**
  42885. * Gets the value of the `R1` button
  42886. */
  42887. get buttonR1(): number;
  42888. /**
  42889. * Sets the value of the `R1` button
  42890. */
  42891. set buttonR1(value: number);
  42892. /**
  42893. * Gets the value of the Left joystick
  42894. */
  42895. get buttonLeftStick(): number;
  42896. /**
  42897. * Sets the value of the Left joystick
  42898. */
  42899. set buttonLeftStick(value: number);
  42900. /**
  42901. * Gets the value of the Right joystick
  42902. */
  42903. get buttonRightStick(): number;
  42904. /**
  42905. * Sets the value of the Right joystick
  42906. */
  42907. set buttonRightStick(value: number);
  42908. /**
  42909. * Gets the value of D-pad up
  42910. */
  42911. get dPadUp(): number;
  42912. /**
  42913. * Sets the value of D-pad up
  42914. */
  42915. set dPadUp(value: number);
  42916. /**
  42917. * Gets the value of D-pad down
  42918. */
  42919. get dPadDown(): number;
  42920. /**
  42921. * Sets the value of D-pad down
  42922. */
  42923. set dPadDown(value: number);
  42924. /**
  42925. * Gets the value of D-pad left
  42926. */
  42927. get dPadLeft(): number;
  42928. /**
  42929. * Sets the value of D-pad left
  42930. */
  42931. set dPadLeft(value: number);
  42932. /**
  42933. * Gets the value of D-pad right
  42934. */
  42935. get dPadRight(): number;
  42936. /**
  42937. * Sets the value of D-pad right
  42938. */
  42939. set dPadRight(value: number);
  42940. /**
  42941. * Force the gamepad to synchronize with device values
  42942. */
  42943. update(): void;
  42944. /**
  42945. * Disposes the gamepad
  42946. */
  42947. dispose(): void;
  42948. }
  42949. }
  42950. declare module "babylonjs/Gamepads/gamepadManager" {
  42951. import { Observable } from "babylonjs/Misc/observable";
  42952. import { Nullable } from "babylonjs/types";
  42953. import { Scene } from "babylonjs/scene";
  42954. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42955. /**
  42956. * Manager for handling gamepads
  42957. */
  42958. export class GamepadManager {
  42959. private _scene?;
  42960. private _babylonGamepads;
  42961. private _oneGamepadConnected;
  42962. /** @hidden */
  42963. _isMonitoring: boolean;
  42964. private _gamepadEventSupported;
  42965. private _gamepadSupport?;
  42966. /**
  42967. * observable to be triggered when the gamepad controller has been connected
  42968. */
  42969. onGamepadConnectedObservable: Observable<Gamepad>;
  42970. /**
  42971. * observable to be triggered when the gamepad controller has been disconnected
  42972. */
  42973. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42974. private _onGamepadConnectedEvent;
  42975. private _onGamepadDisconnectedEvent;
  42976. /**
  42977. * Initializes the gamepad manager
  42978. * @param _scene BabylonJS scene
  42979. */
  42980. constructor(_scene?: Scene | undefined);
  42981. /**
  42982. * The gamepads in the game pad manager
  42983. */
  42984. get gamepads(): Gamepad[];
  42985. /**
  42986. * Get the gamepad controllers based on type
  42987. * @param type The type of gamepad controller
  42988. * @returns Nullable gamepad
  42989. */
  42990. getGamepadByType(type?: number): Nullable<Gamepad>;
  42991. /**
  42992. * Disposes the gamepad manager
  42993. */
  42994. dispose(): void;
  42995. private _addNewGamepad;
  42996. private _startMonitoringGamepads;
  42997. private _stopMonitoringGamepads;
  42998. /** @hidden */
  42999. _checkGamepadsStatus(): void;
  43000. private _updateGamepadObjects;
  43001. }
  43002. }
  43003. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43004. import { Nullable } from "babylonjs/types";
  43005. import { Scene } from "babylonjs/scene";
  43006. import { ISceneComponent } from "babylonjs/sceneComponent";
  43007. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43008. module "babylonjs/scene" {
  43009. interface Scene {
  43010. /** @hidden */
  43011. _gamepadManager: Nullable<GamepadManager>;
  43012. /**
  43013. * Gets the gamepad manager associated with the scene
  43014. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43015. */
  43016. gamepadManager: GamepadManager;
  43017. }
  43018. }
  43019. module "babylonjs/Cameras/freeCameraInputsManager" {
  43020. /**
  43021. * Interface representing a free camera inputs manager
  43022. */
  43023. interface FreeCameraInputsManager {
  43024. /**
  43025. * Adds gamepad input support to the FreeCameraInputsManager.
  43026. * @returns the FreeCameraInputsManager
  43027. */
  43028. addGamepad(): FreeCameraInputsManager;
  43029. }
  43030. }
  43031. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43032. /**
  43033. * Interface representing an arc rotate camera inputs manager
  43034. */
  43035. interface ArcRotateCameraInputsManager {
  43036. /**
  43037. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43038. * @returns the camera inputs manager
  43039. */
  43040. addGamepad(): ArcRotateCameraInputsManager;
  43041. }
  43042. }
  43043. /**
  43044. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43045. */
  43046. export class GamepadSystemSceneComponent implements ISceneComponent {
  43047. /**
  43048. * The component name helpfull to identify the component in the list of scene components.
  43049. */
  43050. readonly name: string;
  43051. /**
  43052. * The scene the component belongs to.
  43053. */
  43054. scene: Scene;
  43055. /**
  43056. * Creates a new instance of the component for the given scene
  43057. * @param scene Defines the scene to register the component in
  43058. */
  43059. constructor(scene: Scene);
  43060. /**
  43061. * Registers the component in a given scene
  43062. */
  43063. register(): void;
  43064. /**
  43065. * Rebuilds the elements related to this component in case of
  43066. * context lost for instance.
  43067. */
  43068. rebuild(): void;
  43069. /**
  43070. * Disposes the component and the associated ressources
  43071. */
  43072. dispose(): void;
  43073. private _beforeCameraUpdate;
  43074. }
  43075. }
  43076. declare module "babylonjs/Cameras/universalCamera" {
  43077. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43078. import { Scene } from "babylonjs/scene";
  43079. import { Vector3 } from "babylonjs/Maths/math.vector";
  43080. import "babylonjs/Gamepads/gamepadSceneComponent";
  43081. /**
  43082. * 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,
  43083. * which still works and will still be found in many Playgrounds.
  43084. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43085. */
  43086. export class UniversalCamera extends TouchCamera {
  43087. /**
  43088. * Defines the gamepad rotation sensiblity.
  43089. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43090. */
  43091. get gamepadAngularSensibility(): number;
  43092. set gamepadAngularSensibility(value: number);
  43093. /**
  43094. * Defines the gamepad move sensiblity.
  43095. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43096. */
  43097. get gamepadMoveSensibility(): number;
  43098. set gamepadMoveSensibility(value: number);
  43099. /**
  43100. * 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,
  43101. * which still works and will still be found in many Playgrounds.
  43102. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43103. * @param name Define the name of the camera in the scene
  43104. * @param position Define the start position of the camera in the scene
  43105. * @param scene Define the scene the camera belongs to
  43106. */
  43107. constructor(name: string, position: Vector3, scene: Scene);
  43108. /**
  43109. * Gets the current object class name.
  43110. * @return the class name
  43111. */
  43112. getClassName(): string;
  43113. }
  43114. }
  43115. declare module "babylonjs/Cameras/gamepadCamera" {
  43116. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43117. import { Scene } from "babylonjs/scene";
  43118. import { Vector3 } from "babylonjs/Maths/math.vector";
  43119. /**
  43120. * This represents a FPS type of camera. This is only here for back compat purpose.
  43121. * Please use the UniversalCamera instead as both are identical.
  43122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43123. */
  43124. export class GamepadCamera extends UniversalCamera {
  43125. /**
  43126. * Instantiates a new Gamepad Camera
  43127. * This represents a FPS type of camera. This is only here for back compat purpose.
  43128. * Please use the UniversalCamera instead as both are identical.
  43129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43130. * @param name Define the name of the camera in the scene
  43131. * @param position Define the start position of the camera in the scene
  43132. * @param scene Define the scene the camera belongs to
  43133. */
  43134. constructor(name: string, position: Vector3, scene: Scene);
  43135. /**
  43136. * Gets the current object class name.
  43137. * @return the class name
  43138. */
  43139. getClassName(): string;
  43140. }
  43141. }
  43142. declare module "babylonjs/Shaders/pass.fragment" {
  43143. /** @hidden */
  43144. export var passPixelShader: {
  43145. name: string;
  43146. shader: string;
  43147. };
  43148. }
  43149. declare module "babylonjs/Shaders/passCube.fragment" {
  43150. /** @hidden */
  43151. export var passCubePixelShader: {
  43152. name: string;
  43153. shader: string;
  43154. };
  43155. }
  43156. declare module "babylonjs/PostProcesses/passPostProcess" {
  43157. import { Nullable } from "babylonjs/types";
  43158. import { Camera } from "babylonjs/Cameras/camera";
  43159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43160. import { Engine } from "babylonjs/Engines/engine";
  43161. import "babylonjs/Shaders/pass.fragment";
  43162. import "babylonjs/Shaders/passCube.fragment";
  43163. /**
  43164. * PassPostProcess which produces an output the same as it's input
  43165. */
  43166. export class PassPostProcess extends PostProcess {
  43167. /**
  43168. * Creates the PassPostProcess
  43169. * @param name The name of the effect.
  43170. * @param options The required width/height ratio to downsize to before computing the render pass.
  43171. * @param camera The camera to apply the render pass to.
  43172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43173. * @param engine The engine which the post process will be applied. (default: current engine)
  43174. * @param reusable If the post process can be reused on the same frame. (default: false)
  43175. * @param textureType The type of texture to be used when performing the post processing.
  43176. * @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)
  43177. */
  43178. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43179. }
  43180. /**
  43181. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43182. */
  43183. export class PassCubePostProcess extends PostProcess {
  43184. private _face;
  43185. /**
  43186. * Gets or sets the cube face to display.
  43187. * * 0 is +X
  43188. * * 1 is -X
  43189. * * 2 is +Y
  43190. * * 3 is -Y
  43191. * * 4 is +Z
  43192. * * 5 is -Z
  43193. */
  43194. get face(): number;
  43195. set face(value: number);
  43196. /**
  43197. * Creates the PassCubePostProcess
  43198. * @param name The name of the effect.
  43199. * @param options The required width/height ratio to downsize to before computing the render pass.
  43200. * @param camera The camera to apply the render pass to.
  43201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43202. * @param engine The engine which the post process will be applied. (default: current engine)
  43203. * @param reusable If the post process can be reused on the same frame. (default: false)
  43204. * @param textureType The type of texture to be used when performing the post processing.
  43205. * @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)
  43206. */
  43207. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43208. }
  43209. }
  43210. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43211. /** @hidden */
  43212. export var anaglyphPixelShader: {
  43213. name: string;
  43214. shader: string;
  43215. };
  43216. }
  43217. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43218. import { Engine } from "babylonjs/Engines/engine";
  43219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43220. import { Camera } from "babylonjs/Cameras/camera";
  43221. import "babylonjs/Shaders/anaglyph.fragment";
  43222. /**
  43223. * Postprocess used to generate anaglyphic rendering
  43224. */
  43225. export class AnaglyphPostProcess extends PostProcess {
  43226. private _passedProcess;
  43227. /**
  43228. * Creates a new AnaglyphPostProcess
  43229. * @param name defines postprocess name
  43230. * @param options defines creation options or target ratio scale
  43231. * @param rigCameras defines cameras using this postprocess
  43232. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43233. * @param engine defines hosting engine
  43234. * @param reusable defines if the postprocess will be reused multiple times per frame
  43235. */
  43236. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43237. }
  43238. }
  43239. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43240. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43241. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43242. import { Scene } from "babylonjs/scene";
  43243. import { Vector3 } from "babylonjs/Maths/math.vector";
  43244. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43245. /**
  43246. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43247. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43248. */
  43249. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43250. /**
  43251. * Creates a new AnaglyphArcRotateCamera
  43252. * @param name defines camera name
  43253. * @param alpha defines alpha angle (in radians)
  43254. * @param beta defines beta angle (in radians)
  43255. * @param radius defines radius
  43256. * @param target defines camera target
  43257. * @param interaxialDistance defines distance between each color axis
  43258. * @param scene defines the hosting scene
  43259. */
  43260. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43261. /**
  43262. * Gets camera class name
  43263. * @returns AnaglyphArcRotateCamera
  43264. */
  43265. getClassName(): string;
  43266. }
  43267. }
  43268. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43269. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43270. import { Scene } from "babylonjs/scene";
  43271. import { Vector3 } from "babylonjs/Maths/math.vector";
  43272. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43273. /**
  43274. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43275. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43276. */
  43277. export class AnaglyphFreeCamera extends FreeCamera {
  43278. /**
  43279. * Creates a new AnaglyphFreeCamera
  43280. * @param name defines camera name
  43281. * @param position defines initial position
  43282. * @param interaxialDistance defines distance between each color axis
  43283. * @param scene defines the hosting scene
  43284. */
  43285. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43286. /**
  43287. * Gets camera class name
  43288. * @returns AnaglyphFreeCamera
  43289. */
  43290. getClassName(): string;
  43291. }
  43292. }
  43293. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43294. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43295. import { Scene } from "babylonjs/scene";
  43296. import { Vector3 } from "babylonjs/Maths/math.vector";
  43297. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43298. /**
  43299. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43300. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43301. */
  43302. export class AnaglyphGamepadCamera extends GamepadCamera {
  43303. /**
  43304. * Creates a new AnaglyphGamepadCamera
  43305. * @param name defines camera name
  43306. * @param position defines initial position
  43307. * @param interaxialDistance defines distance between each color axis
  43308. * @param scene defines the hosting scene
  43309. */
  43310. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43311. /**
  43312. * Gets camera class name
  43313. * @returns AnaglyphGamepadCamera
  43314. */
  43315. getClassName(): string;
  43316. }
  43317. }
  43318. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43319. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43320. import { Scene } from "babylonjs/scene";
  43321. import { Vector3 } from "babylonjs/Maths/math.vector";
  43322. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43323. /**
  43324. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43325. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43326. */
  43327. export class AnaglyphUniversalCamera extends UniversalCamera {
  43328. /**
  43329. * Creates a new AnaglyphUniversalCamera
  43330. * @param name defines camera name
  43331. * @param position defines initial position
  43332. * @param interaxialDistance defines distance between each color axis
  43333. * @param scene defines the hosting scene
  43334. */
  43335. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43336. /**
  43337. * Gets camera class name
  43338. * @returns AnaglyphUniversalCamera
  43339. */
  43340. getClassName(): string;
  43341. }
  43342. }
  43343. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43344. /** @hidden */
  43345. export var stereoscopicInterlacePixelShader: {
  43346. name: string;
  43347. shader: string;
  43348. };
  43349. }
  43350. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43351. import { Camera } from "babylonjs/Cameras/camera";
  43352. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43353. import { Engine } from "babylonjs/Engines/engine";
  43354. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43355. /**
  43356. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43357. */
  43358. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43359. private _stepSize;
  43360. private _passedProcess;
  43361. /**
  43362. * Initializes a StereoscopicInterlacePostProcessI
  43363. * @param name The name of the effect.
  43364. * @param rigCameras The rig cameras to be appled to the post process
  43365. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43366. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43368. * @param engine The engine which the post process will be applied. (default: current engine)
  43369. * @param reusable If the post process can be reused on the same frame. (default: false)
  43370. */
  43371. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43372. }
  43373. /**
  43374. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43375. */
  43376. export class StereoscopicInterlacePostProcess extends PostProcess {
  43377. private _stepSize;
  43378. private _passedProcess;
  43379. /**
  43380. * Initializes a StereoscopicInterlacePostProcess
  43381. * @param name The name of the effect.
  43382. * @param rigCameras The rig cameras to be appled to the post process
  43383. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43385. * @param engine The engine which the post process will be applied. (default: current engine)
  43386. * @param reusable If the post process can be reused on the same frame. (default: false)
  43387. */
  43388. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43389. }
  43390. }
  43391. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43392. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43393. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43394. import { Scene } from "babylonjs/scene";
  43395. import { Vector3 } from "babylonjs/Maths/math.vector";
  43396. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43397. /**
  43398. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43399. * @see http://doc.babylonjs.com/features/cameras
  43400. */
  43401. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43402. /**
  43403. * Creates a new StereoscopicArcRotateCamera
  43404. * @param name defines camera name
  43405. * @param alpha defines alpha angle (in radians)
  43406. * @param beta defines beta angle (in radians)
  43407. * @param radius defines radius
  43408. * @param target defines camera target
  43409. * @param interaxialDistance defines distance between each color axis
  43410. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43411. * @param scene defines the hosting scene
  43412. */
  43413. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43414. /**
  43415. * Gets camera class name
  43416. * @returns StereoscopicArcRotateCamera
  43417. */
  43418. getClassName(): string;
  43419. }
  43420. }
  43421. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43422. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43423. import { Scene } from "babylonjs/scene";
  43424. import { Vector3 } from "babylonjs/Maths/math.vector";
  43425. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43426. /**
  43427. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43428. * @see http://doc.babylonjs.com/features/cameras
  43429. */
  43430. export class StereoscopicFreeCamera extends FreeCamera {
  43431. /**
  43432. * Creates a new StereoscopicFreeCamera
  43433. * @param name defines camera name
  43434. * @param position defines initial position
  43435. * @param interaxialDistance defines distance between each color axis
  43436. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43437. * @param scene defines the hosting scene
  43438. */
  43439. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43440. /**
  43441. * Gets camera class name
  43442. * @returns StereoscopicFreeCamera
  43443. */
  43444. getClassName(): string;
  43445. }
  43446. }
  43447. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43448. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43449. import { Scene } from "babylonjs/scene";
  43450. import { Vector3 } from "babylonjs/Maths/math.vector";
  43451. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43452. /**
  43453. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43454. * @see http://doc.babylonjs.com/features/cameras
  43455. */
  43456. export class StereoscopicGamepadCamera extends GamepadCamera {
  43457. /**
  43458. * Creates a new StereoscopicGamepadCamera
  43459. * @param name defines camera name
  43460. * @param position defines initial position
  43461. * @param interaxialDistance defines distance between each color axis
  43462. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43463. * @param scene defines the hosting scene
  43464. */
  43465. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43466. /**
  43467. * Gets camera class name
  43468. * @returns StereoscopicGamepadCamera
  43469. */
  43470. getClassName(): string;
  43471. }
  43472. }
  43473. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43474. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43475. import { Scene } from "babylonjs/scene";
  43476. import { Vector3 } from "babylonjs/Maths/math.vector";
  43477. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43478. /**
  43479. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43480. * @see http://doc.babylonjs.com/features/cameras
  43481. */
  43482. export class StereoscopicUniversalCamera extends UniversalCamera {
  43483. /**
  43484. * Creates a new StereoscopicUniversalCamera
  43485. * @param name defines camera name
  43486. * @param position defines initial position
  43487. * @param interaxialDistance defines distance between each color axis
  43488. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43489. * @param scene defines the hosting scene
  43490. */
  43491. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43492. /**
  43493. * Gets camera class name
  43494. * @returns StereoscopicUniversalCamera
  43495. */
  43496. getClassName(): string;
  43497. }
  43498. }
  43499. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43500. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43501. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43502. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43503. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43504. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43505. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43506. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43507. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43508. }
  43509. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43510. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43511. import { Scene } from "babylonjs/scene";
  43512. import { Vector3 } from "babylonjs/Maths/math.vector";
  43513. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43514. /**
  43515. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43516. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43517. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43518. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43519. */
  43520. export class VirtualJoysticksCamera extends FreeCamera {
  43521. /**
  43522. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43523. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43524. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43525. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43526. * @param name Define the name of the camera in the scene
  43527. * @param position Define the start position of the camera in the scene
  43528. * @param scene Define the scene the camera belongs to
  43529. */
  43530. constructor(name: string, position: Vector3, scene: Scene);
  43531. /**
  43532. * Gets the current object class name.
  43533. * @return the class name
  43534. */
  43535. getClassName(): string;
  43536. }
  43537. }
  43538. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43539. import { Matrix } from "babylonjs/Maths/math.vector";
  43540. /**
  43541. * This represents all the required metrics to create a VR camera.
  43542. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43543. */
  43544. export class VRCameraMetrics {
  43545. /**
  43546. * Define the horizontal resolution off the screen.
  43547. */
  43548. hResolution: number;
  43549. /**
  43550. * Define the vertical resolution off the screen.
  43551. */
  43552. vResolution: number;
  43553. /**
  43554. * Define the horizontal screen size.
  43555. */
  43556. hScreenSize: number;
  43557. /**
  43558. * Define the vertical screen size.
  43559. */
  43560. vScreenSize: number;
  43561. /**
  43562. * Define the vertical screen center position.
  43563. */
  43564. vScreenCenter: number;
  43565. /**
  43566. * Define the distance of the eyes to the screen.
  43567. */
  43568. eyeToScreenDistance: number;
  43569. /**
  43570. * Define the distance between both lenses
  43571. */
  43572. lensSeparationDistance: number;
  43573. /**
  43574. * Define the distance between both viewer's eyes.
  43575. */
  43576. interpupillaryDistance: number;
  43577. /**
  43578. * Define the distortion factor of the VR postprocess.
  43579. * Please, touch with care.
  43580. */
  43581. distortionK: number[];
  43582. /**
  43583. * Define the chromatic aberration correction factors for the VR post process.
  43584. */
  43585. chromaAbCorrection: number[];
  43586. /**
  43587. * Define the scale factor of the post process.
  43588. * The smaller the better but the slower.
  43589. */
  43590. postProcessScaleFactor: number;
  43591. /**
  43592. * Define an offset for the lens center.
  43593. */
  43594. lensCenterOffset: number;
  43595. /**
  43596. * Define if the current vr camera should compensate the distortion of the lense or not.
  43597. */
  43598. compensateDistortion: boolean;
  43599. /**
  43600. * Defines if multiview should be enabled when rendering (Default: false)
  43601. */
  43602. multiviewEnabled: boolean;
  43603. /**
  43604. * Gets the rendering aspect ratio based on the provided resolutions.
  43605. */
  43606. get aspectRatio(): number;
  43607. /**
  43608. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43609. */
  43610. get aspectRatioFov(): number;
  43611. /**
  43612. * @hidden
  43613. */
  43614. get leftHMatrix(): Matrix;
  43615. /**
  43616. * @hidden
  43617. */
  43618. get rightHMatrix(): Matrix;
  43619. /**
  43620. * @hidden
  43621. */
  43622. get leftPreViewMatrix(): Matrix;
  43623. /**
  43624. * @hidden
  43625. */
  43626. get rightPreViewMatrix(): Matrix;
  43627. /**
  43628. * Get the default VRMetrics based on the most generic setup.
  43629. * @returns the default vr metrics
  43630. */
  43631. static GetDefault(): VRCameraMetrics;
  43632. }
  43633. }
  43634. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43635. /** @hidden */
  43636. export var vrDistortionCorrectionPixelShader: {
  43637. name: string;
  43638. shader: string;
  43639. };
  43640. }
  43641. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43642. import { Camera } from "babylonjs/Cameras/camera";
  43643. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43644. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43645. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43646. /**
  43647. * VRDistortionCorrectionPostProcess used for mobile VR
  43648. */
  43649. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43650. private _isRightEye;
  43651. private _distortionFactors;
  43652. private _postProcessScaleFactor;
  43653. private _lensCenterOffset;
  43654. private _scaleIn;
  43655. private _scaleFactor;
  43656. private _lensCenter;
  43657. /**
  43658. * Initializes the VRDistortionCorrectionPostProcess
  43659. * @param name The name of the effect.
  43660. * @param camera The camera to apply the render pass to.
  43661. * @param isRightEye If this is for the right eye distortion
  43662. * @param vrMetrics All the required metrics for the VR camera
  43663. */
  43664. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43665. }
  43666. }
  43667. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43668. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43669. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43670. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43671. import { Scene } from "babylonjs/scene";
  43672. import { Vector3 } from "babylonjs/Maths/math.vector";
  43673. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43674. import "babylonjs/Cameras/RigModes/vrRigMode";
  43675. /**
  43676. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43677. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43678. */
  43679. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43680. /**
  43681. * Creates a new VRDeviceOrientationArcRotateCamera
  43682. * @param name defines camera name
  43683. * @param alpha defines the camera rotation along the logitudinal axis
  43684. * @param beta defines the camera rotation along the latitudinal axis
  43685. * @param radius defines the camera distance from its target
  43686. * @param target defines the camera target
  43687. * @param scene defines the scene the camera belongs to
  43688. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43689. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43690. */
  43691. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43692. /**
  43693. * Gets camera class name
  43694. * @returns VRDeviceOrientationArcRotateCamera
  43695. */
  43696. getClassName(): string;
  43697. }
  43698. }
  43699. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43700. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43701. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43702. import { Scene } from "babylonjs/scene";
  43703. import { Vector3 } from "babylonjs/Maths/math.vector";
  43704. import "babylonjs/Cameras/RigModes/vrRigMode";
  43705. /**
  43706. * Camera used to simulate VR rendering (based on FreeCamera)
  43707. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43708. */
  43709. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43710. /**
  43711. * Creates a new VRDeviceOrientationFreeCamera
  43712. * @param name defines camera name
  43713. * @param position defines the start position of the camera
  43714. * @param scene defines the scene the camera belongs to
  43715. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43716. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43717. */
  43718. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43719. /**
  43720. * Gets camera class name
  43721. * @returns VRDeviceOrientationFreeCamera
  43722. */
  43723. getClassName(): string;
  43724. }
  43725. }
  43726. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43727. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43728. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43729. import { Scene } from "babylonjs/scene";
  43730. import { Vector3 } from "babylonjs/Maths/math.vector";
  43731. import "babylonjs/Gamepads/gamepadSceneComponent";
  43732. /**
  43733. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43734. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43735. */
  43736. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43737. /**
  43738. * Creates a new VRDeviceOrientationGamepadCamera
  43739. * @param name defines camera name
  43740. * @param position defines the start position of the camera
  43741. * @param scene defines the scene the camera belongs to
  43742. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43743. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43744. */
  43745. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43746. /**
  43747. * Gets camera class name
  43748. * @returns VRDeviceOrientationGamepadCamera
  43749. */
  43750. getClassName(): string;
  43751. }
  43752. }
  43753. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43754. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43755. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43756. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43757. /** @hidden */
  43758. export var imageProcessingPixelShader: {
  43759. name: string;
  43760. shader: string;
  43761. };
  43762. }
  43763. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43764. import { Nullable } from "babylonjs/types";
  43765. import { Color4 } from "babylonjs/Maths/math.color";
  43766. import { Camera } from "babylonjs/Cameras/camera";
  43767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43768. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43769. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43770. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43771. import { Engine } from "babylonjs/Engines/engine";
  43772. import "babylonjs/Shaders/imageProcessing.fragment";
  43773. import "babylonjs/Shaders/postprocess.vertex";
  43774. /**
  43775. * ImageProcessingPostProcess
  43776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43777. */
  43778. export class ImageProcessingPostProcess extends PostProcess {
  43779. /**
  43780. * Default configuration related to image processing available in the PBR Material.
  43781. */
  43782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43783. /**
  43784. * Gets the image processing configuration used either in this material.
  43785. */
  43786. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43787. /**
  43788. * Sets the Default image processing configuration used either in the this material.
  43789. *
  43790. * If sets to null, the scene one is in use.
  43791. */
  43792. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43793. /**
  43794. * Keep track of the image processing observer to allow dispose and replace.
  43795. */
  43796. private _imageProcessingObserver;
  43797. /**
  43798. * Attaches a new image processing configuration to the PBR Material.
  43799. * @param configuration
  43800. */
  43801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43802. /**
  43803. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43804. */
  43805. get colorCurves(): Nullable<ColorCurves>;
  43806. /**
  43807. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43808. */
  43809. set colorCurves(value: Nullable<ColorCurves>);
  43810. /**
  43811. * Gets wether the color curves effect is enabled.
  43812. */
  43813. get colorCurvesEnabled(): boolean;
  43814. /**
  43815. * Sets wether the color curves effect is enabled.
  43816. */
  43817. set colorCurvesEnabled(value: boolean);
  43818. /**
  43819. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43820. */
  43821. get colorGradingTexture(): Nullable<BaseTexture>;
  43822. /**
  43823. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43824. */
  43825. set colorGradingTexture(value: Nullable<BaseTexture>);
  43826. /**
  43827. * Gets wether the color grading effect is enabled.
  43828. */
  43829. get colorGradingEnabled(): boolean;
  43830. /**
  43831. * Gets wether the color grading effect is enabled.
  43832. */
  43833. set colorGradingEnabled(value: boolean);
  43834. /**
  43835. * Gets exposure used in the effect.
  43836. */
  43837. get exposure(): number;
  43838. /**
  43839. * Sets exposure used in the effect.
  43840. */
  43841. set exposure(value: number);
  43842. /**
  43843. * Gets wether tonemapping is enabled or not.
  43844. */
  43845. get toneMappingEnabled(): boolean;
  43846. /**
  43847. * Sets wether tonemapping is enabled or not
  43848. */
  43849. set toneMappingEnabled(value: boolean);
  43850. /**
  43851. * Gets the type of tone mapping effect.
  43852. */
  43853. get toneMappingType(): number;
  43854. /**
  43855. * Sets the type of tone mapping effect.
  43856. */
  43857. set toneMappingType(value: number);
  43858. /**
  43859. * Gets contrast used in the effect.
  43860. */
  43861. get contrast(): number;
  43862. /**
  43863. * Sets contrast used in the effect.
  43864. */
  43865. set contrast(value: number);
  43866. /**
  43867. * Gets Vignette stretch size.
  43868. */
  43869. get vignetteStretch(): number;
  43870. /**
  43871. * Sets Vignette stretch size.
  43872. */
  43873. set vignetteStretch(value: number);
  43874. /**
  43875. * Gets Vignette centre X Offset.
  43876. */
  43877. get vignetteCentreX(): number;
  43878. /**
  43879. * Sets Vignette centre X Offset.
  43880. */
  43881. set vignetteCentreX(value: number);
  43882. /**
  43883. * Gets Vignette centre Y Offset.
  43884. */
  43885. get vignetteCentreY(): number;
  43886. /**
  43887. * Sets Vignette centre Y Offset.
  43888. */
  43889. set vignetteCentreY(value: number);
  43890. /**
  43891. * Gets Vignette weight or intensity of the vignette effect.
  43892. */
  43893. get vignetteWeight(): number;
  43894. /**
  43895. * Sets Vignette weight or intensity of the vignette effect.
  43896. */
  43897. set vignetteWeight(value: number);
  43898. /**
  43899. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43900. * if vignetteEnabled is set to true.
  43901. */
  43902. get vignetteColor(): Color4;
  43903. /**
  43904. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43905. * if vignetteEnabled is set to true.
  43906. */
  43907. set vignetteColor(value: Color4);
  43908. /**
  43909. * Gets Camera field of view used by the Vignette effect.
  43910. */
  43911. get vignetteCameraFov(): number;
  43912. /**
  43913. * Sets Camera field of view used by the Vignette effect.
  43914. */
  43915. set vignetteCameraFov(value: number);
  43916. /**
  43917. * Gets the vignette blend mode allowing different kind of effect.
  43918. */
  43919. get vignetteBlendMode(): number;
  43920. /**
  43921. * Sets the vignette blend mode allowing different kind of effect.
  43922. */
  43923. set vignetteBlendMode(value: number);
  43924. /**
  43925. * Gets wether the vignette effect is enabled.
  43926. */
  43927. get vignetteEnabled(): boolean;
  43928. /**
  43929. * Sets wether the vignette effect is enabled.
  43930. */
  43931. set vignetteEnabled(value: boolean);
  43932. private _fromLinearSpace;
  43933. /**
  43934. * Gets wether the input of the processing is in Gamma or Linear Space.
  43935. */
  43936. get fromLinearSpace(): boolean;
  43937. /**
  43938. * Sets wether the input of the processing is in Gamma or Linear Space.
  43939. */
  43940. set fromLinearSpace(value: boolean);
  43941. /**
  43942. * Defines cache preventing GC.
  43943. */
  43944. private _defines;
  43945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43946. /**
  43947. * "ImageProcessingPostProcess"
  43948. * @returns "ImageProcessingPostProcess"
  43949. */
  43950. getClassName(): string;
  43951. protected _updateParameters(): void;
  43952. dispose(camera?: Camera): void;
  43953. }
  43954. }
  43955. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43956. import { Scene } from "babylonjs/scene";
  43957. import { Color3 } from "babylonjs/Maths/math.color";
  43958. import { Mesh } from "babylonjs/Meshes/mesh";
  43959. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43960. import { Nullable } from "babylonjs/types";
  43961. /**
  43962. * Class containing static functions to help procedurally build meshes
  43963. */
  43964. export class GroundBuilder {
  43965. /**
  43966. * Creates a ground mesh
  43967. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43968. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43970. * @param name defines the name of the mesh
  43971. * @param options defines the options used to create the mesh
  43972. * @param scene defines the hosting scene
  43973. * @returns the ground mesh
  43974. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43975. */
  43976. static CreateGround(name: string, options: {
  43977. width?: number;
  43978. height?: number;
  43979. subdivisions?: number;
  43980. subdivisionsX?: number;
  43981. subdivisionsY?: number;
  43982. updatable?: boolean;
  43983. }, scene: any): Mesh;
  43984. /**
  43985. * Creates a tiled ground mesh
  43986. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43987. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43988. * * 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
  43989. * * 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
  43990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43991. * @param name defines the name of the mesh
  43992. * @param options defines the options used to create the mesh
  43993. * @param scene defines the hosting scene
  43994. * @returns the tiled ground mesh
  43995. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43996. */
  43997. static CreateTiledGround(name: string, options: {
  43998. xmin: number;
  43999. zmin: number;
  44000. xmax: number;
  44001. zmax: number;
  44002. subdivisions?: {
  44003. w: number;
  44004. h: number;
  44005. };
  44006. precision?: {
  44007. w: number;
  44008. h: number;
  44009. };
  44010. updatable?: boolean;
  44011. }, scene?: Nullable<Scene>): Mesh;
  44012. /**
  44013. * Creates a ground mesh from a height map
  44014. * * The parameter `url` sets the URL of the height map image resource.
  44015. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44016. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44017. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44018. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44019. * * 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.
  44020. * * 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).
  44021. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44023. * @param name defines the name of the mesh
  44024. * @param url defines the url to the height map
  44025. * @param options defines the options used to create the mesh
  44026. * @param scene defines the hosting scene
  44027. * @returns the ground mesh
  44028. * @see https://doc.babylonjs.com/babylon101/height_map
  44029. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44030. */
  44031. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44032. width?: number;
  44033. height?: number;
  44034. subdivisions?: number;
  44035. minHeight?: number;
  44036. maxHeight?: number;
  44037. colorFilter?: Color3;
  44038. alphaFilter?: number;
  44039. updatable?: boolean;
  44040. onReady?: (mesh: GroundMesh) => void;
  44041. }, scene?: Nullable<Scene>): GroundMesh;
  44042. }
  44043. }
  44044. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44045. import { Vector4 } from "babylonjs/Maths/math.vector";
  44046. import { Mesh } from "babylonjs/Meshes/mesh";
  44047. /**
  44048. * Class containing static functions to help procedurally build meshes
  44049. */
  44050. export class TorusBuilder {
  44051. /**
  44052. * Creates a torus mesh
  44053. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44054. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44055. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44059. * @param name defines the name of the mesh
  44060. * @param options defines the options used to create the mesh
  44061. * @param scene defines the hosting scene
  44062. * @returns the torus mesh
  44063. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44064. */
  44065. static CreateTorus(name: string, options: {
  44066. diameter?: number;
  44067. thickness?: number;
  44068. tessellation?: number;
  44069. updatable?: boolean;
  44070. sideOrientation?: number;
  44071. frontUVs?: Vector4;
  44072. backUVs?: Vector4;
  44073. }, scene: any): Mesh;
  44074. }
  44075. }
  44076. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44077. import { Vector4 } from "babylonjs/Maths/math.vector";
  44078. import { Color4 } from "babylonjs/Maths/math.color";
  44079. import { Mesh } from "babylonjs/Meshes/mesh";
  44080. /**
  44081. * Class containing static functions to help procedurally build meshes
  44082. */
  44083. export class CylinderBuilder {
  44084. /**
  44085. * Creates a cylinder or a cone mesh
  44086. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44087. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44088. * * 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.
  44089. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44090. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44091. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44092. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44093. * * 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).
  44094. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44095. * * 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).
  44096. * * 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
  44097. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44098. * * 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
  44099. * * 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.
  44100. * * If `enclose` is false, a ring surface is one element.
  44101. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44102. * * 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
  44103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44106. * @param name defines the name of the mesh
  44107. * @param options defines the options used to create the mesh
  44108. * @param scene defines the hosting scene
  44109. * @returns the cylinder mesh
  44110. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44111. */
  44112. static CreateCylinder(name: string, options: {
  44113. height?: number;
  44114. diameterTop?: number;
  44115. diameterBottom?: number;
  44116. diameter?: number;
  44117. tessellation?: number;
  44118. subdivisions?: number;
  44119. arc?: number;
  44120. faceColors?: Color4[];
  44121. faceUV?: Vector4[];
  44122. updatable?: boolean;
  44123. hasRings?: boolean;
  44124. enclose?: boolean;
  44125. cap?: number;
  44126. sideOrientation?: number;
  44127. frontUVs?: Vector4;
  44128. backUVs?: Vector4;
  44129. }, scene: any): Mesh;
  44130. }
  44131. }
  44132. declare module "babylonjs/XR/webXRTypes" {
  44133. import { Nullable } from "babylonjs/types";
  44134. import { IDisposable } from "babylonjs/scene";
  44135. /**
  44136. * States of the webXR experience
  44137. */
  44138. export enum WebXRState {
  44139. /**
  44140. * Transitioning to being in XR mode
  44141. */
  44142. ENTERING_XR = 0,
  44143. /**
  44144. * Transitioning to non XR mode
  44145. */
  44146. EXITING_XR = 1,
  44147. /**
  44148. * In XR mode and presenting
  44149. */
  44150. IN_XR = 2,
  44151. /**
  44152. * Not entered XR mode
  44153. */
  44154. NOT_IN_XR = 3
  44155. }
  44156. /**
  44157. * Abstraction of the XR render target
  44158. */
  44159. export interface WebXRRenderTarget extends IDisposable {
  44160. /**
  44161. * xrpresent context of the canvas which can be used to display/mirror xr content
  44162. */
  44163. canvasContext: WebGLRenderingContext;
  44164. /**
  44165. * xr layer for the canvas
  44166. */
  44167. xrLayer: Nullable<XRWebGLLayer>;
  44168. /**
  44169. * Initializes the xr layer for the session
  44170. * @param xrSession xr session
  44171. * @returns a promise that will resolve once the XR Layer has been created
  44172. */
  44173. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44174. }
  44175. }
  44176. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44177. import { Nullable } from "babylonjs/types";
  44178. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44179. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44180. /**
  44181. * COnfiguration object for WebXR output canvas
  44182. */
  44183. export class WebXRManagedOutputCanvasOptions {
  44184. /**
  44185. * An optional canvas in case you wish to create it yourself and provide it here.
  44186. * If not provided, a new canvas will be created
  44187. */
  44188. canvasElement?: HTMLCanvasElement;
  44189. /**
  44190. * Options for this XR Layer output
  44191. */
  44192. canvasOptions?: XRWebGLLayerOptions;
  44193. /**
  44194. * CSS styling for a newly created canvas (if not provided)
  44195. */
  44196. newCanvasCssStyle?: string;
  44197. /**
  44198. * Get the default values of the configuration object
  44199. * @returns default values of this configuration object
  44200. */
  44201. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44202. }
  44203. /**
  44204. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44205. */
  44206. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44207. private _options;
  44208. private _canvas;
  44209. private _engine;
  44210. /**
  44211. * Rendering context of the canvas which can be used to display/mirror xr content
  44212. */
  44213. canvasContext: WebGLRenderingContext;
  44214. /**
  44215. * xr layer for the canvas
  44216. */
  44217. xrLayer: Nullable<XRWebGLLayer>;
  44218. /**
  44219. * Initializes the canvas to be added/removed upon entering/exiting xr
  44220. * @param _xrSessionManager The XR Session manager
  44221. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44222. */
  44223. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44224. /**
  44225. * Disposes of the object
  44226. */
  44227. dispose(): void;
  44228. /**
  44229. * Initializes the xr layer for the session
  44230. * @param xrSession xr session
  44231. * @returns a promise that will resolve once the XR Layer has been created
  44232. */
  44233. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44234. private _addCanvas;
  44235. private _removeCanvas;
  44236. private _setManagedOutputCanvas;
  44237. }
  44238. }
  44239. declare module "babylonjs/XR/webXRSessionManager" {
  44240. import { Observable } from "babylonjs/Misc/observable";
  44241. import { Nullable } from "babylonjs/types";
  44242. import { IDisposable, Scene } from "babylonjs/scene";
  44243. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44244. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44245. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44246. /**
  44247. * Manages an XRSession to work with Babylon's engine
  44248. * @see https://doc.babylonjs.com/how_to/webxr
  44249. */
  44250. export class WebXRSessionManager implements IDisposable {
  44251. /** The scene which the session should be created for */
  44252. scene: Scene;
  44253. private _referenceSpace;
  44254. private _rttProvider;
  44255. private _sessionEnded;
  44256. private _xrNavigator;
  44257. private baseLayer;
  44258. /**
  44259. * The base reference space from which the session started. good if you want to reset your
  44260. * reference space
  44261. */
  44262. baseReferenceSpace: XRReferenceSpace;
  44263. /**
  44264. * Current XR frame
  44265. */
  44266. currentFrame: Nullable<XRFrame>;
  44267. /** WebXR timestamp updated every frame */
  44268. currentTimestamp: number;
  44269. /**
  44270. * Used just in case of a failure to initialize an immersive session.
  44271. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44272. */
  44273. defaultHeightCompensation: number;
  44274. /**
  44275. * Fires every time a new xrFrame arrives which can be used to update the camera
  44276. */
  44277. onXRFrameObservable: Observable<XRFrame>;
  44278. /**
  44279. * Fires when the reference space changed
  44280. */
  44281. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44282. /**
  44283. * Fires when the xr session is ended either by the device or manually done
  44284. */
  44285. onXRSessionEnded: Observable<any>;
  44286. /**
  44287. * Fires when the xr session is ended either by the device or manually done
  44288. */
  44289. onXRSessionInit: Observable<XRSession>;
  44290. /**
  44291. * Underlying xr session
  44292. */
  44293. session: XRSession;
  44294. /**
  44295. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44296. * or get the offset the player is currently at.
  44297. */
  44298. viewerReferenceSpace: XRReferenceSpace;
  44299. /**
  44300. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44301. * @param scene The scene which the session should be created for
  44302. */
  44303. constructor(
  44304. /** The scene which the session should be created for */
  44305. scene: Scene);
  44306. /**
  44307. * The current reference space used in this session. This reference space can constantly change!
  44308. * It is mainly used to offset the camera's position.
  44309. */
  44310. get referenceSpace(): XRReferenceSpace;
  44311. /**
  44312. * Set a new reference space and triggers the observable
  44313. */
  44314. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44315. /**
  44316. * Disposes of the session manager
  44317. */
  44318. dispose(): void;
  44319. /**
  44320. * Stops the xrSession and restores the render loop
  44321. * @returns Promise which resolves after it exits XR
  44322. */
  44323. exitXRAsync(): Promise<void>;
  44324. /**
  44325. * Gets the correct render target texture to be rendered this frame for this eye
  44326. * @param eye the eye for which to get the render target
  44327. * @returns the render target for the specified eye
  44328. */
  44329. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44330. /**
  44331. * Creates a WebXRRenderTarget object for the XR session
  44332. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44333. * @param options optional options to provide when creating a new render target
  44334. * @returns a WebXR render target to which the session can render
  44335. */
  44336. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44337. /**
  44338. * Initializes the manager
  44339. * After initialization enterXR can be called to start an XR session
  44340. * @returns Promise which resolves after it is initialized
  44341. */
  44342. initializeAsync(): Promise<void>;
  44343. /**
  44344. * Initializes an xr session
  44345. * @param xrSessionMode mode to initialize
  44346. * @param xrSessionInit defines optional and required values to pass to the session builder
  44347. * @returns a promise which will resolve once the session has been initialized
  44348. */
  44349. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44350. /**
  44351. * Checks if a session would be supported for the creation options specified
  44352. * @param sessionMode session mode to check if supported eg. immersive-vr
  44353. * @returns A Promise that resolves to true if supported and false if not
  44354. */
  44355. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44356. /**
  44357. * Resets the reference space to the one started the session
  44358. */
  44359. resetReferenceSpace(): void;
  44360. /**
  44361. * Starts rendering to the xr layer
  44362. */
  44363. runXRRenderLoop(): void;
  44364. /**
  44365. * Sets the reference space on the xr session
  44366. * @param referenceSpaceType space to set
  44367. * @returns a promise that will resolve once the reference space has been set
  44368. */
  44369. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44370. /**
  44371. * Updates the render state of the session
  44372. * @param state state to set
  44373. * @returns a promise that resolves once the render state has been updated
  44374. */
  44375. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44376. /**
  44377. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44378. * @param sessionMode defines the session to test
  44379. * @returns a promise with boolean as final value
  44380. */
  44381. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44382. private _createRenderTargetTexture;
  44383. }
  44384. }
  44385. declare module "babylonjs/XR/webXRCamera" {
  44386. import { Scene } from "babylonjs/scene";
  44387. import { Camera } from "babylonjs/Cameras/camera";
  44388. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44389. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44390. /**
  44391. * WebXR Camera which holds the views for the xrSession
  44392. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44393. */
  44394. export class WebXRCamera extends FreeCamera {
  44395. private _xrSessionManager;
  44396. private _firstFrame;
  44397. private _referenceQuaternion;
  44398. private _referencedPosition;
  44399. private _xrInvPositionCache;
  44400. private _xrInvQuaternionCache;
  44401. /**
  44402. * Should position compensation execute on first frame.
  44403. * This is used when copying the position from a native (non XR) camera
  44404. */
  44405. compensateOnFirstFrame: boolean;
  44406. /**
  44407. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44408. * @param name the name of the camera
  44409. * @param scene the scene to add the camera to
  44410. * @param _xrSessionManager a constructed xr session manager
  44411. */
  44412. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44413. /**
  44414. * Return the user's height, unrelated to the current ground.
  44415. * This will be the y position of this camera, when ground level is 0.
  44416. */
  44417. get realWorldHeight(): number;
  44418. /** @hidden */
  44419. _updateForDualEyeDebugging(): void;
  44420. /**
  44421. * Sets this camera's transformation based on a non-vr camera
  44422. * @param otherCamera the non-vr camera to copy the transformation from
  44423. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44424. */
  44425. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44426. /**
  44427. * Gets the current instance class name ("WebXRCamera").
  44428. * @returns the class name
  44429. */
  44430. getClassName(): string;
  44431. private _updateFromXRSession;
  44432. private _updateNumberOfRigCameras;
  44433. private _updateReferenceSpace;
  44434. private _updateReferenceSpaceOffset;
  44435. }
  44436. }
  44437. declare module "babylonjs/XR/webXRFeaturesManager" {
  44438. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44439. import { IDisposable } from "babylonjs/scene";
  44440. /**
  44441. * Defining the interface required for a (webxr) feature
  44442. */
  44443. export interface IWebXRFeature extends IDisposable {
  44444. /**
  44445. * Is this feature attached
  44446. */
  44447. attached: boolean;
  44448. /**
  44449. * Should auto-attach be disabled?
  44450. */
  44451. disableAutoAttach: boolean;
  44452. /**
  44453. * Attach the feature to the session
  44454. * Will usually be called by the features manager
  44455. *
  44456. * @param force should attachment be forced (even when already attached)
  44457. * @returns true if successful.
  44458. */
  44459. attach(force?: boolean): boolean;
  44460. /**
  44461. * Detach the feature from the session
  44462. * Will usually be called by the features manager
  44463. *
  44464. * @returns true if successful.
  44465. */
  44466. detach(): boolean;
  44467. }
  44468. /**
  44469. * A list of the currently available features without referencing them
  44470. */
  44471. export class WebXRFeatureName {
  44472. /**
  44473. * The name of the anchor system feature
  44474. */
  44475. static ANCHOR_SYSTEM: string;
  44476. /**
  44477. * The name of the background remover feature
  44478. */
  44479. static BACKGROUND_REMOVER: string;
  44480. /**
  44481. * The name of the hit test feature
  44482. */
  44483. static HIT_TEST: string;
  44484. /**
  44485. * physics impostors for xr controllers feature
  44486. */
  44487. static PHYSICS_CONTROLLERS: string;
  44488. /**
  44489. * The name of the plane detection feature
  44490. */
  44491. static PLANE_DETECTION: string;
  44492. /**
  44493. * The name of the pointer selection feature
  44494. */
  44495. static POINTER_SELECTION: string;
  44496. /**
  44497. * The name of the teleportation feature
  44498. */
  44499. static TELEPORTATION: string;
  44500. }
  44501. /**
  44502. * Defining the constructor of a feature. Used to register the modules.
  44503. */
  44504. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44505. /**
  44506. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44507. * It is mainly used in AR sessions.
  44508. *
  44509. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44510. */
  44511. export class WebXRFeaturesManager implements IDisposable {
  44512. private _xrSessionManager;
  44513. private static readonly _AvailableFeatures;
  44514. private _features;
  44515. /**
  44516. * constructs a new features manages.
  44517. *
  44518. * @param _xrSessionManager an instance of WebXRSessionManager
  44519. */
  44520. constructor(_xrSessionManager: WebXRSessionManager);
  44521. /**
  44522. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44523. * Mainly used internally.
  44524. *
  44525. * @param featureName the name of the feature to register
  44526. * @param constructorFunction the function used to construct the module
  44527. * @param version the (babylon) version of the module
  44528. * @param stable is that a stable version of this module
  44529. */
  44530. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44531. /**
  44532. * Returns a constructor of a specific feature.
  44533. *
  44534. * @param featureName the name of the feature to construct
  44535. * @param version the version of the feature to load
  44536. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44537. * @param options optional options provided to the module.
  44538. * @returns a function that, when called, will return a new instance of this feature
  44539. */
  44540. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44541. /**
  44542. * Can be used to return the list of features currently registered
  44543. *
  44544. * @returns an Array of available features
  44545. */
  44546. static GetAvailableFeatures(): string[];
  44547. /**
  44548. * Gets the versions available for a specific feature
  44549. * @param featureName the name of the feature
  44550. * @returns an array with the available versions
  44551. */
  44552. static GetAvailableVersions(featureName: string): string[];
  44553. /**
  44554. * Return the latest unstable version of this feature
  44555. * @param featureName the name of the feature to search
  44556. * @returns the version number. if not found will return -1
  44557. */
  44558. static GetLatestVersionOfFeature(featureName: string): number;
  44559. /**
  44560. * Return the latest stable version of this feature
  44561. * @param featureName the name of the feature to search
  44562. * @returns the version number. if not found will return -1
  44563. */
  44564. static GetStableVersionOfFeature(featureName: string): number;
  44565. /**
  44566. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44567. * Can be used during a session to start a feature
  44568. * @param featureName the name of feature to attach
  44569. */
  44570. attachFeature(featureName: string): void;
  44571. /**
  44572. * Can be used inside a session or when the session ends to detach a specific feature
  44573. * @param featureName the name of the feature to detach
  44574. */
  44575. detachFeature(featureName: string): void;
  44576. /**
  44577. * Used to disable an already-enabled feature
  44578. * The feature will be disposed and will be recreated once enabled.
  44579. * @param featureName the feature to disable
  44580. * @returns true if disable was successful
  44581. */
  44582. disableFeature(featureName: string | {
  44583. Name: string;
  44584. }): boolean;
  44585. /**
  44586. * dispose this features manager
  44587. */
  44588. dispose(): void;
  44589. /**
  44590. * 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.
  44591. * 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.
  44592. *
  44593. * @param featureName the name of the feature to load or the class of the feature
  44594. * @param version optional version to load. if not provided the latest version will be enabled
  44595. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44596. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44597. * @returns a new constructed feature or throws an error if feature not found.
  44598. */
  44599. enableFeature(featureName: string | {
  44600. Name: string;
  44601. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44602. /**
  44603. * get the implementation of an enabled feature.
  44604. * @param featureName the name of the feature to load
  44605. * @returns the feature class, if found
  44606. */
  44607. getEnabledFeature(featureName: string): IWebXRFeature;
  44608. /**
  44609. * Get the list of enabled features
  44610. * @returns an array of enabled features
  44611. */
  44612. getEnabledFeatures(): string[];
  44613. }
  44614. }
  44615. declare module "babylonjs/XR/webXRExperienceHelper" {
  44616. import { Observable } from "babylonjs/Misc/observable";
  44617. import { IDisposable, Scene } from "babylonjs/scene";
  44618. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44619. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44620. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44621. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44622. /**
  44623. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44624. * @see https://doc.babylonjs.com/how_to/webxr
  44625. */
  44626. export class WebXRExperienceHelper implements IDisposable {
  44627. private scene;
  44628. private _nonVRCamera;
  44629. private _originalSceneAutoClear;
  44630. private _supported;
  44631. /**
  44632. * Camera used to render xr content
  44633. */
  44634. camera: WebXRCamera;
  44635. /** A features manager for this xr session */
  44636. featuresManager: WebXRFeaturesManager;
  44637. /**
  44638. * Observers registered here will be triggered after the camera's initial transformation is set
  44639. * This can be used to set a different ground level or an extra rotation.
  44640. *
  44641. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44642. * to the position set after this observable is done executing.
  44643. */
  44644. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44645. /**
  44646. * Fires when the state of the experience helper has changed
  44647. */
  44648. onStateChangedObservable: Observable<WebXRState>;
  44649. /** Session manager used to keep track of xr session */
  44650. sessionManager: WebXRSessionManager;
  44651. /**
  44652. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44653. */
  44654. state: WebXRState;
  44655. /**
  44656. * Creates a WebXRExperienceHelper
  44657. * @param scene The scene the helper should be created in
  44658. */
  44659. private constructor();
  44660. /**
  44661. * Creates the experience helper
  44662. * @param scene the scene to attach the experience helper to
  44663. * @returns a promise for the experience helper
  44664. */
  44665. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44666. /**
  44667. * Disposes of the experience helper
  44668. */
  44669. dispose(): void;
  44670. /**
  44671. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44672. * @param sessionMode options for the XR session
  44673. * @param referenceSpaceType frame of reference of the XR session
  44674. * @param renderTarget the output canvas that will be used to enter XR mode
  44675. * @returns promise that resolves after xr mode has entered
  44676. */
  44677. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44678. /**
  44679. * Exits XR mode and returns the scene to its original state
  44680. * @returns promise that resolves after xr mode has exited
  44681. */
  44682. exitXRAsync(): Promise<void>;
  44683. private _nonXRToXRCamera;
  44684. private _setState;
  44685. }
  44686. }
  44687. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44688. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44689. import { Observable } from "babylonjs/Misc/observable";
  44690. import { IDisposable } from "babylonjs/scene";
  44691. /**
  44692. * X-Y values for axes in WebXR
  44693. */
  44694. export interface IWebXRMotionControllerAxesValue {
  44695. /**
  44696. * The value of the x axis
  44697. */
  44698. x: number;
  44699. /**
  44700. * The value of the y-axis
  44701. */
  44702. y: number;
  44703. }
  44704. /**
  44705. * changed / previous values for the values of this component
  44706. */
  44707. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44708. /**
  44709. * current (this frame) value
  44710. */
  44711. current: T;
  44712. /**
  44713. * previous (last change) value
  44714. */
  44715. previous: T;
  44716. }
  44717. /**
  44718. * Represents changes in the component between current frame and last values recorded
  44719. */
  44720. export interface IWebXRMotionControllerComponentChanges {
  44721. /**
  44722. * will be populated with previous and current values if axes changed
  44723. */
  44724. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44725. /**
  44726. * will be populated with previous and current values if pressed changed
  44727. */
  44728. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44729. /**
  44730. * will be populated with previous and current values if touched changed
  44731. */
  44732. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44733. /**
  44734. * will be populated with previous and current values if value changed
  44735. */
  44736. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44737. }
  44738. /**
  44739. * This class represents a single component (for example button or thumbstick) of a motion controller
  44740. */
  44741. export class WebXRControllerComponent implements IDisposable {
  44742. /**
  44743. * the id of this component
  44744. */
  44745. id: string;
  44746. /**
  44747. * the type of the component
  44748. */
  44749. type: MotionControllerComponentType;
  44750. private _buttonIndex;
  44751. private _axesIndices;
  44752. private _axes;
  44753. private _changes;
  44754. private _currentValue;
  44755. private _hasChanges;
  44756. private _pressed;
  44757. private _touched;
  44758. /**
  44759. * button component type
  44760. */
  44761. static BUTTON_TYPE: MotionControllerComponentType;
  44762. /**
  44763. * squeeze component type
  44764. */
  44765. static SQUEEZE_TYPE: MotionControllerComponentType;
  44766. /**
  44767. * Thumbstick component type
  44768. */
  44769. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44770. /**
  44771. * Touchpad component type
  44772. */
  44773. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44774. /**
  44775. * trigger component type
  44776. */
  44777. static TRIGGER_TYPE: MotionControllerComponentType;
  44778. /**
  44779. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44780. * the axes data changes
  44781. */
  44782. onAxisValueChangedObservable: Observable<{
  44783. x: number;
  44784. y: number;
  44785. }>;
  44786. /**
  44787. * Observers registered here will be triggered when the state of a button changes
  44788. * State change is either pressed / touched / value
  44789. */
  44790. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44791. /**
  44792. * Creates a new component for a motion controller.
  44793. * It is created by the motion controller itself
  44794. *
  44795. * @param id the id of this component
  44796. * @param type the type of the component
  44797. * @param _buttonIndex index in the buttons array of the gamepad
  44798. * @param _axesIndices indices of the values in the axes array of the gamepad
  44799. */
  44800. constructor(
  44801. /**
  44802. * the id of this component
  44803. */
  44804. id: string,
  44805. /**
  44806. * the type of the component
  44807. */
  44808. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44809. /**
  44810. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44811. */
  44812. get axes(): IWebXRMotionControllerAxesValue;
  44813. /**
  44814. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44815. */
  44816. get changes(): IWebXRMotionControllerComponentChanges;
  44817. /**
  44818. * Return whether or not the component changed the last frame
  44819. */
  44820. get hasChanges(): boolean;
  44821. /**
  44822. * is the button currently pressed
  44823. */
  44824. get pressed(): boolean;
  44825. /**
  44826. * is the button currently touched
  44827. */
  44828. get touched(): boolean;
  44829. /**
  44830. * Get the current value of this component
  44831. */
  44832. get value(): number;
  44833. /**
  44834. * Dispose this component
  44835. */
  44836. dispose(): void;
  44837. /**
  44838. * Are there axes correlating to this component
  44839. * @return true is axes data is available
  44840. */
  44841. isAxes(): boolean;
  44842. /**
  44843. * Is this component a button (hence - pressable)
  44844. * @returns true if can be pressed
  44845. */
  44846. isButton(): boolean;
  44847. /**
  44848. * update this component using the gamepad object it is in. Called on every frame
  44849. * @param nativeController the native gamepad controller object
  44850. */
  44851. update(nativeController: IMinimalMotionControllerObject): void;
  44852. }
  44853. }
  44854. declare module "babylonjs/Loading/sceneLoader" {
  44855. import { Observable } from "babylonjs/Misc/observable";
  44856. import { Nullable } from "babylonjs/types";
  44857. import { Scene } from "babylonjs/scene";
  44858. import { Engine } from "babylonjs/Engines/engine";
  44859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44860. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44861. import { AssetContainer } from "babylonjs/assetContainer";
  44862. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44863. import { Skeleton } from "babylonjs/Bones/skeleton";
  44864. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44865. import { WebRequest } from "babylonjs/Misc/webRequest";
  44866. /**
  44867. * Class used to represent data loading progression
  44868. */
  44869. export class SceneLoaderProgressEvent {
  44870. /** defines if data length to load can be evaluated */
  44871. readonly lengthComputable: boolean;
  44872. /** defines the loaded data length */
  44873. readonly loaded: number;
  44874. /** defines the data length to load */
  44875. readonly total: number;
  44876. /**
  44877. * Create a new progress event
  44878. * @param lengthComputable defines if data length to load can be evaluated
  44879. * @param loaded defines the loaded data length
  44880. * @param total defines the data length to load
  44881. */
  44882. constructor(
  44883. /** defines if data length to load can be evaluated */
  44884. lengthComputable: boolean,
  44885. /** defines the loaded data length */
  44886. loaded: number,
  44887. /** defines the data length to load */
  44888. total: number);
  44889. /**
  44890. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44891. * @param event defines the source event
  44892. * @returns a new SceneLoaderProgressEvent
  44893. */
  44894. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44895. }
  44896. /**
  44897. * Interface used by SceneLoader plugins to define supported file extensions
  44898. */
  44899. export interface ISceneLoaderPluginExtensions {
  44900. /**
  44901. * Defines the list of supported extensions
  44902. */
  44903. [extension: string]: {
  44904. isBinary: boolean;
  44905. };
  44906. }
  44907. /**
  44908. * Interface used by SceneLoader plugin factory
  44909. */
  44910. export interface ISceneLoaderPluginFactory {
  44911. /**
  44912. * Defines the name of the factory
  44913. */
  44914. name: string;
  44915. /**
  44916. * Function called to create a new plugin
  44917. * @return the new plugin
  44918. */
  44919. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44920. /**
  44921. * The callback that returns true if the data can be directly loaded.
  44922. * @param data string containing the file data
  44923. * @returns if the data can be loaded directly
  44924. */
  44925. canDirectLoad?(data: string): boolean;
  44926. }
  44927. /**
  44928. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44929. */
  44930. export interface ISceneLoaderPluginBase {
  44931. /**
  44932. * The friendly name of this plugin.
  44933. */
  44934. name: string;
  44935. /**
  44936. * The file extensions supported by this plugin.
  44937. */
  44938. extensions: string | ISceneLoaderPluginExtensions;
  44939. /**
  44940. * The callback called when loading from a url.
  44941. * @param scene scene loading this url
  44942. * @param url url to load
  44943. * @param onSuccess callback called when the file successfully loads
  44944. * @param onProgress callback called while file is loading (if the server supports this mode)
  44945. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44946. * @param onError callback called when the file fails to load
  44947. * @returns a file request object
  44948. */
  44949. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44950. /**
  44951. * The callback called when loading from a file object.
  44952. * @param scene scene loading this file
  44953. * @param file defines the file to load
  44954. * @param onSuccess defines the callback to call when data is loaded
  44955. * @param onProgress defines the callback to call during loading process
  44956. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44957. * @param onError defines the callback to call when an error occurs
  44958. * @returns a file request object
  44959. */
  44960. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44961. /**
  44962. * The callback that returns true if the data can be directly loaded.
  44963. * @param data string containing the file data
  44964. * @returns if the data can be loaded directly
  44965. */
  44966. canDirectLoad?(data: string): boolean;
  44967. /**
  44968. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44969. * @param scene scene loading this data
  44970. * @param data string containing the data
  44971. * @returns data to pass to the plugin
  44972. */
  44973. directLoad?(scene: Scene, data: string): any;
  44974. /**
  44975. * The callback that allows custom handling of the root url based on the response url.
  44976. * @param rootUrl the original root url
  44977. * @param responseURL the response url if available
  44978. * @returns the new root url
  44979. */
  44980. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44981. }
  44982. /**
  44983. * Interface used to define a SceneLoader plugin
  44984. */
  44985. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44986. /**
  44987. * Import meshes into a scene.
  44988. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44989. * @param scene The scene to import into
  44990. * @param data The data to import
  44991. * @param rootUrl The root url for scene and resources
  44992. * @param meshes The meshes array to import into
  44993. * @param particleSystems The particle systems array to import into
  44994. * @param skeletons The skeletons array to import into
  44995. * @param onError The callback when import fails
  44996. * @returns True if successful or false otherwise
  44997. */
  44998. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44999. /**
  45000. * Load into a scene.
  45001. * @param scene The scene to load into
  45002. * @param data The data to import
  45003. * @param rootUrl The root url for scene and resources
  45004. * @param onError The callback when import fails
  45005. * @returns True if successful or false otherwise
  45006. */
  45007. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45008. /**
  45009. * Load into an asset container.
  45010. * @param scene The scene to load into
  45011. * @param data The data to import
  45012. * @param rootUrl The root url for scene and resources
  45013. * @param onError The callback when import fails
  45014. * @returns The loaded asset container
  45015. */
  45016. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45017. }
  45018. /**
  45019. * Interface used to define an async SceneLoader plugin
  45020. */
  45021. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45022. /**
  45023. * Import meshes into a scene.
  45024. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45025. * @param scene The scene to import into
  45026. * @param data The data to import
  45027. * @param rootUrl The root url for scene and resources
  45028. * @param onProgress The callback when the load progresses
  45029. * @param fileName Defines the name of the file to load
  45030. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45031. */
  45032. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45033. meshes: AbstractMesh[];
  45034. particleSystems: IParticleSystem[];
  45035. skeletons: Skeleton[];
  45036. animationGroups: AnimationGroup[];
  45037. }>;
  45038. /**
  45039. * Load into a scene.
  45040. * @param scene The scene to load into
  45041. * @param data The data to import
  45042. * @param rootUrl The root url for scene and resources
  45043. * @param onProgress The callback when the load progresses
  45044. * @param fileName Defines the name of the file to load
  45045. * @returns Nothing
  45046. */
  45047. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45048. /**
  45049. * Load into an asset container.
  45050. * @param scene The scene to load into
  45051. * @param data The data to import
  45052. * @param rootUrl The root url for scene and resources
  45053. * @param onProgress The callback when the load progresses
  45054. * @param fileName Defines the name of the file to load
  45055. * @returns The loaded asset container
  45056. */
  45057. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45058. }
  45059. /**
  45060. * Mode that determines how to handle old animation groups before loading new ones.
  45061. */
  45062. export enum SceneLoaderAnimationGroupLoadingMode {
  45063. /**
  45064. * Reset all old animations to initial state then dispose them.
  45065. */
  45066. Clean = 0,
  45067. /**
  45068. * Stop all old animations.
  45069. */
  45070. Stop = 1,
  45071. /**
  45072. * Restart old animations from first frame.
  45073. */
  45074. Sync = 2,
  45075. /**
  45076. * Old animations remains untouched.
  45077. */
  45078. NoSync = 3
  45079. }
  45080. /**
  45081. * Class used to load scene from various file formats using registered plugins
  45082. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45083. */
  45084. export class SceneLoader {
  45085. /**
  45086. * No logging while loading
  45087. */
  45088. static readonly NO_LOGGING: number;
  45089. /**
  45090. * Minimal logging while loading
  45091. */
  45092. static readonly MINIMAL_LOGGING: number;
  45093. /**
  45094. * Summary logging while loading
  45095. */
  45096. static readonly SUMMARY_LOGGING: number;
  45097. /**
  45098. * Detailled logging while loading
  45099. */
  45100. static readonly DETAILED_LOGGING: number;
  45101. /**
  45102. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45103. */
  45104. static get ForceFullSceneLoadingForIncremental(): boolean;
  45105. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45106. /**
  45107. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45108. */
  45109. static get ShowLoadingScreen(): boolean;
  45110. static set ShowLoadingScreen(value: boolean);
  45111. /**
  45112. * Defines the current logging level (while loading the scene)
  45113. * @ignorenaming
  45114. */
  45115. static get loggingLevel(): number;
  45116. static set loggingLevel(value: number);
  45117. /**
  45118. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45119. */
  45120. static get CleanBoneMatrixWeights(): boolean;
  45121. static set CleanBoneMatrixWeights(value: boolean);
  45122. /**
  45123. * Event raised when a plugin is used to load a scene
  45124. */
  45125. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45126. private static _registeredPlugins;
  45127. private static _getDefaultPlugin;
  45128. private static _getPluginForExtension;
  45129. private static _getPluginForDirectLoad;
  45130. private static _getPluginForFilename;
  45131. private static _getDirectLoad;
  45132. private static _loadData;
  45133. private static _getFileInfo;
  45134. /**
  45135. * Gets a plugin that can load the given extension
  45136. * @param extension defines the extension to load
  45137. * @returns a plugin or null if none works
  45138. */
  45139. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45140. /**
  45141. * Gets a boolean indicating that the given extension can be loaded
  45142. * @param extension defines the extension to load
  45143. * @returns true if the extension is supported
  45144. */
  45145. static IsPluginForExtensionAvailable(extension: string): boolean;
  45146. /**
  45147. * Adds a new plugin to the list of registered plugins
  45148. * @param plugin defines the plugin to add
  45149. */
  45150. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45151. /**
  45152. * Import meshes into a scene
  45153. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45154. * @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)
  45155. * @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)
  45156. * @param scene the instance of BABYLON.Scene to append to
  45157. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45158. * @param onProgress a callback with a progress event for each file being loaded
  45159. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45160. * @param pluginExtension the extension used to determine the plugin
  45161. * @returns The loaded plugin
  45162. */
  45163. 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>;
  45164. /**
  45165. * Import meshes into a scene
  45166. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45167. * @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)
  45168. * @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)
  45169. * @param scene the instance of BABYLON.Scene to append to
  45170. * @param onProgress a callback with a progress event for each file being loaded
  45171. * @param pluginExtension the extension used to determine the plugin
  45172. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45173. */
  45174. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45175. meshes: AbstractMesh[];
  45176. particleSystems: IParticleSystem[];
  45177. skeletons: Skeleton[];
  45178. animationGroups: AnimationGroup[];
  45179. }>;
  45180. /**
  45181. * Load a scene
  45182. * @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)
  45183. * @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)
  45184. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45185. * @param onSuccess a callback with the scene when import succeeds
  45186. * @param onProgress a callback with a progress event for each file being loaded
  45187. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45188. * @param pluginExtension the extension used to determine the plugin
  45189. * @returns The loaded plugin
  45190. */
  45191. 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>;
  45192. /**
  45193. * Load a scene
  45194. * @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)
  45195. * @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)
  45196. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45197. * @param onProgress a callback with a progress event for each file being loaded
  45198. * @param pluginExtension the extension used to determine the plugin
  45199. * @returns The loaded scene
  45200. */
  45201. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45202. /**
  45203. * Append a scene
  45204. * @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)
  45205. * @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)
  45206. * @param scene is the instance of BABYLON.Scene to append to
  45207. * @param onSuccess a callback with the scene when import succeeds
  45208. * @param onProgress a callback with a progress event for each file being loaded
  45209. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45210. * @param pluginExtension the extension used to determine the plugin
  45211. * @returns The loaded plugin
  45212. */
  45213. 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>;
  45214. /**
  45215. * Append a scene
  45216. * @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)
  45217. * @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)
  45218. * @param scene is the instance of BABYLON.Scene to append to
  45219. * @param onProgress a callback with a progress event for each file being loaded
  45220. * @param pluginExtension the extension used to determine the plugin
  45221. * @returns The given scene
  45222. */
  45223. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45224. /**
  45225. * Load a scene into an asset container
  45226. * @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)
  45227. * @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)
  45228. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45229. * @param onSuccess a callback with the scene when import succeeds
  45230. * @param onProgress a callback with a progress event for each file being loaded
  45231. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45232. * @param pluginExtension the extension used to determine the plugin
  45233. * @returns The loaded plugin
  45234. */
  45235. 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>;
  45236. /**
  45237. * Load a scene into an asset container
  45238. * @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)
  45239. * @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)
  45240. * @param scene is the instance of Scene to append to
  45241. * @param onProgress a callback with a progress event for each file being loaded
  45242. * @param pluginExtension the extension used to determine the plugin
  45243. * @returns The loaded asset container
  45244. */
  45245. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45246. /**
  45247. * Import animations from a file into a scene
  45248. * @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)
  45249. * @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)
  45250. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45251. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45252. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45253. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45254. * @param onSuccess a callback with the scene when import succeeds
  45255. * @param onProgress a callback with a progress event for each file being loaded
  45256. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45257. */
  45258. 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;
  45259. /**
  45260. * Import animations from a file into a scene
  45261. * @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)
  45262. * @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)
  45263. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45264. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45265. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45266. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45267. * @param onSuccess a callback with the scene when import succeeds
  45268. * @param onProgress a callback with a progress event for each file being loaded
  45269. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45270. * @returns the updated scene with imported animations
  45271. */
  45272. 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>;
  45273. }
  45274. }
  45275. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45276. import { IDisposable, Scene } from "babylonjs/scene";
  45277. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45278. import { Observable } from "babylonjs/Misc/observable";
  45279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45280. import { Nullable } from "babylonjs/types";
  45281. /**
  45282. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45283. */
  45284. export type MotionControllerHandness = "none" | "left" | "right";
  45285. /**
  45286. * The type of components available in motion controllers.
  45287. * This is not the name of the component.
  45288. */
  45289. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45290. /**
  45291. * The state of a controller component
  45292. */
  45293. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45294. /**
  45295. * The schema of motion controller layout.
  45296. * No object will be initialized using this interface
  45297. * This is used just to define the profile.
  45298. */
  45299. export interface IMotionControllerLayout {
  45300. /**
  45301. * Path to load the assets. Usually relative to the base path
  45302. */
  45303. assetPath: string;
  45304. /**
  45305. * Available components (unsorted)
  45306. */
  45307. components: {
  45308. /**
  45309. * A map of component Ids
  45310. */
  45311. [componentId: string]: {
  45312. /**
  45313. * The type of input the component outputs
  45314. */
  45315. type: MotionControllerComponentType;
  45316. /**
  45317. * The indices of this component in the gamepad object
  45318. */
  45319. gamepadIndices: {
  45320. /**
  45321. * Index of button
  45322. */
  45323. button?: number;
  45324. /**
  45325. * If available, index of x-axis
  45326. */
  45327. xAxis?: number;
  45328. /**
  45329. * If available, index of y-axis
  45330. */
  45331. yAxis?: number;
  45332. };
  45333. /**
  45334. * The mesh's root node name
  45335. */
  45336. rootNodeName: string;
  45337. /**
  45338. * Animation definitions for this model
  45339. */
  45340. visualResponses: {
  45341. [stateKey: string]: {
  45342. /**
  45343. * What property will be animated
  45344. */
  45345. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45346. /**
  45347. * What states influence this visual response
  45348. */
  45349. states: MotionControllerComponentStateType[];
  45350. /**
  45351. * Type of animation - movement or visibility
  45352. */
  45353. valueNodeProperty: "transform" | "visibility";
  45354. /**
  45355. * Base node name to move. Its position will be calculated according to the min and max nodes
  45356. */
  45357. valueNodeName?: string;
  45358. /**
  45359. * Minimum movement node
  45360. */
  45361. minNodeName?: string;
  45362. /**
  45363. * Max movement node
  45364. */
  45365. maxNodeName?: string;
  45366. };
  45367. };
  45368. /**
  45369. * If touch enabled, what is the name of node to display user feedback
  45370. */
  45371. touchPointNodeName?: string;
  45372. };
  45373. };
  45374. /**
  45375. * Is it xr standard mapping or not
  45376. */
  45377. gamepadMapping: "" | "xr-standard";
  45378. /**
  45379. * Base root node of this entire model
  45380. */
  45381. rootNodeName: string;
  45382. /**
  45383. * Defines the main button component id
  45384. */
  45385. selectComponentId: string;
  45386. }
  45387. /**
  45388. * A definition for the layout map in the input profile
  45389. */
  45390. export interface IMotionControllerLayoutMap {
  45391. /**
  45392. * Layouts with handness type as a key
  45393. */
  45394. [handness: string]: IMotionControllerLayout;
  45395. }
  45396. /**
  45397. * The XR Input profile schema
  45398. * Profiles can be found here:
  45399. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45400. */
  45401. export interface IMotionControllerProfile {
  45402. /**
  45403. * fallback profiles for this profileId
  45404. */
  45405. fallbackProfileIds: string[];
  45406. /**
  45407. * The layout map, with handness as key
  45408. */
  45409. layouts: IMotionControllerLayoutMap;
  45410. /**
  45411. * The id of this profile
  45412. * correlates to the profile(s) in the xrInput.profiles array
  45413. */
  45414. profileId: string;
  45415. }
  45416. /**
  45417. * A helper-interface for the 3 meshes needed for controller button animation
  45418. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45419. */
  45420. export interface IMotionControllerButtonMeshMap {
  45421. /**
  45422. * the mesh that defines the pressed value mesh position.
  45423. * This is used to find the max-position of this button
  45424. */
  45425. pressedMesh: AbstractMesh;
  45426. /**
  45427. * the mesh that defines the unpressed value mesh position.
  45428. * This is used to find the min (or initial) position of this button
  45429. */
  45430. unpressedMesh: AbstractMesh;
  45431. /**
  45432. * The mesh that will be changed when value changes
  45433. */
  45434. valueMesh: AbstractMesh;
  45435. }
  45436. /**
  45437. * A helper-interface for the 3 meshes needed for controller axis animation.
  45438. * This will be expanded when touchpad animations are fully supported
  45439. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45440. */
  45441. export interface IMotionControllerMeshMap {
  45442. /**
  45443. * the mesh that defines the maximum value mesh position.
  45444. */
  45445. maxMesh?: AbstractMesh;
  45446. /**
  45447. * the mesh that defines the minimum value mesh position.
  45448. */
  45449. minMesh?: AbstractMesh;
  45450. /**
  45451. * The mesh that will be changed when axis value changes
  45452. */
  45453. valueMesh: AbstractMesh;
  45454. }
  45455. /**
  45456. * The elements needed for change-detection of the gamepad objects in motion controllers
  45457. */
  45458. export interface IMinimalMotionControllerObject {
  45459. /**
  45460. * Available axes of this controller
  45461. */
  45462. axes: number[];
  45463. /**
  45464. * An array of available buttons
  45465. */
  45466. buttons: Array<{
  45467. /**
  45468. * Value of the button/trigger
  45469. */
  45470. value: number;
  45471. /**
  45472. * If the button/trigger is currently touched
  45473. */
  45474. touched: boolean;
  45475. /**
  45476. * If the button/trigger is currently pressed
  45477. */
  45478. pressed: boolean;
  45479. }>;
  45480. }
  45481. /**
  45482. * An Abstract Motion controller
  45483. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45484. * Each component has an observable to check for changes in value and state
  45485. */
  45486. export abstract class WebXRAbstractMotionController implements IDisposable {
  45487. protected scene: Scene;
  45488. protected layout: IMotionControllerLayout;
  45489. /**
  45490. * The gamepad object correlating to this controller
  45491. */
  45492. gamepadObject: IMinimalMotionControllerObject;
  45493. /**
  45494. * handness (left/right/none) of this controller
  45495. */
  45496. handness: MotionControllerHandness;
  45497. private _initComponent;
  45498. private _modelReady;
  45499. /**
  45500. * A map of components (WebXRControllerComponent) in this motion controller
  45501. * Components have a ComponentType and can also have both button and axis definitions
  45502. */
  45503. readonly components: {
  45504. [id: string]: WebXRControllerComponent;
  45505. };
  45506. /**
  45507. * Disable the model's animation. Can be set at any time.
  45508. */
  45509. disableAnimation: boolean;
  45510. /**
  45511. * Observers registered here will be triggered when the model of this controller is done loading
  45512. */
  45513. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45514. /**
  45515. * The profile id of this motion controller
  45516. */
  45517. abstract profileId: string;
  45518. /**
  45519. * The root mesh of the model. It is null if the model was not yet initialized
  45520. */
  45521. rootMesh: Nullable<AbstractMesh>;
  45522. /**
  45523. * constructs a new abstract motion controller
  45524. * @param scene the scene to which the model of the controller will be added
  45525. * @param layout The profile layout to load
  45526. * @param gamepadObject The gamepad object correlating to this controller
  45527. * @param handness handness (left/right/none) of this controller
  45528. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45529. */
  45530. constructor(scene: Scene, layout: IMotionControllerLayout,
  45531. /**
  45532. * The gamepad object correlating to this controller
  45533. */
  45534. gamepadObject: IMinimalMotionControllerObject,
  45535. /**
  45536. * handness (left/right/none) of this controller
  45537. */
  45538. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45539. /**
  45540. * Dispose this controller, the model mesh and all its components
  45541. */
  45542. dispose(): void;
  45543. /**
  45544. * Returns all components of specific type
  45545. * @param type the type to search for
  45546. * @return an array of components with this type
  45547. */
  45548. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45549. /**
  45550. * get a component based an its component id as defined in layout.components
  45551. * @param id the id of the component
  45552. * @returns the component correlates to the id or undefined if not found
  45553. */
  45554. getComponent(id: string): WebXRControllerComponent;
  45555. /**
  45556. * Get the list of components available in this motion controller
  45557. * @returns an array of strings correlating to available components
  45558. */
  45559. getComponentIds(): string[];
  45560. /**
  45561. * Get the first component of specific type
  45562. * @param type type of component to find
  45563. * @return a controller component or null if not found
  45564. */
  45565. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45566. /**
  45567. * Get the main (Select) component of this controller as defined in the layout
  45568. * @returns the main component of this controller
  45569. */
  45570. getMainComponent(): WebXRControllerComponent;
  45571. /**
  45572. * Loads the model correlating to this controller
  45573. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45574. * @returns A promise fulfilled with the result of the model loading
  45575. */
  45576. loadModel(): Promise<boolean>;
  45577. /**
  45578. * Update this model using the current XRFrame
  45579. * @param xrFrame the current xr frame to use and update the model
  45580. */
  45581. updateFromXRFrame(xrFrame: XRFrame): void;
  45582. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45583. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45584. /**
  45585. * Moves the axis on the controller mesh based on its current state
  45586. * @param axis the index of the axis
  45587. * @param axisValue the value of the axis which determines the meshes new position
  45588. * @hidden
  45589. */
  45590. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45591. /**
  45592. * Update the model itself with the current frame data
  45593. * @param xrFrame the frame to use for updating the model mesh
  45594. */
  45595. protected updateModel(xrFrame: XRFrame): void;
  45596. /**
  45597. * Get the filename and path for this controller's model
  45598. * @returns a map of filename and path
  45599. */
  45600. protected abstract _getFilenameAndPath(): {
  45601. filename: string;
  45602. path: string;
  45603. };
  45604. /**
  45605. * This function is called before the mesh is loaded. It checks for loading constraints.
  45606. * For example, this function can check if the GLB loader is available
  45607. * If this function returns false, the generic controller will be loaded instead
  45608. * @returns Is the client ready to load the mesh
  45609. */
  45610. protected abstract _getModelLoadingConstraints(): boolean;
  45611. /**
  45612. * This function will be called after the model was successfully loaded and can be used
  45613. * for mesh transformations before it is available for the user
  45614. * @param meshes the loaded meshes
  45615. */
  45616. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45617. /**
  45618. * Set the root mesh for this controller. Important for the WebXR controller class
  45619. * @param meshes the loaded meshes
  45620. */
  45621. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45622. /**
  45623. * A function executed each frame that updates the mesh (if needed)
  45624. * @param xrFrame the current xrFrame
  45625. */
  45626. protected abstract _updateModel(xrFrame: XRFrame): void;
  45627. private _getGenericFilenameAndPath;
  45628. private _getGenericParentMesh;
  45629. }
  45630. }
  45631. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45632. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45634. import { Scene } from "babylonjs/scene";
  45635. /**
  45636. * A generic trigger-only motion controller for WebXR
  45637. */
  45638. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45639. /**
  45640. * Static version of the profile id of this controller
  45641. */
  45642. static ProfileId: string;
  45643. profileId: string;
  45644. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45645. protected _getFilenameAndPath(): {
  45646. filename: string;
  45647. path: string;
  45648. };
  45649. protected _getModelLoadingConstraints(): boolean;
  45650. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45651. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45652. protected _updateModel(): void;
  45653. }
  45654. }
  45655. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45656. import { Vector4 } from "babylonjs/Maths/math.vector";
  45657. import { Mesh } from "babylonjs/Meshes/mesh";
  45658. import { Scene } from "babylonjs/scene";
  45659. import { Nullable } from "babylonjs/types";
  45660. /**
  45661. * Class containing static functions to help procedurally build meshes
  45662. */
  45663. export class SphereBuilder {
  45664. /**
  45665. * Creates a sphere mesh
  45666. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45667. * * 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`)
  45668. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45669. * * 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
  45670. * * 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)
  45671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45674. * @param name defines the name of the mesh
  45675. * @param options defines the options used to create the mesh
  45676. * @param scene defines the hosting scene
  45677. * @returns the sphere mesh
  45678. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45679. */
  45680. static CreateSphere(name: string, options: {
  45681. segments?: number;
  45682. diameter?: number;
  45683. diameterX?: number;
  45684. diameterY?: number;
  45685. diameterZ?: number;
  45686. arc?: number;
  45687. slice?: number;
  45688. sideOrientation?: number;
  45689. frontUVs?: Vector4;
  45690. backUVs?: Vector4;
  45691. updatable?: boolean;
  45692. }, scene?: Nullable<Scene>): Mesh;
  45693. }
  45694. }
  45695. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45697. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45698. import { Scene } from "babylonjs/scene";
  45699. /**
  45700. * A profiled motion controller has its profile loaded from an online repository.
  45701. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45702. */
  45703. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45704. private _repositoryUrl;
  45705. private _buttonMeshMapping;
  45706. private _touchDots;
  45707. /**
  45708. * The profile ID of this controller. Will be populated when the controller initializes.
  45709. */
  45710. profileId: string;
  45711. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45712. dispose(): void;
  45713. protected _getFilenameAndPath(): {
  45714. filename: string;
  45715. path: string;
  45716. };
  45717. protected _getModelLoadingConstraints(): boolean;
  45718. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45719. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45720. protected _updateModel(_xrFrame: XRFrame): void;
  45721. }
  45722. }
  45723. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45724. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45725. import { Scene } from "babylonjs/scene";
  45726. /**
  45727. * A construction function type to create a new controller based on an xrInput object
  45728. */
  45729. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45730. /**
  45731. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45732. *
  45733. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45734. * it should be replaced with auto-loaded controllers.
  45735. *
  45736. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45737. */
  45738. export class WebXRMotionControllerManager {
  45739. private static _AvailableControllers;
  45740. private static _Fallbacks;
  45741. private static _ProfileLoadingPromises;
  45742. private static _ProfilesList;
  45743. /**
  45744. * The base URL of the online controller repository. Can be changed at any time.
  45745. */
  45746. static BaseRepositoryUrl: string;
  45747. /**
  45748. * Which repository gets priority - local or online
  45749. */
  45750. static PrioritizeOnlineRepository: boolean;
  45751. /**
  45752. * Use the online repository, or use only locally-defined controllers
  45753. */
  45754. static UseOnlineRepository: boolean;
  45755. /**
  45756. * Clear the cache used for profile loading and reload when requested again
  45757. */
  45758. static ClearProfilesCache(): void;
  45759. /**
  45760. * Register the default fallbacks.
  45761. * This function is called automatically when this file is imported.
  45762. */
  45763. static DefaultFallbacks(): void;
  45764. /**
  45765. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45766. * @param profileId the profile to which a fallback needs to be found
  45767. * @return an array with corresponding fallback profiles
  45768. */
  45769. static FindFallbackWithProfileId(profileId: string): string[];
  45770. /**
  45771. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45772. * The order of search:
  45773. *
  45774. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45775. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45776. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45777. * 4) return the generic trigger controller if none were found
  45778. *
  45779. * @param xrInput the xrInput to which a new controller is initialized
  45780. * @param scene the scene to which the model will be added
  45781. * @param forceProfile force a certain profile for this controller
  45782. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45783. */
  45784. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45785. /**
  45786. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45787. *
  45788. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45789. *
  45790. * @param type the profile type to register
  45791. * @param constructFunction the function to be called when loading this profile
  45792. */
  45793. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45794. /**
  45795. * Register a fallback to a specific profile.
  45796. * @param profileId the profileId that will receive the fallbacks
  45797. * @param fallbacks A list of fallback profiles
  45798. */
  45799. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45800. /**
  45801. * Will update the list of profiles available in the repository
  45802. * @return a promise that resolves to a map of profiles available online
  45803. */
  45804. static UpdateProfilesList(): Promise<{
  45805. [profile: string]: string;
  45806. }>;
  45807. private static _LoadProfileFromRepository;
  45808. private static _LoadProfilesFromAvailableControllers;
  45809. }
  45810. }
  45811. declare module "babylonjs/XR/webXRInputSource" {
  45812. import { Observable } from "babylonjs/Misc/observable";
  45813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45814. import { Ray } from "babylonjs/Culling/ray";
  45815. import { Scene } from "babylonjs/scene";
  45816. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45817. /**
  45818. * Configuration options for the WebXR controller creation
  45819. */
  45820. export interface IWebXRControllerOptions {
  45821. /**
  45822. * Should the controller mesh be animated when a user interacts with it
  45823. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45824. */
  45825. disableMotionControllerAnimation?: boolean;
  45826. /**
  45827. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45828. */
  45829. doNotLoadControllerMesh?: boolean;
  45830. /**
  45831. * Force a specific controller type for this controller.
  45832. * This can be used when creating your own profile or when testing different controllers
  45833. */
  45834. forceControllerProfile?: string;
  45835. }
  45836. /**
  45837. * Represents an XR controller
  45838. */
  45839. export class WebXRInputSource {
  45840. private _scene;
  45841. /** The underlying input source for the controller */
  45842. inputSource: XRInputSource;
  45843. private _options;
  45844. private _tmpQuaternion;
  45845. private _tmpVector;
  45846. private _uniqueId;
  45847. /**
  45848. * 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
  45849. */
  45850. grip?: AbstractMesh;
  45851. /**
  45852. * If available, this is the gamepad object related to this controller.
  45853. * Using this object it is possible to get click events and trackpad changes of the
  45854. * webxr controller that is currently being used.
  45855. */
  45856. motionController?: WebXRAbstractMotionController;
  45857. /**
  45858. * Event that fires when the controller is removed/disposed.
  45859. * The object provided as event data is this controller, after associated assets were disposed.
  45860. * uniqueId is still available.
  45861. */
  45862. onDisposeObservable: Observable<WebXRInputSource>;
  45863. /**
  45864. * Will be triggered when the mesh associated with the motion controller is done loading.
  45865. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45866. * A shortened version of controller -> motion controller -> on mesh loaded.
  45867. */
  45868. onMeshLoadedObservable: Observable<AbstractMesh>;
  45869. /**
  45870. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45871. */
  45872. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45873. /**
  45874. * Pointer which can be used to select objects or attach a visible laser to
  45875. */
  45876. pointer: AbstractMesh;
  45877. /**
  45878. * Creates the controller
  45879. * @see https://doc.babylonjs.com/how_to/webxr
  45880. * @param _scene the scene which the controller should be associated to
  45881. * @param inputSource the underlying input source for the controller
  45882. * @param _options options for this controller creation
  45883. */
  45884. constructor(_scene: Scene,
  45885. /** The underlying input source for the controller */
  45886. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45887. /**
  45888. * Get this controllers unique id
  45889. */
  45890. get uniqueId(): string;
  45891. /**
  45892. * Disposes of the object
  45893. */
  45894. dispose(): void;
  45895. /**
  45896. * Gets a world space ray coming from the pointer or grip
  45897. * @param result the resulting ray
  45898. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45899. */
  45900. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45901. /**
  45902. * Updates the controller pose based on the given XRFrame
  45903. * @param xrFrame xr frame to update the pose with
  45904. * @param referenceSpace reference space to use
  45905. */
  45906. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45907. }
  45908. }
  45909. declare module "babylonjs/XR/webXRInput" {
  45910. import { Observable } from "babylonjs/Misc/observable";
  45911. import { IDisposable } from "babylonjs/scene";
  45912. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45913. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45914. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45915. /**
  45916. * The schema for initialization options of the XR Input class
  45917. */
  45918. export interface IWebXRInputOptions {
  45919. /**
  45920. * If set to true no model will be automatically loaded
  45921. */
  45922. doNotLoadControllerMeshes?: boolean;
  45923. /**
  45924. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45925. * If not found, the xr input profile data will be used.
  45926. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45927. */
  45928. forceInputProfile?: string;
  45929. /**
  45930. * Do not send a request to the controller repository to load the profile.
  45931. *
  45932. * Instead, use the controllers available in babylon itself.
  45933. */
  45934. disableOnlineControllerRepository?: boolean;
  45935. /**
  45936. * A custom URL for the controllers repository
  45937. */
  45938. customControllersRepositoryURL?: string;
  45939. /**
  45940. * Should the controller model's components not move according to the user input
  45941. */
  45942. disableControllerAnimation?: boolean;
  45943. }
  45944. /**
  45945. * XR input used to track XR inputs such as controllers/rays
  45946. */
  45947. export class WebXRInput implements IDisposable {
  45948. /**
  45949. * the xr session manager for this session
  45950. */
  45951. xrSessionManager: WebXRSessionManager;
  45952. /**
  45953. * the WebXR camera for this session. Mainly used for teleportation
  45954. */
  45955. xrCamera: WebXRCamera;
  45956. private readonly options;
  45957. /**
  45958. * XR controllers being tracked
  45959. */
  45960. controllers: Array<WebXRInputSource>;
  45961. private _frameObserver;
  45962. private _sessionEndedObserver;
  45963. private _sessionInitObserver;
  45964. /**
  45965. * Event when a controller has been connected/added
  45966. */
  45967. onControllerAddedObservable: Observable<WebXRInputSource>;
  45968. /**
  45969. * Event when a controller has been removed/disconnected
  45970. */
  45971. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45972. /**
  45973. * Initializes the WebXRInput
  45974. * @param xrSessionManager the xr session manager for this session
  45975. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45976. * @param options = initialization options for this xr input
  45977. */
  45978. constructor(
  45979. /**
  45980. * the xr session manager for this session
  45981. */
  45982. xrSessionManager: WebXRSessionManager,
  45983. /**
  45984. * the WebXR camera for this session. Mainly used for teleportation
  45985. */
  45986. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45987. private _onInputSourcesChange;
  45988. private _addAndRemoveControllers;
  45989. /**
  45990. * Disposes of the object
  45991. */
  45992. dispose(): void;
  45993. }
  45994. }
  45995. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45996. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45997. import { Observable, EventState } from "babylonjs/Misc/observable";
  45998. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45999. /**
  46000. * This is the base class for all WebXR features.
  46001. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46002. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46003. */
  46004. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46005. protected _xrSessionManager: WebXRSessionManager;
  46006. private _attached;
  46007. private _removeOnDetach;
  46008. /**
  46009. * Should auto-attach be disabled?
  46010. */
  46011. disableAutoAttach: boolean;
  46012. /**
  46013. * Construct a new (abstract) WebXR feature
  46014. * @param _xrSessionManager the xr session manager for this feature
  46015. */
  46016. constructor(_xrSessionManager: WebXRSessionManager);
  46017. /**
  46018. * Is this feature attached
  46019. */
  46020. get attached(): boolean;
  46021. /**
  46022. * attach this feature
  46023. *
  46024. * @param force should attachment be forced (even when already attached)
  46025. * @returns true if successful, false is failed or already attached
  46026. */
  46027. attach(force?: boolean): boolean;
  46028. /**
  46029. * detach this feature.
  46030. *
  46031. * @returns true if successful, false if failed or already detached
  46032. */
  46033. detach(): boolean;
  46034. /**
  46035. * Dispose this feature and all of the resources attached
  46036. */
  46037. dispose(): void;
  46038. /**
  46039. * This is used to register callbacks that will automatically be removed when detach is called.
  46040. * @param observable the observable to which the observer will be attached
  46041. * @param callback the callback to register
  46042. */
  46043. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46044. /**
  46045. * Code in this function will be executed on each xrFrame received from the browser.
  46046. * This function will not execute after the feature is detached.
  46047. * @param _xrFrame the current frame
  46048. */
  46049. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46050. }
  46051. }
  46052. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46053. import { IDisposable, Scene } from "babylonjs/scene";
  46054. import { Nullable } from "babylonjs/types";
  46055. import { Observable } from "babylonjs/Misc/observable";
  46056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46057. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46058. import { Camera } from "babylonjs/Cameras/camera";
  46059. /**
  46060. * Renders a layer on top of an existing scene
  46061. */
  46062. export class UtilityLayerRenderer implements IDisposable {
  46063. /** the original scene that will be rendered on top of */
  46064. originalScene: Scene;
  46065. private _pointerCaptures;
  46066. private _lastPointerEvents;
  46067. private static _DefaultUtilityLayer;
  46068. private static _DefaultKeepDepthUtilityLayer;
  46069. private _sharedGizmoLight;
  46070. private _renderCamera;
  46071. /**
  46072. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46073. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46074. * @returns the camera that is used when rendering the utility layer
  46075. */
  46076. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46077. /**
  46078. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46079. * @param cam the camera that should be used when rendering the utility layer
  46080. */
  46081. setRenderCamera(cam: Nullable<Camera>): void;
  46082. /**
  46083. * @hidden
  46084. * Light which used by gizmos to get light shading
  46085. */
  46086. _getSharedGizmoLight(): HemisphericLight;
  46087. /**
  46088. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46089. */
  46090. pickUtilitySceneFirst: boolean;
  46091. /**
  46092. * 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)
  46093. */
  46094. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46095. /**
  46096. * 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)
  46097. */
  46098. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46099. /**
  46100. * The scene that is rendered on top of the original scene
  46101. */
  46102. utilityLayerScene: Scene;
  46103. /**
  46104. * If the utility layer should automatically be rendered on top of existing scene
  46105. */
  46106. shouldRender: boolean;
  46107. /**
  46108. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46109. */
  46110. onlyCheckPointerDownEvents: boolean;
  46111. /**
  46112. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46113. */
  46114. processAllEvents: boolean;
  46115. /**
  46116. * Observable raised when the pointer move from the utility layer scene to the main scene
  46117. */
  46118. onPointerOutObservable: Observable<number>;
  46119. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46120. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46121. private _afterRenderObserver;
  46122. private _sceneDisposeObserver;
  46123. private _originalPointerObserver;
  46124. /**
  46125. * Instantiates a UtilityLayerRenderer
  46126. * @param originalScene the original scene that will be rendered on top of
  46127. * @param handleEvents boolean indicating if the utility layer should handle events
  46128. */
  46129. constructor(
  46130. /** the original scene that will be rendered on top of */
  46131. originalScene: Scene, handleEvents?: boolean);
  46132. private _notifyObservers;
  46133. /**
  46134. * Renders the utility layers scene on top of the original scene
  46135. */
  46136. render(): void;
  46137. /**
  46138. * Disposes of the renderer
  46139. */
  46140. dispose(): void;
  46141. private _updateCamera;
  46142. }
  46143. }
  46144. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46145. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46147. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46148. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46149. import { Scene } from "babylonjs/scene";
  46150. import { Nullable } from "babylonjs/types";
  46151. import { Color3 } from "babylonjs/Maths/math.color";
  46152. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46153. /**
  46154. * Options interface for the pointer selection module
  46155. */
  46156. export interface IWebXRControllerPointerSelectionOptions {
  46157. /**
  46158. * if provided, this scene will be used to render meshes.
  46159. */
  46160. customUtilityLayerScene?: Scene;
  46161. /**
  46162. * 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)
  46163. * If not disabled, the last picked point will be used to execute a pointer up event
  46164. * If disabled, pointer up event will be triggered right after the pointer down event.
  46165. * Used in screen and gaze target ray mode only
  46166. */
  46167. disablePointerUpOnTouchOut: boolean;
  46168. /**
  46169. * For gaze mode (time to select instead of press)
  46170. */
  46171. forceGazeMode: boolean;
  46172. /**
  46173. * 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
  46174. * to start a new countdown to the pointer down event.
  46175. * Defaults to 1.
  46176. */
  46177. gazeModePointerMovedFactor?: number;
  46178. /**
  46179. * Different button type to use instead of the main component
  46180. */
  46181. overrideButtonId?: string;
  46182. /**
  46183. * use this rendering group id for the meshes (optional)
  46184. */
  46185. renderingGroupId?: number;
  46186. /**
  46187. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46188. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46189. * 3000 means 3 seconds between pointing at something and selecting it
  46190. */
  46191. timeToSelect?: number;
  46192. /**
  46193. * Should meshes created here be added to a utility layer or the main scene
  46194. */
  46195. useUtilityLayer?: boolean;
  46196. /**
  46197. * the xr input to use with this pointer selection
  46198. */
  46199. xrInput: WebXRInput;
  46200. }
  46201. /**
  46202. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46203. */
  46204. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46205. private readonly _options;
  46206. private static _idCounter;
  46207. private _attachController;
  46208. private _controllers;
  46209. private _scene;
  46210. private _tmpVectorForPickCompare;
  46211. /**
  46212. * The module's name
  46213. */
  46214. static readonly Name: string;
  46215. /**
  46216. * The (Babylon) version of this module.
  46217. * This is an integer representing the implementation version.
  46218. * This number does not correspond to the WebXR specs version
  46219. */
  46220. static readonly Version: number;
  46221. /**
  46222. * Disable lighting on the laser pointer (so it will always be visible)
  46223. */
  46224. disablePointerLighting: boolean;
  46225. /**
  46226. * Disable lighting on the selection mesh (so it will always be visible)
  46227. */
  46228. disableSelectionMeshLighting: boolean;
  46229. /**
  46230. * Should the laser pointer be displayed
  46231. */
  46232. displayLaserPointer: boolean;
  46233. /**
  46234. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46235. */
  46236. displaySelectionMesh: boolean;
  46237. /**
  46238. * This color will be set to the laser pointer when selection is triggered
  46239. */
  46240. laserPointerPickedColor: Color3;
  46241. /**
  46242. * Default color of the laser pointer
  46243. */
  46244. lasterPointerDefaultColor: Color3;
  46245. /**
  46246. * default color of the selection ring
  46247. */
  46248. selectionMeshDefaultColor: Color3;
  46249. /**
  46250. * This color will be applied to the selection ring when selection is triggered
  46251. */
  46252. selectionMeshPickedColor: Color3;
  46253. /**
  46254. * Optional filter to be used for ray selection. This predicate shares behavior with
  46255. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46256. */
  46257. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46258. /**
  46259. * constructs a new background remover module
  46260. * @param _xrSessionManager the session manager for this module
  46261. * @param _options read-only options to be used in this module
  46262. */
  46263. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46264. /**
  46265. * attach this feature
  46266. * Will usually be called by the features manager
  46267. *
  46268. * @returns true if successful.
  46269. */
  46270. attach(): boolean;
  46271. /**
  46272. * detach this feature.
  46273. * Will usually be called by the features manager
  46274. *
  46275. * @returns true if successful.
  46276. */
  46277. detach(): boolean;
  46278. /**
  46279. * Will get the mesh under a specific pointer.
  46280. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46281. * @param controllerId the controllerId to check
  46282. * @returns The mesh under pointer or null if no mesh is under the pointer
  46283. */
  46284. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46285. /**
  46286. * Get the xr controller that correlates to the pointer id in the pointer event
  46287. *
  46288. * @param id the pointer id to search for
  46289. * @returns the controller that correlates to this id or null if not found
  46290. */
  46291. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46292. protected _onXRFrame(_xrFrame: XRFrame): void;
  46293. private _attachGazeMode;
  46294. private _attachScreenRayMode;
  46295. private _attachTrackedPointerRayMode;
  46296. private _convertNormalToDirectionOfRay;
  46297. private _detachController;
  46298. private _generateNewMeshPair;
  46299. private _pickingMoved;
  46300. private _updatePointerDistance;
  46301. }
  46302. }
  46303. declare module "babylonjs/XR/webXREnterExitUI" {
  46304. import { Nullable } from "babylonjs/types";
  46305. import { Observable } from "babylonjs/Misc/observable";
  46306. import { IDisposable, Scene } from "babylonjs/scene";
  46307. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46308. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46309. /**
  46310. * Button which can be used to enter a different mode of XR
  46311. */
  46312. export class WebXREnterExitUIButton {
  46313. /** button element */
  46314. element: HTMLElement;
  46315. /** XR initialization options for the button */
  46316. sessionMode: XRSessionMode;
  46317. /** Reference space type */
  46318. referenceSpaceType: XRReferenceSpaceType;
  46319. /**
  46320. * Creates a WebXREnterExitUIButton
  46321. * @param element button element
  46322. * @param sessionMode XR initialization session mode
  46323. * @param referenceSpaceType the type of reference space to be used
  46324. */
  46325. constructor(
  46326. /** button element */
  46327. element: HTMLElement,
  46328. /** XR initialization options for the button */
  46329. sessionMode: XRSessionMode,
  46330. /** Reference space type */
  46331. referenceSpaceType: XRReferenceSpaceType);
  46332. /**
  46333. * Extendable function which can be used to update the button's visuals when the state changes
  46334. * @param activeButton the current active button in the UI
  46335. */
  46336. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46337. }
  46338. /**
  46339. * Options to create the webXR UI
  46340. */
  46341. export class WebXREnterExitUIOptions {
  46342. /**
  46343. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46344. */
  46345. customButtons?: Array<WebXREnterExitUIButton>;
  46346. /**
  46347. * A reference space type to use when creating the default button.
  46348. * Default is local-floor
  46349. */
  46350. referenceSpaceType?: XRReferenceSpaceType;
  46351. /**
  46352. * Context to enter xr with
  46353. */
  46354. renderTarget?: Nullable<WebXRRenderTarget>;
  46355. /**
  46356. * A session mode to use when creating the default button.
  46357. * Default is immersive-vr
  46358. */
  46359. sessionMode?: XRSessionMode;
  46360. }
  46361. /**
  46362. * UI to allow the user to enter/exit XR mode
  46363. */
  46364. export class WebXREnterExitUI implements IDisposable {
  46365. private scene;
  46366. /** version of the options passed to this UI */
  46367. options: WebXREnterExitUIOptions;
  46368. private _activeButton;
  46369. private _buttons;
  46370. private _overlay;
  46371. /**
  46372. * Fired every time the active button is changed.
  46373. *
  46374. * When xr is entered via a button that launches xr that button will be the callback parameter
  46375. *
  46376. * When exiting xr the callback parameter will be null)
  46377. */
  46378. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46379. /**
  46380. *
  46381. * @param scene babylon scene object to use
  46382. * @param options (read-only) version of the options passed to this UI
  46383. */
  46384. private constructor();
  46385. /**
  46386. * Creates UI to allow the user to enter/exit XR mode
  46387. * @param scene the scene to add the ui to
  46388. * @param helper the xr experience helper to enter/exit xr with
  46389. * @param options options to configure the UI
  46390. * @returns the created ui
  46391. */
  46392. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46393. /**
  46394. * Disposes of the XR UI component
  46395. */
  46396. dispose(): void;
  46397. private _updateButtons;
  46398. }
  46399. }
  46400. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46401. import { Vector3 } from "babylonjs/Maths/math.vector";
  46402. import { Color4 } from "babylonjs/Maths/math.color";
  46403. import { Nullable } from "babylonjs/types";
  46404. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46405. import { Scene } from "babylonjs/scene";
  46406. /**
  46407. * Class containing static functions to help procedurally build meshes
  46408. */
  46409. export class LinesBuilder {
  46410. /**
  46411. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46412. * * 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
  46413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46414. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46415. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46416. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46417. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46418. * * 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
  46419. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46422. * @param name defines the name of the new line system
  46423. * @param options defines the options used to create the line system
  46424. * @param scene defines the hosting scene
  46425. * @returns a new line system mesh
  46426. */
  46427. static CreateLineSystem(name: string, options: {
  46428. lines: Vector3[][];
  46429. updatable?: boolean;
  46430. instance?: Nullable<LinesMesh>;
  46431. colors?: Nullable<Color4[][]>;
  46432. useVertexAlpha?: boolean;
  46433. }, scene: Nullable<Scene>): LinesMesh;
  46434. /**
  46435. * Creates a line mesh
  46436. * 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
  46437. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46438. * * The parameter `points` is an array successive Vector3
  46439. * * 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
  46440. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46441. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46442. * * When updating an instance, remember that only point positions can change, not the number of points
  46443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46445. * @param name defines the name of the new line system
  46446. * @param options defines the options used to create the line system
  46447. * @param scene defines the hosting scene
  46448. * @returns a new line mesh
  46449. */
  46450. static CreateLines(name: string, options: {
  46451. points: Vector3[];
  46452. updatable?: boolean;
  46453. instance?: Nullable<LinesMesh>;
  46454. colors?: Color4[];
  46455. useVertexAlpha?: boolean;
  46456. }, scene?: Nullable<Scene>): LinesMesh;
  46457. /**
  46458. * Creates a dashed line mesh
  46459. * * 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
  46460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46461. * * The parameter `points` is an array successive Vector3
  46462. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46463. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46464. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46465. * * 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
  46466. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46467. * * When updating an instance, remember that only point positions can change, not the number of points
  46468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46469. * @param name defines the name of the mesh
  46470. * @param options defines the options used to create the mesh
  46471. * @param scene defines the hosting scene
  46472. * @returns the dashed line mesh
  46473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46474. */
  46475. static CreateDashedLines(name: string, options: {
  46476. points: Vector3[];
  46477. dashSize?: number;
  46478. gapSize?: number;
  46479. dashNb?: number;
  46480. updatable?: boolean;
  46481. instance?: LinesMesh;
  46482. useVertexAlpha?: boolean;
  46483. }, scene?: Nullable<Scene>): LinesMesh;
  46484. }
  46485. }
  46486. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46487. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46488. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46489. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46491. import { Vector3 } from "babylonjs/Maths/math.vector";
  46492. import { Material } from "babylonjs/Materials/material";
  46493. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46494. import { Scene } from "babylonjs/scene";
  46495. /**
  46496. * The options container for the teleportation module
  46497. */
  46498. export interface IWebXRTeleportationOptions {
  46499. /**
  46500. * if provided, this scene will be used to render meshes.
  46501. */
  46502. customUtilityLayerScene?: Scene;
  46503. /**
  46504. * Values to configure the default target mesh
  46505. */
  46506. defaultTargetMeshOptions?: {
  46507. /**
  46508. * Fill color of the teleportation area
  46509. */
  46510. teleportationFillColor?: string;
  46511. /**
  46512. * Border color for the teleportation area
  46513. */
  46514. teleportationBorderColor?: string;
  46515. /**
  46516. * Disable the mesh's animation sequence
  46517. */
  46518. disableAnimation?: boolean;
  46519. /**
  46520. * Disable lighting on the material or the ring and arrow
  46521. */
  46522. disableLighting?: boolean;
  46523. /**
  46524. * Override the default material of the torus and arrow
  46525. */
  46526. torusArrowMaterial?: Material;
  46527. };
  46528. /**
  46529. * A list of meshes to use as floor meshes.
  46530. * Meshes can be added and removed after initializing the feature using the
  46531. * addFloorMesh and removeFloorMesh functions
  46532. * If empty, rotation will still work
  46533. */
  46534. floorMeshes?: AbstractMesh[];
  46535. /**
  46536. * use this rendering group id for the meshes (optional)
  46537. */
  46538. renderingGroupId?: number;
  46539. /**
  46540. * Should teleportation move only to snap points
  46541. */
  46542. snapPointsOnly?: boolean;
  46543. /**
  46544. * An array of points to which the teleportation will snap to.
  46545. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46546. */
  46547. snapPositions?: Vector3[];
  46548. /**
  46549. * How close should the teleportation ray be in order to snap to position.
  46550. * Default to 0.8 units (meters)
  46551. */
  46552. snapToPositionRadius?: number;
  46553. /**
  46554. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46555. * If you want to support rotation, make sure your mesh has a direction indicator.
  46556. *
  46557. * When left untouched, the default mesh will be initialized.
  46558. */
  46559. teleportationTargetMesh?: AbstractMesh;
  46560. /**
  46561. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46562. */
  46563. timeToTeleport?: number;
  46564. /**
  46565. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46566. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46567. */
  46568. useMainComponentOnly?: boolean;
  46569. /**
  46570. * Should meshes created here be added to a utility layer or the main scene
  46571. */
  46572. useUtilityLayer?: boolean;
  46573. /**
  46574. * Babylon XR Input class for controller
  46575. */
  46576. xrInput: WebXRInput;
  46577. }
  46578. /**
  46579. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46580. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46581. * the input of the attached controllers.
  46582. */
  46583. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46584. private _options;
  46585. private _controllers;
  46586. private _currentTeleportationControllerId;
  46587. private _floorMeshes;
  46588. private _quadraticBezierCurve;
  46589. private _selectionFeature;
  46590. private _snapToPositions;
  46591. private _snappedToPoint;
  46592. private _teleportationRingMaterial?;
  46593. private _tmpRay;
  46594. private _tmpVector;
  46595. /**
  46596. * The module's name
  46597. */
  46598. static readonly Name: string;
  46599. /**
  46600. * The (Babylon) version of this module.
  46601. * This is an integer representing the implementation version.
  46602. * This number does not correspond to the webxr specs version
  46603. */
  46604. static readonly Version: number;
  46605. /**
  46606. * Is movement backwards enabled
  46607. */
  46608. backwardsMovementEnabled: boolean;
  46609. /**
  46610. * Distance to travel when moving backwards
  46611. */
  46612. backwardsTeleportationDistance: number;
  46613. /**
  46614. * The distance from the user to the inspection point in the direction of the controller
  46615. * A higher number will allow the user to move further
  46616. * defaults to 5 (meters, in xr units)
  46617. */
  46618. parabolicCheckRadius: number;
  46619. /**
  46620. * Should the module support parabolic ray on top of direct ray
  46621. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46622. * Very helpful when moving between floors / different heights
  46623. */
  46624. parabolicRayEnabled: boolean;
  46625. /**
  46626. * How much rotation should be applied when rotating right and left
  46627. */
  46628. rotationAngle: number;
  46629. /**
  46630. * Is rotation enabled when moving forward?
  46631. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46632. */
  46633. rotationEnabled: boolean;
  46634. /**
  46635. * constructs a new anchor system
  46636. * @param _xrSessionManager an instance of WebXRSessionManager
  46637. * @param _options configuration object for this feature
  46638. */
  46639. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46640. /**
  46641. * Get the snapPointsOnly flag
  46642. */
  46643. get snapPointsOnly(): boolean;
  46644. /**
  46645. * Sets the snapPointsOnly flag
  46646. * @param snapToPoints should teleportation be exclusively to snap points
  46647. */
  46648. set snapPointsOnly(snapToPoints: boolean);
  46649. /**
  46650. * Add a new mesh to the floor meshes array
  46651. * @param mesh the mesh to use as floor mesh
  46652. */
  46653. addFloorMesh(mesh: AbstractMesh): void;
  46654. /**
  46655. * Add a new snap-to point to fix teleportation to this position
  46656. * @param newSnapPoint The new Snap-To point
  46657. */
  46658. addSnapPoint(newSnapPoint: Vector3): void;
  46659. attach(): boolean;
  46660. detach(): boolean;
  46661. dispose(): void;
  46662. /**
  46663. * Remove a mesh from the floor meshes array
  46664. * @param mesh the mesh to remove
  46665. */
  46666. removeFloorMesh(mesh: AbstractMesh): void;
  46667. /**
  46668. * Remove a mesh from the floor meshes array using its name
  46669. * @param name the mesh name to remove
  46670. */
  46671. removeFloorMeshByName(name: string): void;
  46672. /**
  46673. * 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
  46674. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46675. * @returns was the point found and removed or not
  46676. */
  46677. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46678. /**
  46679. * This function sets a selection feature that will be disabled when
  46680. * the forward ray is shown and will be reattached when hidden.
  46681. * This is used to remove the selection rays when moving.
  46682. * @param selectionFeature the feature to disable when forward movement is enabled
  46683. */
  46684. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46685. protected _onXRFrame(_xrFrame: XRFrame): void;
  46686. private _attachController;
  46687. private _createDefaultTargetMesh;
  46688. private _detachController;
  46689. private _findClosestSnapPointWithRadius;
  46690. private _setTargetMeshPosition;
  46691. private _setTargetMeshVisibility;
  46692. private _showParabolicPath;
  46693. private _teleportForward;
  46694. }
  46695. }
  46696. declare module "babylonjs/XR/webXRDefaultExperience" {
  46697. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46698. import { Scene } from "babylonjs/scene";
  46699. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46700. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46701. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46702. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46704. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46705. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46706. /**
  46707. * Options for the default xr helper
  46708. */
  46709. export class WebXRDefaultExperienceOptions {
  46710. /**
  46711. * Enable or disable default UI to enter XR
  46712. */
  46713. disableDefaultUI?: boolean;
  46714. /**
  46715. * Should teleportation not initialize. defaults to false.
  46716. */
  46717. disableTeleportation?: boolean;
  46718. /**
  46719. * Floor meshes that will be used for teleport
  46720. */
  46721. floorMeshes?: Array<AbstractMesh>;
  46722. /**
  46723. * If set to true, the first frame will not be used to reset position
  46724. * The first frame is mainly used when copying transformation from the old camera
  46725. * Mainly used in AR
  46726. */
  46727. ignoreNativeCameraTransformation?: boolean;
  46728. /**
  46729. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46730. */
  46731. inputOptions?: IWebXRInputOptions;
  46732. /**
  46733. * optional configuration for the output canvas
  46734. */
  46735. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46736. /**
  46737. * optional UI options. This can be used among other to change session mode and reference space type
  46738. */
  46739. uiOptions?: WebXREnterExitUIOptions;
  46740. /**
  46741. * When loading teleportation and pointer select, use stable versions instead of latest.
  46742. */
  46743. useStablePlugins?: boolean;
  46744. }
  46745. /**
  46746. * Default experience which provides a similar setup to the previous webVRExperience
  46747. */
  46748. export class WebXRDefaultExperience {
  46749. /**
  46750. * Base experience
  46751. */
  46752. baseExperience: WebXRExperienceHelper;
  46753. /**
  46754. * Enables ui for entering/exiting xr
  46755. */
  46756. enterExitUI: WebXREnterExitUI;
  46757. /**
  46758. * Input experience extension
  46759. */
  46760. input: WebXRInput;
  46761. /**
  46762. * Enables laser pointer and selection
  46763. */
  46764. pointerSelection: WebXRControllerPointerSelection;
  46765. /**
  46766. * Default target xr should render to
  46767. */
  46768. renderTarget: WebXRRenderTarget;
  46769. /**
  46770. * Enables teleportation
  46771. */
  46772. teleportation: WebXRMotionControllerTeleportation;
  46773. private constructor();
  46774. /**
  46775. * Creates the default xr experience
  46776. * @param scene scene
  46777. * @param options options for basic configuration
  46778. * @returns resulting WebXRDefaultExperience
  46779. */
  46780. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46781. /**
  46782. * DIsposes of the experience helper
  46783. */
  46784. dispose(): void;
  46785. }
  46786. }
  46787. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46788. import { Observable } from "babylonjs/Misc/observable";
  46789. import { Nullable } from "babylonjs/types";
  46790. import { Camera } from "babylonjs/Cameras/camera";
  46791. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46792. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46793. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46794. import { Scene } from "babylonjs/scene";
  46795. import { Vector3 } from "babylonjs/Maths/math.vector";
  46796. import { Color3 } from "babylonjs/Maths/math.color";
  46797. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46799. import { Mesh } from "babylonjs/Meshes/mesh";
  46800. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46801. import { EasingFunction } from "babylonjs/Animations/easing";
  46802. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46803. import "babylonjs/Meshes/Builders/groundBuilder";
  46804. import "babylonjs/Meshes/Builders/torusBuilder";
  46805. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46806. import "babylonjs/Gamepads/gamepadSceneComponent";
  46807. import "babylonjs/Animations/animatable";
  46808. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46809. /**
  46810. * Options to modify the vr teleportation behavior.
  46811. */
  46812. export interface VRTeleportationOptions {
  46813. /**
  46814. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46815. */
  46816. floorMeshName?: string;
  46817. /**
  46818. * A list of meshes to be used as the teleportation floor. (default: empty)
  46819. */
  46820. floorMeshes?: Mesh[];
  46821. /**
  46822. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46823. */
  46824. teleportationMode?: number;
  46825. /**
  46826. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46827. */
  46828. teleportationTime?: number;
  46829. /**
  46830. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46831. */
  46832. teleportationSpeed?: number;
  46833. /**
  46834. * The easing function used in the animation or null for Linear. (default CircleEase)
  46835. */
  46836. easingFunction?: EasingFunction;
  46837. }
  46838. /**
  46839. * Options to modify the vr experience helper's behavior.
  46840. */
  46841. export interface VRExperienceHelperOptions extends WebVROptions {
  46842. /**
  46843. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46844. */
  46845. createDeviceOrientationCamera?: boolean;
  46846. /**
  46847. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46848. */
  46849. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46850. /**
  46851. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46852. */
  46853. laserToggle?: boolean;
  46854. /**
  46855. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46856. */
  46857. floorMeshes?: Mesh[];
  46858. /**
  46859. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46860. */
  46861. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46862. /**
  46863. * Defines if WebXR should be used instead of WebVR (if available)
  46864. */
  46865. useXR?: boolean;
  46866. }
  46867. /**
  46868. * Event containing information after VR has been entered
  46869. */
  46870. export class OnAfterEnteringVRObservableEvent {
  46871. /**
  46872. * If entering vr was successful
  46873. */
  46874. success: boolean;
  46875. }
  46876. /**
  46877. * Helps to quickly add VR support to an existing scene.
  46878. * See http://doc.babylonjs.com/how_to/webvr_helper
  46879. */
  46880. export class VRExperienceHelper {
  46881. /** Options to modify the vr experience helper's behavior. */
  46882. webVROptions: VRExperienceHelperOptions;
  46883. private _scene;
  46884. private _position;
  46885. private _btnVR;
  46886. private _btnVRDisplayed;
  46887. private _webVRsupported;
  46888. private _webVRready;
  46889. private _webVRrequesting;
  46890. private _webVRpresenting;
  46891. private _hasEnteredVR;
  46892. private _fullscreenVRpresenting;
  46893. private _inputElement;
  46894. private _webVRCamera;
  46895. private _vrDeviceOrientationCamera;
  46896. private _deviceOrientationCamera;
  46897. private _existingCamera;
  46898. private _onKeyDown;
  46899. private _onVrDisplayPresentChange;
  46900. private _onVRDisplayChanged;
  46901. private _onVRRequestPresentStart;
  46902. private _onVRRequestPresentComplete;
  46903. /**
  46904. * 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)
  46905. */
  46906. enableGazeEvenWhenNoPointerLock: boolean;
  46907. /**
  46908. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46909. */
  46910. exitVROnDoubleTap: boolean;
  46911. /**
  46912. * Observable raised right before entering VR.
  46913. */
  46914. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46915. /**
  46916. * Observable raised when entering VR has completed.
  46917. */
  46918. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46919. /**
  46920. * Observable raised when exiting VR.
  46921. */
  46922. onExitingVRObservable: Observable<VRExperienceHelper>;
  46923. /**
  46924. * Observable raised when controller mesh is loaded.
  46925. */
  46926. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46927. /** Return this.onEnteringVRObservable
  46928. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46929. */
  46930. get onEnteringVR(): Observable<VRExperienceHelper>;
  46931. /** Return this.onExitingVRObservable
  46932. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46933. */
  46934. get onExitingVR(): Observable<VRExperienceHelper>;
  46935. /** Return this.onControllerMeshLoadedObservable
  46936. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46937. */
  46938. get onControllerMeshLoaded(): Observable<WebVRController>;
  46939. private _rayLength;
  46940. private _useCustomVRButton;
  46941. private _teleportationRequested;
  46942. private _teleportActive;
  46943. private _floorMeshName;
  46944. private _floorMeshesCollection;
  46945. private _teleportationMode;
  46946. private _teleportationTime;
  46947. private _teleportationSpeed;
  46948. private _teleportationEasing;
  46949. private _rotationAllowed;
  46950. private _teleportBackwardsVector;
  46951. private _teleportationTarget;
  46952. private _isDefaultTeleportationTarget;
  46953. private _postProcessMove;
  46954. private _teleportationFillColor;
  46955. private _teleportationBorderColor;
  46956. private _rotationAngle;
  46957. private _haloCenter;
  46958. private _cameraGazer;
  46959. private _padSensibilityUp;
  46960. private _padSensibilityDown;
  46961. private _leftController;
  46962. private _rightController;
  46963. private _gazeColor;
  46964. private _laserColor;
  46965. private _pickedLaserColor;
  46966. private _pickedGazeColor;
  46967. /**
  46968. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46969. */
  46970. onNewMeshSelected: Observable<AbstractMesh>;
  46971. /**
  46972. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46973. * This observable will provide the mesh and the controller used to select the mesh
  46974. */
  46975. onMeshSelectedWithController: Observable<{
  46976. mesh: AbstractMesh;
  46977. controller: WebVRController;
  46978. }>;
  46979. /**
  46980. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46981. */
  46982. onNewMeshPicked: Observable<PickingInfo>;
  46983. private _circleEase;
  46984. /**
  46985. * Observable raised before camera teleportation
  46986. */
  46987. onBeforeCameraTeleport: Observable<Vector3>;
  46988. /**
  46989. * Observable raised after camera teleportation
  46990. */
  46991. onAfterCameraTeleport: Observable<Vector3>;
  46992. /**
  46993. * Observable raised when current selected mesh gets unselected
  46994. */
  46995. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46996. private _raySelectionPredicate;
  46997. /**
  46998. * To be optionaly changed by user to define custom ray selection
  46999. */
  47000. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47001. /**
  47002. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47003. */
  47004. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47005. /**
  47006. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47007. */
  47008. teleportationEnabled: boolean;
  47009. private _defaultHeight;
  47010. private _teleportationInitialized;
  47011. private _interactionsEnabled;
  47012. private _interactionsRequested;
  47013. private _displayGaze;
  47014. private _displayLaserPointer;
  47015. /**
  47016. * The mesh used to display where the user is going to teleport.
  47017. */
  47018. get teleportationTarget(): Mesh;
  47019. /**
  47020. * Sets the mesh to be used to display where the user is going to teleport.
  47021. */
  47022. set teleportationTarget(value: Mesh);
  47023. /**
  47024. * 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
  47025. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47026. * See http://doc.babylonjs.com/resources/baking_transformations
  47027. */
  47028. get gazeTrackerMesh(): Mesh;
  47029. set gazeTrackerMesh(value: Mesh);
  47030. /**
  47031. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47032. */
  47033. updateGazeTrackerScale: boolean;
  47034. /**
  47035. * If the gaze trackers color should be updated when selecting meshes
  47036. */
  47037. updateGazeTrackerColor: boolean;
  47038. /**
  47039. * If the controller laser color should be updated when selecting meshes
  47040. */
  47041. updateControllerLaserColor: boolean;
  47042. /**
  47043. * The gaze tracking mesh corresponding to the left controller
  47044. */
  47045. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47046. /**
  47047. * The gaze tracking mesh corresponding to the right controller
  47048. */
  47049. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47050. /**
  47051. * If the ray of the gaze should be displayed.
  47052. */
  47053. get displayGaze(): boolean;
  47054. /**
  47055. * Sets if the ray of the gaze should be displayed.
  47056. */
  47057. set displayGaze(value: boolean);
  47058. /**
  47059. * If the ray of the LaserPointer should be displayed.
  47060. */
  47061. get displayLaserPointer(): boolean;
  47062. /**
  47063. * Sets if the ray of the LaserPointer should be displayed.
  47064. */
  47065. set displayLaserPointer(value: boolean);
  47066. /**
  47067. * The deviceOrientationCamera used as the camera when not in VR.
  47068. */
  47069. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47070. /**
  47071. * Based on the current WebVR support, returns the current VR camera used.
  47072. */
  47073. get currentVRCamera(): Nullable<Camera>;
  47074. /**
  47075. * The webVRCamera which is used when in VR.
  47076. */
  47077. get webVRCamera(): WebVRFreeCamera;
  47078. /**
  47079. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47080. */
  47081. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47082. /**
  47083. * The html button that is used to trigger entering into VR.
  47084. */
  47085. get vrButton(): Nullable<HTMLButtonElement>;
  47086. private get _teleportationRequestInitiated();
  47087. /**
  47088. * Defines whether or not Pointer lock should be requested when switching to
  47089. * full screen.
  47090. */
  47091. requestPointerLockOnFullScreen: boolean;
  47092. /**
  47093. * If asking to force XR, this will be populated with the default xr experience
  47094. */
  47095. xr: WebXRDefaultExperience;
  47096. /**
  47097. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47098. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47099. */
  47100. xrTestDone: boolean;
  47101. /**
  47102. * Instantiates a VRExperienceHelper.
  47103. * Helps to quickly add VR support to an existing scene.
  47104. * @param scene The scene the VRExperienceHelper belongs to.
  47105. * @param webVROptions Options to modify the vr experience helper's behavior.
  47106. */
  47107. constructor(scene: Scene,
  47108. /** Options to modify the vr experience helper's behavior. */
  47109. webVROptions?: VRExperienceHelperOptions);
  47110. private completeVRInit;
  47111. private _onDefaultMeshLoaded;
  47112. private _onResize;
  47113. private _onFullscreenChange;
  47114. /**
  47115. * Gets a value indicating if we are currently in VR mode.
  47116. */
  47117. get isInVRMode(): boolean;
  47118. private onVrDisplayPresentChange;
  47119. private onVRDisplayChanged;
  47120. private moveButtonToBottomRight;
  47121. private displayVRButton;
  47122. private updateButtonVisibility;
  47123. private _cachedAngularSensibility;
  47124. /**
  47125. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47126. * Otherwise, will use the fullscreen API.
  47127. */
  47128. enterVR(): void;
  47129. /**
  47130. * Attempt to exit VR, or fullscreen.
  47131. */
  47132. exitVR(): void;
  47133. /**
  47134. * The position of the vr experience helper.
  47135. */
  47136. get position(): Vector3;
  47137. /**
  47138. * Sets the position of the vr experience helper.
  47139. */
  47140. set position(value: Vector3);
  47141. /**
  47142. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47143. */
  47144. enableInteractions(): void;
  47145. private get _noControllerIsActive();
  47146. private beforeRender;
  47147. private _isTeleportationFloor;
  47148. /**
  47149. * Adds a floor mesh to be used for teleportation.
  47150. * @param floorMesh the mesh to be used for teleportation.
  47151. */
  47152. addFloorMesh(floorMesh: Mesh): void;
  47153. /**
  47154. * Removes a floor mesh from being used for teleportation.
  47155. * @param floorMesh the mesh to be removed.
  47156. */
  47157. removeFloorMesh(floorMesh: Mesh): void;
  47158. /**
  47159. * Enables interactions and teleportation using the VR controllers and gaze.
  47160. * @param vrTeleportationOptions options to modify teleportation behavior.
  47161. */
  47162. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47163. private _onNewGamepadConnected;
  47164. private _tryEnableInteractionOnController;
  47165. private _onNewGamepadDisconnected;
  47166. private _enableInteractionOnController;
  47167. private _checkTeleportWithRay;
  47168. private _checkRotate;
  47169. private _checkTeleportBackwards;
  47170. private _enableTeleportationOnController;
  47171. private _createTeleportationCircles;
  47172. private _displayTeleportationTarget;
  47173. private _hideTeleportationTarget;
  47174. private _rotateCamera;
  47175. private _moveTeleportationSelectorTo;
  47176. private _workingVector;
  47177. private _workingQuaternion;
  47178. private _workingMatrix;
  47179. /**
  47180. * Time Constant Teleportation Mode
  47181. */
  47182. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47183. /**
  47184. * Speed Constant Teleportation Mode
  47185. */
  47186. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47187. /**
  47188. * Teleports the users feet to the desired location
  47189. * @param location The location where the user's feet should be placed
  47190. */
  47191. teleportCamera(location: Vector3): void;
  47192. private _convertNormalToDirectionOfRay;
  47193. private _castRayAndSelectObject;
  47194. private _notifySelectedMeshUnselected;
  47195. /**
  47196. * Permanently set new colors for the laser pointer
  47197. * @param color the new laser color
  47198. * @param pickedColor the new laser color when picked mesh detected
  47199. */
  47200. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47201. /**
  47202. * Set lighting enabled / disabled on the laser pointer of both controllers
  47203. * @param enabled should the lighting be enabled on the laser pointer
  47204. */
  47205. setLaserLightingState(enabled?: boolean): void;
  47206. /**
  47207. * Permanently set new colors for the gaze pointer
  47208. * @param color the new gaze color
  47209. * @param pickedColor the new gaze color when picked mesh detected
  47210. */
  47211. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47212. /**
  47213. * Sets the color of the laser ray from the vr controllers.
  47214. * @param color new color for the ray.
  47215. */
  47216. changeLaserColor(color: Color3): void;
  47217. /**
  47218. * Sets the color of the ray from the vr headsets gaze.
  47219. * @param color new color for the ray.
  47220. */
  47221. changeGazeColor(color: Color3): void;
  47222. /**
  47223. * Exits VR and disposes of the vr experience helper
  47224. */
  47225. dispose(): void;
  47226. /**
  47227. * Gets the name of the VRExperienceHelper class
  47228. * @returns "VRExperienceHelper"
  47229. */
  47230. getClassName(): string;
  47231. }
  47232. }
  47233. declare module "babylonjs/Cameras/VR/index" {
  47234. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47235. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47236. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47237. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47238. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47239. export * from "babylonjs/Cameras/VR/webVRCamera";
  47240. }
  47241. declare module "babylonjs/Cameras/RigModes/index" {
  47242. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47243. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47244. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47245. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47246. }
  47247. declare module "babylonjs/Cameras/index" {
  47248. export * from "babylonjs/Cameras/Inputs/index";
  47249. export * from "babylonjs/Cameras/cameraInputsManager";
  47250. export * from "babylonjs/Cameras/camera";
  47251. export * from "babylonjs/Cameras/targetCamera";
  47252. export * from "babylonjs/Cameras/freeCamera";
  47253. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47254. export * from "babylonjs/Cameras/touchCamera";
  47255. export * from "babylonjs/Cameras/arcRotateCamera";
  47256. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47257. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47258. export * from "babylonjs/Cameras/flyCamera";
  47259. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47260. export * from "babylonjs/Cameras/followCamera";
  47261. export * from "babylonjs/Cameras/followCameraInputsManager";
  47262. export * from "babylonjs/Cameras/gamepadCamera";
  47263. export * from "babylonjs/Cameras/Stereoscopic/index";
  47264. export * from "babylonjs/Cameras/universalCamera";
  47265. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47266. export * from "babylonjs/Cameras/VR/index";
  47267. export * from "babylonjs/Cameras/RigModes/index";
  47268. }
  47269. declare module "babylonjs/Collisions/index" {
  47270. export * from "babylonjs/Collisions/collider";
  47271. export * from "babylonjs/Collisions/collisionCoordinator";
  47272. export * from "babylonjs/Collisions/pickingInfo";
  47273. export * from "babylonjs/Collisions/intersectionInfo";
  47274. export * from "babylonjs/Collisions/meshCollisionData";
  47275. }
  47276. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47277. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47278. import { Vector3 } from "babylonjs/Maths/math.vector";
  47279. import { Ray } from "babylonjs/Culling/ray";
  47280. import { Plane } from "babylonjs/Maths/math.plane";
  47281. /**
  47282. * Contains an array of blocks representing the octree
  47283. */
  47284. export interface IOctreeContainer<T> {
  47285. /**
  47286. * Blocks within the octree
  47287. */
  47288. blocks: Array<OctreeBlock<T>>;
  47289. }
  47290. /**
  47291. * Class used to store a cell in an octree
  47292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47293. */
  47294. export class OctreeBlock<T> {
  47295. /**
  47296. * Gets the content of the current block
  47297. */
  47298. entries: T[];
  47299. /**
  47300. * Gets the list of block children
  47301. */
  47302. blocks: Array<OctreeBlock<T>>;
  47303. private _depth;
  47304. private _maxDepth;
  47305. private _capacity;
  47306. private _minPoint;
  47307. private _maxPoint;
  47308. private _boundingVectors;
  47309. private _creationFunc;
  47310. /**
  47311. * Creates a new block
  47312. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47313. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47314. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47315. * @param depth defines the current depth of this block in the octree
  47316. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47317. * @param creationFunc defines a callback to call when an element is added to the block
  47318. */
  47319. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47320. /**
  47321. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47322. */
  47323. get capacity(): number;
  47324. /**
  47325. * Gets the minimum vector (in world space) of the block's bounding box
  47326. */
  47327. get minPoint(): Vector3;
  47328. /**
  47329. * Gets the maximum vector (in world space) of the block's bounding box
  47330. */
  47331. get maxPoint(): Vector3;
  47332. /**
  47333. * Add a new element to this block
  47334. * @param entry defines the element to add
  47335. */
  47336. addEntry(entry: T): void;
  47337. /**
  47338. * Remove an element from this block
  47339. * @param entry defines the element to remove
  47340. */
  47341. removeEntry(entry: T): void;
  47342. /**
  47343. * Add an array of elements to this block
  47344. * @param entries defines the array of elements to add
  47345. */
  47346. addEntries(entries: T[]): void;
  47347. /**
  47348. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47349. * @param frustumPlanes defines the frustum planes to test
  47350. * @param selection defines the array to store current content if selection is positive
  47351. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47352. */
  47353. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47354. /**
  47355. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47356. * @param sphereCenter defines the bounding sphere center
  47357. * @param sphereRadius defines the bounding sphere radius
  47358. * @param selection defines the array to store current content if selection is positive
  47359. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47360. */
  47361. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47362. /**
  47363. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47364. * @param ray defines the ray to test with
  47365. * @param selection defines the array to store current content if selection is positive
  47366. */
  47367. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47368. /**
  47369. * Subdivide the content into child blocks (this block will then be empty)
  47370. */
  47371. createInnerBlocks(): void;
  47372. /**
  47373. * @hidden
  47374. */
  47375. 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;
  47376. }
  47377. }
  47378. declare module "babylonjs/Culling/Octrees/octree" {
  47379. import { SmartArray } from "babylonjs/Misc/smartArray";
  47380. import { Vector3 } from "babylonjs/Maths/math.vector";
  47381. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47383. import { Ray } from "babylonjs/Culling/ray";
  47384. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47385. import { Plane } from "babylonjs/Maths/math.plane";
  47386. /**
  47387. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47388. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47389. */
  47390. export class Octree<T> {
  47391. /** 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.) */
  47392. maxDepth: number;
  47393. /**
  47394. * Blocks within the octree containing objects
  47395. */
  47396. blocks: Array<OctreeBlock<T>>;
  47397. /**
  47398. * Content stored in the octree
  47399. */
  47400. dynamicContent: T[];
  47401. private _maxBlockCapacity;
  47402. private _selectionContent;
  47403. private _creationFunc;
  47404. /**
  47405. * Creates a octree
  47406. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47407. * @param creationFunc function to be used to instatiate the octree
  47408. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47409. * @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.)
  47410. */
  47411. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47412. /** 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.) */
  47413. maxDepth?: number);
  47414. /**
  47415. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47416. * @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);
  47417. * @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);
  47418. * @param entries meshes to be added to the octree blocks
  47419. */
  47420. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47421. /**
  47422. * Adds a mesh to the octree
  47423. * @param entry Mesh to add to the octree
  47424. */
  47425. addMesh(entry: T): void;
  47426. /**
  47427. * Remove an element from the octree
  47428. * @param entry defines the element to remove
  47429. */
  47430. removeMesh(entry: T): void;
  47431. /**
  47432. * Selects an array of meshes within the frustum
  47433. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47434. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47435. * @returns array of meshes within the frustum
  47436. */
  47437. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47438. /**
  47439. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47440. * @param sphereCenter defines the bounding sphere center
  47441. * @param sphereRadius defines the bounding sphere radius
  47442. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47443. * @returns an array of objects that intersect the sphere
  47444. */
  47445. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47446. /**
  47447. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47448. * @param ray defines the ray to test with
  47449. * @returns array of intersected objects
  47450. */
  47451. intersectsRay(ray: Ray): SmartArray<T>;
  47452. /**
  47453. * Adds a mesh into the octree block if it intersects the block
  47454. */
  47455. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47456. /**
  47457. * Adds a submesh into the octree block if it intersects the block
  47458. */
  47459. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47460. }
  47461. }
  47462. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47463. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47464. import { Scene } from "babylonjs/scene";
  47465. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47467. import { Ray } from "babylonjs/Culling/ray";
  47468. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47469. import { Collider } from "babylonjs/Collisions/collider";
  47470. module "babylonjs/scene" {
  47471. interface Scene {
  47472. /**
  47473. * @hidden
  47474. * Backing Filed
  47475. */
  47476. _selectionOctree: Octree<AbstractMesh>;
  47477. /**
  47478. * Gets the octree used to boost mesh selection (picking)
  47479. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47480. */
  47481. selectionOctree: Octree<AbstractMesh>;
  47482. /**
  47483. * Creates or updates the octree used to boost selection (picking)
  47484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47485. * @param maxCapacity defines the maximum capacity per leaf
  47486. * @param maxDepth defines the maximum depth of the octree
  47487. * @returns an octree of AbstractMesh
  47488. */
  47489. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47490. }
  47491. }
  47492. module "babylonjs/Meshes/abstractMesh" {
  47493. interface AbstractMesh {
  47494. /**
  47495. * @hidden
  47496. * Backing Field
  47497. */
  47498. _submeshesOctree: Octree<SubMesh>;
  47499. /**
  47500. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47501. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47502. * @param maxCapacity defines the maximum size of each block (64 by default)
  47503. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47504. * @returns the new octree
  47505. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47507. */
  47508. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47509. }
  47510. }
  47511. /**
  47512. * Defines the octree scene component responsible to manage any octrees
  47513. * in a given scene.
  47514. */
  47515. export class OctreeSceneComponent {
  47516. /**
  47517. * The component name help to identify the component in the list of scene components.
  47518. */
  47519. readonly name: string;
  47520. /**
  47521. * The scene the component belongs to.
  47522. */
  47523. scene: Scene;
  47524. /**
  47525. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47526. */
  47527. readonly checksIsEnabled: boolean;
  47528. /**
  47529. * Creates a new instance of the component for the given scene
  47530. * @param scene Defines the scene to register the component in
  47531. */
  47532. constructor(scene: Scene);
  47533. /**
  47534. * Registers the component in a given scene
  47535. */
  47536. register(): void;
  47537. /**
  47538. * Return the list of active meshes
  47539. * @returns the list of active meshes
  47540. */
  47541. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47542. /**
  47543. * Return the list of active sub meshes
  47544. * @param mesh The mesh to get the candidates sub meshes from
  47545. * @returns the list of active sub meshes
  47546. */
  47547. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47548. private _tempRay;
  47549. /**
  47550. * Return the list of sub meshes intersecting with a given local ray
  47551. * @param mesh defines the mesh to find the submesh for
  47552. * @param localRay defines the ray in local space
  47553. * @returns the list of intersecting sub meshes
  47554. */
  47555. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47556. /**
  47557. * Return the list of sub meshes colliding with a collider
  47558. * @param mesh defines the mesh to find the submesh for
  47559. * @param collider defines the collider to evaluate the collision against
  47560. * @returns the list of colliding sub meshes
  47561. */
  47562. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47563. /**
  47564. * Rebuilds the elements related to this component in case of
  47565. * context lost for instance.
  47566. */
  47567. rebuild(): void;
  47568. /**
  47569. * Disposes the component and the associated ressources.
  47570. */
  47571. dispose(): void;
  47572. }
  47573. }
  47574. declare module "babylonjs/Culling/Octrees/index" {
  47575. export * from "babylonjs/Culling/Octrees/octree";
  47576. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47577. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47578. }
  47579. declare module "babylonjs/Culling/index" {
  47580. export * from "babylonjs/Culling/boundingBox";
  47581. export * from "babylonjs/Culling/boundingInfo";
  47582. export * from "babylonjs/Culling/boundingSphere";
  47583. export * from "babylonjs/Culling/Octrees/index";
  47584. export * from "babylonjs/Culling/ray";
  47585. }
  47586. declare module "babylonjs/Gizmos/gizmo" {
  47587. import { Nullable } from "babylonjs/types";
  47588. import { IDisposable } from "babylonjs/scene";
  47589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47590. import { Mesh } from "babylonjs/Meshes/mesh";
  47591. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47592. /**
  47593. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47594. */
  47595. export class Gizmo implements IDisposable {
  47596. /** The utility layer the gizmo will be added to */
  47597. gizmoLayer: UtilityLayerRenderer;
  47598. /**
  47599. * The root mesh of the gizmo
  47600. */
  47601. _rootMesh: Mesh;
  47602. private _attachedMesh;
  47603. /**
  47604. * Ratio for the scale of the gizmo (Default: 1)
  47605. */
  47606. scaleRatio: number;
  47607. /**
  47608. * If a custom mesh has been set (Default: false)
  47609. */
  47610. protected _customMeshSet: boolean;
  47611. /**
  47612. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47613. * * When set, interactions will be enabled
  47614. */
  47615. get attachedMesh(): Nullable<AbstractMesh>;
  47616. set attachedMesh(value: Nullable<AbstractMesh>);
  47617. /**
  47618. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47619. * @param mesh The mesh to replace the default mesh of the gizmo
  47620. */
  47621. setCustomMesh(mesh: Mesh): void;
  47622. /**
  47623. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47624. */
  47625. updateGizmoRotationToMatchAttachedMesh: boolean;
  47626. /**
  47627. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47628. */
  47629. updateGizmoPositionToMatchAttachedMesh: boolean;
  47630. /**
  47631. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47632. */
  47633. updateScale: boolean;
  47634. protected _interactionsEnabled: boolean;
  47635. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47636. private _beforeRenderObserver;
  47637. private _tempVector;
  47638. /**
  47639. * Creates a gizmo
  47640. * @param gizmoLayer The utility layer the gizmo will be added to
  47641. */
  47642. constructor(
  47643. /** The utility layer the gizmo will be added to */
  47644. gizmoLayer?: UtilityLayerRenderer);
  47645. /**
  47646. * Updates the gizmo to match the attached mesh's position/rotation
  47647. */
  47648. protected _update(): void;
  47649. /**
  47650. * Disposes of the gizmo
  47651. */
  47652. dispose(): void;
  47653. }
  47654. }
  47655. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47656. import { Observable } from "babylonjs/Misc/observable";
  47657. import { Nullable } from "babylonjs/types";
  47658. import { Vector3 } from "babylonjs/Maths/math.vector";
  47659. import { Color3 } from "babylonjs/Maths/math.color";
  47660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47662. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47663. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47664. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47665. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47666. import { Scene } from "babylonjs/scene";
  47667. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47668. /**
  47669. * Single plane drag gizmo
  47670. */
  47671. export class PlaneDragGizmo extends Gizmo {
  47672. /**
  47673. * Drag behavior responsible for the gizmos dragging interactions
  47674. */
  47675. dragBehavior: PointerDragBehavior;
  47676. private _pointerObserver;
  47677. /**
  47678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47679. */
  47680. snapDistance: number;
  47681. /**
  47682. * Event that fires each time the gizmo snaps to a new location.
  47683. * * snapDistance is the the change in distance
  47684. */
  47685. onSnapObservable: Observable<{
  47686. snapDistance: number;
  47687. }>;
  47688. private _plane;
  47689. private _coloredMaterial;
  47690. private _hoverMaterial;
  47691. private _isEnabled;
  47692. private _parent;
  47693. /** @hidden */
  47694. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47695. /** @hidden */
  47696. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47697. /**
  47698. * Creates a PlaneDragGizmo
  47699. * @param gizmoLayer The utility layer the gizmo will be added to
  47700. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47701. * @param color The color of the gizmo
  47702. */
  47703. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47704. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47705. /**
  47706. * If the gizmo is enabled
  47707. */
  47708. set isEnabled(value: boolean);
  47709. get isEnabled(): boolean;
  47710. /**
  47711. * Disposes of the gizmo
  47712. */
  47713. dispose(): void;
  47714. }
  47715. }
  47716. declare module "babylonjs/Gizmos/positionGizmo" {
  47717. import { Observable } from "babylonjs/Misc/observable";
  47718. import { Nullable } from "babylonjs/types";
  47719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47720. import { Mesh } from "babylonjs/Meshes/mesh";
  47721. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47722. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47723. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47724. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47725. /**
  47726. * Gizmo that enables dragging a mesh along 3 axis
  47727. */
  47728. export class PositionGizmo extends Gizmo {
  47729. /**
  47730. * Internal gizmo used for interactions on the x axis
  47731. */
  47732. xGizmo: AxisDragGizmo;
  47733. /**
  47734. * Internal gizmo used for interactions on the y axis
  47735. */
  47736. yGizmo: AxisDragGizmo;
  47737. /**
  47738. * Internal gizmo used for interactions on the z axis
  47739. */
  47740. zGizmo: AxisDragGizmo;
  47741. /**
  47742. * Internal gizmo used for interactions on the yz plane
  47743. */
  47744. xPlaneGizmo: PlaneDragGizmo;
  47745. /**
  47746. * Internal gizmo used for interactions on the xz plane
  47747. */
  47748. yPlaneGizmo: PlaneDragGizmo;
  47749. /**
  47750. * Internal gizmo used for interactions on the xy plane
  47751. */
  47752. zPlaneGizmo: PlaneDragGizmo;
  47753. /**
  47754. * private variables
  47755. */
  47756. private _meshAttached;
  47757. private _updateGizmoRotationToMatchAttachedMesh;
  47758. private _snapDistance;
  47759. private _scaleRatio;
  47760. /** Fires an event when any of it's sub gizmos are dragged */
  47761. onDragStartObservable: Observable<unknown>;
  47762. /** Fires an event when any of it's sub gizmos are released from dragging */
  47763. onDragEndObservable: Observable<unknown>;
  47764. /**
  47765. * If set to true, planar drag is enabled
  47766. */
  47767. private _planarGizmoEnabled;
  47768. get attachedMesh(): Nullable<AbstractMesh>;
  47769. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47770. /**
  47771. * Creates a PositionGizmo
  47772. * @param gizmoLayer The utility layer the gizmo will be added to
  47773. */
  47774. constructor(gizmoLayer?: UtilityLayerRenderer);
  47775. /**
  47776. * If the planar drag gizmo is enabled
  47777. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47778. */
  47779. set planarGizmoEnabled(value: boolean);
  47780. get planarGizmoEnabled(): boolean;
  47781. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47782. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47783. /**
  47784. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47785. */
  47786. set snapDistance(value: number);
  47787. get snapDistance(): number;
  47788. /**
  47789. * Ratio for the scale of the gizmo (Default: 1)
  47790. */
  47791. set scaleRatio(value: number);
  47792. get scaleRatio(): number;
  47793. /**
  47794. * Disposes of the gizmo
  47795. */
  47796. dispose(): void;
  47797. /**
  47798. * CustomMeshes are not supported by this gizmo
  47799. * @param mesh The mesh to replace the default mesh of the gizmo
  47800. */
  47801. setCustomMesh(mesh: Mesh): void;
  47802. }
  47803. }
  47804. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47805. import { Observable } from "babylonjs/Misc/observable";
  47806. import { Nullable } from "babylonjs/types";
  47807. import { Vector3 } from "babylonjs/Maths/math.vector";
  47808. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47810. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47811. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47812. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47813. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47814. import { Scene } from "babylonjs/scene";
  47815. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47816. import { Color3 } from "babylonjs/Maths/math.color";
  47817. /**
  47818. * Single axis drag gizmo
  47819. */
  47820. export class AxisDragGizmo extends Gizmo {
  47821. /**
  47822. * Drag behavior responsible for the gizmos dragging interactions
  47823. */
  47824. dragBehavior: PointerDragBehavior;
  47825. private _pointerObserver;
  47826. /**
  47827. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47828. */
  47829. snapDistance: number;
  47830. /**
  47831. * Event that fires each time the gizmo snaps to a new location.
  47832. * * snapDistance is the the change in distance
  47833. */
  47834. onSnapObservable: Observable<{
  47835. snapDistance: number;
  47836. }>;
  47837. private _isEnabled;
  47838. private _parent;
  47839. private _arrow;
  47840. private _coloredMaterial;
  47841. private _hoverMaterial;
  47842. /** @hidden */
  47843. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47844. /** @hidden */
  47845. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47846. /**
  47847. * Creates an AxisDragGizmo
  47848. * @param gizmoLayer The utility layer the gizmo will be added to
  47849. * @param dragAxis The axis which the gizmo will be able to drag on
  47850. * @param color The color of the gizmo
  47851. */
  47852. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47854. /**
  47855. * If the gizmo is enabled
  47856. */
  47857. set isEnabled(value: boolean);
  47858. get isEnabled(): boolean;
  47859. /**
  47860. * Disposes of the gizmo
  47861. */
  47862. dispose(): void;
  47863. }
  47864. }
  47865. declare module "babylonjs/Debug/axesViewer" {
  47866. import { Vector3 } from "babylonjs/Maths/math.vector";
  47867. import { Nullable } from "babylonjs/types";
  47868. import { Scene } from "babylonjs/scene";
  47869. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47870. /**
  47871. * The Axes viewer will show 3 axes in a specific point in space
  47872. */
  47873. export class AxesViewer {
  47874. private _xAxis;
  47875. private _yAxis;
  47876. private _zAxis;
  47877. private _scaleLinesFactor;
  47878. private _instanced;
  47879. /**
  47880. * Gets the hosting scene
  47881. */
  47882. scene: Scene;
  47883. /**
  47884. * Gets or sets a number used to scale line length
  47885. */
  47886. scaleLines: number;
  47887. /** Gets the node hierarchy used to render x-axis */
  47888. get xAxis(): TransformNode;
  47889. /** Gets the node hierarchy used to render y-axis */
  47890. get yAxis(): TransformNode;
  47891. /** Gets the node hierarchy used to render z-axis */
  47892. get zAxis(): TransformNode;
  47893. /**
  47894. * Creates a new AxesViewer
  47895. * @param scene defines the hosting scene
  47896. * @param scaleLines defines a number used to scale line length (1 by default)
  47897. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47898. * @param xAxis defines the node hierarchy used to render the x-axis
  47899. * @param yAxis defines the node hierarchy used to render the y-axis
  47900. * @param zAxis defines the node hierarchy used to render the z-axis
  47901. */
  47902. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47903. /**
  47904. * Force the viewer to update
  47905. * @param position defines the position of the viewer
  47906. * @param xaxis defines the x axis of the viewer
  47907. * @param yaxis defines the y axis of the viewer
  47908. * @param zaxis defines the z axis of the viewer
  47909. */
  47910. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47911. /**
  47912. * Creates an instance of this axes viewer.
  47913. * @returns a new axes viewer with instanced meshes
  47914. */
  47915. createInstance(): AxesViewer;
  47916. /** Releases resources */
  47917. dispose(): void;
  47918. private static _SetRenderingGroupId;
  47919. }
  47920. }
  47921. declare module "babylonjs/Debug/boneAxesViewer" {
  47922. import { Nullable } from "babylonjs/types";
  47923. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47924. import { Vector3 } from "babylonjs/Maths/math.vector";
  47925. import { Mesh } from "babylonjs/Meshes/mesh";
  47926. import { Bone } from "babylonjs/Bones/bone";
  47927. import { Scene } from "babylonjs/scene";
  47928. /**
  47929. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47930. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47931. */
  47932. export class BoneAxesViewer extends AxesViewer {
  47933. /**
  47934. * Gets or sets the target mesh where to display the axes viewer
  47935. */
  47936. mesh: Nullable<Mesh>;
  47937. /**
  47938. * Gets or sets the target bone where to display the axes viewer
  47939. */
  47940. bone: Nullable<Bone>;
  47941. /** Gets current position */
  47942. pos: Vector3;
  47943. /** Gets direction of X axis */
  47944. xaxis: Vector3;
  47945. /** Gets direction of Y axis */
  47946. yaxis: Vector3;
  47947. /** Gets direction of Z axis */
  47948. zaxis: Vector3;
  47949. /**
  47950. * Creates a new BoneAxesViewer
  47951. * @param scene defines the hosting scene
  47952. * @param bone defines the target bone
  47953. * @param mesh defines the target mesh
  47954. * @param scaleLines defines a scaling factor for line length (1 by default)
  47955. */
  47956. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47957. /**
  47958. * Force the viewer to update
  47959. */
  47960. update(): void;
  47961. /** Releases resources */
  47962. dispose(): void;
  47963. }
  47964. }
  47965. declare module "babylonjs/Debug/debugLayer" {
  47966. import { Scene } from "babylonjs/scene";
  47967. /**
  47968. * Interface used to define scene explorer extensibility option
  47969. */
  47970. export interface IExplorerExtensibilityOption {
  47971. /**
  47972. * Define the option label
  47973. */
  47974. label: string;
  47975. /**
  47976. * Defines the action to execute on click
  47977. */
  47978. action: (entity: any) => void;
  47979. }
  47980. /**
  47981. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47982. */
  47983. export interface IExplorerExtensibilityGroup {
  47984. /**
  47985. * Defines a predicate to test if a given type mut be extended
  47986. */
  47987. predicate: (entity: any) => boolean;
  47988. /**
  47989. * Gets the list of options added to a type
  47990. */
  47991. entries: IExplorerExtensibilityOption[];
  47992. }
  47993. /**
  47994. * Interface used to define the options to use to create the Inspector
  47995. */
  47996. export interface IInspectorOptions {
  47997. /**
  47998. * Display in overlay mode (default: false)
  47999. */
  48000. overlay?: boolean;
  48001. /**
  48002. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48003. */
  48004. globalRoot?: HTMLElement;
  48005. /**
  48006. * Display the Scene explorer
  48007. */
  48008. showExplorer?: boolean;
  48009. /**
  48010. * Display the property inspector
  48011. */
  48012. showInspector?: boolean;
  48013. /**
  48014. * Display in embed mode (both panes on the right)
  48015. */
  48016. embedMode?: boolean;
  48017. /**
  48018. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48019. */
  48020. handleResize?: boolean;
  48021. /**
  48022. * Allow the panes to popup (default: true)
  48023. */
  48024. enablePopup?: boolean;
  48025. /**
  48026. * Allow the panes to be closed by users (default: true)
  48027. */
  48028. enableClose?: boolean;
  48029. /**
  48030. * Optional list of extensibility entries
  48031. */
  48032. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48033. /**
  48034. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48035. */
  48036. inspectorURL?: string;
  48037. /**
  48038. * Optional initial tab (default to DebugLayerTab.Properties)
  48039. */
  48040. initialTab?: DebugLayerTab;
  48041. }
  48042. module "babylonjs/scene" {
  48043. interface Scene {
  48044. /**
  48045. * @hidden
  48046. * Backing field
  48047. */
  48048. _debugLayer: DebugLayer;
  48049. /**
  48050. * Gets the debug layer (aka Inspector) associated with the scene
  48051. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48052. */
  48053. debugLayer: DebugLayer;
  48054. }
  48055. }
  48056. /**
  48057. * Enum of inspector action tab
  48058. */
  48059. export enum DebugLayerTab {
  48060. /**
  48061. * Properties tag (default)
  48062. */
  48063. Properties = 0,
  48064. /**
  48065. * Debug tab
  48066. */
  48067. Debug = 1,
  48068. /**
  48069. * Statistics tab
  48070. */
  48071. Statistics = 2,
  48072. /**
  48073. * Tools tab
  48074. */
  48075. Tools = 3,
  48076. /**
  48077. * Settings tab
  48078. */
  48079. Settings = 4
  48080. }
  48081. /**
  48082. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48083. * what is happening in your scene
  48084. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48085. */
  48086. export class DebugLayer {
  48087. /**
  48088. * Define the url to get the inspector script from.
  48089. * By default it uses the babylonjs CDN.
  48090. * @ignoreNaming
  48091. */
  48092. static InspectorURL: string;
  48093. private _scene;
  48094. private BJSINSPECTOR;
  48095. private _onPropertyChangedObservable?;
  48096. /**
  48097. * Observable triggered when a property is changed through the inspector.
  48098. */
  48099. get onPropertyChangedObservable(): any;
  48100. /**
  48101. * Instantiates a new debug layer.
  48102. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48103. * what is happening in your scene
  48104. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48105. * @param scene Defines the scene to inspect
  48106. */
  48107. constructor(scene: Scene);
  48108. /** Creates the inspector window. */
  48109. private _createInspector;
  48110. /**
  48111. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48112. * @param entity defines the entity to select
  48113. * @param lineContainerTitle defines the specific block to highlight
  48114. */
  48115. select(entity: any, lineContainerTitle?: string): void;
  48116. /** Get the inspector from bundle or global */
  48117. private _getGlobalInspector;
  48118. /**
  48119. * Get if the inspector is visible or not.
  48120. * @returns true if visible otherwise, false
  48121. */
  48122. isVisible(): boolean;
  48123. /**
  48124. * Hide the inspector and close its window.
  48125. */
  48126. hide(): void;
  48127. /**
  48128. * Launch the debugLayer.
  48129. * @param config Define the configuration of the inspector
  48130. * @return a promise fulfilled when the debug layer is visible
  48131. */
  48132. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48133. }
  48134. }
  48135. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48136. import { Nullable } from "babylonjs/types";
  48137. import { Scene } from "babylonjs/scene";
  48138. import { Vector4 } from "babylonjs/Maths/math.vector";
  48139. import { Color4 } from "babylonjs/Maths/math.color";
  48140. import { Mesh } from "babylonjs/Meshes/mesh";
  48141. /**
  48142. * Class containing static functions to help procedurally build meshes
  48143. */
  48144. export class BoxBuilder {
  48145. /**
  48146. * Creates a box mesh
  48147. * * The parameter `size` sets the size (float) of each box side (default 1)
  48148. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48149. * * 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)
  48150. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48154. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48155. * @param name defines the name of the mesh
  48156. * @param options defines the options used to create the mesh
  48157. * @param scene defines the hosting scene
  48158. * @returns the box mesh
  48159. */
  48160. static CreateBox(name: string, options: {
  48161. size?: number;
  48162. width?: number;
  48163. height?: number;
  48164. depth?: number;
  48165. faceUV?: Vector4[];
  48166. faceColors?: Color4[];
  48167. sideOrientation?: number;
  48168. frontUVs?: Vector4;
  48169. backUVs?: Vector4;
  48170. wrap?: boolean;
  48171. topBaseAt?: number;
  48172. bottomBaseAt?: number;
  48173. updatable?: boolean;
  48174. }, scene?: Nullable<Scene>): Mesh;
  48175. }
  48176. }
  48177. declare module "babylonjs/Debug/physicsViewer" {
  48178. import { Nullable } from "babylonjs/types";
  48179. import { Scene } from "babylonjs/scene";
  48180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48181. import { Mesh } from "babylonjs/Meshes/mesh";
  48182. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48183. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48184. /**
  48185. * Used to show the physics impostor around the specific mesh
  48186. */
  48187. export class PhysicsViewer {
  48188. /** @hidden */
  48189. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48190. /** @hidden */
  48191. protected _meshes: Array<Nullable<AbstractMesh>>;
  48192. /** @hidden */
  48193. protected _scene: Nullable<Scene>;
  48194. /** @hidden */
  48195. protected _numMeshes: number;
  48196. /** @hidden */
  48197. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48198. private _renderFunction;
  48199. private _utilityLayer;
  48200. private _debugBoxMesh;
  48201. private _debugSphereMesh;
  48202. private _debugCylinderMesh;
  48203. private _debugMaterial;
  48204. private _debugMeshMeshes;
  48205. /**
  48206. * Creates a new PhysicsViewer
  48207. * @param scene defines the hosting scene
  48208. */
  48209. constructor(scene: Scene);
  48210. /** @hidden */
  48211. protected _updateDebugMeshes(): void;
  48212. /**
  48213. * Renders a specified physic impostor
  48214. * @param impostor defines the impostor to render
  48215. * @param targetMesh defines the mesh represented by the impostor
  48216. * @returns the new debug mesh used to render the impostor
  48217. */
  48218. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48219. /**
  48220. * Hides a specified physic impostor
  48221. * @param impostor defines the impostor to hide
  48222. */
  48223. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48224. private _getDebugMaterial;
  48225. private _getDebugBoxMesh;
  48226. private _getDebugSphereMesh;
  48227. private _getDebugCylinderMesh;
  48228. private _getDebugMeshMesh;
  48229. private _getDebugMesh;
  48230. /** Releases all resources */
  48231. dispose(): void;
  48232. }
  48233. }
  48234. declare module "babylonjs/Debug/rayHelper" {
  48235. import { Nullable } from "babylonjs/types";
  48236. import { Ray } from "babylonjs/Culling/ray";
  48237. import { Vector3 } from "babylonjs/Maths/math.vector";
  48238. import { Color3 } from "babylonjs/Maths/math.color";
  48239. import { Scene } from "babylonjs/scene";
  48240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48241. import "babylonjs/Meshes/Builders/linesBuilder";
  48242. /**
  48243. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48244. * in order to better appreciate the issue one might have.
  48245. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48246. */
  48247. export class RayHelper {
  48248. /**
  48249. * Defines the ray we are currently tryin to visualize.
  48250. */
  48251. ray: Nullable<Ray>;
  48252. private _renderPoints;
  48253. private _renderLine;
  48254. private _renderFunction;
  48255. private _scene;
  48256. private _updateToMeshFunction;
  48257. private _attachedToMesh;
  48258. private _meshSpaceDirection;
  48259. private _meshSpaceOrigin;
  48260. /**
  48261. * Helper function to create a colored helper in a scene in one line.
  48262. * @param ray Defines the ray we are currently tryin to visualize
  48263. * @param scene Defines the scene the ray is used in
  48264. * @param color Defines the color we want to see the ray in
  48265. * @returns The newly created ray helper.
  48266. */
  48267. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48268. /**
  48269. * Instantiate a new ray helper.
  48270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48271. * in order to better appreciate the issue one might have.
  48272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48273. * @param ray Defines the ray we are currently tryin to visualize
  48274. */
  48275. constructor(ray: Ray);
  48276. /**
  48277. * Shows the ray we are willing to debug.
  48278. * @param scene Defines the scene the ray needs to be rendered in
  48279. * @param color Defines the color the ray needs to be rendered in
  48280. */
  48281. show(scene: Scene, color?: Color3): void;
  48282. /**
  48283. * Hides the ray we are debugging.
  48284. */
  48285. hide(): void;
  48286. private _render;
  48287. /**
  48288. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48289. * @param mesh Defines the mesh we want the helper attached to
  48290. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48291. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48292. * @param length Defines the length of the ray
  48293. */
  48294. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48295. /**
  48296. * Detach the ray helper from the mesh it has previously been attached to.
  48297. */
  48298. detachFromMesh(): void;
  48299. private _updateToMesh;
  48300. /**
  48301. * Dispose the helper and release its associated resources.
  48302. */
  48303. dispose(): void;
  48304. }
  48305. }
  48306. declare module "babylonjs/Debug/skeletonViewer" {
  48307. import { Color3 } from "babylonjs/Maths/math.color";
  48308. import { Scene } from "babylonjs/scene";
  48309. import { Nullable } from "babylonjs/types";
  48310. import { Skeleton } from "babylonjs/Bones/skeleton";
  48311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48312. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48313. /**
  48314. * Class used to render a debug view of a given skeleton
  48315. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48316. */
  48317. export class SkeletonViewer {
  48318. /** defines the skeleton to render */
  48319. skeleton: Skeleton;
  48320. /** defines the mesh attached to the skeleton */
  48321. mesh: AbstractMesh;
  48322. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48323. autoUpdateBonesMatrices: boolean;
  48324. /** defines the rendering group id to use with the viewer */
  48325. renderingGroupId: number;
  48326. /** Gets or sets the color used to render the skeleton */
  48327. color: Color3;
  48328. private _scene;
  48329. private _debugLines;
  48330. private _debugMesh;
  48331. private _isEnabled;
  48332. private _renderFunction;
  48333. private _utilityLayer;
  48334. /**
  48335. * Returns the mesh used to render the bones
  48336. */
  48337. get debugMesh(): Nullable<LinesMesh>;
  48338. /**
  48339. * Creates a new SkeletonViewer
  48340. * @param skeleton defines the skeleton to render
  48341. * @param mesh defines the mesh attached to the skeleton
  48342. * @param scene defines the hosting scene
  48343. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48344. * @param renderingGroupId defines the rendering group id to use with the viewer
  48345. */
  48346. constructor(
  48347. /** defines the skeleton to render */
  48348. skeleton: Skeleton,
  48349. /** defines the mesh attached to the skeleton */
  48350. mesh: AbstractMesh, scene: Scene,
  48351. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48352. autoUpdateBonesMatrices?: boolean,
  48353. /** defines the rendering group id to use with the viewer */
  48354. renderingGroupId?: number);
  48355. /** Gets or sets a boolean indicating if the viewer is enabled */
  48356. set isEnabled(value: boolean);
  48357. get isEnabled(): boolean;
  48358. private _getBonePosition;
  48359. private _getLinesForBonesWithLength;
  48360. private _getLinesForBonesNoLength;
  48361. /** Update the viewer to sync with current skeleton state */
  48362. update(): void;
  48363. /** Release associated resources */
  48364. dispose(): void;
  48365. }
  48366. }
  48367. declare module "babylonjs/Debug/index" {
  48368. export * from "babylonjs/Debug/axesViewer";
  48369. export * from "babylonjs/Debug/boneAxesViewer";
  48370. export * from "babylonjs/Debug/debugLayer";
  48371. export * from "babylonjs/Debug/physicsViewer";
  48372. export * from "babylonjs/Debug/rayHelper";
  48373. export * from "babylonjs/Debug/skeletonViewer";
  48374. }
  48375. declare module "babylonjs/Engines/nullEngine" {
  48376. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48377. import { Engine } from "babylonjs/Engines/engine";
  48378. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48379. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48381. import { Effect } from "babylonjs/Materials/effect";
  48382. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48383. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48384. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48385. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48386. /**
  48387. * Options to create the null engine
  48388. */
  48389. export class NullEngineOptions {
  48390. /**
  48391. * Render width (Default: 512)
  48392. */
  48393. renderWidth: number;
  48394. /**
  48395. * Render height (Default: 256)
  48396. */
  48397. renderHeight: number;
  48398. /**
  48399. * Texture size (Default: 512)
  48400. */
  48401. textureSize: number;
  48402. /**
  48403. * If delta time between frames should be constant
  48404. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48405. */
  48406. deterministicLockstep: boolean;
  48407. /**
  48408. * Maximum about of steps between frames (Default: 4)
  48409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48410. */
  48411. lockstepMaxSteps: number;
  48412. }
  48413. /**
  48414. * The null engine class provides support for headless version of babylon.js.
  48415. * This can be used in server side scenario or for testing purposes
  48416. */
  48417. export class NullEngine extends Engine {
  48418. private _options;
  48419. /**
  48420. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48422. * @returns true if engine is in deterministic lock step mode
  48423. */
  48424. isDeterministicLockStep(): boolean;
  48425. /**
  48426. * Gets the max steps when engine is running in deterministic lock step
  48427. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48428. * @returns the max steps
  48429. */
  48430. getLockstepMaxSteps(): number;
  48431. /**
  48432. * Gets the current hardware scaling level.
  48433. * By default the hardware scaling level is computed from the window device ratio.
  48434. * 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.
  48435. * @returns a number indicating the current hardware scaling level
  48436. */
  48437. getHardwareScalingLevel(): number;
  48438. constructor(options?: NullEngineOptions);
  48439. /**
  48440. * Creates a vertex buffer
  48441. * @param vertices the data for the vertex buffer
  48442. * @returns the new WebGL static buffer
  48443. */
  48444. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48445. /**
  48446. * Creates a new index buffer
  48447. * @param indices defines the content of the index buffer
  48448. * @param updatable defines if the index buffer must be updatable
  48449. * @returns a new webGL buffer
  48450. */
  48451. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48452. /**
  48453. * Clear the current render buffer or the current render target (if any is set up)
  48454. * @param color defines the color to use
  48455. * @param backBuffer defines if the back buffer must be cleared
  48456. * @param depth defines if the depth buffer must be cleared
  48457. * @param stencil defines if the stencil buffer must be cleared
  48458. */
  48459. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48460. /**
  48461. * Gets the current render width
  48462. * @param useScreen defines if screen size must be used (or the current render target if any)
  48463. * @returns a number defining the current render width
  48464. */
  48465. getRenderWidth(useScreen?: boolean): number;
  48466. /**
  48467. * Gets the current render height
  48468. * @param useScreen defines if screen size must be used (or the current render target if any)
  48469. * @returns a number defining the current render height
  48470. */
  48471. getRenderHeight(useScreen?: boolean): number;
  48472. /**
  48473. * Set the WebGL's viewport
  48474. * @param viewport defines the viewport element to be used
  48475. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48476. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48477. */
  48478. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48479. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48480. /**
  48481. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48482. * @param pipelineContext defines the pipeline context to use
  48483. * @param uniformsNames defines the list of uniform names
  48484. * @returns an array of webGL uniform locations
  48485. */
  48486. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48487. /**
  48488. * Gets the lsit of active attributes for a given webGL program
  48489. * @param pipelineContext defines the pipeline context to use
  48490. * @param attributesNames defines the list of attribute names to get
  48491. * @returns an array of indices indicating the offset of each attribute
  48492. */
  48493. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48494. /**
  48495. * Binds an effect to the webGL context
  48496. * @param effect defines the effect to bind
  48497. */
  48498. bindSamplers(effect: Effect): void;
  48499. /**
  48500. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48501. * @param effect defines the effect to activate
  48502. */
  48503. enableEffect(effect: Effect): void;
  48504. /**
  48505. * Set various states to the webGL context
  48506. * @param culling defines backface culling state
  48507. * @param zOffset defines the value to apply to zOffset (0 by default)
  48508. * @param force defines if states must be applied even if cache is up to date
  48509. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48510. */
  48511. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48512. /**
  48513. * Set the value of an uniform to an array of int32
  48514. * @param uniform defines the webGL uniform location where to store the value
  48515. * @param array defines the array of int32 to store
  48516. */
  48517. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48518. /**
  48519. * Set the value of an uniform to an array of int32 (stored as vec2)
  48520. * @param uniform defines the webGL uniform location where to store the value
  48521. * @param array defines the array of int32 to store
  48522. */
  48523. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48524. /**
  48525. * Set the value of an uniform to an array of int32 (stored as vec3)
  48526. * @param uniform defines the webGL uniform location where to store the value
  48527. * @param array defines the array of int32 to store
  48528. */
  48529. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48530. /**
  48531. * Set the value of an uniform to an array of int32 (stored as vec4)
  48532. * @param uniform defines the webGL uniform location where to store the value
  48533. * @param array defines the array of int32 to store
  48534. */
  48535. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48536. /**
  48537. * Set the value of an uniform to an array of float32
  48538. * @param uniform defines the webGL uniform location where to store the value
  48539. * @param array defines the array of float32 to store
  48540. */
  48541. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48542. /**
  48543. * Set the value of an uniform to an array of float32 (stored as vec2)
  48544. * @param uniform defines the webGL uniform location where to store the value
  48545. * @param array defines the array of float32 to store
  48546. */
  48547. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48548. /**
  48549. * Set the value of an uniform to an array of float32 (stored as vec3)
  48550. * @param uniform defines the webGL uniform location where to store the value
  48551. * @param array defines the array of float32 to store
  48552. */
  48553. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48554. /**
  48555. * Set the value of an uniform to an array of float32 (stored as vec4)
  48556. * @param uniform defines the webGL uniform location where to store the value
  48557. * @param array defines the array of float32 to store
  48558. */
  48559. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48560. /**
  48561. * Set the value of an uniform to an array of number
  48562. * @param uniform defines the webGL uniform location where to store the value
  48563. * @param array defines the array of number to store
  48564. */
  48565. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48566. /**
  48567. * Set the value of an uniform to an array of number (stored as vec2)
  48568. * @param uniform defines the webGL uniform location where to store the value
  48569. * @param array defines the array of number to store
  48570. */
  48571. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48572. /**
  48573. * Set the value of an uniform to an array of number (stored as vec3)
  48574. * @param uniform defines the webGL uniform location where to store the value
  48575. * @param array defines the array of number to store
  48576. */
  48577. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48578. /**
  48579. * Set the value of an uniform to an array of number (stored as vec4)
  48580. * @param uniform defines the webGL uniform location where to store the value
  48581. * @param array defines the array of number to store
  48582. */
  48583. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48584. /**
  48585. * Set the value of an uniform to an array of float32 (stored as matrices)
  48586. * @param uniform defines the webGL uniform location where to store the value
  48587. * @param matrices defines the array of float32 to store
  48588. */
  48589. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48590. /**
  48591. * Set the value of an uniform to a matrix (3x3)
  48592. * @param uniform defines the webGL uniform location where to store the value
  48593. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48594. */
  48595. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48596. /**
  48597. * Set the value of an uniform to a matrix (2x2)
  48598. * @param uniform defines the webGL uniform location where to store the value
  48599. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48600. */
  48601. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48602. /**
  48603. * Set the value of an uniform to a number (float)
  48604. * @param uniform defines the webGL uniform location where to store the value
  48605. * @param value defines the float number to store
  48606. */
  48607. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48608. /**
  48609. * Set the value of an uniform to a vec2
  48610. * @param uniform defines the webGL uniform location where to store the value
  48611. * @param x defines the 1st component of the value
  48612. * @param y defines the 2nd component of the value
  48613. */
  48614. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48615. /**
  48616. * Set the value of an uniform to a vec3
  48617. * @param uniform defines the webGL uniform location where to store the value
  48618. * @param x defines the 1st component of the value
  48619. * @param y defines the 2nd component of the value
  48620. * @param z defines the 3rd component of the value
  48621. */
  48622. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48623. /**
  48624. * Set the value of an uniform to a boolean
  48625. * @param uniform defines the webGL uniform location where to store the value
  48626. * @param bool defines the boolean to store
  48627. */
  48628. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48629. /**
  48630. * Set the value of an uniform to a vec4
  48631. * @param uniform defines the webGL uniform location where to store the value
  48632. * @param x defines the 1st component of the value
  48633. * @param y defines the 2nd component of the value
  48634. * @param z defines the 3rd component of the value
  48635. * @param w defines the 4th component of the value
  48636. */
  48637. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48638. /**
  48639. * Sets the current alpha mode
  48640. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48641. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48642. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48643. */
  48644. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48645. /**
  48646. * Bind webGl buffers directly to the webGL context
  48647. * @param vertexBuffers defines the vertex buffer to bind
  48648. * @param indexBuffer defines the index buffer to bind
  48649. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48650. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48651. * @param effect defines the effect associated with the vertex buffer
  48652. */
  48653. bindBuffers(vertexBuffers: {
  48654. [key: string]: VertexBuffer;
  48655. }, indexBuffer: DataBuffer, effect: Effect): void;
  48656. /**
  48657. * Force the entire cache to be cleared
  48658. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48659. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48660. */
  48661. wipeCaches(bruteForce?: boolean): void;
  48662. /**
  48663. * Send a draw order
  48664. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48665. * @param indexStart defines the starting index
  48666. * @param indexCount defines the number of index to draw
  48667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48668. */
  48669. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48670. /**
  48671. * Draw a list of indexed primitives
  48672. * @param fillMode defines the primitive to use
  48673. * @param indexStart defines the starting index
  48674. * @param indexCount defines the number of index to draw
  48675. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48676. */
  48677. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48678. /**
  48679. * Draw a list of unindexed primitives
  48680. * @param fillMode defines the primitive to use
  48681. * @param verticesStart defines the index of first vertex to draw
  48682. * @param verticesCount defines the count of vertices to draw
  48683. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48684. */
  48685. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48686. /** @hidden */
  48687. _createTexture(): WebGLTexture;
  48688. /** @hidden */
  48689. _releaseTexture(texture: InternalTexture): void;
  48690. /**
  48691. * Usually called from Texture.ts.
  48692. * Passed information to create a WebGLTexture
  48693. * @param urlArg defines a value which contains one of the following:
  48694. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48695. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48696. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48698. * @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)
  48699. * @param scene needed for loading to the correct scene
  48700. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48701. * @param onLoad optional callback to be called upon successful completion
  48702. * @param onError optional callback to be called upon failure
  48703. * @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
  48704. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48705. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48706. * @param forcedExtension defines the extension to use to pick the right loader
  48707. * @param mimeType defines an optional mime type
  48708. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48709. */
  48710. 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;
  48711. /**
  48712. * Creates a new render target texture
  48713. * @param size defines the size of the texture
  48714. * @param options defines the options used to create the texture
  48715. * @returns a new render target texture stored in an InternalTexture
  48716. */
  48717. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48718. /**
  48719. * Update the sampling mode of a given texture
  48720. * @param samplingMode defines the required sampling mode
  48721. * @param texture defines the texture to update
  48722. */
  48723. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48724. /**
  48725. * Binds the frame buffer to the specified texture.
  48726. * @param texture The texture to render to or null for the default canvas
  48727. * @param faceIndex The face of the texture to render to in case of cube texture
  48728. * @param requiredWidth The width of the target to render to
  48729. * @param requiredHeight The height of the target to render to
  48730. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48731. * @param lodLevel defines le lod level to bind to the frame buffer
  48732. */
  48733. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48734. /**
  48735. * Unbind the current render target texture from the webGL context
  48736. * @param texture defines the render target texture to unbind
  48737. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48738. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48739. */
  48740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48741. /**
  48742. * Creates a dynamic vertex buffer
  48743. * @param vertices the data for the dynamic vertex buffer
  48744. * @returns the new WebGL dynamic buffer
  48745. */
  48746. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48747. /**
  48748. * Update the content of a dynamic texture
  48749. * @param texture defines the texture to update
  48750. * @param canvas defines the canvas containing the source
  48751. * @param invertY defines if data must be stored with Y axis inverted
  48752. * @param premulAlpha defines if alpha is stored as premultiplied
  48753. * @param format defines the format of the data
  48754. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48755. */
  48756. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48757. /**
  48758. * Gets a boolean indicating if all created effects are ready
  48759. * @returns true if all effects are ready
  48760. */
  48761. areAllEffectsReady(): boolean;
  48762. /**
  48763. * @hidden
  48764. * Get the current error code of the webGL context
  48765. * @returns the error code
  48766. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48767. */
  48768. getError(): number;
  48769. /** @hidden */
  48770. _getUnpackAlignement(): number;
  48771. /** @hidden */
  48772. _unpackFlipY(value: boolean): void;
  48773. /**
  48774. * Update a dynamic index buffer
  48775. * @param indexBuffer defines the target index buffer
  48776. * @param indices defines the data to update
  48777. * @param offset defines the offset in the target index buffer where update should start
  48778. */
  48779. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48780. /**
  48781. * Updates a dynamic vertex buffer.
  48782. * @param vertexBuffer the vertex buffer to update
  48783. * @param vertices the data used to update the vertex buffer
  48784. * @param byteOffset the byte offset of the data (optional)
  48785. * @param byteLength the byte length of the data (optional)
  48786. */
  48787. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48788. /** @hidden */
  48789. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48790. /** @hidden */
  48791. _bindTexture(channel: number, texture: InternalTexture): void;
  48792. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48793. /**
  48794. * 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
  48795. */
  48796. releaseEffects(): void;
  48797. displayLoadingUI(): void;
  48798. hideLoadingUI(): void;
  48799. /** @hidden */
  48800. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48801. /** @hidden */
  48802. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48803. /** @hidden */
  48804. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48805. /** @hidden */
  48806. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48807. }
  48808. }
  48809. declare module "babylonjs/Instrumentation/timeToken" {
  48810. import { Nullable } from "babylonjs/types";
  48811. /**
  48812. * @hidden
  48813. **/
  48814. export class _TimeToken {
  48815. _startTimeQuery: Nullable<WebGLQuery>;
  48816. _endTimeQuery: Nullable<WebGLQuery>;
  48817. _timeElapsedQuery: Nullable<WebGLQuery>;
  48818. _timeElapsedQueryEnded: boolean;
  48819. }
  48820. }
  48821. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48822. import { Nullable, int } from "babylonjs/types";
  48823. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48824. /** @hidden */
  48825. export class _OcclusionDataStorage {
  48826. /** @hidden */
  48827. occlusionInternalRetryCounter: number;
  48828. /** @hidden */
  48829. isOcclusionQueryInProgress: boolean;
  48830. /** @hidden */
  48831. isOccluded: boolean;
  48832. /** @hidden */
  48833. occlusionRetryCount: number;
  48834. /** @hidden */
  48835. occlusionType: number;
  48836. /** @hidden */
  48837. occlusionQueryAlgorithmType: number;
  48838. }
  48839. module "babylonjs/Engines/engine" {
  48840. interface Engine {
  48841. /**
  48842. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48843. * @return the new query
  48844. */
  48845. createQuery(): WebGLQuery;
  48846. /**
  48847. * Delete and release a webGL query
  48848. * @param query defines the query to delete
  48849. * @return the current engine
  48850. */
  48851. deleteQuery(query: WebGLQuery): Engine;
  48852. /**
  48853. * Check if a given query has resolved and got its value
  48854. * @param query defines the query to check
  48855. * @returns true if the query got its value
  48856. */
  48857. isQueryResultAvailable(query: WebGLQuery): boolean;
  48858. /**
  48859. * Gets the value of a given query
  48860. * @param query defines the query to check
  48861. * @returns the value of the query
  48862. */
  48863. getQueryResult(query: WebGLQuery): number;
  48864. /**
  48865. * Initiates an occlusion query
  48866. * @param algorithmType defines the algorithm to use
  48867. * @param query defines the query to use
  48868. * @returns the current engine
  48869. * @see http://doc.babylonjs.com/features/occlusionquery
  48870. */
  48871. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48872. /**
  48873. * Ends an occlusion query
  48874. * @see http://doc.babylonjs.com/features/occlusionquery
  48875. * @param algorithmType defines the algorithm to use
  48876. * @returns the current engine
  48877. */
  48878. endOcclusionQuery(algorithmType: number): Engine;
  48879. /**
  48880. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48881. * Please note that only one query can be issued at a time
  48882. * @returns a time token used to track the time span
  48883. */
  48884. startTimeQuery(): Nullable<_TimeToken>;
  48885. /**
  48886. * Ends a time query
  48887. * @param token defines the token used to measure the time span
  48888. * @returns the time spent (in ns)
  48889. */
  48890. endTimeQuery(token: _TimeToken): int;
  48891. /** @hidden */
  48892. _currentNonTimestampToken: Nullable<_TimeToken>;
  48893. /** @hidden */
  48894. _createTimeQuery(): WebGLQuery;
  48895. /** @hidden */
  48896. _deleteTimeQuery(query: WebGLQuery): void;
  48897. /** @hidden */
  48898. _getGlAlgorithmType(algorithmType: number): number;
  48899. /** @hidden */
  48900. _getTimeQueryResult(query: WebGLQuery): any;
  48901. /** @hidden */
  48902. _getTimeQueryAvailability(query: WebGLQuery): any;
  48903. }
  48904. }
  48905. module "babylonjs/Meshes/abstractMesh" {
  48906. interface AbstractMesh {
  48907. /**
  48908. * Backing filed
  48909. * @hidden
  48910. */
  48911. __occlusionDataStorage: _OcclusionDataStorage;
  48912. /**
  48913. * Access property
  48914. * @hidden
  48915. */
  48916. _occlusionDataStorage: _OcclusionDataStorage;
  48917. /**
  48918. * 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.
  48919. * The default value is -1 which means don't break the query and wait till the result
  48920. * @see http://doc.babylonjs.com/features/occlusionquery
  48921. */
  48922. occlusionRetryCount: number;
  48923. /**
  48924. * 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:
  48925. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48926. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48927. * * 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.
  48928. * @see http://doc.babylonjs.com/features/occlusionquery
  48929. */
  48930. occlusionType: number;
  48931. /**
  48932. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48933. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48934. * * 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.
  48935. * @see http://doc.babylonjs.com/features/occlusionquery
  48936. */
  48937. occlusionQueryAlgorithmType: number;
  48938. /**
  48939. * 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
  48940. * @see http://doc.babylonjs.com/features/occlusionquery
  48941. */
  48942. isOccluded: boolean;
  48943. /**
  48944. * Flag to check the progress status of the query
  48945. * @see http://doc.babylonjs.com/features/occlusionquery
  48946. */
  48947. isOcclusionQueryInProgress: boolean;
  48948. }
  48949. }
  48950. }
  48951. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48952. import { Nullable } from "babylonjs/types";
  48953. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48954. /** @hidden */
  48955. export var _forceTransformFeedbackToBundle: boolean;
  48956. module "babylonjs/Engines/engine" {
  48957. interface Engine {
  48958. /**
  48959. * Creates a webGL transform feedback object
  48960. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48961. * @returns the webGL transform feedback object
  48962. */
  48963. createTransformFeedback(): WebGLTransformFeedback;
  48964. /**
  48965. * Delete a webGL transform feedback object
  48966. * @param value defines the webGL transform feedback object to delete
  48967. */
  48968. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48969. /**
  48970. * Bind a webGL transform feedback object to the webgl context
  48971. * @param value defines the webGL transform feedback object to bind
  48972. */
  48973. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48974. /**
  48975. * Begins a transform feedback operation
  48976. * @param usePoints defines if points or triangles must be used
  48977. */
  48978. beginTransformFeedback(usePoints: boolean): void;
  48979. /**
  48980. * Ends a transform feedback operation
  48981. */
  48982. endTransformFeedback(): void;
  48983. /**
  48984. * Specify the varyings to use with transform feedback
  48985. * @param program defines the associated webGL program
  48986. * @param value defines the list of strings representing the varying names
  48987. */
  48988. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48989. /**
  48990. * Bind a webGL buffer for a transform feedback operation
  48991. * @param value defines the webGL buffer to bind
  48992. */
  48993. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48994. }
  48995. }
  48996. }
  48997. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48998. import { Scene } from "babylonjs/scene";
  48999. import { Engine } from "babylonjs/Engines/engine";
  49000. import { Texture } from "babylonjs/Materials/Textures/texture";
  49001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49002. import "babylonjs/Engines/Extensions/engine.multiRender";
  49003. /**
  49004. * Creation options of the multi render target texture.
  49005. */
  49006. export interface IMultiRenderTargetOptions {
  49007. /**
  49008. * Define if the texture needs to create mip maps after render.
  49009. */
  49010. generateMipMaps?: boolean;
  49011. /**
  49012. * Define the types of all the draw buffers we want to create
  49013. */
  49014. types?: number[];
  49015. /**
  49016. * Define the sampling modes of all the draw buffers we want to create
  49017. */
  49018. samplingModes?: number[];
  49019. /**
  49020. * Define if a depth buffer is required
  49021. */
  49022. generateDepthBuffer?: boolean;
  49023. /**
  49024. * Define if a stencil buffer is required
  49025. */
  49026. generateStencilBuffer?: boolean;
  49027. /**
  49028. * Define if a depth texture is required instead of a depth buffer
  49029. */
  49030. generateDepthTexture?: boolean;
  49031. /**
  49032. * Define the number of desired draw buffers
  49033. */
  49034. textureCount?: number;
  49035. /**
  49036. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49037. */
  49038. doNotChangeAspectRatio?: boolean;
  49039. /**
  49040. * Define the default type of the buffers we are creating
  49041. */
  49042. defaultType?: number;
  49043. }
  49044. /**
  49045. * A multi render target, like a render target provides the ability to render to a texture.
  49046. * Unlike the render target, it can render to several draw buffers in one draw.
  49047. * This is specially interesting in deferred rendering or for any effects requiring more than
  49048. * just one color from a single pass.
  49049. */
  49050. export class MultiRenderTarget extends RenderTargetTexture {
  49051. private _internalTextures;
  49052. private _textures;
  49053. private _multiRenderTargetOptions;
  49054. /**
  49055. * Get if draw buffers are currently supported by the used hardware and browser.
  49056. */
  49057. get isSupported(): boolean;
  49058. /**
  49059. * Get the list of textures generated by the multi render target.
  49060. */
  49061. get textures(): Texture[];
  49062. /**
  49063. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49064. */
  49065. get depthTexture(): Texture;
  49066. /**
  49067. * Set the wrapping mode on U of all the textures we are rendering to.
  49068. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49069. */
  49070. set wrapU(wrap: number);
  49071. /**
  49072. * Set the wrapping mode on V of all the textures we are rendering to.
  49073. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49074. */
  49075. set wrapV(wrap: number);
  49076. /**
  49077. * Instantiate a new multi render target texture.
  49078. * A multi render target, like a render target provides the ability to render to a texture.
  49079. * Unlike the render target, it can render to several draw buffers in one draw.
  49080. * This is specially interesting in deferred rendering or for any effects requiring more than
  49081. * just one color from a single pass.
  49082. * @param name Define the name of the texture
  49083. * @param size Define the size of the buffers to render to
  49084. * @param count Define the number of target we are rendering into
  49085. * @param scene Define the scene the texture belongs to
  49086. * @param options Define the options used to create the multi render target
  49087. */
  49088. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49089. /** @hidden */
  49090. _rebuild(): void;
  49091. private _createInternalTextures;
  49092. private _createTextures;
  49093. /**
  49094. * Define the number of samples used if MSAA is enabled.
  49095. */
  49096. get samples(): number;
  49097. set samples(value: number);
  49098. /**
  49099. * Resize all the textures in the multi render target.
  49100. * Be carrefull as it will recreate all the data in the new texture.
  49101. * @param size Define the new size
  49102. */
  49103. resize(size: any): void;
  49104. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49105. /**
  49106. * Dispose the render targets and their associated resources
  49107. */
  49108. dispose(): void;
  49109. /**
  49110. * Release all the underlying texture used as draw buffers.
  49111. */
  49112. releaseInternalTextures(): void;
  49113. }
  49114. }
  49115. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49116. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49117. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49118. import { Nullable } from "babylonjs/types";
  49119. module "babylonjs/Engines/thinEngine" {
  49120. interface ThinEngine {
  49121. /**
  49122. * Unbind a list of render target textures from the webGL context
  49123. * This is used only when drawBuffer extension or webGL2 are active
  49124. * @param textures defines the render target textures to unbind
  49125. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49126. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49127. */
  49128. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49129. /**
  49130. * Create a multi render target texture
  49131. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49132. * @param size defines the size of the texture
  49133. * @param options defines the creation options
  49134. * @returns the cube texture as an InternalTexture
  49135. */
  49136. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49137. /**
  49138. * Update the sample count for a given multiple render target texture
  49139. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49140. * @param textures defines the textures to update
  49141. * @param samples defines the sample count to set
  49142. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49143. */
  49144. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49145. }
  49146. }
  49147. }
  49148. declare module "babylonjs/Engines/Extensions/engine.views" {
  49149. import { Camera } from "babylonjs/Cameras/camera";
  49150. import { Nullable } from "babylonjs/types";
  49151. /**
  49152. * Class used to define an additional view for the engine
  49153. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49154. */
  49155. export class EngineView {
  49156. /** Defines the canvas where to render the view */
  49157. target: HTMLCanvasElement;
  49158. /** Defines an optional camera used to render the view (will use active camera else) */
  49159. camera?: Camera;
  49160. }
  49161. module "babylonjs/Engines/engine" {
  49162. interface Engine {
  49163. /**
  49164. * Gets or sets the HTML element to use for attaching events
  49165. */
  49166. inputElement: Nullable<HTMLElement>;
  49167. /**
  49168. * Gets the current engine view
  49169. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49170. */
  49171. activeView: Nullable<EngineView>;
  49172. /** Gets or sets the list of views */
  49173. views: EngineView[];
  49174. /**
  49175. * Register a new child canvas
  49176. * @param canvas defines the canvas to register
  49177. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49178. * @returns the associated view
  49179. */
  49180. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49181. /**
  49182. * Remove a registered child canvas
  49183. * @param canvas defines the canvas to remove
  49184. * @returns the current engine
  49185. */
  49186. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49187. }
  49188. }
  49189. }
  49190. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49191. import { Nullable } from "babylonjs/types";
  49192. module "babylonjs/Engines/engine" {
  49193. interface Engine {
  49194. /** @hidden */
  49195. _excludedCompressedTextures: string[];
  49196. /** @hidden */
  49197. _textureFormatInUse: string;
  49198. /**
  49199. * Gets the list of texture formats supported
  49200. */
  49201. readonly texturesSupported: Array<string>;
  49202. /**
  49203. * Gets the texture format in use
  49204. */
  49205. readonly textureFormatInUse: Nullable<string>;
  49206. /**
  49207. * Set the compressed texture extensions or file names to skip.
  49208. *
  49209. * @param skippedFiles defines the list of those texture files you want to skip
  49210. * Example: [".dds", ".env", "myfile.png"]
  49211. */
  49212. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49213. /**
  49214. * Set the compressed texture format to use, based on the formats you have, and the formats
  49215. * supported by the hardware / browser.
  49216. *
  49217. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49218. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49219. * to API arguments needed to compressed textures. This puts the burden on the container
  49220. * generator to house the arcane code for determining these for current & future formats.
  49221. *
  49222. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49223. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49224. *
  49225. * Note: The result of this call is not taken into account when a texture is base64.
  49226. *
  49227. * @param formatsAvailable defines the list of those format families you have created
  49228. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49229. *
  49230. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49231. * @returns The extension selected.
  49232. */
  49233. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49234. }
  49235. }
  49236. }
  49237. declare module "babylonjs/Engines/Extensions/index" {
  49238. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49239. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49240. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49241. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49242. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49243. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49244. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49245. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49246. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49247. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49248. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49249. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49250. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49251. export * from "babylonjs/Engines/Extensions/engine.views";
  49252. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49253. }
  49254. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49255. import { Nullable } from "babylonjs/types";
  49256. /**
  49257. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49258. */
  49259. export interface CubeMapInfo {
  49260. /**
  49261. * The pixel array for the front face.
  49262. * This is stored in format, left to right, up to down format.
  49263. */
  49264. front: Nullable<ArrayBufferView>;
  49265. /**
  49266. * The pixel array for the back face.
  49267. * This is stored in format, left to right, up to down format.
  49268. */
  49269. back: Nullable<ArrayBufferView>;
  49270. /**
  49271. * The pixel array for the left face.
  49272. * This is stored in format, left to right, up to down format.
  49273. */
  49274. left: Nullable<ArrayBufferView>;
  49275. /**
  49276. * The pixel array for the right face.
  49277. * This is stored in format, left to right, up to down format.
  49278. */
  49279. right: Nullable<ArrayBufferView>;
  49280. /**
  49281. * The pixel array for the up face.
  49282. * This is stored in format, left to right, up to down format.
  49283. */
  49284. up: Nullable<ArrayBufferView>;
  49285. /**
  49286. * The pixel array for the down face.
  49287. * This is stored in format, left to right, up to down format.
  49288. */
  49289. down: Nullable<ArrayBufferView>;
  49290. /**
  49291. * The size of the cubemap stored.
  49292. *
  49293. * Each faces will be size * size pixels.
  49294. */
  49295. size: number;
  49296. /**
  49297. * The format of the texture.
  49298. *
  49299. * RGBA, RGB.
  49300. */
  49301. format: number;
  49302. /**
  49303. * The type of the texture data.
  49304. *
  49305. * UNSIGNED_INT, FLOAT.
  49306. */
  49307. type: number;
  49308. /**
  49309. * Specifies whether the texture is in gamma space.
  49310. */
  49311. gammaSpace: boolean;
  49312. }
  49313. /**
  49314. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49315. */
  49316. export class PanoramaToCubeMapTools {
  49317. private static FACE_FRONT;
  49318. private static FACE_BACK;
  49319. private static FACE_RIGHT;
  49320. private static FACE_LEFT;
  49321. private static FACE_DOWN;
  49322. private static FACE_UP;
  49323. /**
  49324. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49325. *
  49326. * @param float32Array The source data.
  49327. * @param inputWidth The width of the input panorama.
  49328. * @param inputHeight The height of the input panorama.
  49329. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49330. * @return The cubemap data
  49331. */
  49332. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49333. private static CreateCubemapTexture;
  49334. private static CalcProjectionSpherical;
  49335. }
  49336. }
  49337. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49338. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49340. import { Nullable } from "babylonjs/types";
  49341. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49342. /**
  49343. * Helper class dealing with the extraction of spherical polynomial dataArray
  49344. * from a cube map.
  49345. */
  49346. export class CubeMapToSphericalPolynomialTools {
  49347. private static FileFaces;
  49348. /**
  49349. * Converts a texture to the according Spherical Polynomial data.
  49350. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49351. *
  49352. * @param texture The texture to extract the information from.
  49353. * @return The Spherical Polynomial data.
  49354. */
  49355. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49356. /**
  49357. * Converts a cubemap to the according Spherical Polynomial data.
  49358. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49359. *
  49360. * @param cubeInfo The Cube map to extract the information from.
  49361. * @return The Spherical Polynomial data.
  49362. */
  49363. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49364. }
  49365. }
  49366. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49367. import { Nullable } from "babylonjs/types";
  49368. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49369. module "babylonjs/Materials/Textures/baseTexture" {
  49370. interface BaseTexture {
  49371. /**
  49372. * Get the polynomial representation of the texture data.
  49373. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49374. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49375. */
  49376. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49377. }
  49378. }
  49379. }
  49380. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49382. /** @hidden */
  49383. export var rgbdEncodePixelShader: {
  49384. name: string;
  49385. shader: string;
  49386. };
  49387. }
  49388. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49390. /** @hidden */
  49391. export var rgbdDecodePixelShader: {
  49392. name: string;
  49393. shader: string;
  49394. };
  49395. }
  49396. declare module "babylonjs/Misc/environmentTextureTools" {
  49397. import { Nullable } from "babylonjs/types";
  49398. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49400. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49401. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49402. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49403. import "babylonjs/Shaders/rgbdEncode.fragment";
  49404. import "babylonjs/Shaders/rgbdDecode.fragment";
  49405. /**
  49406. * Raw texture data and descriptor sufficient for WebGL texture upload
  49407. */
  49408. export interface EnvironmentTextureInfo {
  49409. /**
  49410. * Version of the environment map
  49411. */
  49412. version: number;
  49413. /**
  49414. * Width of image
  49415. */
  49416. width: number;
  49417. /**
  49418. * Irradiance information stored in the file.
  49419. */
  49420. irradiance: any;
  49421. /**
  49422. * Specular information stored in the file.
  49423. */
  49424. specular: any;
  49425. }
  49426. /**
  49427. * Defines One Image in the file. It requires only the position in the file
  49428. * as well as the length.
  49429. */
  49430. interface BufferImageData {
  49431. /**
  49432. * Length of the image data.
  49433. */
  49434. length: number;
  49435. /**
  49436. * Position of the data from the null terminator delimiting the end of the JSON.
  49437. */
  49438. position: number;
  49439. }
  49440. /**
  49441. * Defines the specular data enclosed in the file.
  49442. * This corresponds to the version 1 of the data.
  49443. */
  49444. export interface EnvironmentTextureSpecularInfoV1 {
  49445. /**
  49446. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49447. */
  49448. specularDataPosition?: number;
  49449. /**
  49450. * This contains all the images data needed to reconstruct the cubemap.
  49451. */
  49452. mipmaps: Array<BufferImageData>;
  49453. /**
  49454. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49455. */
  49456. lodGenerationScale: number;
  49457. }
  49458. /**
  49459. * Sets of helpers addressing the serialization and deserialization of environment texture
  49460. * stored in a BabylonJS env file.
  49461. * Those files are usually stored as .env files.
  49462. */
  49463. export class EnvironmentTextureTools {
  49464. /**
  49465. * Magic number identifying the env file.
  49466. */
  49467. private static _MagicBytes;
  49468. /**
  49469. * Gets the environment info from an env file.
  49470. * @param data The array buffer containing the .env bytes.
  49471. * @returns the environment file info (the json header) if successfully parsed.
  49472. */
  49473. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49474. /**
  49475. * Creates an environment texture from a loaded cube texture.
  49476. * @param texture defines the cube texture to convert in env file
  49477. * @return a promise containing the environment data if succesfull.
  49478. */
  49479. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49480. /**
  49481. * Creates a JSON representation of the spherical data.
  49482. * @param texture defines the texture containing the polynomials
  49483. * @return the JSON representation of the spherical info
  49484. */
  49485. private static _CreateEnvTextureIrradiance;
  49486. /**
  49487. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49488. * @param data the image data
  49489. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49490. * @return the views described by info providing access to the underlying buffer
  49491. */
  49492. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49493. /**
  49494. * Uploads the texture info contained in the env file to the GPU.
  49495. * @param texture defines the internal texture to upload to
  49496. * @param data defines the data to load
  49497. * @param info defines the texture info retrieved through the GetEnvInfo method
  49498. * @returns a promise
  49499. */
  49500. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49501. private static _OnImageReadyAsync;
  49502. /**
  49503. * Uploads the levels of image data to the GPU.
  49504. * @param texture defines the internal texture to upload to
  49505. * @param imageData defines the array buffer views of image data [mipmap][face]
  49506. * @returns a promise
  49507. */
  49508. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49509. /**
  49510. * Uploads spherical polynomials information to the texture.
  49511. * @param texture defines the texture we are trying to upload the information to
  49512. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49513. */
  49514. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49515. /** @hidden */
  49516. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49517. }
  49518. }
  49519. declare module "babylonjs/Maths/math.vertexFormat" {
  49520. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49521. /**
  49522. * Contains position and normal vectors for a vertex
  49523. */
  49524. export class PositionNormalVertex {
  49525. /** the position of the vertex (defaut: 0,0,0) */
  49526. position: Vector3;
  49527. /** the normal of the vertex (defaut: 0,1,0) */
  49528. normal: Vector3;
  49529. /**
  49530. * Creates a PositionNormalVertex
  49531. * @param position the position of the vertex (defaut: 0,0,0)
  49532. * @param normal the normal of the vertex (defaut: 0,1,0)
  49533. */
  49534. constructor(
  49535. /** the position of the vertex (defaut: 0,0,0) */
  49536. position?: Vector3,
  49537. /** the normal of the vertex (defaut: 0,1,0) */
  49538. normal?: Vector3);
  49539. /**
  49540. * Clones the PositionNormalVertex
  49541. * @returns the cloned PositionNormalVertex
  49542. */
  49543. clone(): PositionNormalVertex;
  49544. }
  49545. /**
  49546. * Contains position, normal and uv vectors for a vertex
  49547. */
  49548. export class PositionNormalTextureVertex {
  49549. /** the position of the vertex (defaut: 0,0,0) */
  49550. position: Vector3;
  49551. /** the normal of the vertex (defaut: 0,1,0) */
  49552. normal: Vector3;
  49553. /** the uv of the vertex (default: 0,0) */
  49554. uv: Vector2;
  49555. /**
  49556. * Creates a PositionNormalTextureVertex
  49557. * @param position the position of the vertex (defaut: 0,0,0)
  49558. * @param normal the normal of the vertex (defaut: 0,1,0)
  49559. * @param uv the uv of the vertex (default: 0,0)
  49560. */
  49561. constructor(
  49562. /** the position of the vertex (defaut: 0,0,0) */
  49563. position?: Vector3,
  49564. /** the normal of the vertex (defaut: 0,1,0) */
  49565. normal?: Vector3,
  49566. /** the uv of the vertex (default: 0,0) */
  49567. uv?: Vector2);
  49568. /**
  49569. * Clones the PositionNormalTextureVertex
  49570. * @returns the cloned PositionNormalTextureVertex
  49571. */
  49572. clone(): PositionNormalTextureVertex;
  49573. }
  49574. }
  49575. declare module "babylonjs/Maths/math" {
  49576. export * from "babylonjs/Maths/math.axis";
  49577. export * from "babylonjs/Maths/math.color";
  49578. export * from "babylonjs/Maths/math.constants";
  49579. export * from "babylonjs/Maths/math.frustum";
  49580. export * from "babylonjs/Maths/math.path";
  49581. export * from "babylonjs/Maths/math.plane";
  49582. export * from "babylonjs/Maths/math.size";
  49583. export * from "babylonjs/Maths/math.vector";
  49584. export * from "babylonjs/Maths/math.vertexFormat";
  49585. export * from "babylonjs/Maths/math.viewport";
  49586. }
  49587. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49588. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49589. /** @hidden */
  49590. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49591. private _genericAttributeLocation;
  49592. private _varyingLocationCount;
  49593. private _varyingLocationMap;
  49594. private _replacements;
  49595. private _textureCount;
  49596. private _uniforms;
  49597. lineProcessor(line: string): string;
  49598. attributeProcessor(attribute: string): string;
  49599. varyingProcessor(varying: string, isFragment: boolean): string;
  49600. uniformProcessor(uniform: string): string;
  49601. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49602. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49603. }
  49604. }
  49605. declare module "babylonjs/Engines/nativeEngine" {
  49606. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49607. import { Engine } from "babylonjs/Engines/engine";
  49608. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49609. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49611. import { Effect } from "babylonjs/Materials/effect";
  49612. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49613. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49614. import { IColor4Like } from "babylonjs/Maths/math.like";
  49615. import { Scene } from "babylonjs/scene";
  49616. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49617. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49618. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49619. /**
  49620. * Container for accessors for natively-stored mesh data buffers.
  49621. */
  49622. class NativeDataBuffer extends DataBuffer {
  49623. /**
  49624. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49625. */
  49626. nativeIndexBuffer?: any;
  49627. /**
  49628. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49629. */
  49630. nativeVertexBuffer?: any;
  49631. }
  49632. /** @hidden */
  49633. class NativeTexture extends InternalTexture {
  49634. getInternalTexture(): InternalTexture;
  49635. getViewCount(): number;
  49636. }
  49637. /** @hidden */
  49638. export class NativeEngine extends Engine {
  49639. private readonly _native;
  49640. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49641. private readonly INVALID_HANDLE;
  49642. getHardwareScalingLevel(): number;
  49643. constructor();
  49644. /**
  49645. * Can be used to override the current requestAnimationFrame requester.
  49646. * @hidden
  49647. */
  49648. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49649. /**
  49650. * Override default engine behavior.
  49651. * @param color
  49652. * @param backBuffer
  49653. * @param depth
  49654. * @param stencil
  49655. */
  49656. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49657. /**
  49658. * Gets host document
  49659. * @returns the host document object
  49660. */
  49661. getHostDocument(): Nullable<Document>;
  49662. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49663. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49664. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49665. recordVertexArrayObject(vertexBuffers: {
  49666. [key: string]: VertexBuffer;
  49667. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49668. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49669. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49670. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49671. /**
  49672. * Draw a list of indexed primitives
  49673. * @param fillMode defines the primitive to use
  49674. * @param indexStart defines the starting index
  49675. * @param indexCount defines the number of index to draw
  49676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49677. */
  49678. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49679. /**
  49680. * Draw a list of unindexed primitives
  49681. * @param fillMode defines the primitive to use
  49682. * @param verticesStart defines the index of first vertex to draw
  49683. * @param verticesCount defines the count of vertices to draw
  49684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49685. */
  49686. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49687. createPipelineContext(): IPipelineContext;
  49688. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49689. /** @hidden */
  49690. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49691. /** @hidden */
  49692. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49693. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49694. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49695. protected _setProgram(program: WebGLProgram): void;
  49696. _releaseEffect(effect: Effect): void;
  49697. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49698. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49699. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49700. bindSamplers(effect: Effect): void;
  49701. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49702. getRenderWidth(useScreen?: boolean): number;
  49703. getRenderHeight(useScreen?: boolean): number;
  49704. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49705. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49706. /**
  49707. * Set the z offset to apply to current rendering
  49708. * @param value defines the offset to apply
  49709. */
  49710. setZOffset(value: number): void;
  49711. /**
  49712. * Gets the current value of the zOffset
  49713. * @returns the current zOffset state
  49714. */
  49715. getZOffset(): number;
  49716. /**
  49717. * Enable or disable depth buffering
  49718. * @param enable defines the state to set
  49719. */
  49720. setDepthBuffer(enable: boolean): void;
  49721. /**
  49722. * Gets a boolean indicating if depth writing is enabled
  49723. * @returns the current depth writing state
  49724. */
  49725. getDepthWrite(): boolean;
  49726. /**
  49727. * Enable or disable depth writing
  49728. * @param enable defines the state to set
  49729. */
  49730. setDepthWrite(enable: boolean): void;
  49731. /**
  49732. * Enable or disable color writing
  49733. * @param enable defines the state to set
  49734. */
  49735. setColorWrite(enable: boolean): void;
  49736. /**
  49737. * Gets a boolean indicating if color writing is enabled
  49738. * @returns the current color writing state
  49739. */
  49740. getColorWrite(): boolean;
  49741. /**
  49742. * Sets alpha constants used by some alpha blending modes
  49743. * @param r defines the red component
  49744. * @param g defines the green component
  49745. * @param b defines the blue component
  49746. * @param a defines the alpha component
  49747. */
  49748. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49749. /**
  49750. * Sets the current alpha mode
  49751. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49752. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49754. */
  49755. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49756. /**
  49757. * Gets the current alpha mode
  49758. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49759. * @returns the current alpha mode
  49760. */
  49761. getAlphaMode(): number;
  49762. setInt(uniform: WebGLUniformLocation, int: number): void;
  49763. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49764. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49765. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49766. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49767. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49768. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49769. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49770. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49771. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49772. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49773. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49774. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49775. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49776. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49777. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49778. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49779. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49780. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49781. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49782. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49783. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49784. wipeCaches(bruteForce?: boolean): void;
  49785. _createTexture(): WebGLTexture;
  49786. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49787. /**
  49788. * Usually called from Texture.ts.
  49789. * Passed information to create a WebGLTexture
  49790. * @param urlArg defines a value which contains one of the following:
  49791. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49792. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49793. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49794. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49795. * @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)
  49796. * @param scene needed for loading to the correct scene
  49797. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49798. * @param onLoad optional callback to be called upon successful completion
  49799. * @param onError optional callback to be called upon failure
  49800. * @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
  49801. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49802. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49803. * @param forcedExtension defines the extension to use to pick the right loader
  49804. * @param mimeType defines an optional mime type
  49805. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49806. */
  49807. 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;
  49808. /**
  49809. * Creates a cube texture
  49810. * @param rootUrl defines the url where the files to load is located
  49811. * @param scene defines the current scene
  49812. * @param files defines the list of files to load (1 per face)
  49813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49814. * @param onLoad defines an optional callback raised when the texture is loaded
  49815. * @param onError defines an optional callback raised if there is an issue to load the texture
  49816. * @param format defines the format of the data
  49817. * @param forcedExtension defines the extension to use to pick the right loader
  49818. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49819. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49820. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49821. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49822. * @returns the cube texture as an InternalTexture
  49823. */
  49824. 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;
  49825. private _getSamplingFilter;
  49826. private static _GetNativeTextureFormat;
  49827. createRenderTargetTexture(size: number | {
  49828. width: number;
  49829. height: number;
  49830. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49831. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49832. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49833. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49834. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49835. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49836. /**
  49837. * Updates a dynamic vertex buffer.
  49838. * @param vertexBuffer the vertex buffer to update
  49839. * @param data the data used to update the vertex buffer
  49840. * @param byteOffset the byte offset of the data (optional)
  49841. * @param byteLength the byte length of the data (optional)
  49842. */
  49843. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49844. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49845. private _updateAnisotropicLevel;
  49846. private _getAddressMode;
  49847. /** @hidden */
  49848. _bindTexture(channel: number, texture: InternalTexture): void;
  49849. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49850. releaseEffects(): void;
  49851. /** @hidden */
  49852. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49853. /** @hidden */
  49854. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49855. /** @hidden */
  49856. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49857. /** @hidden */
  49858. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49859. }
  49860. }
  49861. declare module "babylonjs/Engines/index" {
  49862. export * from "babylonjs/Engines/constants";
  49863. export * from "babylonjs/Engines/engineCapabilities";
  49864. export * from "babylonjs/Engines/instancingAttributeInfo";
  49865. export * from "babylonjs/Engines/thinEngine";
  49866. export * from "babylonjs/Engines/engine";
  49867. export * from "babylonjs/Engines/engineStore";
  49868. export * from "babylonjs/Engines/nullEngine";
  49869. export * from "babylonjs/Engines/Extensions/index";
  49870. export * from "babylonjs/Engines/IPipelineContext";
  49871. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49872. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49873. export * from "babylonjs/Engines/nativeEngine";
  49874. }
  49875. declare module "babylonjs/Events/clipboardEvents" {
  49876. /**
  49877. * Gather the list of clipboard event types as constants.
  49878. */
  49879. export class ClipboardEventTypes {
  49880. /**
  49881. * The clipboard event is fired when a copy command is active (pressed).
  49882. */
  49883. static readonly COPY: number;
  49884. /**
  49885. * The clipboard event is fired when a cut command is active (pressed).
  49886. */
  49887. static readonly CUT: number;
  49888. /**
  49889. * The clipboard event is fired when a paste command is active (pressed).
  49890. */
  49891. static readonly PASTE: number;
  49892. }
  49893. /**
  49894. * This class is used to store clipboard related info for the onClipboardObservable event.
  49895. */
  49896. export class ClipboardInfo {
  49897. /**
  49898. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49899. */
  49900. type: number;
  49901. /**
  49902. * Defines the related dom event
  49903. */
  49904. event: ClipboardEvent;
  49905. /**
  49906. *Creates an instance of ClipboardInfo.
  49907. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49908. * @param event Defines the related dom event
  49909. */
  49910. constructor(
  49911. /**
  49912. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49913. */
  49914. type: number,
  49915. /**
  49916. * Defines the related dom event
  49917. */
  49918. event: ClipboardEvent);
  49919. /**
  49920. * Get the clipboard event's type from the keycode.
  49921. * @param keyCode Defines the keyCode for the current keyboard event.
  49922. * @return {number}
  49923. */
  49924. static GetTypeFromCharacter(keyCode: number): number;
  49925. }
  49926. }
  49927. declare module "babylonjs/Events/index" {
  49928. export * from "babylonjs/Events/keyboardEvents";
  49929. export * from "babylonjs/Events/pointerEvents";
  49930. export * from "babylonjs/Events/clipboardEvents";
  49931. }
  49932. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49933. import { Scene } from "babylonjs/scene";
  49934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49935. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49936. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49937. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49938. /**
  49939. * Google Daydream controller
  49940. */
  49941. export class DaydreamController extends WebVRController {
  49942. /**
  49943. * Base Url for the controller model.
  49944. */
  49945. static MODEL_BASE_URL: string;
  49946. /**
  49947. * File name for the controller model.
  49948. */
  49949. static MODEL_FILENAME: string;
  49950. /**
  49951. * Gamepad Id prefix used to identify Daydream Controller.
  49952. */
  49953. static readonly GAMEPAD_ID_PREFIX: string;
  49954. /**
  49955. * Creates a new DaydreamController from a gamepad
  49956. * @param vrGamepad the gamepad that the controller should be created from
  49957. */
  49958. constructor(vrGamepad: any);
  49959. /**
  49960. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49961. * @param scene scene in which to add meshes
  49962. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49963. */
  49964. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49965. /**
  49966. * Called once for each button that changed state since the last frame
  49967. * @param buttonIdx Which button index changed
  49968. * @param state New state of the button
  49969. * @param changes Which properties on the state changed since last frame
  49970. */
  49971. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49972. }
  49973. }
  49974. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49975. import { Scene } from "babylonjs/scene";
  49976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49977. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49978. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49979. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49980. /**
  49981. * Gear VR Controller
  49982. */
  49983. export class GearVRController extends WebVRController {
  49984. /**
  49985. * Base Url for the controller model.
  49986. */
  49987. static MODEL_BASE_URL: string;
  49988. /**
  49989. * File name for the controller model.
  49990. */
  49991. static MODEL_FILENAME: string;
  49992. /**
  49993. * Gamepad Id prefix used to identify this controller.
  49994. */
  49995. static readonly GAMEPAD_ID_PREFIX: string;
  49996. private readonly _buttonIndexToObservableNameMap;
  49997. /**
  49998. * Creates a new GearVRController from a gamepad
  49999. * @param vrGamepad the gamepad that the controller should be created from
  50000. */
  50001. constructor(vrGamepad: any);
  50002. /**
  50003. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50004. * @param scene scene in which to add meshes
  50005. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50006. */
  50007. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50008. /**
  50009. * Called once for each button that changed state since the last frame
  50010. * @param buttonIdx Which button index changed
  50011. * @param state New state of the button
  50012. * @param changes Which properties on the state changed since last frame
  50013. */
  50014. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50015. }
  50016. }
  50017. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50018. import { Scene } from "babylonjs/scene";
  50019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50020. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50021. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50022. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50023. /**
  50024. * Generic Controller
  50025. */
  50026. export class GenericController extends WebVRController {
  50027. /**
  50028. * Base Url for the controller model.
  50029. */
  50030. static readonly MODEL_BASE_URL: string;
  50031. /**
  50032. * File name for the controller model.
  50033. */
  50034. static readonly MODEL_FILENAME: string;
  50035. /**
  50036. * Creates a new GenericController from a gamepad
  50037. * @param vrGamepad the gamepad that the controller should be created from
  50038. */
  50039. constructor(vrGamepad: any);
  50040. /**
  50041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50042. * @param scene scene in which to add meshes
  50043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50044. */
  50045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50046. /**
  50047. * Called once for each button that changed state since the last frame
  50048. * @param buttonIdx Which button index changed
  50049. * @param state New state of the button
  50050. * @param changes Which properties on the state changed since last frame
  50051. */
  50052. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50053. }
  50054. }
  50055. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50056. import { Observable } from "babylonjs/Misc/observable";
  50057. import { Scene } from "babylonjs/scene";
  50058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50059. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50060. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50061. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50062. /**
  50063. * Oculus Touch Controller
  50064. */
  50065. export class OculusTouchController extends WebVRController {
  50066. /**
  50067. * Base Url for the controller model.
  50068. */
  50069. static MODEL_BASE_URL: string;
  50070. /**
  50071. * File name for the left controller model.
  50072. */
  50073. static MODEL_LEFT_FILENAME: string;
  50074. /**
  50075. * File name for the right controller model.
  50076. */
  50077. static MODEL_RIGHT_FILENAME: string;
  50078. /**
  50079. * Base Url for the Quest controller model.
  50080. */
  50081. static QUEST_MODEL_BASE_URL: string;
  50082. /**
  50083. * @hidden
  50084. * If the controllers are running on a device that needs the updated Quest controller models
  50085. */
  50086. static _IsQuest: boolean;
  50087. /**
  50088. * Fired when the secondary trigger on this controller is modified
  50089. */
  50090. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50091. /**
  50092. * Fired when the thumb rest on this controller is modified
  50093. */
  50094. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50095. /**
  50096. * Creates a new OculusTouchController from a gamepad
  50097. * @param vrGamepad the gamepad that the controller should be created from
  50098. */
  50099. constructor(vrGamepad: any);
  50100. /**
  50101. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50102. * @param scene scene in which to add meshes
  50103. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50104. */
  50105. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50106. /**
  50107. * Fired when the A button on this controller is modified
  50108. */
  50109. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50110. /**
  50111. * Fired when the B button on this controller is modified
  50112. */
  50113. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50114. /**
  50115. * Fired when the X button on this controller is modified
  50116. */
  50117. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50118. /**
  50119. * Fired when the Y button on this controller is modified
  50120. */
  50121. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50122. /**
  50123. * Called once for each button that changed state since the last frame
  50124. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50125. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50126. * 2) secondary trigger (same)
  50127. * 3) A (right) X (left), touch, pressed = value
  50128. * 4) B / Y
  50129. * 5) thumb rest
  50130. * @param buttonIdx Which button index changed
  50131. * @param state New state of the button
  50132. * @param changes Which properties on the state changed since last frame
  50133. */
  50134. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50135. }
  50136. }
  50137. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50138. import { Scene } from "babylonjs/scene";
  50139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50140. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50141. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50142. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50143. import { Observable } from "babylonjs/Misc/observable";
  50144. /**
  50145. * Vive Controller
  50146. */
  50147. export class ViveController extends WebVRController {
  50148. /**
  50149. * Base Url for the controller model.
  50150. */
  50151. static MODEL_BASE_URL: string;
  50152. /**
  50153. * File name for the controller model.
  50154. */
  50155. static MODEL_FILENAME: string;
  50156. /**
  50157. * Creates a new ViveController from a gamepad
  50158. * @param vrGamepad the gamepad that the controller should be created from
  50159. */
  50160. constructor(vrGamepad: any);
  50161. /**
  50162. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50163. * @param scene scene in which to add meshes
  50164. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50165. */
  50166. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50167. /**
  50168. * Fired when the left button on this controller is modified
  50169. */
  50170. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50171. /**
  50172. * Fired when the right button on this controller is modified
  50173. */
  50174. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50175. /**
  50176. * Fired when the menu button on this controller is modified
  50177. */
  50178. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50179. /**
  50180. * Called once for each button that changed state since the last frame
  50181. * Vive mapping:
  50182. * 0: touchpad
  50183. * 1: trigger
  50184. * 2: left AND right buttons
  50185. * 3: menu button
  50186. * @param buttonIdx Which button index changed
  50187. * @param state New state of the button
  50188. * @param changes Which properties on the state changed since last frame
  50189. */
  50190. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50191. }
  50192. }
  50193. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50194. import { Observable } from "babylonjs/Misc/observable";
  50195. import { Scene } from "babylonjs/scene";
  50196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50197. import { Ray } from "babylonjs/Culling/ray";
  50198. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50199. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50200. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50201. /**
  50202. * Defines the WindowsMotionController object that the state of the windows motion controller
  50203. */
  50204. export class WindowsMotionController extends WebVRController {
  50205. /**
  50206. * The base url used to load the left and right controller models
  50207. */
  50208. static MODEL_BASE_URL: string;
  50209. /**
  50210. * The name of the left controller model file
  50211. */
  50212. static MODEL_LEFT_FILENAME: string;
  50213. /**
  50214. * The name of the right controller model file
  50215. */
  50216. static MODEL_RIGHT_FILENAME: string;
  50217. /**
  50218. * The controller name prefix for this controller type
  50219. */
  50220. static readonly GAMEPAD_ID_PREFIX: string;
  50221. /**
  50222. * The controller id pattern for this controller type
  50223. */
  50224. private static readonly GAMEPAD_ID_PATTERN;
  50225. private _loadedMeshInfo;
  50226. protected readonly _mapping: {
  50227. buttons: string[];
  50228. buttonMeshNames: {
  50229. 'trigger': string;
  50230. 'menu': string;
  50231. 'grip': string;
  50232. 'thumbstick': string;
  50233. 'trackpad': string;
  50234. };
  50235. buttonObservableNames: {
  50236. 'trigger': string;
  50237. 'menu': string;
  50238. 'grip': string;
  50239. 'thumbstick': string;
  50240. 'trackpad': string;
  50241. };
  50242. axisMeshNames: string[];
  50243. pointingPoseMeshName: string;
  50244. };
  50245. /**
  50246. * Fired when the trackpad on this controller is clicked
  50247. */
  50248. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50249. /**
  50250. * Fired when the trackpad on this controller is modified
  50251. */
  50252. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50253. /**
  50254. * The current x and y values of this controller's trackpad
  50255. */
  50256. trackpad: StickValues;
  50257. /**
  50258. * Creates a new WindowsMotionController from a gamepad
  50259. * @param vrGamepad the gamepad that the controller should be created from
  50260. */
  50261. constructor(vrGamepad: any);
  50262. /**
  50263. * Fired when the trigger on this controller is modified
  50264. */
  50265. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50266. /**
  50267. * Fired when the menu button on this controller is modified
  50268. */
  50269. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50270. /**
  50271. * Fired when the grip button on this controller is modified
  50272. */
  50273. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50274. /**
  50275. * Fired when the thumbstick button on this controller is modified
  50276. */
  50277. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50278. /**
  50279. * Fired when the touchpad button on this controller is modified
  50280. */
  50281. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50282. /**
  50283. * Fired when the touchpad values on this controller are modified
  50284. */
  50285. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50286. protected _updateTrackpad(): void;
  50287. /**
  50288. * Called once per frame by the engine.
  50289. */
  50290. update(): void;
  50291. /**
  50292. * Called once for each button that changed state since the last frame
  50293. * @param buttonIdx Which button index changed
  50294. * @param state New state of the button
  50295. * @param changes Which properties on the state changed since last frame
  50296. */
  50297. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50298. /**
  50299. * Moves the buttons on the controller mesh based on their current state
  50300. * @param buttonName the name of the button to move
  50301. * @param buttonValue the value of the button which determines the buttons new position
  50302. */
  50303. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50304. /**
  50305. * Moves the axis on the controller mesh based on its current state
  50306. * @param axis the index of the axis
  50307. * @param axisValue the value of the axis which determines the meshes new position
  50308. * @hidden
  50309. */
  50310. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50311. /**
  50312. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50313. * @param scene scene in which to add meshes
  50314. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50315. */
  50316. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50317. /**
  50318. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50319. * can be transformed by button presses and axes values, based on this._mapping.
  50320. *
  50321. * @param scene scene in which the meshes exist
  50322. * @param meshes list of meshes that make up the controller model to process
  50323. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50324. */
  50325. private processModel;
  50326. private createMeshInfo;
  50327. /**
  50328. * Gets the ray of the controller in the direction the controller is pointing
  50329. * @param length the length the resulting ray should be
  50330. * @returns a ray in the direction the controller is pointing
  50331. */
  50332. getForwardRay(length?: number): Ray;
  50333. /**
  50334. * Disposes of the controller
  50335. */
  50336. dispose(): void;
  50337. }
  50338. /**
  50339. * This class represents a new windows motion controller in XR.
  50340. */
  50341. export class XRWindowsMotionController extends WindowsMotionController {
  50342. /**
  50343. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50344. */
  50345. protected readonly _mapping: {
  50346. buttons: string[];
  50347. buttonMeshNames: {
  50348. 'trigger': string;
  50349. 'menu': string;
  50350. 'grip': string;
  50351. 'thumbstick': string;
  50352. 'trackpad': string;
  50353. };
  50354. buttonObservableNames: {
  50355. 'trigger': string;
  50356. 'menu': string;
  50357. 'grip': string;
  50358. 'thumbstick': string;
  50359. 'trackpad': string;
  50360. };
  50361. axisMeshNames: string[];
  50362. pointingPoseMeshName: string;
  50363. };
  50364. /**
  50365. * Construct a new XR-Based windows motion controller
  50366. *
  50367. * @param gamepadInfo the gamepad object from the browser
  50368. */
  50369. constructor(gamepadInfo: any);
  50370. /**
  50371. * holds the thumbstick values (X,Y)
  50372. */
  50373. thumbstickValues: StickValues;
  50374. /**
  50375. * Fired when the thumbstick on this controller is clicked
  50376. */
  50377. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50378. /**
  50379. * Fired when the thumbstick on this controller is modified
  50380. */
  50381. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50382. /**
  50383. * Fired when the touchpad button on this controller is modified
  50384. */
  50385. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50386. /**
  50387. * Fired when the touchpad values on this controller are modified
  50388. */
  50389. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50390. /**
  50391. * Fired when the thumbstick button on this controller is modified
  50392. * here to prevent breaking changes
  50393. */
  50394. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50395. /**
  50396. * updating the thumbstick(!) and not the trackpad.
  50397. * This is named this way due to the difference between WebVR and XR and to avoid
  50398. * changing the parent class.
  50399. */
  50400. protected _updateTrackpad(): void;
  50401. /**
  50402. * Disposes the class with joy
  50403. */
  50404. dispose(): void;
  50405. }
  50406. }
  50407. declare module "babylonjs/Gamepads/Controllers/index" {
  50408. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50409. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50410. export * from "babylonjs/Gamepads/Controllers/genericController";
  50411. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50412. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50413. export * from "babylonjs/Gamepads/Controllers/viveController";
  50414. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50415. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50416. }
  50417. declare module "babylonjs/Gamepads/index" {
  50418. export * from "babylonjs/Gamepads/Controllers/index";
  50419. export * from "babylonjs/Gamepads/gamepad";
  50420. export * from "babylonjs/Gamepads/gamepadManager";
  50421. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50422. export * from "babylonjs/Gamepads/xboxGamepad";
  50423. export * from "babylonjs/Gamepads/dualShockGamepad";
  50424. }
  50425. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50426. import { Scene } from "babylonjs/scene";
  50427. import { Vector4 } from "babylonjs/Maths/math.vector";
  50428. import { Color4 } from "babylonjs/Maths/math.color";
  50429. import { Mesh } from "babylonjs/Meshes/mesh";
  50430. import { Nullable } from "babylonjs/types";
  50431. /**
  50432. * Class containing static functions to help procedurally build meshes
  50433. */
  50434. export class PolyhedronBuilder {
  50435. /**
  50436. * Creates a polyhedron mesh
  50437. * * 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
  50438. * * The parameter `size` (positive float, default 1) sets the polygon size
  50439. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50440. * * 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`
  50441. * * 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
  50442. * * 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)`)
  50443. * * 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
  50444. * * 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
  50445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50448. * @param name defines the name of the mesh
  50449. * @param options defines the options used to create the mesh
  50450. * @param scene defines the hosting scene
  50451. * @returns the polyhedron mesh
  50452. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50453. */
  50454. static CreatePolyhedron(name: string, options: {
  50455. type?: number;
  50456. size?: number;
  50457. sizeX?: number;
  50458. sizeY?: number;
  50459. sizeZ?: number;
  50460. custom?: any;
  50461. faceUV?: Vector4[];
  50462. faceColors?: Color4[];
  50463. flat?: boolean;
  50464. updatable?: boolean;
  50465. sideOrientation?: number;
  50466. frontUVs?: Vector4;
  50467. backUVs?: Vector4;
  50468. }, scene?: Nullable<Scene>): Mesh;
  50469. }
  50470. }
  50471. declare module "babylonjs/Gizmos/scaleGizmo" {
  50472. import { Observable } from "babylonjs/Misc/observable";
  50473. import { Nullable } from "babylonjs/types";
  50474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50475. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50476. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50477. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50478. /**
  50479. * Gizmo that enables scaling a mesh along 3 axis
  50480. */
  50481. export class ScaleGizmo extends Gizmo {
  50482. /**
  50483. * Internal gizmo used for interactions on the x axis
  50484. */
  50485. xGizmo: AxisScaleGizmo;
  50486. /**
  50487. * Internal gizmo used for interactions on the y axis
  50488. */
  50489. yGizmo: AxisScaleGizmo;
  50490. /**
  50491. * Internal gizmo used for interactions on the z axis
  50492. */
  50493. zGizmo: AxisScaleGizmo;
  50494. /**
  50495. * Internal gizmo used to scale all axis equally
  50496. */
  50497. uniformScaleGizmo: AxisScaleGizmo;
  50498. private _meshAttached;
  50499. private _updateGizmoRotationToMatchAttachedMesh;
  50500. private _snapDistance;
  50501. private _scaleRatio;
  50502. private _uniformScalingMesh;
  50503. private _octahedron;
  50504. private _sensitivity;
  50505. /** Fires an event when any of it's sub gizmos are dragged */
  50506. onDragStartObservable: Observable<unknown>;
  50507. /** Fires an event when any of it's sub gizmos are released from dragging */
  50508. onDragEndObservable: Observable<unknown>;
  50509. get attachedMesh(): Nullable<AbstractMesh>;
  50510. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50511. /**
  50512. * Creates a ScaleGizmo
  50513. * @param gizmoLayer The utility layer the gizmo will be added to
  50514. */
  50515. constructor(gizmoLayer?: UtilityLayerRenderer);
  50516. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50517. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50518. /**
  50519. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50520. */
  50521. set snapDistance(value: number);
  50522. get snapDistance(): number;
  50523. /**
  50524. * Ratio for the scale of the gizmo (Default: 1)
  50525. */
  50526. set scaleRatio(value: number);
  50527. get scaleRatio(): number;
  50528. /**
  50529. * Sensitivity factor for dragging (Default: 1)
  50530. */
  50531. set sensitivity(value: number);
  50532. get sensitivity(): number;
  50533. /**
  50534. * Disposes of the gizmo
  50535. */
  50536. dispose(): void;
  50537. }
  50538. }
  50539. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50540. import { Observable } from "babylonjs/Misc/observable";
  50541. import { Nullable } from "babylonjs/types";
  50542. import { Vector3 } from "babylonjs/Maths/math.vector";
  50543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50544. import { Mesh } from "babylonjs/Meshes/mesh";
  50545. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50547. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50548. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50549. import { Color3 } from "babylonjs/Maths/math.color";
  50550. /**
  50551. * Single axis scale gizmo
  50552. */
  50553. export class AxisScaleGizmo extends Gizmo {
  50554. /**
  50555. * Drag behavior responsible for the gizmos dragging interactions
  50556. */
  50557. dragBehavior: PointerDragBehavior;
  50558. private _pointerObserver;
  50559. /**
  50560. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50561. */
  50562. snapDistance: number;
  50563. /**
  50564. * Event that fires each time the gizmo snaps to a new location.
  50565. * * snapDistance is the the change in distance
  50566. */
  50567. onSnapObservable: Observable<{
  50568. snapDistance: number;
  50569. }>;
  50570. /**
  50571. * If the scaling operation should be done on all axis (default: false)
  50572. */
  50573. uniformScaling: boolean;
  50574. /**
  50575. * Custom sensitivity value for the drag strength
  50576. */
  50577. sensitivity: number;
  50578. private _isEnabled;
  50579. private _parent;
  50580. private _arrow;
  50581. private _coloredMaterial;
  50582. private _hoverMaterial;
  50583. /**
  50584. * Creates an AxisScaleGizmo
  50585. * @param gizmoLayer The utility layer the gizmo will be added to
  50586. * @param dragAxis The axis which the gizmo will be able to scale on
  50587. * @param color The color of the gizmo
  50588. */
  50589. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50590. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50591. /**
  50592. * If the gizmo is enabled
  50593. */
  50594. set isEnabled(value: boolean);
  50595. get isEnabled(): boolean;
  50596. /**
  50597. * Disposes of the gizmo
  50598. */
  50599. dispose(): void;
  50600. /**
  50601. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50602. * @param mesh The mesh to replace the default mesh of the gizmo
  50603. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50604. */
  50605. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50606. }
  50607. }
  50608. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50609. import { Observable } from "babylonjs/Misc/observable";
  50610. import { Nullable } from "babylonjs/types";
  50611. import { Vector3 } from "babylonjs/Maths/math.vector";
  50612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50613. import { Mesh } from "babylonjs/Meshes/mesh";
  50614. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50615. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50616. import { Color3 } from "babylonjs/Maths/math.color";
  50617. import "babylonjs/Meshes/Builders/boxBuilder";
  50618. /**
  50619. * Bounding box gizmo
  50620. */
  50621. export class BoundingBoxGizmo extends Gizmo {
  50622. private _lineBoundingBox;
  50623. private _rotateSpheresParent;
  50624. private _scaleBoxesParent;
  50625. private _boundingDimensions;
  50626. private _renderObserver;
  50627. private _pointerObserver;
  50628. private _scaleDragSpeed;
  50629. private _tmpQuaternion;
  50630. private _tmpVector;
  50631. private _tmpRotationMatrix;
  50632. /**
  50633. * 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)
  50634. */
  50635. ignoreChildren: boolean;
  50636. /**
  50637. * 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)
  50638. */
  50639. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50640. /**
  50641. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50642. */
  50643. rotationSphereSize: number;
  50644. /**
  50645. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50646. */
  50647. scaleBoxSize: number;
  50648. /**
  50649. * 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)
  50650. */
  50651. fixedDragMeshScreenSize: boolean;
  50652. /**
  50653. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50654. */
  50655. fixedDragMeshScreenSizeDistanceFactor: number;
  50656. /**
  50657. * Fired when a rotation sphere or scale box is dragged
  50658. */
  50659. onDragStartObservable: Observable<{}>;
  50660. /**
  50661. * Fired when a scale box is dragged
  50662. */
  50663. onScaleBoxDragObservable: Observable<{}>;
  50664. /**
  50665. * Fired when a scale box drag is ended
  50666. */
  50667. onScaleBoxDragEndObservable: Observable<{}>;
  50668. /**
  50669. * Fired when a rotation sphere is dragged
  50670. */
  50671. onRotationSphereDragObservable: Observable<{}>;
  50672. /**
  50673. * Fired when a rotation sphere drag is ended
  50674. */
  50675. onRotationSphereDragEndObservable: Observable<{}>;
  50676. /**
  50677. * 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)
  50678. */
  50679. scalePivot: Nullable<Vector3>;
  50680. /**
  50681. * Mesh used as a pivot to rotate the attached mesh
  50682. */
  50683. private _anchorMesh;
  50684. private _existingMeshScale;
  50685. private _dragMesh;
  50686. private pointerDragBehavior;
  50687. private coloredMaterial;
  50688. private hoverColoredMaterial;
  50689. /**
  50690. * Sets the color of the bounding box gizmo
  50691. * @param color the color to set
  50692. */
  50693. setColor(color: Color3): void;
  50694. /**
  50695. * Creates an BoundingBoxGizmo
  50696. * @param gizmoLayer The utility layer the gizmo will be added to
  50697. * @param color The color of the gizmo
  50698. */
  50699. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50700. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50701. private _selectNode;
  50702. /**
  50703. * Updates the bounding box information for the Gizmo
  50704. */
  50705. updateBoundingBox(): void;
  50706. private _updateRotationSpheres;
  50707. private _updateScaleBoxes;
  50708. /**
  50709. * Enables rotation on the specified axis and disables rotation on the others
  50710. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50711. */
  50712. setEnabledRotationAxis(axis: string): void;
  50713. /**
  50714. * Enables/disables scaling
  50715. * @param enable if scaling should be enabled
  50716. */
  50717. setEnabledScaling(enable: boolean): void;
  50718. private _updateDummy;
  50719. /**
  50720. * Enables a pointer drag behavior on the bounding box of the gizmo
  50721. */
  50722. enableDragBehavior(): void;
  50723. /**
  50724. * Disposes of the gizmo
  50725. */
  50726. dispose(): void;
  50727. /**
  50728. * 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)
  50729. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50730. * @returns the bounding box mesh with the passed in mesh as a child
  50731. */
  50732. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50733. /**
  50734. * CustomMeshes are not supported by this gizmo
  50735. * @param mesh The mesh to replace the default mesh of the gizmo
  50736. */
  50737. setCustomMesh(mesh: Mesh): void;
  50738. }
  50739. }
  50740. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50741. import { Observable } from "babylonjs/Misc/observable";
  50742. import { Nullable } from "babylonjs/types";
  50743. import { Vector3 } from "babylonjs/Maths/math.vector";
  50744. import { Color3 } from "babylonjs/Maths/math.color";
  50745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50746. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50747. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50748. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50749. import "babylonjs/Meshes/Builders/linesBuilder";
  50750. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50751. /**
  50752. * Single plane rotation gizmo
  50753. */
  50754. export class PlaneRotationGizmo extends Gizmo {
  50755. /**
  50756. * Drag behavior responsible for the gizmos dragging interactions
  50757. */
  50758. dragBehavior: PointerDragBehavior;
  50759. private _pointerObserver;
  50760. /**
  50761. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50762. */
  50763. snapDistance: number;
  50764. /**
  50765. * Event that fires each time the gizmo snaps to a new location.
  50766. * * snapDistance is the the change in distance
  50767. */
  50768. onSnapObservable: Observable<{
  50769. snapDistance: number;
  50770. }>;
  50771. private _isEnabled;
  50772. private _parent;
  50773. /**
  50774. * Creates a PlaneRotationGizmo
  50775. * @param gizmoLayer The utility layer the gizmo will be added to
  50776. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50777. * @param color The color of the gizmo
  50778. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50779. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50780. */
  50781. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50782. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50783. /**
  50784. * If the gizmo is enabled
  50785. */
  50786. set isEnabled(value: boolean);
  50787. get isEnabled(): boolean;
  50788. /**
  50789. * Disposes of the gizmo
  50790. */
  50791. dispose(): void;
  50792. }
  50793. }
  50794. declare module "babylonjs/Gizmos/rotationGizmo" {
  50795. import { Observable } from "babylonjs/Misc/observable";
  50796. import { Nullable } from "babylonjs/types";
  50797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50798. import { Mesh } from "babylonjs/Meshes/mesh";
  50799. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50800. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50801. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50802. /**
  50803. * Gizmo that enables rotating a mesh along 3 axis
  50804. */
  50805. export class RotationGizmo extends Gizmo {
  50806. /**
  50807. * Internal gizmo used for interactions on the x axis
  50808. */
  50809. xGizmo: PlaneRotationGizmo;
  50810. /**
  50811. * Internal gizmo used for interactions on the y axis
  50812. */
  50813. yGizmo: PlaneRotationGizmo;
  50814. /**
  50815. * Internal gizmo used for interactions on the z axis
  50816. */
  50817. zGizmo: PlaneRotationGizmo;
  50818. /** Fires an event when any of it's sub gizmos are dragged */
  50819. onDragStartObservable: Observable<unknown>;
  50820. /** Fires an event when any of it's sub gizmos are released from dragging */
  50821. onDragEndObservable: Observable<unknown>;
  50822. private _meshAttached;
  50823. get attachedMesh(): Nullable<AbstractMesh>;
  50824. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50825. /**
  50826. * Creates a RotationGizmo
  50827. * @param gizmoLayer The utility layer the gizmo will be added to
  50828. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50829. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50830. */
  50831. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50832. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50833. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50834. /**
  50835. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50836. */
  50837. set snapDistance(value: number);
  50838. get snapDistance(): number;
  50839. /**
  50840. * Ratio for the scale of the gizmo (Default: 1)
  50841. */
  50842. set scaleRatio(value: number);
  50843. get scaleRatio(): number;
  50844. /**
  50845. * Disposes of the gizmo
  50846. */
  50847. dispose(): void;
  50848. /**
  50849. * CustomMeshes are not supported by this gizmo
  50850. * @param mesh The mesh to replace the default mesh of the gizmo
  50851. */
  50852. setCustomMesh(mesh: Mesh): void;
  50853. }
  50854. }
  50855. declare module "babylonjs/Gizmos/gizmoManager" {
  50856. import { Observable } from "babylonjs/Misc/observable";
  50857. import { Nullable } from "babylonjs/types";
  50858. import { Scene, IDisposable } from "babylonjs/scene";
  50859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50860. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50861. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50862. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50863. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50864. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50865. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50866. /**
  50867. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50868. */
  50869. export class GizmoManager implements IDisposable {
  50870. private scene;
  50871. /**
  50872. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50873. */
  50874. gizmos: {
  50875. positionGizmo: Nullable<PositionGizmo>;
  50876. rotationGizmo: Nullable<RotationGizmo>;
  50877. scaleGizmo: Nullable<ScaleGizmo>;
  50878. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50879. };
  50880. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50881. clearGizmoOnEmptyPointerEvent: boolean;
  50882. /** Fires an event when the manager is attached to a mesh */
  50883. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50884. private _gizmosEnabled;
  50885. private _pointerObserver;
  50886. private _attachedMesh;
  50887. private _boundingBoxColor;
  50888. private _defaultUtilityLayer;
  50889. private _defaultKeepDepthUtilityLayer;
  50890. /**
  50891. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50892. */
  50893. boundingBoxDragBehavior: SixDofDragBehavior;
  50894. /**
  50895. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50896. */
  50897. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50898. /**
  50899. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50900. */
  50901. usePointerToAttachGizmos: boolean;
  50902. /**
  50903. * Utility layer that the bounding box gizmo belongs to
  50904. */
  50905. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50906. /**
  50907. * Utility layer that all gizmos besides bounding box belong to
  50908. */
  50909. get utilityLayer(): UtilityLayerRenderer;
  50910. /**
  50911. * Instatiates a gizmo manager
  50912. * @param scene the scene to overlay the gizmos on top of
  50913. */
  50914. constructor(scene: Scene);
  50915. /**
  50916. * Attaches a set of gizmos to the specified mesh
  50917. * @param mesh The mesh the gizmo's should be attached to
  50918. */
  50919. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50920. /**
  50921. * If the position gizmo is enabled
  50922. */
  50923. set positionGizmoEnabled(value: boolean);
  50924. get positionGizmoEnabled(): boolean;
  50925. /**
  50926. * If the rotation gizmo is enabled
  50927. */
  50928. set rotationGizmoEnabled(value: boolean);
  50929. get rotationGizmoEnabled(): boolean;
  50930. /**
  50931. * If the scale gizmo is enabled
  50932. */
  50933. set scaleGizmoEnabled(value: boolean);
  50934. get scaleGizmoEnabled(): boolean;
  50935. /**
  50936. * If the boundingBox gizmo is enabled
  50937. */
  50938. set boundingBoxGizmoEnabled(value: boolean);
  50939. get boundingBoxGizmoEnabled(): boolean;
  50940. /**
  50941. * Disposes of the gizmo manager
  50942. */
  50943. dispose(): void;
  50944. }
  50945. }
  50946. declare module "babylonjs/Lights/directionalLight" {
  50947. import { Camera } from "babylonjs/Cameras/camera";
  50948. import { Scene } from "babylonjs/scene";
  50949. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50951. import { Light } from "babylonjs/Lights/light";
  50952. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50953. import { Effect } from "babylonjs/Materials/effect";
  50954. /**
  50955. * A directional light is defined by a direction (what a surprise!).
  50956. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50957. * 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.
  50958. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50959. */
  50960. export class DirectionalLight extends ShadowLight {
  50961. private _shadowFrustumSize;
  50962. /**
  50963. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50964. */
  50965. get shadowFrustumSize(): number;
  50966. /**
  50967. * Specifies a fix frustum size for the shadow generation.
  50968. */
  50969. set shadowFrustumSize(value: number);
  50970. private _shadowOrthoScale;
  50971. /**
  50972. * Gets the shadow projection scale against the optimal computed one.
  50973. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50974. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50975. */
  50976. get shadowOrthoScale(): number;
  50977. /**
  50978. * Sets the shadow projection scale against the optimal computed one.
  50979. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50980. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50981. */
  50982. set shadowOrthoScale(value: number);
  50983. /**
  50984. * Automatically compute the projection matrix to best fit (including all the casters)
  50985. * on each frame.
  50986. */
  50987. autoUpdateExtends: boolean;
  50988. /**
  50989. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50990. * on each frame. autoUpdateExtends must be set to true for this to work
  50991. */
  50992. autoCalcShadowZBounds: boolean;
  50993. private _orthoLeft;
  50994. private _orthoRight;
  50995. private _orthoTop;
  50996. private _orthoBottom;
  50997. /**
  50998. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50999. * The directional light is emitted from everywhere in the given direction.
  51000. * It can cast shadows.
  51001. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51002. * @param name The friendly name of the light
  51003. * @param direction The direction of the light
  51004. * @param scene The scene the light belongs to
  51005. */
  51006. constructor(name: string, direction: Vector3, scene: Scene);
  51007. /**
  51008. * Returns the string "DirectionalLight".
  51009. * @return The class name
  51010. */
  51011. getClassName(): string;
  51012. /**
  51013. * Returns the integer 1.
  51014. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51015. */
  51016. getTypeID(): number;
  51017. /**
  51018. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51019. * Returns the DirectionalLight Shadow projection matrix.
  51020. */
  51021. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51022. /**
  51023. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51024. * Returns the DirectionalLight Shadow projection matrix.
  51025. */
  51026. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51027. /**
  51028. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51029. * Returns the DirectionalLight Shadow projection matrix.
  51030. */
  51031. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51032. protected _buildUniformLayout(): void;
  51033. /**
  51034. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51035. * @param effect The effect to update
  51036. * @param lightIndex The index of the light in the effect to update
  51037. * @returns The directional light
  51038. */
  51039. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51040. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51041. /**
  51042. * Gets the minZ used for shadow according to both the scene and the light.
  51043. *
  51044. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51045. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51046. * @param activeCamera The camera we are returning the min for
  51047. * @returns the depth min z
  51048. */
  51049. getDepthMinZ(activeCamera: Camera): number;
  51050. /**
  51051. * Gets the maxZ used for shadow according to both the scene and the light.
  51052. *
  51053. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51054. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51055. * @param activeCamera The camera we are returning the max for
  51056. * @returns the depth max z
  51057. */
  51058. getDepthMaxZ(activeCamera: Camera): number;
  51059. /**
  51060. * Prepares the list of defines specific to the light type.
  51061. * @param defines the list of defines
  51062. * @param lightIndex defines the index of the light for the effect
  51063. */
  51064. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51065. }
  51066. }
  51067. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51068. import { Mesh } from "babylonjs/Meshes/mesh";
  51069. /**
  51070. * Class containing static functions to help procedurally build meshes
  51071. */
  51072. export class HemisphereBuilder {
  51073. /**
  51074. * Creates a hemisphere mesh
  51075. * @param name defines the name of the mesh
  51076. * @param options defines the options used to create the mesh
  51077. * @param scene defines the hosting scene
  51078. * @returns the hemisphere mesh
  51079. */
  51080. static CreateHemisphere(name: string, options: {
  51081. segments?: number;
  51082. diameter?: number;
  51083. sideOrientation?: number;
  51084. }, scene: any): Mesh;
  51085. }
  51086. }
  51087. declare module "babylonjs/Lights/spotLight" {
  51088. import { Nullable } from "babylonjs/types";
  51089. import { Scene } from "babylonjs/scene";
  51090. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51092. import { Effect } from "babylonjs/Materials/effect";
  51093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51094. import { Light } from "babylonjs/Lights/light";
  51095. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51096. /**
  51097. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51098. * These values define a cone of light starting from the position, emitting toward the direction.
  51099. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51100. * and the exponent defines the speed of the decay of the light with distance (reach).
  51101. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51102. */
  51103. export class SpotLight extends ShadowLight {
  51104. private _angle;
  51105. private _innerAngle;
  51106. private _cosHalfAngle;
  51107. private _lightAngleScale;
  51108. private _lightAngleOffset;
  51109. /**
  51110. * Gets the cone angle of the spot light in Radians.
  51111. */
  51112. get angle(): number;
  51113. /**
  51114. * Sets the cone angle of the spot light in Radians.
  51115. */
  51116. set angle(value: number);
  51117. /**
  51118. * Only used in gltf falloff mode, this defines the angle where
  51119. * the directional falloff will start before cutting at angle which could be seen
  51120. * as outer angle.
  51121. */
  51122. get innerAngle(): number;
  51123. /**
  51124. * Only used in gltf falloff mode, this defines the angle where
  51125. * the directional falloff will start before cutting at angle which could be seen
  51126. * as outer angle.
  51127. */
  51128. set innerAngle(value: number);
  51129. private _shadowAngleScale;
  51130. /**
  51131. * Allows scaling the angle of the light for shadow generation only.
  51132. */
  51133. get shadowAngleScale(): number;
  51134. /**
  51135. * Allows scaling the angle of the light for shadow generation only.
  51136. */
  51137. set shadowAngleScale(value: number);
  51138. /**
  51139. * The light decay speed with the distance from the emission spot.
  51140. */
  51141. exponent: number;
  51142. private _projectionTextureMatrix;
  51143. /**
  51144. * Allows reading the projecton texture
  51145. */
  51146. get projectionTextureMatrix(): Matrix;
  51147. protected _projectionTextureLightNear: number;
  51148. /**
  51149. * Gets the near clip of the Spotlight for texture projection.
  51150. */
  51151. get projectionTextureLightNear(): number;
  51152. /**
  51153. * Sets the near clip of the Spotlight for texture projection.
  51154. */
  51155. set projectionTextureLightNear(value: number);
  51156. protected _projectionTextureLightFar: number;
  51157. /**
  51158. * Gets the far clip of the Spotlight for texture projection.
  51159. */
  51160. get projectionTextureLightFar(): number;
  51161. /**
  51162. * Sets the far clip of the Spotlight for texture projection.
  51163. */
  51164. set projectionTextureLightFar(value: number);
  51165. protected _projectionTextureUpDirection: Vector3;
  51166. /**
  51167. * Gets the Up vector of the Spotlight for texture projection.
  51168. */
  51169. get projectionTextureUpDirection(): Vector3;
  51170. /**
  51171. * Sets the Up vector of the Spotlight for texture projection.
  51172. */
  51173. set projectionTextureUpDirection(value: Vector3);
  51174. private _projectionTexture;
  51175. /**
  51176. * Gets the projection texture of the light.
  51177. */
  51178. get projectionTexture(): Nullable<BaseTexture>;
  51179. /**
  51180. * Sets the projection texture of the light.
  51181. */
  51182. set projectionTexture(value: Nullable<BaseTexture>);
  51183. private _projectionTextureViewLightDirty;
  51184. private _projectionTextureProjectionLightDirty;
  51185. private _projectionTextureDirty;
  51186. private _projectionTextureViewTargetVector;
  51187. private _projectionTextureViewLightMatrix;
  51188. private _projectionTextureProjectionLightMatrix;
  51189. private _projectionTextureScalingMatrix;
  51190. /**
  51191. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51192. * It can cast shadows.
  51193. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51194. * @param name The light friendly name
  51195. * @param position The position of the spot light in the scene
  51196. * @param direction The direction of the light in the scene
  51197. * @param angle The cone angle of the light in Radians
  51198. * @param exponent The light decay speed with the distance from the emission spot
  51199. * @param scene The scene the lights belongs to
  51200. */
  51201. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51202. /**
  51203. * Returns the string "SpotLight".
  51204. * @returns the class name
  51205. */
  51206. getClassName(): string;
  51207. /**
  51208. * Returns the integer 2.
  51209. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51210. */
  51211. getTypeID(): number;
  51212. /**
  51213. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51214. */
  51215. protected _setDirection(value: Vector3): void;
  51216. /**
  51217. * Overrides the position setter to recompute the projection texture view light Matrix.
  51218. */
  51219. protected _setPosition(value: Vector3): void;
  51220. /**
  51221. * 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.
  51222. * Returns the SpotLight.
  51223. */
  51224. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51225. protected _computeProjectionTextureViewLightMatrix(): void;
  51226. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51227. /**
  51228. * Main function for light texture projection matrix computing.
  51229. */
  51230. protected _computeProjectionTextureMatrix(): void;
  51231. protected _buildUniformLayout(): void;
  51232. private _computeAngleValues;
  51233. /**
  51234. * Sets the passed Effect "effect" with the Light textures.
  51235. * @param effect The effect to update
  51236. * @param lightIndex The index of the light in the effect to update
  51237. * @returns The light
  51238. */
  51239. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51240. /**
  51241. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51242. * @param effect The effect to update
  51243. * @param lightIndex The index of the light in the effect to update
  51244. * @returns The spot light
  51245. */
  51246. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51247. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51248. /**
  51249. * Disposes the light and the associated resources.
  51250. */
  51251. dispose(): void;
  51252. /**
  51253. * Prepares the list of defines specific to the light type.
  51254. * @param defines the list of defines
  51255. * @param lightIndex defines the index of the light for the effect
  51256. */
  51257. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51258. }
  51259. }
  51260. declare module "babylonjs/Gizmos/lightGizmo" {
  51261. import { Nullable } from "babylonjs/types";
  51262. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51263. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51264. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51265. import { Light } from "babylonjs/Lights/light";
  51266. /**
  51267. * Gizmo that enables viewing a light
  51268. */
  51269. export class LightGizmo extends Gizmo {
  51270. private _lightMesh;
  51271. private _material;
  51272. private _cachedPosition;
  51273. private _cachedForward;
  51274. private _attachedMeshParent;
  51275. /**
  51276. * Creates a LightGizmo
  51277. * @param gizmoLayer The utility layer the gizmo will be added to
  51278. */
  51279. constructor(gizmoLayer?: UtilityLayerRenderer);
  51280. private _light;
  51281. /**
  51282. * The light that the gizmo is attached to
  51283. */
  51284. set light(light: Nullable<Light>);
  51285. get light(): Nullable<Light>;
  51286. /**
  51287. * Gets the material used to render the light gizmo
  51288. */
  51289. get material(): StandardMaterial;
  51290. /**
  51291. * @hidden
  51292. * Updates the gizmo to match the attached mesh's position/rotation
  51293. */
  51294. protected _update(): void;
  51295. private static _Scale;
  51296. /**
  51297. * Creates the lines for a light mesh
  51298. */
  51299. private static _CreateLightLines;
  51300. /**
  51301. * Disposes of the light gizmo
  51302. */
  51303. dispose(): void;
  51304. private static _CreateHemisphericLightMesh;
  51305. private static _CreatePointLightMesh;
  51306. private static _CreateSpotLightMesh;
  51307. private static _CreateDirectionalLightMesh;
  51308. }
  51309. }
  51310. declare module "babylonjs/Gizmos/index" {
  51311. export * from "babylonjs/Gizmos/axisDragGizmo";
  51312. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51313. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51314. export * from "babylonjs/Gizmos/gizmo";
  51315. export * from "babylonjs/Gizmos/gizmoManager";
  51316. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51317. export * from "babylonjs/Gizmos/positionGizmo";
  51318. export * from "babylonjs/Gizmos/rotationGizmo";
  51319. export * from "babylonjs/Gizmos/scaleGizmo";
  51320. export * from "babylonjs/Gizmos/lightGizmo";
  51321. export * from "babylonjs/Gizmos/planeDragGizmo";
  51322. }
  51323. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51324. /** @hidden */
  51325. export var backgroundFragmentDeclaration: {
  51326. name: string;
  51327. shader: string;
  51328. };
  51329. }
  51330. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51331. /** @hidden */
  51332. export var backgroundUboDeclaration: {
  51333. name: string;
  51334. shader: string;
  51335. };
  51336. }
  51337. declare module "babylonjs/Shaders/background.fragment" {
  51338. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51339. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51340. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51341. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51342. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51343. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51344. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51345. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51346. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51347. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51348. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51349. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51351. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51352. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51353. /** @hidden */
  51354. export var backgroundPixelShader: {
  51355. name: string;
  51356. shader: string;
  51357. };
  51358. }
  51359. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51360. /** @hidden */
  51361. export var backgroundVertexDeclaration: {
  51362. name: string;
  51363. shader: string;
  51364. };
  51365. }
  51366. declare module "babylonjs/Shaders/background.vertex" {
  51367. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51368. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51370. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51371. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51372. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51373. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51374. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51375. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51376. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51377. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51378. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51379. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51380. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51381. /** @hidden */
  51382. export var backgroundVertexShader: {
  51383. name: string;
  51384. shader: string;
  51385. };
  51386. }
  51387. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51388. import { Nullable, int, float } from "babylonjs/types";
  51389. import { Scene } from "babylonjs/scene";
  51390. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51391. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51393. import { Mesh } from "babylonjs/Meshes/mesh";
  51394. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51395. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51396. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51398. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51399. import { Color3 } from "babylonjs/Maths/math.color";
  51400. import "babylonjs/Shaders/background.fragment";
  51401. import "babylonjs/Shaders/background.vertex";
  51402. /**
  51403. * Background material used to create an efficient environement around your scene.
  51404. */
  51405. export class BackgroundMaterial extends PushMaterial {
  51406. /**
  51407. * Standard reflectance value at parallel view angle.
  51408. */
  51409. static StandardReflectance0: number;
  51410. /**
  51411. * Standard reflectance value at grazing angle.
  51412. */
  51413. static StandardReflectance90: number;
  51414. protected _primaryColor: Color3;
  51415. /**
  51416. * Key light Color (multiply against the environement texture)
  51417. */
  51418. primaryColor: Color3;
  51419. protected __perceptualColor: Nullable<Color3>;
  51420. /**
  51421. * Experimental Internal Use Only.
  51422. *
  51423. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51424. * This acts as a helper to set the primary color to a more "human friendly" value.
  51425. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51426. * output color as close as possible from the chosen value.
  51427. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51428. * part of lighting setup.)
  51429. */
  51430. get _perceptualColor(): Nullable<Color3>;
  51431. set _perceptualColor(value: Nullable<Color3>);
  51432. protected _primaryColorShadowLevel: float;
  51433. /**
  51434. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51435. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51436. */
  51437. get primaryColorShadowLevel(): float;
  51438. set primaryColorShadowLevel(value: float);
  51439. protected _primaryColorHighlightLevel: float;
  51440. /**
  51441. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51442. * The primary color is used at the level chosen to define what the white area would look.
  51443. */
  51444. get primaryColorHighlightLevel(): float;
  51445. set primaryColorHighlightLevel(value: float);
  51446. protected _reflectionTexture: Nullable<BaseTexture>;
  51447. /**
  51448. * Reflection Texture used in the material.
  51449. * Should be author in a specific way for the best result (refer to the documentation).
  51450. */
  51451. reflectionTexture: Nullable<BaseTexture>;
  51452. protected _reflectionBlur: float;
  51453. /**
  51454. * Reflection Texture level of blur.
  51455. *
  51456. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51457. * texture twice.
  51458. */
  51459. reflectionBlur: float;
  51460. protected _diffuseTexture: Nullable<BaseTexture>;
  51461. /**
  51462. * Diffuse Texture used in the material.
  51463. * Should be author in a specific way for the best result (refer to the documentation).
  51464. */
  51465. diffuseTexture: Nullable<BaseTexture>;
  51466. protected _shadowLights: Nullable<IShadowLight[]>;
  51467. /**
  51468. * Specify the list of lights casting shadow on the material.
  51469. * All scene shadow lights will be included if null.
  51470. */
  51471. shadowLights: Nullable<IShadowLight[]>;
  51472. protected _shadowLevel: float;
  51473. /**
  51474. * Helps adjusting the shadow to a softer level if required.
  51475. * 0 means black shadows and 1 means no shadows.
  51476. */
  51477. shadowLevel: float;
  51478. protected _sceneCenter: Vector3;
  51479. /**
  51480. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51481. * It is usually zero but might be interesting to modify according to your setup.
  51482. */
  51483. sceneCenter: Vector3;
  51484. protected _opacityFresnel: boolean;
  51485. /**
  51486. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51487. * This helps ensuring a nice transition when the camera goes under the ground.
  51488. */
  51489. opacityFresnel: boolean;
  51490. protected _reflectionFresnel: boolean;
  51491. /**
  51492. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51493. * This helps adding a mirror texture on the ground.
  51494. */
  51495. reflectionFresnel: boolean;
  51496. protected _reflectionFalloffDistance: number;
  51497. /**
  51498. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51499. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51500. */
  51501. reflectionFalloffDistance: number;
  51502. protected _reflectionAmount: number;
  51503. /**
  51504. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51505. */
  51506. reflectionAmount: number;
  51507. protected _reflectionReflectance0: number;
  51508. /**
  51509. * This specifies the weight of the reflection at grazing angle.
  51510. */
  51511. reflectionReflectance0: number;
  51512. protected _reflectionReflectance90: number;
  51513. /**
  51514. * This specifies the weight of the reflection at a perpendicular point of view.
  51515. */
  51516. reflectionReflectance90: number;
  51517. /**
  51518. * Sets the reflection reflectance fresnel values according to the default standard
  51519. * empirically know to work well :-)
  51520. */
  51521. set reflectionStandardFresnelWeight(value: number);
  51522. protected _useRGBColor: boolean;
  51523. /**
  51524. * Helps to directly use the maps channels instead of their level.
  51525. */
  51526. useRGBColor: boolean;
  51527. protected _enableNoise: boolean;
  51528. /**
  51529. * This helps reducing the banding effect that could occur on the background.
  51530. */
  51531. enableNoise: boolean;
  51532. /**
  51533. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51534. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51535. * Recommended to be keep at 1.0 except for special cases.
  51536. */
  51537. get fovMultiplier(): number;
  51538. set fovMultiplier(value: number);
  51539. private _fovMultiplier;
  51540. /**
  51541. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51542. */
  51543. useEquirectangularFOV: boolean;
  51544. private _maxSimultaneousLights;
  51545. /**
  51546. * Number of Simultaneous lights allowed on the material.
  51547. */
  51548. maxSimultaneousLights: int;
  51549. /**
  51550. * Default configuration related to image processing available in the Background Material.
  51551. */
  51552. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51553. /**
  51554. * Keep track of the image processing observer to allow dispose and replace.
  51555. */
  51556. private _imageProcessingObserver;
  51557. /**
  51558. * Attaches a new image processing configuration to the PBR Material.
  51559. * @param configuration (if null the scene configuration will be use)
  51560. */
  51561. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51562. /**
  51563. * Gets the image processing configuration used either in this material.
  51564. */
  51565. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51566. /**
  51567. * Sets the Default image processing configuration used either in the this material.
  51568. *
  51569. * If sets to null, the scene one is in use.
  51570. */
  51571. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51572. /**
  51573. * Gets wether the color curves effect is enabled.
  51574. */
  51575. get cameraColorCurvesEnabled(): boolean;
  51576. /**
  51577. * Sets wether the color curves effect is enabled.
  51578. */
  51579. set cameraColorCurvesEnabled(value: boolean);
  51580. /**
  51581. * Gets wether the color grading effect is enabled.
  51582. */
  51583. get cameraColorGradingEnabled(): boolean;
  51584. /**
  51585. * Gets wether the color grading effect is enabled.
  51586. */
  51587. set cameraColorGradingEnabled(value: boolean);
  51588. /**
  51589. * Gets wether tonemapping is enabled or not.
  51590. */
  51591. get cameraToneMappingEnabled(): boolean;
  51592. /**
  51593. * Sets wether tonemapping is enabled or not
  51594. */
  51595. set cameraToneMappingEnabled(value: boolean);
  51596. /**
  51597. * The camera exposure used on this material.
  51598. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51599. * This corresponds to a photographic exposure.
  51600. */
  51601. get cameraExposure(): float;
  51602. /**
  51603. * The camera exposure used on this material.
  51604. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51605. * This corresponds to a photographic exposure.
  51606. */
  51607. set cameraExposure(value: float);
  51608. /**
  51609. * Gets The camera contrast used on this material.
  51610. */
  51611. get cameraContrast(): float;
  51612. /**
  51613. * Sets The camera contrast used on this material.
  51614. */
  51615. set cameraContrast(value: float);
  51616. /**
  51617. * Gets the Color Grading 2D Lookup Texture.
  51618. */
  51619. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51620. /**
  51621. * Sets the Color Grading 2D Lookup Texture.
  51622. */
  51623. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51624. /**
  51625. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51626. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51627. * 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;
  51628. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51629. */
  51630. get cameraColorCurves(): Nullable<ColorCurves>;
  51631. /**
  51632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51634. * 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;
  51635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51636. */
  51637. set cameraColorCurves(value: Nullable<ColorCurves>);
  51638. /**
  51639. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51640. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51641. */
  51642. switchToBGR: boolean;
  51643. private _renderTargets;
  51644. private _reflectionControls;
  51645. private _white;
  51646. private _primaryShadowColor;
  51647. private _primaryHighlightColor;
  51648. /**
  51649. * Instantiates a Background Material in the given scene
  51650. * @param name The friendly name of the material
  51651. * @param scene The scene to add the material to
  51652. */
  51653. constructor(name: string, scene: Scene);
  51654. /**
  51655. * Gets a boolean indicating that current material needs to register RTT
  51656. */
  51657. get hasRenderTargetTextures(): boolean;
  51658. /**
  51659. * The entire material has been created in order to prevent overdraw.
  51660. * @returns false
  51661. */
  51662. needAlphaTesting(): boolean;
  51663. /**
  51664. * The entire material has been created in order to prevent overdraw.
  51665. * @returns true if blending is enable
  51666. */
  51667. needAlphaBlending(): boolean;
  51668. /**
  51669. * Checks wether the material is ready to be rendered for a given mesh.
  51670. * @param mesh The mesh to render
  51671. * @param subMesh The submesh to check against
  51672. * @param useInstances Specify wether or not the material is used with instances
  51673. * @returns true if all the dependencies are ready (Textures, Effects...)
  51674. */
  51675. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51676. /**
  51677. * Compute the primary color according to the chosen perceptual color.
  51678. */
  51679. private _computePrimaryColorFromPerceptualColor;
  51680. /**
  51681. * Compute the highlights and shadow colors according to their chosen levels.
  51682. */
  51683. private _computePrimaryColors;
  51684. /**
  51685. * Build the uniform buffer used in the material.
  51686. */
  51687. buildUniformLayout(): void;
  51688. /**
  51689. * Unbind the material.
  51690. */
  51691. unbind(): void;
  51692. /**
  51693. * Bind only the world matrix to the material.
  51694. * @param world The world matrix to bind.
  51695. */
  51696. bindOnlyWorldMatrix(world: Matrix): void;
  51697. /**
  51698. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51699. * @param world The world matrix to bind.
  51700. * @param subMesh The submesh to bind for.
  51701. */
  51702. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51703. /**
  51704. * Checks to see if a texture is used in the material.
  51705. * @param texture - Base texture to use.
  51706. * @returns - Boolean specifying if a texture is used in the material.
  51707. */
  51708. hasTexture(texture: BaseTexture): boolean;
  51709. /**
  51710. * Dispose the material.
  51711. * @param forceDisposeEffect Force disposal of the associated effect.
  51712. * @param forceDisposeTextures Force disposal of the associated textures.
  51713. */
  51714. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51715. /**
  51716. * Clones the material.
  51717. * @param name The cloned name.
  51718. * @returns The cloned material.
  51719. */
  51720. clone(name: string): BackgroundMaterial;
  51721. /**
  51722. * Serializes the current material to its JSON representation.
  51723. * @returns The JSON representation.
  51724. */
  51725. serialize(): any;
  51726. /**
  51727. * Gets the class name of the material
  51728. * @returns "BackgroundMaterial"
  51729. */
  51730. getClassName(): string;
  51731. /**
  51732. * Parse a JSON input to create back a background material.
  51733. * @param source The JSON data to parse
  51734. * @param scene The scene to create the parsed material in
  51735. * @param rootUrl The root url of the assets the material depends upon
  51736. * @returns the instantiated BackgroundMaterial.
  51737. */
  51738. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51739. }
  51740. }
  51741. declare module "babylonjs/Helpers/environmentHelper" {
  51742. import { Observable } from "babylonjs/Misc/observable";
  51743. import { Nullable } from "babylonjs/types";
  51744. import { Scene } from "babylonjs/scene";
  51745. import { Vector3 } from "babylonjs/Maths/math.vector";
  51746. import { Color3 } from "babylonjs/Maths/math.color";
  51747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51748. import { Mesh } from "babylonjs/Meshes/mesh";
  51749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51750. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51751. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51752. import "babylonjs/Meshes/Builders/planeBuilder";
  51753. import "babylonjs/Meshes/Builders/boxBuilder";
  51754. /**
  51755. * Represents the different options available during the creation of
  51756. * a Environment helper.
  51757. *
  51758. * This can control the default ground, skybox and image processing setup of your scene.
  51759. */
  51760. export interface IEnvironmentHelperOptions {
  51761. /**
  51762. * Specifies whether or not to create a ground.
  51763. * True by default.
  51764. */
  51765. createGround: boolean;
  51766. /**
  51767. * Specifies the ground size.
  51768. * 15 by default.
  51769. */
  51770. groundSize: number;
  51771. /**
  51772. * The texture used on the ground for the main color.
  51773. * Comes from the BabylonJS CDN by default.
  51774. *
  51775. * Remarks: Can be either a texture or a url.
  51776. */
  51777. groundTexture: string | BaseTexture;
  51778. /**
  51779. * The color mixed in the ground texture by default.
  51780. * BabylonJS clearColor by default.
  51781. */
  51782. groundColor: Color3;
  51783. /**
  51784. * Specifies the ground opacity.
  51785. * 1 by default.
  51786. */
  51787. groundOpacity: number;
  51788. /**
  51789. * Enables the ground to receive shadows.
  51790. * True by default.
  51791. */
  51792. enableGroundShadow: boolean;
  51793. /**
  51794. * Helps preventing the shadow to be fully black on the ground.
  51795. * 0.5 by default.
  51796. */
  51797. groundShadowLevel: number;
  51798. /**
  51799. * Creates a mirror texture attach to the ground.
  51800. * false by default.
  51801. */
  51802. enableGroundMirror: boolean;
  51803. /**
  51804. * Specifies the ground mirror size ratio.
  51805. * 0.3 by default as the default kernel is 64.
  51806. */
  51807. groundMirrorSizeRatio: number;
  51808. /**
  51809. * Specifies the ground mirror blur kernel size.
  51810. * 64 by default.
  51811. */
  51812. groundMirrorBlurKernel: number;
  51813. /**
  51814. * Specifies the ground mirror visibility amount.
  51815. * 1 by default
  51816. */
  51817. groundMirrorAmount: number;
  51818. /**
  51819. * Specifies the ground mirror reflectance weight.
  51820. * This uses the standard weight of the background material to setup the fresnel effect
  51821. * of the mirror.
  51822. * 1 by default.
  51823. */
  51824. groundMirrorFresnelWeight: number;
  51825. /**
  51826. * Specifies the ground mirror Falloff distance.
  51827. * This can helps reducing the size of the reflection.
  51828. * 0 by Default.
  51829. */
  51830. groundMirrorFallOffDistance: number;
  51831. /**
  51832. * Specifies the ground mirror texture type.
  51833. * Unsigned Int by Default.
  51834. */
  51835. groundMirrorTextureType: number;
  51836. /**
  51837. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51838. * the shown objects.
  51839. */
  51840. groundYBias: number;
  51841. /**
  51842. * Specifies whether or not to create a skybox.
  51843. * True by default.
  51844. */
  51845. createSkybox: boolean;
  51846. /**
  51847. * Specifies the skybox size.
  51848. * 20 by default.
  51849. */
  51850. skyboxSize: number;
  51851. /**
  51852. * The texture used on the skybox for the main color.
  51853. * Comes from the BabylonJS CDN by default.
  51854. *
  51855. * Remarks: Can be either a texture or a url.
  51856. */
  51857. skyboxTexture: string | BaseTexture;
  51858. /**
  51859. * The color mixed in the skybox texture by default.
  51860. * BabylonJS clearColor by default.
  51861. */
  51862. skyboxColor: Color3;
  51863. /**
  51864. * The background rotation around the Y axis of the scene.
  51865. * This helps aligning the key lights of your scene with the background.
  51866. * 0 by default.
  51867. */
  51868. backgroundYRotation: number;
  51869. /**
  51870. * Compute automatically the size of the elements to best fit with the scene.
  51871. */
  51872. sizeAuto: boolean;
  51873. /**
  51874. * Default position of the rootMesh if autoSize is not true.
  51875. */
  51876. rootPosition: Vector3;
  51877. /**
  51878. * Sets up the image processing in the scene.
  51879. * true by default.
  51880. */
  51881. setupImageProcessing: boolean;
  51882. /**
  51883. * The texture used as your environment texture in the scene.
  51884. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51885. *
  51886. * Remarks: Can be either a texture or a url.
  51887. */
  51888. environmentTexture: string | BaseTexture;
  51889. /**
  51890. * The value of the exposure to apply to the scene.
  51891. * 0.6 by default if setupImageProcessing is true.
  51892. */
  51893. cameraExposure: number;
  51894. /**
  51895. * The value of the contrast to apply to the scene.
  51896. * 1.6 by default if setupImageProcessing is true.
  51897. */
  51898. cameraContrast: number;
  51899. /**
  51900. * Specifies whether or not tonemapping should be enabled in the scene.
  51901. * true by default if setupImageProcessing is true.
  51902. */
  51903. toneMappingEnabled: boolean;
  51904. }
  51905. /**
  51906. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51907. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51908. * It also helps with the default setup of your imageProcessing configuration.
  51909. */
  51910. export class EnvironmentHelper {
  51911. /**
  51912. * Default ground texture URL.
  51913. */
  51914. private static _groundTextureCDNUrl;
  51915. /**
  51916. * Default skybox texture URL.
  51917. */
  51918. private static _skyboxTextureCDNUrl;
  51919. /**
  51920. * Default environment texture URL.
  51921. */
  51922. private static _environmentTextureCDNUrl;
  51923. /**
  51924. * Creates the default options for the helper.
  51925. */
  51926. private static _getDefaultOptions;
  51927. private _rootMesh;
  51928. /**
  51929. * Gets the root mesh created by the helper.
  51930. */
  51931. get rootMesh(): Mesh;
  51932. private _skybox;
  51933. /**
  51934. * Gets the skybox created by the helper.
  51935. */
  51936. get skybox(): Nullable<Mesh>;
  51937. private _skyboxTexture;
  51938. /**
  51939. * Gets the skybox texture created by the helper.
  51940. */
  51941. get skyboxTexture(): Nullable<BaseTexture>;
  51942. private _skyboxMaterial;
  51943. /**
  51944. * Gets the skybox material created by the helper.
  51945. */
  51946. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51947. private _ground;
  51948. /**
  51949. * Gets the ground mesh created by the helper.
  51950. */
  51951. get ground(): Nullable<Mesh>;
  51952. private _groundTexture;
  51953. /**
  51954. * Gets the ground texture created by the helper.
  51955. */
  51956. get groundTexture(): Nullable<BaseTexture>;
  51957. private _groundMirror;
  51958. /**
  51959. * Gets the ground mirror created by the helper.
  51960. */
  51961. get groundMirror(): Nullable<MirrorTexture>;
  51962. /**
  51963. * Gets the ground mirror render list to helps pushing the meshes
  51964. * you wish in the ground reflection.
  51965. */
  51966. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51967. private _groundMaterial;
  51968. /**
  51969. * Gets the ground material created by the helper.
  51970. */
  51971. get groundMaterial(): Nullable<BackgroundMaterial>;
  51972. /**
  51973. * Stores the creation options.
  51974. */
  51975. private readonly _scene;
  51976. private _options;
  51977. /**
  51978. * This observable will be notified with any error during the creation of the environment,
  51979. * mainly texture creation errors.
  51980. */
  51981. onErrorObservable: Observable<{
  51982. message?: string;
  51983. exception?: any;
  51984. }>;
  51985. /**
  51986. * constructor
  51987. * @param options Defines the options we want to customize the helper
  51988. * @param scene The scene to add the material to
  51989. */
  51990. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51991. /**
  51992. * Updates the background according to the new options
  51993. * @param options
  51994. */
  51995. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51996. /**
  51997. * Sets the primary color of all the available elements.
  51998. * @param color the main color to affect to the ground and the background
  51999. */
  52000. setMainColor(color: Color3): void;
  52001. /**
  52002. * Setup the image processing according to the specified options.
  52003. */
  52004. private _setupImageProcessing;
  52005. /**
  52006. * Setup the environment texture according to the specified options.
  52007. */
  52008. private _setupEnvironmentTexture;
  52009. /**
  52010. * Setup the background according to the specified options.
  52011. */
  52012. private _setupBackground;
  52013. /**
  52014. * Get the scene sizes according to the setup.
  52015. */
  52016. private _getSceneSize;
  52017. /**
  52018. * Setup the ground according to the specified options.
  52019. */
  52020. private _setupGround;
  52021. /**
  52022. * Setup the ground material according to the specified options.
  52023. */
  52024. private _setupGroundMaterial;
  52025. /**
  52026. * Setup the ground diffuse texture according to the specified options.
  52027. */
  52028. private _setupGroundDiffuseTexture;
  52029. /**
  52030. * Setup the ground mirror texture according to the specified options.
  52031. */
  52032. private _setupGroundMirrorTexture;
  52033. /**
  52034. * Setup the ground to receive the mirror texture.
  52035. */
  52036. private _setupMirrorInGroundMaterial;
  52037. /**
  52038. * Setup the skybox according to the specified options.
  52039. */
  52040. private _setupSkybox;
  52041. /**
  52042. * Setup the skybox material according to the specified options.
  52043. */
  52044. private _setupSkyboxMaterial;
  52045. /**
  52046. * Setup the skybox reflection texture according to the specified options.
  52047. */
  52048. private _setupSkyboxReflectionTexture;
  52049. private _errorHandler;
  52050. /**
  52051. * Dispose all the elements created by the Helper.
  52052. */
  52053. dispose(): void;
  52054. }
  52055. }
  52056. declare module "babylonjs/Helpers/photoDome" {
  52057. import { Observable } from "babylonjs/Misc/observable";
  52058. import { Nullable } from "babylonjs/types";
  52059. import { Scene } from "babylonjs/scene";
  52060. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52061. import { Mesh } from "babylonjs/Meshes/mesh";
  52062. import { Texture } from "babylonjs/Materials/Textures/texture";
  52063. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52064. import "babylonjs/Meshes/Builders/sphereBuilder";
  52065. /**
  52066. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52067. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52068. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52069. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52070. */
  52071. export class PhotoDome extends TransformNode {
  52072. /**
  52073. * Define the image as a Monoscopic panoramic 360 image.
  52074. */
  52075. static readonly MODE_MONOSCOPIC: number;
  52076. /**
  52077. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52078. */
  52079. static readonly MODE_TOPBOTTOM: number;
  52080. /**
  52081. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52082. */
  52083. static readonly MODE_SIDEBYSIDE: number;
  52084. private _useDirectMapping;
  52085. /**
  52086. * The texture being displayed on the sphere
  52087. */
  52088. protected _photoTexture: Texture;
  52089. /**
  52090. * Gets or sets the texture being displayed on the sphere
  52091. */
  52092. get photoTexture(): Texture;
  52093. set photoTexture(value: Texture);
  52094. /**
  52095. * Observable raised when an error occured while loading the 360 image
  52096. */
  52097. onLoadErrorObservable: Observable<string>;
  52098. /**
  52099. * The skybox material
  52100. */
  52101. protected _material: BackgroundMaterial;
  52102. /**
  52103. * The surface used for the skybox
  52104. */
  52105. protected _mesh: Mesh;
  52106. /**
  52107. * Gets the mesh used for the skybox.
  52108. */
  52109. get mesh(): Mesh;
  52110. /**
  52111. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52112. * Also see the options.resolution property.
  52113. */
  52114. get fovMultiplier(): number;
  52115. set fovMultiplier(value: number);
  52116. private _imageMode;
  52117. /**
  52118. * Gets or set the current video mode for the video. It can be:
  52119. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52120. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52121. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52122. */
  52123. get imageMode(): number;
  52124. set imageMode(value: number);
  52125. /**
  52126. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52127. * @param name Element's name, child elements will append suffixes for their own names.
  52128. * @param urlsOfPhoto defines the url of the photo to display
  52129. * @param options defines an object containing optional or exposed sub element properties
  52130. * @param onError defines a callback called when an error occured while loading the texture
  52131. */
  52132. constructor(name: string, urlOfPhoto: string, options: {
  52133. resolution?: number;
  52134. size?: number;
  52135. useDirectMapping?: boolean;
  52136. faceForward?: boolean;
  52137. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52138. private _onBeforeCameraRenderObserver;
  52139. private _changeImageMode;
  52140. /**
  52141. * Releases resources associated with this node.
  52142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52144. */
  52145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52146. }
  52147. }
  52148. declare module "babylonjs/Misc/rgbdTextureTools" {
  52149. import "babylonjs/Shaders/rgbdDecode.fragment";
  52150. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52151. import { Texture } from "babylonjs/Materials/Textures/texture";
  52152. /**
  52153. * Class used to host RGBD texture specific utilities
  52154. */
  52155. export class RGBDTextureTools {
  52156. /**
  52157. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52158. * @param texture the texture to expand.
  52159. */
  52160. static ExpandRGBDTexture(texture: Texture): void;
  52161. }
  52162. }
  52163. declare module "babylonjs/Misc/brdfTextureTools" {
  52164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52165. import { Scene } from "babylonjs/scene";
  52166. /**
  52167. * Class used to host texture specific utilities
  52168. */
  52169. export class BRDFTextureTools {
  52170. /**
  52171. * Prevents texture cache collision
  52172. */
  52173. private static _instanceNumber;
  52174. /**
  52175. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52176. * @param scene defines the hosting scene
  52177. * @returns the environment BRDF texture
  52178. */
  52179. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52180. private static _environmentBRDFBase64Texture;
  52181. }
  52182. }
  52183. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52184. import { Nullable } from "babylonjs/types";
  52185. import { Color3 } from "babylonjs/Maths/math.color";
  52186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52187. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52188. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52189. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52190. import { Engine } from "babylonjs/Engines/engine";
  52191. import { Scene } from "babylonjs/scene";
  52192. /**
  52193. * @hidden
  52194. */
  52195. export interface IMaterialClearCoatDefines {
  52196. CLEARCOAT: boolean;
  52197. CLEARCOAT_DEFAULTIOR: boolean;
  52198. CLEARCOAT_TEXTURE: boolean;
  52199. CLEARCOAT_TEXTUREDIRECTUV: number;
  52200. CLEARCOAT_BUMP: boolean;
  52201. CLEARCOAT_BUMPDIRECTUV: number;
  52202. CLEARCOAT_TINT: boolean;
  52203. CLEARCOAT_TINT_TEXTURE: boolean;
  52204. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52205. /** @hidden */
  52206. _areTexturesDirty: boolean;
  52207. }
  52208. /**
  52209. * Define the code related to the clear coat parameters of the pbr material.
  52210. */
  52211. export class PBRClearCoatConfiguration {
  52212. /**
  52213. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52214. * The default fits with a polyurethane material.
  52215. */
  52216. private static readonly _DefaultIndexOfRefraction;
  52217. private _isEnabled;
  52218. /**
  52219. * Defines if the clear coat is enabled in the material.
  52220. */
  52221. isEnabled: boolean;
  52222. /**
  52223. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52224. */
  52225. intensity: number;
  52226. /**
  52227. * Defines the clear coat layer roughness.
  52228. */
  52229. roughness: number;
  52230. private _indexOfRefraction;
  52231. /**
  52232. * Defines the index of refraction of the clear coat.
  52233. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52234. * The default fits with a polyurethane material.
  52235. * Changing the default value is more performance intensive.
  52236. */
  52237. indexOfRefraction: number;
  52238. private _texture;
  52239. /**
  52240. * Stores the clear coat values in a texture.
  52241. */
  52242. texture: Nullable<BaseTexture>;
  52243. private _bumpTexture;
  52244. /**
  52245. * Define the clear coat specific bump texture.
  52246. */
  52247. bumpTexture: Nullable<BaseTexture>;
  52248. private _isTintEnabled;
  52249. /**
  52250. * Defines if the clear coat tint is enabled in the material.
  52251. */
  52252. isTintEnabled: boolean;
  52253. /**
  52254. * Defines the clear coat tint of the material.
  52255. * This is only use if tint is enabled
  52256. */
  52257. tintColor: Color3;
  52258. /**
  52259. * Defines the distance at which the tint color should be found in the
  52260. * clear coat media.
  52261. * This is only use if tint is enabled
  52262. */
  52263. tintColorAtDistance: number;
  52264. /**
  52265. * Defines the clear coat layer thickness.
  52266. * This is only use if tint is enabled
  52267. */
  52268. tintThickness: number;
  52269. private _tintTexture;
  52270. /**
  52271. * Stores the clear tint values in a texture.
  52272. * rgb is tint
  52273. * a is a thickness factor
  52274. */
  52275. tintTexture: Nullable<BaseTexture>;
  52276. /** @hidden */
  52277. private _internalMarkAllSubMeshesAsTexturesDirty;
  52278. /** @hidden */
  52279. _markAllSubMeshesAsTexturesDirty(): void;
  52280. /**
  52281. * Instantiate a new istance of clear coat configuration.
  52282. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52283. */
  52284. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52285. /**
  52286. * Gets wehter the submesh is ready to be used or not.
  52287. * @param defines the list of "defines" to update.
  52288. * @param scene defines the scene the material belongs to.
  52289. * @param engine defines the engine the material belongs to.
  52290. * @param disableBumpMap defines wether the material disables bump or not.
  52291. * @returns - boolean indicating that the submesh is ready or not.
  52292. */
  52293. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52294. /**
  52295. * Checks to see if a texture is used in the material.
  52296. * @param defines the list of "defines" to update.
  52297. * @param scene defines the scene to the material belongs to.
  52298. */
  52299. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52300. /**
  52301. * Binds the material data.
  52302. * @param uniformBuffer defines the Uniform buffer to fill in.
  52303. * @param scene defines the scene the material belongs to.
  52304. * @param engine defines the engine the material belongs to.
  52305. * @param disableBumpMap defines wether the material disables bump or not.
  52306. * @param isFrozen defines wether the material is frozen or not.
  52307. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52308. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52309. */
  52310. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52311. /**
  52312. * Checks to see if a texture is used in the material.
  52313. * @param texture - Base texture to use.
  52314. * @returns - Boolean specifying if a texture is used in the material.
  52315. */
  52316. hasTexture(texture: BaseTexture): boolean;
  52317. /**
  52318. * Returns an array of the actively used textures.
  52319. * @param activeTextures Array of BaseTextures
  52320. */
  52321. getActiveTextures(activeTextures: BaseTexture[]): void;
  52322. /**
  52323. * Returns the animatable textures.
  52324. * @param animatables Array of animatable textures.
  52325. */
  52326. getAnimatables(animatables: IAnimatable[]): void;
  52327. /**
  52328. * Disposes the resources of the material.
  52329. * @param forceDisposeTextures - Forces the disposal of all textures.
  52330. */
  52331. dispose(forceDisposeTextures?: boolean): void;
  52332. /**
  52333. * Get the current class name of the texture useful for serialization or dynamic coding.
  52334. * @returns "PBRClearCoatConfiguration"
  52335. */
  52336. getClassName(): string;
  52337. /**
  52338. * Add fallbacks to the effect fallbacks list.
  52339. * @param defines defines the Base texture to use.
  52340. * @param fallbacks defines the current fallback list.
  52341. * @param currentRank defines the current fallback rank.
  52342. * @returns the new fallback rank.
  52343. */
  52344. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52345. /**
  52346. * Add the required uniforms to the current list.
  52347. * @param uniforms defines the current uniform list.
  52348. */
  52349. static AddUniforms(uniforms: string[]): void;
  52350. /**
  52351. * Add the required samplers to the current list.
  52352. * @param samplers defines the current sampler list.
  52353. */
  52354. static AddSamplers(samplers: string[]): void;
  52355. /**
  52356. * Add the required uniforms to the current buffer.
  52357. * @param uniformBuffer defines the current uniform buffer.
  52358. */
  52359. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52360. /**
  52361. * Makes a duplicate of the current configuration into another one.
  52362. * @param clearCoatConfiguration define the config where to copy the info
  52363. */
  52364. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52365. /**
  52366. * Serializes this clear coat configuration.
  52367. * @returns - An object with the serialized config.
  52368. */
  52369. serialize(): any;
  52370. /**
  52371. * Parses a anisotropy Configuration from a serialized object.
  52372. * @param source - Serialized object.
  52373. * @param scene Defines the scene we are parsing for
  52374. * @param rootUrl Defines the rootUrl to load from
  52375. */
  52376. parse(source: any, scene: Scene, rootUrl: string): void;
  52377. }
  52378. }
  52379. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52380. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52382. import { Vector2 } from "babylonjs/Maths/math.vector";
  52383. import { Scene } from "babylonjs/scene";
  52384. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52385. import { Nullable } from "babylonjs/types";
  52386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52387. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52388. /**
  52389. * @hidden
  52390. */
  52391. export interface IMaterialAnisotropicDefines {
  52392. ANISOTROPIC: boolean;
  52393. ANISOTROPIC_TEXTURE: boolean;
  52394. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52395. MAINUV1: boolean;
  52396. _areTexturesDirty: boolean;
  52397. _needUVs: boolean;
  52398. }
  52399. /**
  52400. * Define the code related to the anisotropic parameters of the pbr material.
  52401. */
  52402. export class PBRAnisotropicConfiguration {
  52403. private _isEnabled;
  52404. /**
  52405. * Defines if the anisotropy is enabled in the material.
  52406. */
  52407. isEnabled: boolean;
  52408. /**
  52409. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52410. */
  52411. intensity: number;
  52412. /**
  52413. * Defines if the effect is along the tangents, bitangents or in between.
  52414. * By default, the effect is "strectching" the highlights along the tangents.
  52415. */
  52416. direction: Vector2;
  52417. private _texture;
  52418. /**
  52419. * Stores the anisotropy values in a texture.
  52420. * rg is direction (like normal from -1 to 1)
  52421. * b is a intensity
  52422. */
  52423. texture: Nullable<BaseTexture>;
  52424. /** @hidden */
  52425. private _internalMarkAllSubMeshesAsTexturesDirty;
  52426. /** @hidden */
  52427. _markAllSubMeshesAsTexturesDirty(): void;
  52428. /**
  52429. * Instantiate a new istance of anisotropy configuration.
  52430. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52431. */
  52432. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52433. /**
  52434. * Specifies that the submesh is ready to be used.
  52435. * @param defines the list of "defines" to update.
  52436. * @param scene defines the scene the material belongs to.
  52437. * @returns - boolean indicating that the submesh is ready or not.
  52438. */
  52439. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52440. /**
  52441. * Checks to see if a texture is used in the material.
  52442. * @param defines the list of "defines" to update.
  52443. * @param mesh the mesh we are preparing the defines for.
  52444. * @param scene defines the scene the material belongs to.
  52445. */
  52446. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52447. /**
  52448. * Binds the material data.
  52449. * @param uniformBuffer defines the Uniform buffer to fill in.
  52450. * @param scene defines the scene the material belongs to.
  52451. * @param isFrozen defines wether the material is frozen or not.
  52452. */
  52453. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52454. /**
  52455. * Checks to see if a texture is used in the material.
  52456. * @param texture - Base texture to use.
  52457. * @returns - Boolean specifying if a texture is used in the material.
  52458. */
  52459. hasTexture(texture: BaseTexture): boolean;
  52460. /**
  52461. * Returns an array of the actively used textures.
  52462. * @param activeTextures Array of BaseTextures
  52463. */
  52464. getActiveTextures(activeTextures: BaseTexture[]): void;
  52465. /**
  52466. * Returns the animatable textures.
  52467. * @param animatables Array of animatable textures.
  52468. */
  52469. getAnimatables(animatables: IAnimatable[]): void;
  52470. /**
  52471. * Disposes the resources of the material.
  52472. * @param forceDisposeTextures - Forces the disposal of all textures.
  52473. */
  52474. dispose(forceDisposeTextures?: boolean): void;
  52475. /**
  52476. * Get the current class name of the texture useful for serialization or dynamic coding.
  52477. * @returns "PBRAnisotropicConfiguration"
  52478. */
  52479. getClassName(): string;
  52480. /**
  52481. * Add fallbacks to the effect fallbacks list.
  52482. * @param defines defines the Base texture to use.
  52483. * @param fallbacks defines the current fallback list.
  52484. * @param currentRank defines the current fallback rank.
  52485. * @returns the new fallback rank.
  52486. */
  52487. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52488. /**
  52489. * Add the required uniforms to the current list.
  52490. * @param uniforms defines the current uniform list.
  52491. */
  52492. static AddUniforms(uniforms: string[]): void;
  52493. /**
  52494. * Add the required uniforms to the current buffer.
  52495. * @param uniformBuffer defines the current uniform buffer.
  52496. */
  52497. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52498. /**
  52499. * Add the required samplers to the current list.
  52500. * @param samplers defines the current sampler list.
  52501. */
  52502. static AddSamplers(samplers: string[]): void;
  52503. /**
  52504. * Makes a duplicate of the current configuration into another one.
  52505. * @param anisotropicConfiguration define the config where to copy the info
  52506. */
  52507. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52508. /**
  52509. * Serializes this anisotropy configuration.
  52510. * @returns - An object with the serialized config.
  52511. */
  52512. serialize(): any;
  52513. /**
  52514. * Parses a anisotropy Configuration from a serialized object.
  52515. * @param source - Serialized object.
  52516. * @param scene Defines the scene we are parsing for
  52517. * @param rootUrl Defines the rootUrl to load from
  52518. */
  52519. parse(source: any, scene: Scene, rootUrl: string): void;
  52520. }
  52521. }
  52522. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52523. import { Scene } from "babylonjs/scene";
  52524. /**
  52525. * @hidden
  52526. */
  52527. export interface IMaterialBRDFDefines {
  52528. BRDF_V_HEIGHT_CORRELATED: boolean;
  52529. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52530. SPHERICAL_HARMONICS: boolean;
  52531. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52532. /** @hidden */
  52533. _areMiscDirty: boolean;
  52534. }
  52535. /**
  52536. * Define the code related to the BRDF parameters of the pbr material.
  52537. */
  52538. export class PBRBRDFConfiguration {
  52539. /**
  52540. * Default value used for the energy conservation.
  52541. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52542. */
  52543. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52544. /**
  52545. * Default value used for the Smith Visibility Height Correlated mode.
  52546. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52547. */
  52548. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52549. /**
  52550. * Default value used for the IBL diffuse part.
  52551. * This can help switching back to the polynomials mode globally which is a tiny bit
  52552. * less GPU intensive at the drawback of a lower quality.
  52553. */
  52554. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52555. /**
  52556. * Default value used for activating energy conservation for the specular workflow.
  52557. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52558. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52559. */
  52560. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52561. private _useEnergyConservation;
  52562. /**
  52563. * Defines if the material uses energy conservation.
  52564. */
  52565. useEnergyConservation: boolean;
  52566. private _useSmithVisibilityHeightCorrelated;
  52567. /**
  52568. * LEGACY Mode set to false
  52569. * Defines if the material uses height smith correlated visibility term.
  52570. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52571. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52572. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52573. * Not relying on height correlated will also disable energy conservation.
  52574. */
  52575. useSmithVisibilityHeightCorrelated: boolean;
  52576. private _useSphericalHarmonics;
  52577. /**
  52578. * LEGACY Mode set to false
  52579. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52580. * diffuse part of the IBL.
  52581. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52582. * to the ground truth.
  52583. */
  52584. useSphericalHarmonics: boolean;
  52585. private _useSpecularGlossinessInputEnergyConservation;
  52586. /**
  52587. * Defines if the material uses energy conservation, when the specular workflow is active.
  52588. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52589. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52590. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52591. */
  52592. useSpecularGlossinessInputEnergyConservation: boolean;
  52593. /** @hidden */
  52594. private _internalMarkAllSubMeshesAsMiscDirty;
  52595. /** @hidden */
  52596. _markAllSubMeshesAsMiscDirty(): void;
  52597. /**
  52598. * Instantiate a new istance of clear coat configuration.
  52599. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52600. */
  52601. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52602. /**
  52603. * Checks to see if a texture is used in the material.
  52604. * @param defines the list of "defines" to update.
  52605. */
  52606. prepareDefines(defines: IMaterialBRDFDefines): void;
  52607. /**
  52608. * Get the current class name of the texture useful for serialization or dynamic coding.
  52609. * @returns "PBRClearCoatConfiguration"
  52610. */
  52611. getClassName(): string;
  52612. /**
  52613. * Makes a duplicate of the current configuration into another one.
  52614. * @param brdfConfiguration define the config where to copy the info
  52615. */
  52616. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52617. /**
  52618. * Serializes this BRDF configuration.
  52619. * @returns - An object with the serialized config.
  52620. */
  52621. serialize(): any;
  52622. /**
  52623. * Parses a anisotropy Configuration from a serialized object.
  52624. * @param source - Serialized object.
  52625. * @param scene Defines the scene we are parsing for
  52626. * @param rootUrl Defines the rootUrl to load from
  52627. */
  52628. parse(source: any, scene: Scene, rootUrl: string): void;
  52629. }
  52630. }
  52631. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52632. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52633. import { Color3 } from "babylonjs/Maths/math.color";
  52634. import { Scene } from "babylonjs/scene";
  52635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52636. import { Nullable } from "babylonjs/types";
  52637. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52638. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52639. /**
  52640. * @hidden
  52641. */
  52642. export interface IMaterialSheenDefines {
  52643. SHEEN: boolean;
  52644. SHEEN_TEXTURE: boolean;
  52645. SHEEN_TEXTUREDIRECTUV: number;
  52646. SHEEN_LINKWITHALBEDO: boolean;
  52647. SHEEN_ROUGHNESS: boolean;
  52648. SHEEN_ALBEDOSCALING: boolean;
  52649. /** @hidden */
  52650. _areTexturesDirty: boolean;
  52651. }
  52652. /**
  52653. * Define the code related to the Sheen parameters of the pbr material.
  52654. */
  52655. export class PBRSheenConfiguration {
  52656. private _isEnabled;
  52657. /**
  52658. * Defines if the material uses sheen.
  52659. */
  52660. isEnabled: boolean;
  52661. private _linkSheenWithAlbedo;
  52662. /**
  52663. * Defines if the sheen is linked to the sheen color.
  52664. */
  52665. linkSheenWithAlbedo: boolean;
  52666. /**
  52667. * Defines the sheen intensity.
  52668. */
  52669. intensity: number;
  52670. /**
  52671. * Defines the sheen color.
  52672. */
  52673. color: Color3;
  52674. private _texture;
  52675. /**
  52676. * Stores the sheen tint values in a texture.
  52677. * rgb is tint
  52678. * a is a intensity
  52679. */
  52680. texture: Nullable<BaseTexture>;
  52681. private _roughness;
  52682. /**
  52683. * Defines the sheen roughness.
  52684. * It is not taken into account if linkSheenWithAlbedo is true.
  52685. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52686. */
  52687. roughness: Nullable<number>;
  52688. private _albedoScaling;
  52689. /**
  52690. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52691. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52692. * making it easier to setup and tweak the effect
  52693. */
  52694. albedoScaling: boolean;
  52695. /** @hidden */
  52696. private _internalMarkAllSubMeshesAsTexturesDirty;
  52697. /** @hidden */
  52698. _markAllSubMeshesAsTexturesDirty(): void;
  52699. /**
  52700. * Instantiate a new istance of clear coat configuration.
  52701. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52702. */
  52703. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52704. /**
  52705. * Specifies that the submesh is ready to be used.
  52706. * @param defines the list of "defines" to update.
  52707. * @param scene defines the scene the material belongs to.
  52708. * @returns - boolean indicating that the submesh is ready or not.
  52709. */
  52710. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52711. /**
  52712. * Checks to see if a texture is used in the material.
  52713. * @param defines the list of "defines" to update.
  52714. * @param scene defines the scene the material belongs to.
  52715. */
  52716. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52717. /**
  52718. * Binds the material data.
  52719. * @param uniformBuffer defines the Uniform buffer to fill in.
  52720. * @param scene defines the scene the material belongs to.
  52721. * @param isFrozen defines wether the material is frozen or not.
  52722. */
  52723. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52724. /**
  52725. * Checks to see if a texture is used in the material.
  52726. * @param texture - Base texture to use.
  52727. * @returns - Boolean specifying if a texture is used in the material.
  52728. */
  52729. hasTexture(texture: BaseTexture): boolean;
  52730. /**
  52731. * Returns an array of the actively used textures.
  52732. * @param activeTextures Array of BaseTextures
  52733. */
  52734. getActiveTextures(activeTextures: BaseTexture[]): void;
  52735. /**
  52736. * Returns the animatable textures.
  52737. * @param animatables Array of animatable textures.
  52738. */
  52739. getAnimatables(animatables: IAnimatable[]): void;
  52740. /**
  52741. * Disposes the resources of the material.
  52742. * @param forceDisposeTextures - Forces the disposal of all textures.
  52743. */
  52744. dispose(forceDisposeTextures?: boolean): void;
  52745. /**
  52746. * Get the current class name of the texture useful for serialization or dynamic coding.
  52747. * @returns "PBRSheenConfiguration"
  52748. */
  52749. getClassName(): string;
  52750. /**
  52751. * Add fallbacks to the effect fallbacks list.
  52752. * @param defines defines the Base texture to use.
  52753. * @param fallbacks defines the current fallback list.
  52754. * @param currentRank defines the current fallback rank.
  52755. * @returns the new fallback rank.
  52756. */
  52757. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52758. /**
  52759. * Add the required uniforms to the current list.
  52760. * @param uniforms defines the current uniform list.
  52761. */
  52762. static AddUniforms(uniforms: string[]): void;
  52763. /**
  52764. * Add the required uniforms to the current buffer.
  52765. * @param uniformBuffer defines the current uniform buffer.
  52766. */
  52767. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52768. /**
  52769. * Add the required samplers to the current list.
  52770. * @param samplers defines the current sampler list.
  52771. */
  52772. static AddSamplers(samplers: string[]): void;
  52773. /**
  52774. * Makes a duplicate of the current configuration into another one.
  52775. * @param sheenConfiguration define the config where to copy the info
  52776. */
  52777. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52778. /**
  52779. * Serializes this BRDF configuration.
  52780. * @returns - An object with the serialized config.
  52781. */
  52782. serialize(): any;
  52783. /**
  52784. * Parses a anisotropy Configuration from a serialized object.
  52785. * @param source - Serialized object.
  52786. * @param scene Defines the scene we are parsing for
  52787. * @param rootUrl Defines the rootUrl to load from
  52788. */
  52789. parse(source: any, scene: Scene, rootUrl: string): void;
  52790. }
  52791. }
  52792. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52793. import { Nullable } from "babylonjs/types";
  52794. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52795. import { Color3 } from "babylonjs/Maths/math.color";
  52796. import { SmartArray } from "babylonjs/Misc/smartArray";
  52797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52799. import { Effect } from "babylonjs/Materials/effect";
  52800. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52801. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52802. import { Engine } from "babylonjs/Engines/engine";
  52803. import { Scene } from "babylonjs/scene";
  52804. /**
  52805. * @hidden
  52806. */
  52807. export interface IMaterialSubSurfaceDefines {
  52808. SUBSURFACE: boolean;
  52809. SS_REFRACTION: boolean;
  52810. SS_TRANSLUCENCY: boolean;
  52811. SS_SCATERRING: boolean;
  52812. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52813. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52814. SS_REFRACTIONMAP_3D: boolean;
  52815. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52816. SS_LODINREFRACTIONALPHA: boolean;
  52817. SS_GAMMAREFRACTION: boolean;
  52818. SS_RGBDREFRACTION: boolean;
  52819. SS_LINEARSPECULARREFRACTION: boolean;
  52820. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52821. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52822. /** @hidden */
  52823. _areTexturesDirty: boolean;
  52824. }
  52825. /**
  52826. * Define the code related to the sub surface parameters of the pbr material.
  52827. */
  52828. export class PBRSubSurfaceConfiguration {
  52829. private _isRefractionEnabled;
  52830. /**
  52831. * Defines if the refraction is enabled in the material.
  52832. */
  52833. isRefractionEnabled: boolean;
  52834. private _isTranslucencyEnabled;
  52835. /**
  52836. * Defines if the translucency is enabled in the material.
  52837. */
  52838. isTranslucencyEnabled: boolean;
  52839. private _isScatteringEnabled;
  52840. /**
  52841. * Defines the refraction intensity of the material.
  52842. * The refraction when enabled replaces the Diffuse part of the material.
  52843. * The intensity helps transitionning between diffuse and refraction.
  52844. */
  52845. refractionIntensity: number;
  52846. /**
  52847. * Defines the translucency intensity of the material.
  52848. * When translucency has been enabled, this defines how much of the "translucency"
  52849. * is addded to the diffuse part of the material.
  52850. */
  52851. translucencyIntensity: number;
  52852. /**
  52853. * Defines the scattering intensity of the material.
  52854. * When scattering has been enabled, this defines how much of the "scattered light"
  52855. * is addded to the diffuse part of the material.
  52856. */
  52857. scatteringIntensity: number;
  52858. private _thicknessTexture;
  52859. /**
  52860. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52861. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52862. * 0 would mean minimumThickness
  52863. * 1 would mean maximumThickness
  52864. * The other channels might be use as a mask to vary the different effects intensity.
  52865. */
  52866. thicknessTexture: Nullable<BaseTexture>;
  52867. private _refractionTexture;
  52868. /**
  52869. * Defines the texture to use for refraction.
  52870. */
  52871. refractionTexture: Nullable<BaseTexture>;
  52872. private _indexOfRefraction;
  52873. /**
  52874. * Defines the index of refraction used in the material.
  52875. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52876. */
  52877. indexOfRefraction: number;
  52878. private _invertRefractionY;
  52879. /**
  52880. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52881. */
  52882. invertRefractionY: boolean;
  52883. private _linkRefractionWithTransparency;
  52884. /**
  52885. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52886. * Materials half opaque for instance using refraction could benefit from this control.
  52887. */
  52888. linkRefractionWithTransparency: boolean;
  52889. /**
  52890. * Defines the minimum thickness stored in the thickness map.
  52891. * If no thickness map is defined, this value will be used to simulate thickness.
  52892. */
  52893. minimumThickness: number;
  52894. /**
  52895. * Defines the maximum thickness stored in the thickness map.
  52896. */
  52897. maximumThickness: number;
  52898. /**
  52899. * Defines the volume tint of the material.
  52900. * This is used for both translucency and scattering.
  52901. */
  52902. tintColor: Color3;
  52903. /**
  52904. * Defines the distance at which the tint color should be found in the media.
  52905. * This is used for refraction only.
  52906. */
  52907. tintColorAtDistance: number;
  52908. /**
  52909. * Defines how far each channel transmit through the media.
  52910. * It is defined as a color to simplify it selection.
  52911. */
  52912. diffusionDistance: Color3;
  52913. private _useMaskFromThicknessTexture;
  52914. /**
  52915. * Stores the intensity of the different subsurface effects in the thickness texture.
  52916. * * the green channel is the translucency intensity.
  52917. * * the blue channel is the scattering intensity.
  52918. * * the alpha channel is the refraction intensity.
  52919. */
  52920. useMaskFromThicknessTexture: boolean;
  52921. /** @hidden */
  52922. private _internalMarkAllSubMeshesAsTexturesDirty;
  52923. /** @hidden */
  52924. _markAllSubMeshesAsTexturesDirty(): void;
  52925. /**
  52926. * Instantiate a new istance of sub surface configuration.
  52927. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52928. */
  52929. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52930. /**
  52931. * Gets wehter the submesh is ready to be used or not.
  52932. * @param defines the list of "defines" to update.
  52933. * @param scene defines the scene the material belongs to.
  52934. * @returns - boolean indicating that the submesh is ready or not.
  52935. */
  52936. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52937. /**
  52938. * Checks to see if a texture is used in the material.
  52939. * @param defines the list of "defines" to update.
  52940. * @param scene defines the scene to the material belongs to.
  52941. */
  52942. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52943. /**
  52944. * Binds the material data.
  52945. * @param uniformBuffer defines the Uniform buffer to fill in.
  52946. * @param scene defines the scene the material belongs to.
  52947. * @param engine defines the engine the material belongs to.
  52948. * @param isFrozen defines wether the material is frozen or not.
  52949. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52950. */
  52951. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52952. /**
  52953. * Unbinds the material from the mesh.
  52954. * @param activeEffect defines the effect that should be unbound from.
  52955. * @returns true if unbound, otherwise false
  52956. */
  52957. unbind(activeEffect: Effect): boolean;
  52958. /**
  52959. * Returns the texture used for refraction or null if none is used.
  52960. * @param scene defines the scene the material belongs to.
  52961. * @returns - Refraction texture if present. If no refraction texture and refraction
  52962. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52963. */
  52964. private _getRefractionTexture;
  52965. /**
  52966. * Returns true if alpha blending should be disabled.
  52967. */
  52968. get disableAlphaBlending(): boolean;
  52969. /**
  52970. * Fills the list of render target textures.
  52971. * @param renderTargets the list of render targets to update
  52972. */
  52973. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52974. /**
  52975. * Checks to see if a texture is used in the material.
  52976. * @param texture - Base texture to use.
  52977. * @returns - Boolean specifying if a texture is used in the material.
  52978. */
  52979. hasTexture(texture: BaseTexture): boolean;
  52980. /**
  52981. * Gets a boolean indicating that current material needs to register RTT
  52982. * @returns true if this uses a render target otherwise false.
  52983. */
  52984. hasRenderTargetTextures(): boolean;
  52985. /**
  52986. * Returns an array of the actively used textures.
  52987. * @param activeTextures Array of BaseTextures
  52988. */
  52989. getActiveTextures(activeTextures: BaseTexture[]): void;
  52990. /**
  52991. * Returns the animatable textures.
  52992. * @param animatables Array of animatable textures.
  52993. */
  52994. getAnimatables(animatables: IAnimatable[]): void;
  52995. /**
  52996. * Disposes the resources of the material.
  52997. * @param forceDisposeTextures - Forces the disposal of all textures.
  52998. */
  52999. dispose(forceDisposeTextures?: boolean): void;
  53000. /**
  53001. * Get the current class name of the texture useful for serialization or dynamic coding.
  53002. * @returns "PBRSubSurfaceConfiguration"
  53003. */
  53004. getClassName(): string;
  53005. /**
  53006. * Add fallbacks to the effect fallbacks list.
  53007. * @param defines defines the Base texture to use.
  53008. * @param fallbacks defines the current fallback list.
  53009. * @param currentRank defines the current fallback rank.
  53010. * @returns the new fallback rank.
  53011. */
  53012. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53013. /**
  53014. * Add the required uniforms to the current list.
  53015. * @param uniforms defines the current uniform list.
  53016. */
  53017. static AddUniforms(uniforms: string[]): void;
  53018. /**
  53019. * Add the required samplers to the current list.
  53020. * @param samplers defines the current sampler list.
  53021. */
  53022. static AddSamplers(samplers: string[]): void;
  53023. /**
  53024. * Add the required uniforms to the current buffer.
  53025. * @param uniformBuffer defines the current uniform buffer.
  53026. */
  53027. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53028. /**
  53029. * Makes a duplicate of the current configuration into another one.
  53030. * @param configuration define the config where to copy the info
  53031. */
  53032. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53033. /**
  53034. * Serializes this Sub Surface configuration.
  53035. * @returns - An object with the serialized config.
  53036. */
  53037. serialize(): any;
  53038. /**
  53039. * Parses a anisotropy Configuration from a serialized object.
  53040. * @param source - Serialized object.
  53041. * @param scene Defines the scene we are parsing for
  53042. * @param rootUrl Defines the rootUrl to load from
  53043. */
  53044. parse(source: any, scene: Scene, rootUrl: string): void;
  53045. }
  53046. }
  53047. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53048. /** @hidden */
  53049. export var pbrFragmentDeclaration: {
  53050. name: string;
  53051. shader: string;
  53052. };
  53053. }
  53054. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53055. /** @hidden */
  53056. export var pbrUboDeclaration: {
  53057. name: string;
  53058. shader: string;
  53059. };
  53060. }
  53061. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53062. /** @hidden */
  53063. export var pbrFragmentExtraDeclaration: {
  53064. name: string;
  53065. shader: string;
  53066. };
  53067. }
  53068. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53069. /** @hidden */
  53070. export var pbrFragmentSamplersDeclaration: {
  53071. name: string;
  53072. shader: string;
  53073. };
  53074. }
  53075. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53076. /** @hidden */
  53077. export var pbrHelperFunctions: {
  53078. name: string;
  53079. shader: string;
  53080. };
  53081. }
  53082. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53083. /** @hidden */
  53084. export var harmonicsFunctions: {
  53085. name: string;
  53086. shader: string;
  53087. };
  53088. }
  53089. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53090. /** @hidden */
  53091. export var pbrDirectLightingSetupFunctions: {
  53092. name: string;
  53093. shader: string;
  53094. };
  53095. }
  53096. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53097. /** @hidden */
  53098. export var pbrDirectLightingFalloffFunctions: {
  53099. name: string;
  53100. shader: string;
  53101. };
  53102. }
  53103. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53104. /** @hidden */
  53105. export var pbrBRDFFunctions: {
  53106. name: string;
  53107. shader: string;
  53108. };
  53109. }
  53110. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53111. /** @hidden */
  53112. export var pbrDirectLightingFunctions: {
  53113. name: string;
  53114. shader: string;
  53115. };
  53116. }
  53117. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53118. /** @hidden */
  53119. export var pbrIBLFunctions: {
  53120. name: string;
  53121. shader: string;
  53122. };
  53123. }
  53124. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53125. /** @hidden */
  53126. export var pbrDebug: {
  53127. name: string;
  53128. shader: string;
  53129. };
  53130. }
  53131. declare module "babylonjs/Shaders/pbr.fragment" {
  53132. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53133. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53134. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53135. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53136. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53137. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53138. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53139. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53140. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53141. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53142. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53143. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53144. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53145. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53146. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53147. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53148. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53149. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53150. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53151. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53152. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53153. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53154. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53155. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53156. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53157. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53158. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53159. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53160. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53161. /** @hidden */
  53162. export var pbrPixelShader: {
  53163. name: string;
  53164. shader: string;
  53165. };
  53166. }
  53167. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53168. /** @hidden */
  53169. export var pbrVertexDeclaration: {
  53170. name: string;
  53171. shader: string;
  53172. };
  53173. }
  53174. declare module "babylonjs/Shaders/pbr.vertex" {
  53175. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53176. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53178. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53179. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53180. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53181. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53182. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53183. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53184. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53185. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53186. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53188. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53189. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53190. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53191. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53192. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53193. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53194. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53195. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53196. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53197. /** @hidden */
  53198. export var pbrVertexShader: {
  53199. name: string;
  53200. shader: string;
  53201. };
  53202. }
  53203. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53204. import { Nullable } from "babylonjs/types";
  53205. import { Scene } from "babylonjs/scene";
  53206. import { Matrix } from "babylonjs/Maths/math.vector";
  53207. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53209. import { Mesh } from "babylonjs/Meshes/mesh";
  53210. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53211. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53212. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53213. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53214. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53215. import { Color3 } from "babylonjs/Maths/math.color";
  53216. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53217. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53218. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53219. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53221. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53222. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53223. import "babylonjs/Shaders/pbr.fragment";
  53224. import "babylonjs/Shaders/pbr.vertex";
  53225. /**
  53226. * Manages the defines for the PBR Material.
  53227. * @hidden
  53228. */
  53229. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53230. PBR: boolean;
  53231. MAINUV1: boolean;
  53232. MAINUV2: boolean;
  53233. UV1: boolean;
  53234. UV2: boolean;
  53235. ALBEDO: boolean;
  53236. GAMMAALBEDO: boolean;
  53237. ALBEDODIRECTUV: number;
  53238. VERTEXCOLOR: boolean;
  53239. AMBIENT: boolean;
  53240. AMBIENTDIRECTUV: number;
  53241. AMBIENTINGRAYSCALE: boolean;
  53242. OPACITY: boolean;
  53243. VERTEXALPHA: boolean;
  53244. OPACITYDIRECTUV: number;
  53245. OPACITYRGB: boolean;
  53246. ALPHATEST: boolean;
  53247. DEPTHPREPASS: boolean;
  53248. ALPHABLEND: boolean;
  53249. ALPHAFROMALBEDO: boolean;
  53250. ALPHATESTVALUE: string;
  53251. SPECULAROVERALPHA: boolean;
  53252. RADIANCEOVERALPHA: boolean;
  53253. ALPHAFRESNEL: boolean;
  53254. LINEARALPHAFRESNEL: boolean;
  53255. PREMULTIPLYALPHA: boolean;
  53256. EMISSIVE: boolean;
  53257. EMISSIVEDIRECTUV: number;
  53258. REFLECTIVITY: boolean;
  53259. REFLECTIVITYDIRECTUV: number;
  53260. SPECULARTERM: boolean;
  53261. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53262. MICROSURFACEAUTOMATIC: boolean;
  53263. LODBASEDMICROSFURACE: boolean;
  53264. MICROSURFACEMAP: boolean;
  53265. MICROSURFACEMAPDIRECTUV: number;
  53266. METALLICWORKFLOW: boolean;
  53267. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53268. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53269. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53270. AOSTOREINMETALMAPRED: boolean;
  53271. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53272. ENVIRONMENTBRDF: boolean;
  53273. ENVIRONMENTBRDF_RGBD: boolean;
  53274. NORMAL: boolean;
  53275. TANGENT: boolean;
  53276. BUMP: boolean;
  53277. BUMPDIRECTUV: number;
  53278. OBJECTSPACE_NORMALMAP: boolean;
  53279. PARALLAX: boolean;
  53280. PARALLAXOCCLUSION: boolean;
  53281. NORMALXYSCALE: boolean;
  53282. LIGHTMAP: boolean;
  53283. LIGHTMAPDIRECTUV: number;
  53284. USELIGHTMAPASSHADOWMAP: boolean;
  53285. GAMMALIGHTMAP: boolean;
  53286. RGBDLIGHTMAP: boolean;
  53287. REFLECTION: boolean;
  53288. REFLECTIONMAP_3D: boolean;
  53289. REFLECTIONMAP_SPHERICAL: boolean;
  53290. REFLECTIONMAP_PLANAR: boolean;
  53291. REFLECTIONMAP_CUBIC: boolean;
  53292. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53293. REFLECTIONMAP_PROJECTION: boolean;
  53294. REFLECTIONMAP_SKYBOX: boolean;
  53295. REFLECTIONMAP_EXPLICIT: boolean;
  53296. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53297. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53298. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53299. INVERTCUBICMAP: boolean;
  53300. USESPHERICALFROMREFLECTIONMAP: boolean;
  53301. USEIRRADIANCEMAP: boolean;
  53302. SPHERICAL_HARMONICS: boolean;
  53303. USESPHERICALINVERTEX: boolean;
  53304. REFLECTIONMAP_OPPOSITEZ: boolean;
  53305. LODINREFLECTIONALPHA: boolean;
  53306. GAMMAREFLECTION: boolean;
  53307. RGBDREFLECTION: boolean;
  53308. LINEARSPECULARREFLECTION: boolean;
  53309. RADIANCEOCCLUSION: boolean;
  53310. HORIZONOCCLUSION: boolean;
  53311. INSTANCES: boolean;
  53312. NUM_BONE_INFLUENCERS: number;
  53313. BonesPerMesh: number;
  53314. BONETEXTURE: boolean;
  53315. NONUNIFORMSCALING: boolean;
  53316. MORPHTARGETS: boolean;
  53317. MORPHTARGETS_NORMAL: boolean;
  53318. MORPHTARGETS_TANGENT: boolean;
  53319. MORPHTARGETS_UV: boolean;
  53320. NUM_MORPH_INFLUENCERS: number;
  53321. IMAGEPROCESSING: boolean;
  53322. VIGNETTE: boolean;
  53323. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53324. VIGNETTEBLENDMODEOPAQUE: boolean;
  53325. TONEMAPPING: boolean;
  53326. TONEMAPPING_ACES: boolean;
  53327. CONTRAST: boolean;
  53328. COLORCURVES: boolean;
  53329. COLORGRADING: boolean;
  53330. COLORGRADING3D: boolean;
  53331. SAMPLER3DGREENDEPTH: boolean;
  53332. SAMPLER3DBGRMAP: boolean;
  53333. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53334. EXPOSURE: boolean;
  53335. MULTIVIEW: boolean;
  53336. USEPHYSICALLIGHTFALLOFF: boolean;
  53337. USEGLTFLIGHTFALLOFF: boolean;
  53338. TWOSIDEDLIGHTING: boolean;
  53339. SHADOWFLOAT: boolean;
  53340. CLIPPLANE: boolean;
  53341. CLIPPLANE2: boolean;
  53342. CLIPPLANE3: boolean;
  53343. CLIPPLANE4: boolean;
  53344. CLIPPLANE5: boolean;
  53345. CLIPPLANE6: boolean;
  53346. POINTSIZE: boolean;
  53347. FOG: boolean;
  53348. LOGARITHMICDEPTH: boolean;
  53349. FORCENORMALFORWARD: boolean;
  53350. SPECULARAA: boolean;
  53351. CLEARCOAT: boolean;
  53352. CLEARCOAT_DEFAULTIOR: boolean;
  53353. CLEARCOAT_TEXTURE: boolean;
  53354. CLEARCOAT_TEXTUREDIRECTUV: number;
  53355. CLEARCOAT_BUMP: boolean;
  53356. CLEARCOAT_BUMPDIRECTUV: number;
  53357. CLEARCOAT_TINT: boolean;
  53358. CLEARCOAT_TINT_TEXTURE: boolean;
  53359. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53360. ANISOTROPIC: boolean;
  53361. ANISOTROPIC_TEXTURE: boolean;
  53362. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53363. BRDF_V_HEIGHT_CORRELATED: boolean;
  53364. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53365. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53366. SHEEN: boolean;
  53367. SHEEN_TEXTURE: boolean;
  53368. SHEEN_TEXTUREDIRECTUV: number;
  53369. SHEEN_LINKWITHALBEDO: boolean;
  53370. SHEEN_ROUGHNESS: boolean;
  53371. SHEEN_ALBEDOSCALING: boolean;
  53372. SUBSURFACE: boolean;
  53373. SS_REFRACTION: boolean;
  53374. SS_TRANSLUCENCY: boolean;
  53375. SS_SCATERRING: boolean;
  53376. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53377. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53378. SS_REFRACTIONMAP_3D: boolean;
  53379. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53380. SS_LODINREFRACTIONALPHA: boolean;
  53381. SS_GAMMAREFRACTION: boolean;
  53382. SS_RGBDREFRACTION: boolean;
  53383. SS_LINEARSPECULARREFRACTION: boolean;
  53384. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53385. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53386. UNLIT: boolean;
  53387. DEBUGMODE: number;
  53388. /**
  53389. * Initializes the PBR Material defines.
  53390. */
  53391. constructor();
  53392. /**
  53393. * Resets the PBR Material defines.
  53394. */
  53395. reset(): void;
  53396. }
  53397. /**
  53398. * The Physically based material base class of BJS.
  53399. *
  53400. * This offers the main features of a standard PBR material.
  53401. * For more information, please refer to the documentation :
  53402. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53403. */
  53404. export abstract class PBRBaseMaterial extends PushMaterial {
  53405. /**
  53406. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53407. */
  53408. static readonly PBRMATERIAL_OPAQUE: number;
  53409. /**
  53410. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53411. */
  53412. static readonly PBRMATERIAL_ALPHATEST: number;
  53413. /**
  53414. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53415. */
  53416. static readonly PBRMATERIAL_ALPHABLEND: number;
  53417. /**
  53418. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53419. * They are also discarded below the alpha cutoff threshold to improve performances.
  53420. */
  53421. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53422. /**
  53423. * Defines the default value of how much AO map is occluding the analytical lights
  53424. * (point spot...).
  53425. */
  53426. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53427. /**
  53428. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53429. */
  53430. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53431. /**
  53432. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53433. * to enhance interoperability with other engines.
  53434. */
  53435. static readonly LIGHTFALLOFF_GLTF: number;
  53436. /**
  53437. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53438. * to enhance interoperability with other materials.
  53439. */
  53440. static readonly LIGHTFALLOFF_STANDARD: number;
  53441. /**
  53442. * Intensity of the direct lights e.g. the four lights available in your scene.
  53443. * This impacts both the direct diffuse and specular highlights.
  53444. */
  53445. protected _directIntensity: number;
  53446. /**
  53447. * Intensity of the emissive part of the material.
  53448. * This helps controlling the emissive effect without modifying the emissive color.
  53449. */
  53450. protected _emissiveIntensity: number;
  53451. /**
  53452. * Intensity of the environment e.g. how much the environment will light the object
  53453. * either through harmonics for rough material or through the refelction for shiny ones.
  53454. */
  53455. protected _environmentIntensity: number;
  53456. /**
  53457. * This is a special control allowing the reduction of the specular highlights coming from the
  53458. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53459. */
  53460. protected _specularIntensity: number;
  53461. /**
  53462. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53463. */
  53464. private _lightingInfos;
  53465. /**
  53466. * Debug Control allowing disabling the bump map on this material.
  53467. */
  53468. protected _disableBumpMap: boolean;
  53469. /**
  53470. * AKA Diffuse Texture in standard nomenclature.
  53471. */
  53472. protected _albedoTexture: Nullable<BaseTexture>;
  53473. /**
  53474. * AKA Occlusion Texture in other nomenclature.
  53475. */
  53476. protected _ambientTexture: Nullable<BaseTexture>;
  53477. /**
  53478. * AKA Occlusion Texture Intensity in other nomenclature.
  53479. */
  53480. protected _ambientTextureStrength: number;
  53481. /**
  53482. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53483. * 1 means it completely occludes it
  53484. * 0 mean it has no impact
  53485. */
  53486. protected _ambientTextureImpactOnAnalyticalLights: number;
  53487. /**
  53488. * Stores the alpha values in a texture.
  53489. */
  53490. protected _opacityTexture: Nullable<BaseTexture>;
  53491. /**
  53492. * Stores the reflection values in a texture.
  53493. */
  53494. protected _reflectionTexture: Nullable<BaseTexture>;
  53495. /**
  53496. * Stores the emissive values in a texture.
  53497. */
  53498. protected _emissiveTexture: Nullable<BaseTexture>;
  53499. /**
  53500. * AKA Specular texture in other nomenclature.
  53501. */
  53502. protected _reflectivityTexture: Nullable<BaseTexture>;
  53503. /**
  53504. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53505. */
  53506. protected _metallicTexture: Nullable<BaseTexture>;
  53507. /**
  53508. * Specifies the metallic scalar of the metallic/roughness workflow.
  53509. * Can also be used to scale the metalness values of the metallic texture.
  53510. */
  53511. protected _metallic: Nullable<number>;
  53512. /**
  53513. * Specifies the roughness scalar of the metallic/roughness workflow.
  53514. * Can also be used to scale the roughness values of the metallic texture.
  53515. */
  53516. protected _roughness: Nullable<number>;
  53517. /**
  53518. * Specifies the an F0 factor to help configuring the material F0.
  53519. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53520. * to 0.5 the previously hard coded value stays the same.
  53521. * Can also be used to scale the F0 values of the metallic texture.
  53522. */
  53523. protected _metallicF0Factor: number;
  53524. /**
  53525. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53526. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53527. * your expectation as it multiplies with the texture data.
  53528. */
  53529. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53530. /**
  53531. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53532. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53533. */
  53534. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53535. /**
  53536. * Stores surface normal data used to displace a mesh in a texture.
  53537. */
  53538. protected _bumpTexture: Nullable<BaseTexture>;
  53539. /**
  53540. * Stores the pre-calculated light information of a mesh in a texture.
  53541. */
  53542. protected _lightmapTexture: Nullable<BaseTexture>;
  53543. /**
  53544. * The color of a material in ambient lighting.
  53545. */
  53546. protected _ambientColor: Color3;
  53547. /**
  53548. * AKA Diffuse Color in other nomenclature.
  53549. */
  53550. protected _albedoColor: Color3;
  53551. /**
  53552. * AKA Specular Color in other nomenclature.
  53553. */
  53554. protected _reflectivityColor: Color3;
  53555. /**
  53556. * The color applied when light is reflected from a material.
  53557. */
  53558. protected _reflectionColor: Color3;
  53559. /**
  53560. * The color applied when light is emitted from a material.
  53561. */
  53562. protected _emissiveColor: Color3;
  53563. /**
  53564. * AKA Glossiness in other nomenclature.
  53565. */
  53566. protected _microSurface: number;
  53567. /**
  53568. * Specifies that the material will use the light map as a show map.
  53569. */
  53570. protected _useLightmapAsShadowmap: boolean;
  53571. /**
  53572. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53573. * makes the reflect vector face the model (under horizon).
  53574. */
  53575. protected _useHorizonOcclusion: boolean;
  53576. /**
  53577. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53578. * too much the area relying on ambient texture to define their ambient occlusion.
  53579. */
  53580. protected _useRadianceOcclusion: boolean;
  53581. /**
  53582. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53583. */
  53584. protected _useAlphaFromAlbedoTexture: boolean;
  53585. /**
  53586. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53587. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53588. */
  53589. protected _useSpecularOverAlpha: boolean;
  53590. /**
  53591. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53592. */
  53593. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53594. /**
  53595. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53596. */
  53597. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53598. /**
  53599. * Specifies if the metallic texture contains the roughness information in its green channel.
  53600. */
  53601. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53602. /**
  53603. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53604. */
  53605. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53606. /**
  53607. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53608. */
  53609. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53610. /**
  53611. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53612. */
  53613. protected _useAmbientInGrayScale: boolean;
  53614. /**
  53615. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53616. * The material will try to infer what glossiness each pixel should be.
  53617. */
  53618. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53619. /**
  53620. * Defines the falloff type used in this material.
  53621. * It by default is Physical.
  53622. */
  53623. protected _lightFalloff: number;
  53624. /**
  53625. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53626. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53627. */
  53628. protected _useRadianceOverAlpha: boolean;
  53629. /**
  53630. * Allows using an object space normal map (instead of tangent space).
  53631. */
  53632. protected _useObjectSpaceNormalMap: boolean;
  53633. /**
  53634. * Allows using the bump map in parallax mode.
  53635. */
  53636. protected _useParallax: boolean;
  53637. /**
  53638. * Allows using the bump map in parallax occlusion mode.
  53639. */
  53640. protected _useParallaxOcclusion: boolean;
  53641. /**
  53642. * Controls the scale bias of the parallax mode.
  53643. */
  53644. protected _parallaxScaleBias: number;
  53645. /**
  53646. * If sets to true, disables all the lights affecting the material.
  53647. */
  53648. protected _disableLighting: boolean;
  53649. /**
  53650. * Number of Simultaneous lights allowed on the material.
  53651. */
  53652. protected _maxSimultaneousLights: number;
  53653. /**
  53654. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53655. */
  53656. protected _invertNormalMapX: boolean;
  53657. /**
  53658. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53659. */
  53660. protected _invertNormalMapY: boolean;
  53661. /**
  53662. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53663. */
  53664. protected _twoSidedLighting: boolean;
  53665. /**
  53666. * Defines the alpha limits in alpha test mode.
  53667. */
  53668. protected _alphaCutOff: number;
  53669. /**
  53670. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53671. */
  53672. protected _forceAlphaTest: boolean;
  53673. /**
  53674. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53675. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53676. */
  53677. protected _useAlphaFresnel: boolean;
  53678. /**
  53679. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53680. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53681. */
  53682. protected _useLinearAlphaFresnel: boolean;
  53683. /**
  53684. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53685. * from cos thetav and roughness:
  53686. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53687. */
  53688. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53689. /**
  53690. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53691. */
  53692. protected _forceIrradianceInFragment: boolean;
  53693. /**
  53694. * Force normal to face away from face.
  53695. */
  53696. protected _forceNormalForward: boolean;
  53697. /**
  53698. * Enables specular anti aliasing in the PBR shader.
  53699. * It will both interacts on the Geometry for analytical and IBL lighting.
  53700. * It also prefilter the roughness map based on the bump values.
  53701. */
  53702. protected _enableSpecularAntiAliasing: boolean;
  53703. /**
  53704. * Default configuration related to image processing available in the PBR Material.
  53705. */
  53706. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53707. /**
  53708. * Keep track of the image processing observer to allow dispose and replace.
  53709. */
  53710. private _imageProcessingObserver;
  53711. /**
  53712. * Attaches a new image processing configuration to the PBR Material.
  53713. * @param configuration
  53714. */
  53715. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53716. /**
  53717. * Stores the available render targets.
  53718. */
  53719. private _renderTargets;
  53720. /**
  53721. * Sets the global ambient color for the material used in lighting calculations.
  53722. */
  53723. private _globalAmbientColor;
  53724. /**
  53725. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53726. */
  53727. private _useLogarithmicDepth;
  53728. /**
  53729. * If set to true, no lighting calculations will be applied.
  53730. */
  53731. private _unlit;
  53732. private _debugMode;
  53733. /**
  53734. * @hidden
  53735. * This is reserved for the inspector.
  53736. * Defines the material debug mode.
  53737. * It helps seeing only some components of the material while troubleshooting.
  53738. */
  53739. debugMode: number;
  53740. /**
  53741. * @hidden
  53742. * This is reserved for the inspector.
  53743. * Specify from where on screen the debug mode should start.
  53744. * The value goes from -1 (full screen) to 1 (not visible)
  53745. * It helps with side by side comparison against the final render
  53746. * This defaults to -1
  53747. */
  53748. private debugLimit;
  53749. /**
  53750. * @hidden
  53751. * This is reserved for the inspector.
  53752. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53753. * You can use the factor to better multiply the final value.
  53754. */
  53755. private debugFactor;
  53756. /**
  53757. * Defines the clear coat layer parameters for the material.
  53758. */
  53759. readonly clearCoat: PBRClearCoatConfiguration;
  53760. /**
  53761. * Defines the anisotropic parameters for the material.
  53762. */
  53763. readonly anisotropy: PBRAnisotropicConfiguration;
  53764. /**
  53765. * Defines the BRDF parameters for the material.
  53766. */
  53767. readonly brdf: PBRBRDFConfiguration;
  53768. /**
  53769. * Defines the Sheen parameters for the material.
  53770. */
  53771. readonly sheen: PBRSheenConfiguration;
  53772. /**
  53773. * Defines the SubSurface parameters for the material.
  53774. */
  53775. readonly subSurface: PBRSubSurfaceConfiguration;
  53776. /**
  53777. * Custom callback helping to override the default shader used in the material.
  53778. */
  53779. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53780. protected _rebuildInParallel: boolean;
  53781. /**
  53782. * Instantiates a new PBRMaterial instance.
  53783. *
  53784. * @param name The material name
  53785. * @param scene The scene the material will be use in.
  53786. */
  53787. constructor(name: string, scene: Scene);
  53788. /**
  53789. * Gets a boolean indicating that current material needs to register RTT
  53790. */
  53791. get hasRenderTargetTextures(): boolean;
  53792. /**
  53793. * Gets the name of the material class.
  53794. */
  53795. getClassName(): string;
  53796. /**
  53797. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53798. */
  53799. get useLogarithmicDepth(): boolean;
  53800. /**
  53801. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53802. */
  53803. set useLogarithmicDepth(value: boolean);
  53804. /**
  53805. * Returns true if alpha blending should be disabled.
  53806. */
  53807. protected get _disableAlphaBlending(): boolean;
  53808. /**
  53809. * Specifies whether or not this material should be rendered in alpha blend mode.
  53810. */
  53811. needAlphaBlending(): boolean;
  53812. /**
  53813. * Specifies whether or not this material should be rendered in alpha test mode.
  53814. */
  53815. needAlphaTesting(): boolean;
  53816. /**
  53817. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53818. */
  53819. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53820. /**
  53821. * Gets the texture used for the alpha test.
  53822. */
  53823. getAlphaTestTexture(): Nullable<BaseTexture>;
  53824. /**
  53825. * Specifies that the submesh is ready to be used.
  53826. * @param mesh - BJS mesh.
  53827. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53828. * @param useInstances - Specifies that instances should be used.
  53829. * @returns - boolean indicating that the submesh is ready or not.
  53830. */
  53831. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53832. /**
  53833. * Specifies if the material uses metallic roughness workflow.
  53834. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53835. */
  53836. isMetallicWorkflow(): boolean;
  53837. private _prepareEffect;
  53838. private _prepareDefines;
  53839. /**
  53840. * Force shader compilation
  53841. */
  53842. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53843. /**
  53844. * Initializes the uniform buffer layout for the shader.
  53845. */
  53846. buildUniformLayout(): void;
  53847. /**
  53848. * Unbinds the material from the mesh
  53849. */
  53850. unbind(): void;
  53851. /**
  53852. * Binds the submesh data.
  53853. * @param world - The world matrix.
  53854. * @param mesh - The BJS mesh.
  53855. * @param subMesh - A submesh of the BJS mesh.
  53856. */
  53857. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53858. /**
  53859. * Returns the animatable textures.
  53860. * @returns - Array of animatable textures.
  53861. */
  53862. getAnimatables(): IAnimatable[];
  53863. /**
  53864. * Returns the texture used for reflections.
  53865. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53866. */
  53867. private _getReflectionTexture;
  53868. /**
  53869. * Returns an array of the actively used textures.
  53870. * @returns - Array of BaseTextures
  53871. */
  53872. getActiveTextures(): BaseTexture[];
  53873. /**
  53874. * Checks to see if a texture is used in the material.
  53875. * @param texture - Base texture to use.
  53876. * @returns - Boolean specifying if a texture is used in the material.
  53877. */
  53878. hasTexture(texture: BaseTexture): boolean;
  53879. /**
  53880. * Disposes the resources of the material.
  53881. * @param forceDisposeEffect - Forces the disposal of effects.
  53882. * @param forceDisposeTextures - Forces the disposal of all textures.
  53883. */
  53884. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53885. }
  53886. }
  53887. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53888. import { Nullable } from "babylonjs/types";
  53889. import { Scene } from "babylonjs/scene";
  53890. import { Color3 } from "babylonjs/Maths/math.color";
  53891. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53892. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53894. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53895. /**
  53896. * The Physically based material of BJS.
  53897. *
  53898. * This offers the main features of a standard PBR material.
  53899. * For more information, please refer to the documentation :
  53900. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53901. */
  53902. export class PBRMaterial extends PBRBaseMaterial {
  53903. /**
  53904. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53905. */
  53906. static readonly PBRMATERIAL_OPAQUE: number;
  53907. /**
  53908. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53909. */
  53910. static readonly PBRMATERIAL_ALPHATEST: number;
  53911. /**
  53912. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53913. */
  53914. static readonly PBRMATERIAL_ALPHABLEND: number;
  53915. /**
  53916. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53917. * They are also discarded below the alpha cutoff threshold to improve performances.
  53918. */
  53919. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53920. /**
  53921. * Defines the default value of how much AO map is occluding the analytical lights
  53922. * (point spot...).
  53923. */
  53924. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53925. /**
  53926. * Intensity of the direct lights e.g. the four lights available in your scene.
  53927. * This impacts both the direct diffuse and specular highlights.
  53928. */
  53929. directIntensity: number;
  53930. /**
  53931. * Intensity of the emissive part of the material.
  53932. * This helps controlling the emissive effect without modifying the emissive color.
  53933. */
  53934. emissiveIntensity: number;
  53935. /**
  53936. * Intensity of the environment e.g. how much the environment will light the object
  53937. * either through harmonics for rough material or through the refelction for shiny ones.
  53938. */
  53939. environmentIntensity: number;
  53940. /**
  53941. * This is a special control allowing the reduction of the specular highlights coming from the
  53942. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53943. */
  53944. specularIntensity: number;
  53945. /**
  53946. * Debug Control allowing disabling the bump map on this material.
  53947. */
  53948. disableBumpMap: boolean;
  53949. /**
  53950. * AKA Diffuse Texture in standard nomenclature.
  53951. */
  53952. albedoTexture: BaseTexture;
  53953. /**
  53954. * AKA Occlusion Texture in other nomenclature.
  53955. */
  53956. ambientTexture: BaseTexture;
  53957. /**
  53958. * AKA Occlusion Texture Intensity in other nomenclature.
  53959. */
  53960. ambientTextureStrength: number;
  53961. /**
  53962. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53963. * 1 means it completely occludes it
  53964. * 0 mean it has no impact
  53965. */
  53966. ambientTextureImpactOnAnalyticalLights: number;
  53967. /**
  53968. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53969. */
  53970. opacityTexture: BaseTexture;
  53971. /**
  53972. * Stores the reflection values in a texture.
  53973. */
  53974. reflectionTexture: Nullable<BaseTexture>;
  53975. /**
  53976. * Stores the emissive values in a texture.
  53977. */
  53978. emissiveTexture: BaseTexture;
  53979. /**
  53980. * AKA Specular texture in other nomenclature.
  53981. */
  53982. reflectivityTexture: BaseTexture;
  53983. /**
  53984. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53985. */
  53986. metallicTexture: BaseTexture;
  53987. /**
  53988. * Specifies the metallic scalar of the metallic/roughness workflow.
  53989. * Can also be used to scale the metalness values of the metallic texture.
  53990. */
  53991. metallic: Nullable<number>;
  53992. /**
  53993. * Specifies the roughness scalar of the metallic/roughness workflow.
  53994. * Can also be used to scale the roughness values of the metallic texture.
  53995. */
  53996. roughness: Nullable<number>;
  53997. /**
  53998. * Specifies the an F0 factor to help configuring the material F0.
  53999. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54000. * to 0.5 the previously hard coded value stays the same.
  54001. * Can also be used to scale the F0 values of the metallic texture.
  54002. */
  54003. metallicF0Factor: number;
  54004. /**
  54005. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54006. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54007. * your expectation as it multiplies with the texture data.
  54008. */
  54009. useMetallicF0FactorFromMetallicTexture: boolean;
  54010. /**
  54011. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54012. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54013. */
  54014. microSurfaceTexture: BaseTexture;
  54015. /**
  54016. * Stores surface normal data used to displace a mesh in a texture.
  54017. */
  54018. bumpTexture: BaseTexture;
  54019. /**
  54020. * Stores the pre-calculated light information of a mesh in a texture.
  54021. */
  54022. lightmapTexture: BaseTexture;
  54023. /**
  54024. * Stores the refracted light information in a texture.
  54025. */
  54026. get refractionTexture(): Nullable<BaseTexture>;
  54027. set refractionTexture(value: Nullable<BaseTexture>);
  54028. /**
  54029. * The color of a material in ambient lighting.
  54030. */
  54031. ambientColor: Color3;
  54032. /**
  54033. * AKA Diffuse Color in other nomenclature.
  54034. */
  54035. albedoColor: Color3;
  54036. /**
  54037. * AKA Specular Color in other nomenclature.
  54038. */
  54039. reflectivityColor: Color3;
  54040. /**
  54041. * The color reflected from the material.
  54042. */
  54043. reflectionColor: Color3;
  54044. /**
  54045. * The color emitted from the material.
  54046. */
  54047. emissiveColor: Color3;
  54048. /**
  54049. * AKA Glossiness in other nomenclature.
  54050. */
  54051. microSurface: number;
  54052. /**
  54053. * source material index of refraction (IOR)' / 'destination material IOR.
  54054. */
  54055. get indexOfRefraction(): number;
  54056. set indexOfRefraction(value: number);
  54057. /**
  54058. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54059. */
  54060. get invertRefractionY(): boolean;
  54061. set invertRefractionY(value: boolean);
  54062. /**
  54063. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54064. * Materials half opaque for instance using refraction could benefit from this control.
  54065. */
  54066. get linkRefractionWithTransparency(): boolean;
  54067. set linkRefractionWithTransparency(value: boolean);
  54068. /**
  54069. * If true, the light map contains occlusion information instead of lighting info.
  54070. */
  54071. useLightmapAsShadowmap: boolean;
  54072. /**
  54073. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54074. */
  54075. useAlphaFromAlbedoTexture: boolean;
  54076. /**
  54077. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54078. */
  54079. forceAlphaTest: boolean;
  54080. /**
  54081. * Defines the alpha limits in alpha test mode.
  54082. */
  54083. alphaCutOff: number;
  54084. /**
  54085. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54086. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54087. */
  54088. useSpecularOverAlpha: boolean;
  54089. /**
  54090. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54091. */
  54092. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54093. /**
  54094. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54095. */
  54096. useRoughnessFromMetallicTextureAlpha: boolean;
  54097. /**
  54098. * Specifies if the metallic texture contains the roughness information in its green channel.
  54099. */
  54100. useRoughnessFromMetallicTextureGreen: boolean;
  54101. /**
  54102. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54103. */
  54104. useMetallnessFromMetallicTextureBlue: boolean;
  54105. /**
  54106. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54107. */
  54108. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54109. /**
  54110. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54111. */
  54112. useAmbientInGrayScale: boolean;
  54113. /**
  54114. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54115. * The material will try to infer what glossiness each pixel should be.
  54116. */
  54117. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54118. /**
  54119. * BJS is using an harcoded light falloff based on a manually sets up range.
  54120. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54121. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54122. */
  54123. get usePhysicalLightFalloff(): boolean;
  54124. /**
  54125. * BJS is using an harcoded light falloff based on a manually sets up range.
  54126. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54127. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54128. */
  54129. set usePhysicalLightFalloff(value: boolean);
  54130. /**
  54131. * In order to support the falloff compatibility with gltf, a special mode has been added
  54132. * to reproduce the gltf light falloff.
  54133. */
  54134. get useGLTFLightFalloff(): boolean;
  54135. /**
  54136. * In order to support the falloff compatibility with gltf, a special mode has been added
  54137. * to reproduce the gltf light falloff.
  54138. */
  54139. set useGLTFLightFalloff(value: boolean);
  54140. /**
  54141. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54142. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54143. */
  54144. useRadianceOverAlpha: boolean;
  54145. /**
  54146. * Allows using an object space normal map (instead of tangent space).
  54147. */
  54148. useObjectSpaceNormalMap: boolean;
  54149. /**
  54150. * Allows using the bump map in parallax mode.
  54151. */
  54152. useParallax: boolean;
  54153. /**
  54154. * Allows using the bump map in parallax occlusion mode.
  54155. */
  54156. useParallaxOcclusion: boolean;
  54157. /**
  54158. * Controls the scale bias of the parallax mode.
  54159. */
  54160. parallaxScaleBias: number;
  54161. /**
  54162. * If sets to true, disables all the lights affecting the material.
  54163. */
  54164. disableLighting: boolean;
  54165. /**
  54166. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54167. */
  54168. forceIrradianceInFragment: boolean;
  54169. /**
  54170. * Number of Simultaneous lights allowed on the material.
  54171. */
  54172. maxSimultaneousLights: number;
  54173. /**
  54174. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54175. */
  54176. invertNormalMapX: boolean;
  54177. /**
  54178. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54179. */
  54180. invertNormalMapY: boolean;
  54181. /**
  54182. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54183. */
  54184. twoSidedLighting: boolean;
  54185. /**
  54186. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54187. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54188. */
  54189. useAlphaFresnel: boolean;
  54190. /**
  54191. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54192. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54193. */
  54194. useLinearAlphaFresnel: boolean;
  54195. /**
  54196. * Let user defines the brdf lookup texture used for IBL.
  54197. * A default 8bit version is embedded but you could point at :
  54198. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54199. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54200. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54201. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54202. */
  54203. environmentBRDFTexture: Nullable<BaseTexture>;
  54204. /**
  54205. * Force normal to face away from face.
  54206. */
  54207. forceNormalForward: boolean;
  54208. /**
  54209. * Enables specular anti aliasing in the PBR shader.
  54210. * It will both interacts on the Geometry for analytical and IBL lighting.
  54211. * It also prefilter the roughness map based on the bump values.
  54212. */
  54213. enableSpecularAntiAliasing: boolean;
  54214. /**
  54215. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54216. * makes the reflect vector face the model (under horizon).
  54217. */
  54218. useHorizonOcclusion: boolean;
  54219. /**
  54220. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54221. * too much the area relying on ambient texture to define their ambient occlusion.
  54222. */
  54223. useRadianceOcclusion: boolean;
  54224. /**
  54225. * If set to true, no lighting calculations will be applied.
  54226. */
  54227. unlit: boolean;
  54228. /**
  54229. * Gets the image processing configuration used either in this material.
  54230. */
  54231. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54232. /**
  54233. * Sets the Default image processing configuration used either in the this material.
  54234. *
  54235. * If sets to null, the scene one is in use.
  54236. */
  54237. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54238. /**
  54239. * Gets wether the color curves effect is enabled.
  54240. */
  54241. get cameraColorCurvesEnabled(): boolean;
  54242. /**
  54243. * Sets wether the color curves effect is enabled.
  54244. */
  54245. set cameraColorCurvesEnabled(value: boolean);
  54246. /**
  54247. * Gets wether the color grading effect is enabled.
  54248. */
  54249. get cameraColorGradingEnabled(): boolean;
  54250. /**
  54251. * Gets wether the color grading effect is enabled.
  54252. */
  54253. set cameraColorGradingEnabled(value: boolean);
  54254. /**
  54255. * Gets wether tonemapping is enabled or not.
  54256. */
  54257. get cameraToneMappingEnabled(): boolean;
  54258. /**
  54259. * Sets wether tonemapping is enabled or not
  54260. */
  54261. set cameraToneMappingEnabled(value: boolean);
  54262. /**
  54263. * The camera exposure used on this material.
  54264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54265. * This corresponds to a photographic exposure.
  54266. */
  54267. get cameraExposure(): number;
  54268. /**
  54269. * The camera exposure used on this material.
  54270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54271. * This corresponds to a photographic exposure.
  54272. */
  54273. set cameraExposure(value: number);
  54274. /**
  54275. * Gets The camera contrast used on this material.
  54276. */
  54277. get cameraContrast(): number;
  54278. /**
  54279. * Sets The camera contrast used on this material.
  54280. */
  54281. set cameraContrast(value: number);
  54282. /**
  54283. * Gets the Color Grading 2D Lookup Texture.
  54284. */
  54285. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54286. /**
  54287. * Sets the Color Grading 2D Lookup Texture.
  54288. */
  54289. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54290. /**
  54291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54293. * 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;
  54294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54295. */
  54296. get cameraColorCurves(): Nullable<ColorCurves>;
  54297. /**
  54298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54300. * 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;
  54301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54302. */
  54303. set cameraColorCurves(value: Nullable<ColorCurves>);
  54304. /**
  54305. * Instantiates a new PBRMaterial instance.
  54306. *
  54307. * @param name The material name
  54308. * @param scene The scene the material will be use in.
  54309. */
  54310. constructor(name: string, scene: Scene);
  54311. /**
  54312. * Returns the name of this material class.
  54313. */
  54314. getClassName(): string;
  54315. /**
  54316. * Makes a duplicate of the current material.
  54317. * @param name - name to use for the new material.
  54318. */
  54319. clone(name: string): PBRMaterial;
  54320. /**
  54321. * Serializes this PBR Material.
  54322. * @returns - An object with the serialized material.
  54323. */
  54324. serialize(): any;
  54325. /**
  54326. * Parses a PBR Material from a serialized object.
  54327. * @param source - Serialized object.
  54328. * @param scene - BJS scene instance.
  54329. * @param rootUrl - url for the scene object
  54330. * @returns - PBRMaterial
  54331. */
  54332. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54333. }
  54334. }
  54335. declare module "babylonjs/Misc/dds" {
  54336. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54337. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54338. import { Nullable } from "babylonjs/types";
  54339. import { Scene } from "babylonjs/scene";
  54340. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54341. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54342. /**
  54343. * Direct draw surface info
  54344. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54345. */
  54346. export interface DDSInfo {
  54347. /**
  54348. * Width of the texture
  54349. */
  54350. width: number;
  54351. /**
  54352. * Width of the texture
  54353. */
  54354. height: number;
  54355. /**
  54356. * Number of Mipmaps for the texture
  54357. * @see https://en.wikipedia.org/wiki/Mipmap
  54358. */
  54359. mipmapCount: number;
  54360. /**
  54361. * If the textures format is a known fourCC format
  54362. * @see https://www.fourcc.org/
  54363. */
  54364. isFourCC: boolean;
  54365. /**
  54366. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54367. */
  54368. isRGB: boolean;
  54369. /**
  54370. * If the texture is a lumincance format
  54371. */
  54372. isLuminance: boolean;
  54373. /**
  54374. * If this is a cube texture
  54375. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54376. */
  54377. isCube: boolean;
  54378. /**
  54379. * If the texture is a compressed format eg. FOURCC_DXT1
  54380. */
  54381. isCompressed: boolean;
  54382. /**
  54383. * The dxgiFormat of the texture
  54384. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54385. */
  54386. dxgiFormat: number;
  54387. /**
  54388. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54389. */
  54390. textureType: number;
  54391. /**
  54392. * Sphericle polynomial created for the dds texture
  54393. */
  54394. sphericalPolynomial?: SphericalPolynomial;
  54395. }
  54396. /**
  54397. * Class used to provide DDS decompression tools
  54398. */
  54399. export class DDSTools {
  54400. /**
  54401. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54402. */
  54403. static StoreLODInAlphaChannel: boolean;
  54404. /**
  54405. * Gets DDS information from an array buffer
  54406. * @param data defines the array buffer view to read data from
  54407. * @returns the DDS information
  54408. */
  54409. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54410. private static _FloatView;
  54411. private static _Int32View;
  54412. private static _ToHalfFloat;
  54413. private static _FromHalfFloat;
  54414. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54415. private static _GetHalfFloatRGBAArrayBuffer;
  54416. private static _GetFloatRGBAArrayBuffer;
  54417. private static _GetFloatAsUIntRGBAArrayBuffer;
  54418. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54419. private static _GetRGBAArrayBuffer;
  54420. private static _ExtractLongWordOrder;
  54421. private static _GetRGBArrayBuffer;
  54422. private static _GetLuminanceArrayBuffer;
  54423. /**
  54424. * Uploads DDS Levels to a Babylon Texture
  54425. * @hidden
  54426. */
  54427. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54428. }
  54429. module "babylonjs/Engines/thinEngine" {
  54430. interface ThinEngine {
  54431. /**
  54432. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54433. * @param rootUrl defines the url where the file to load is located
  54434. * @param scene defines the current scene
  54435. * @param lodScale defines scale to apply to the mip map selection
  54436. * @param lodOffset defines offset to apply to the mip map selection
  54437. * @param onLoad defines an optional callback raised when the texture is loaded
  54438. * @param onError defines an optional callback raised if there is an issue to load the texture
  54439. * @param format defines the format of the data
  54440. * @param forcedExtension defines the extension to use to pick the right loader
  54441. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54442. * @returns the cube texture as an InternalTexture
  54443. */
  54444. 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;
  54445. }
  54446. }
  54447. }
  54448. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54449. import { Nullable } from "babylonjs/types";
  54450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54451. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54452. /**
  54453. * Implementation of the DDS Texture Loader.
  54454. * @hidden
  54455. */
  54456. export class _DDSTextureLoader implements IInternalTextureLoader {
  54457. /**
  54458. * Defines wether the loader supports cascade loading the different faces.
  54459. */
  54460. readonly supportCascades: boolean;
  54461. /**
  54462. * This returns if the loader support the current file information.
  54463. * @param extension defines the file extension of the file being loaded
  54464. * @returns true if the loader can load the specified file
  54465. */
  54466. canLoad(extension: string): boolean;
  54467. /**
  54468. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54469. * @param data contains the texture data
  54470. * @param texture defines the BabylonJS internal texture
  54471. * @param createPolynomials will be true if polynomials have been requested
  54472. * @param onLoad defines the callback to trigger once the texture is ready
  54473. * @param onError defines the callback to trigger in case of error
  54474. */
  54475. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54476. /**
  54477. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54478. * @param data contains the texture data
  54479. * @param texture defines the BabylonJS internal texture
  54480. * @param callback defines the method to call once ready to upload
  54481. */
  54482. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54483. }
  54484. }
  54485. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54486. import { Nullable } from "babylonjs/types";
  54487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54488. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54489. /**
  54490. * Implementation of the ENV Texture Loader.
  54491. * @hidden
  54492. */
  54493. export class _ENVTextureLoader implements IInternalTextureLoader {
  54494. /**
  54495. * Defines wether the loader supports cascade loading the different faces.
  54496. */
  54497. readonly supportCascades: boolean;
  54498. /**
  54499. * This returns if the loader support the current file information.
  54500. * @param extension defines the file extension of the file being loaded
  54501. * @returns true if the loader can load the specified file
  54502. */
  54503. canLoad(extension: string): boolean;
  54504. /**
  54505. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54506. * @param data contains the texture data
  54507. * @param texture defines the BabylonJS internal texture
  54508. * @param createPolynomials will be true if polynomials have been requested
  54509. * @param onLoad defines the callback to trigger once the texture is ready
  54510. * @param onError defines the callback to trigger in case of error
  54511. */
  54512. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54513. /**
  54514. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54515. * @param data contains the texture data
  54516. * @param texture defines the BabylonJS internal texture
  54517. * @param callback defines the method to call once ready to upload
  54518. */
  54519. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54520. }
  54521. }
  54522. declare module "babylonjs/Misc/khronosTextureContainer" {
  54523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54524. /**
  54525. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54526. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54527. */
  54528. export class KhronosTextureContainer {
  54529. /** contents of the KTX container file */
  54530. data: ArrayBufferView;
  54531. private static HEADER_LEN;
  54532. private static COMPRESSED_2D;
  54533. private static COMPRESSED_3D;
  54534. private static TEX_2D;
  54535. private static TEX_3D;
  54536. /**
  54537. * Gets the openGL type
  54538. */
  54539. glType: number;
  54540. /**
  54541. * Gets the openGL type size
  54542. */
  54543. glTypeSize: number;
  54544. /**
  54545. * Gets the openGL format
  54546. */
  54547. glFormat: number;
  54548. /**
  54549. * Gets the openGL internal format
  54550. */
  54551. glInternalFormat: number;
  54552. /**
  54553. * Gets the base internal format
  54554. */
  54555. glBaseInternalFormat: number;
  54556. /**
  54557. * Gets image width in pixel
  54558. */
  54559. pixelWidth: number;
  54560. /**
  54561. * Gets image height in pixel
  54562. */
  54563. pixelHeight: number;
  54564. /**
  54565. * Gets image depth in pixels
  54566. */
  54567. pixelDepth: number;
  54568. /**
  54569. * Gets the number of array elements
  54570. */
  54571. numberOfArrayElements: number;
  54572. /**
  54573. * Gets the number of faces
  54574. */
  54575. numberOfFaces: number;
  54576. /**
  54577. * Gets the number of mipmap levels
  54578. */
  54579. numberOfMipmapLevels: number;
  54580. /**
  54581. * Gets the bytes of key value data
  54582. */
  54583. bytesOfKeyValueData: number;
  54584. /**
  54585. * Gets the load type
  54586. */
  54587. loadType: number;
  54588. /**
  54589. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54590. */
  54591. isInvalid: boolean;
  54592. /**
  54593. * Creates a new KhronosTextureContainer
  54594. * @param data contents of the KTX container file
  54595. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54596. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54597. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54598. */
  54599. constructor(
  54600. /** contents of the KTX container file */
  54601. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54602. /**
  54603. * Uploads KTX content to a Babylon Texture.
  54604. * It is assumed that the texture has already been created & is currently bound
  54605. * @hidden
  54606. */
  54607. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54608. private _upload2DCompressedLevels;
  54609. /**
  54610. * Checks if the given data starts with a KTX file identifier.
  54611. * @param data the data to check
  54612. * @returns true if the data is a KTX file or false otherwise
  54613. */
  54614. static IsValid(data: ArrayBufferView): boolean;
  54615. }
  54616. }
  54617. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54618. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54619. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54620. /**
  54621. * Class for loading KTX2 files
  54622. * !!! Experimental Extension Subject to Changes !!!
  54623. * @hidden
  54624. */
  54625. export class KhronosTextureContainer2 {
  54626. private static _ModulePromise;
  54627. private static _TranscodeFormat;
  54628. constructor(engine: ThinEngine);
  54629. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54630. private _determineTranscodeFormat;
  54631. /**
  54632. * Checks if the given data starts with a KTX2 file identifier.
  54633. * @param data the data to check
  54634. * @returns true if the data is a KTX2 file or false otherwise
  54635. */
  54636. static IsValid(data: ArrayBufferView): boolean;
  54637. }
  54638. }
  54639. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54640. import { Nullable } from "babylonjs/types";
  54641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54642. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54643. /**
  54644. * Implementation of the KTX Texture Loader.
  54645. * @hidden
  54646. */
  54647. export class _KTXTextureLoader implements IInternalTextureLoader {
  54648. /**
  54649. * Defines wether the loader supports cascade loading the different faces.
  54650. */
  54651. readonly supportCascades: boolean;
  54652. /**
  54653. * This returns if the loader support the current file information.
  54654. * @param extension defines the file extension of the file being loaded
  54655. * @returns true if the loader can load the specified file
  54656. */
  54657. canLoad(extension: string): boolean;
  54658. /**
  54659. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54660. * @param data contains the texture data
  54661. * @param texture defines the BabylonJS internal texture
  54662. * @param createPolynomials will be true if polynomials have been requested
  54663. * @param onLoad defines the callback to trigger once the texture is ready
  54664. * @param onError defines the callback to trigger in case of error
  54665. */
  54666. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54667. /**
  54668. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54669. * @param data contains the texture data
  54670. * @param texture defines the BabylonJS internal texture
  54671. * @param callback defines the method to call once ready to upload
  54672. */
  54673. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54674. }
  54675. }
  54676. declare module "babylonjs/Helpers/sceneHelpers" {
  54677. import { Nullable } from "babylonjs/types";
  54678. import { Mesh } from "babylonjs/Meshes/mesh";
  54679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54680. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54681. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54682. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54683. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54684. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54685. import "babylonjs/Meshes/Builders/boxBuilder";
  54686. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54687. /** @hidden */
  54688. export var _forceSceneHelpersToBundle: boolean;
  54689. module "babylonjs/scene" {
  54690. interface Scene {
  54691. /**
  54692. * Creates a default light for the scene.
  54693. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54694. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54695. */
  54696. createDefaultLight(replace?: boolean): void;
  54697. /**
  54698. * Creates a default camera for the scene.
  54699. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54700. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54701. * @param replace has default false, when true replaces the active camera in the scene
  54702. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54703. */
  54704. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54705. /**
  54706. * Creates a default camera and a default light.
  54707. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54708. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54709. * @param replace has the default false, when true replaces the active camera/light in the scene
  54710. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54711. */
  54712. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54713. /**
  54714. * Creates a new sky box
  54715. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54716. * @param environmentTexture defines the texture to use as environment texture
  54717. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54718. * @param scale defines the overall scale of the skybox
  54719. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54720. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54721. * @returns a new mesh holding the sky box
  54722. */
  54723. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54724. /**
  54725. * Creates a new environment
  54726. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54727. * @param options defines the options you can use to configure the environment
  54728. * @returns the new EnvironmentHelper
  54729. */
  54730. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54731. /**
  54732. * Creates a new VREXperienceHelper
  54733. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54734. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54735. * @returns a new VREXperienceHelper
  54736. */
  54737. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54738. /**
  54739. * Creates a new WebXRDefaultExperience
  54740. * @see http://doc.babylonjs.com/how_to/webxr
  54741. * @param options experience options
  54742. * @returns a promise for a new WebXRDefaultExperience
  54743. */
  54744. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54745. }
  54746. }
  54747. }
  54748. declare module "babylonjs/Helpers/videoDome" {
  54749. import { Scene } from "babylonjs/scene";
  54750. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54751. import { Mesh } from "babylonjs/Meshes/mesh";
  54752. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54753. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54754. import "babylonjs/Meshes/Builders/sphereBuilder";
  54755. /**
  54756. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54757. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54758. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54759. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54760. */
  54761. export class VideoDome extends TransformNode {
  54762. /**
  54763. * Define the video source as a Monoscopic panoramic 360 video.
  54764. */
  54765. static readonly MODE_MONOSCOPIC: number;
  54766. /**
  54767. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54768. */
  54769. static readonly MODE_TOPBOTTOM: number;
  54770. /**
  54771. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54772. */
  54773. static readonly MODE_SIDEBYSIDE: number;
  54774. private _halfDome;
  54775. private _useDirectMapping;
  54776. /**
  54777. * The video texture being displayed on the sphere
  54778. */
  54779. protected _videoTexture: VideoTexture;
  54780. /**
  54781. * Gets the video texture being displayed on the sphere
  54782. */
  54783. get videoTexture(): VideoTexture;
  54784. /**
  54785. * The skybox material
  54786. */
  54787. protected _material: BackgroundMaterial;
  54788. /**
  54789. * The surface used for the skybox
  54790. */
  54791. protected _mesh: Mesh;
  54792. /**
  54793. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54794. */
  54795. private _halfDomeMask;
  54796. /**
  54797. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54798. * Also see the options.resolution property.
  54799. */
  54800. get fovMultiplier(): number;
  54801. set fovMultiplier(value: number);
  54802. private _videoMode;
  54803. /**
  54804. * Gets or set the current video mode for the video. It can be:
  54805. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54806. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54807. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54808. */
  54809. get videoMode(): number;
  54810. set videoMode(value: number);
  54811. /**
  54812. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54813. *
  54814. */
  54815. get halfDome(): boolean;
  54816. /**
  54817. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54818. */
  54819. set halfDome(enabled: boolean);
  54820. /**
  54821. * Oberserver used in Stereoscopic VR Mode.
  54822. */
  54823. private _onBeforeCameraRenderObserver;
  54824. /**
  54825. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54826. * @param name Element's name, child elements will append suffixes for their own names.
  54827. * @param urlsOrVideo defines the url(s) or the video element to use
  54828. * @param options An object containing optional or exposed sub element properties
  54829. */
  54830. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54831. resolution?: number;
  54832. clickToPlay?: boolean;
  54833. autoPlay?: boolean;
  54834. loop?: boolean;
  54835. size?: number;
  54836. poster?: string;
  54837. faceForward?: boolean;
  54838. useDirectMapping?: boolean;
  54839. halfDomeMode?: boolean;
  54840. }, scene: Scene);
  54841. private _changeVideoMode;
  54842. /**
  54843. * Releases resources associated with this node.
  54844. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54845. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54846. */
  54847. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54848. }
  54849. }
  54850. declare module "babylonjs/Helpers/index" {
  54851. export * from "babylonjs/Helpers/environmentHelper";
  54852. export * from "babylonjs/Helpers/photoDome";
  54853. export * from "babylonjs/Helpers/sceneHelpers";
  54854. export * from "babylonjs/Helpers/videoDome";
  54855. }
  54856. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54857. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54858. import { IDisposable } from "babylonjs/scene";
  54859. import { Engine } from "babylonjs/Engines/engine";
  54860. /**
  54861. * This class can be used to get instrumentation data from a Babylon engine
  54862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54863. */
  54864. export class EngineInstrumentation implements IDisposable {
  54865. /**
  54866. * Define the instrumented engine.
  54867. */
  54868. engine: Engine;
  54869. private _captureGPUFrameTime;
  54870. private _gpuFrameTimeToken;
  54871. private _gpuFrameTime;
  54872. private _captureShaderCompilationTime;
  54873. private _shaderCompilationTime;
  54874. private _onBeginFrameObserver;
  54875. private _onEndFrameObserver;
  54876. private _onBeforeShaderCompilationObserver;
  54877. private _onAfterShaderCompilationObserver;
  54878. /**
  54879. * Gets the perf counter used for GPU frame time
  54880. */
  54881. get gpuFrameTimeCounter(): PerfCounter;
  54882. /**
  54883. * Gets the GPU frame time capture status
  54884. */
  54885. get captureGPUFrameTime(): boolean;
  54886. /**
  54887. * Enable or disable the GPU frame time capture
  54888. */
  54889. set captureGPUFrameTime(value: boolean);
  54890. /**
  54891. * Gets the perf counter used for shader compilation time
  54892. */
  54893. get shaderCompilationTimeCounter(): PerfCounter;
  54894. /**
  54895. * Gets the shader compilation time capture status
  54896. */
  54897. get captureShaderCompilationTime(): boolean;
  54898. /**
  54899. * Enable or disable the shader compilation time capture
  54900. */
  54901. set captureShaderCompilationTime(value: boolean);
  54902. /**
  54903. * Instantiates a new engine instrumentation.
  54904. * This class can be used to get instrumentation data from a Babylon engine
  54905. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54906. * @param engine Defines the engine to instrument
  54907. */
  54908. constructor(
  54909. /**
  54910. * Define the instrumented engine.
  54911. */
  54912. engine: Engine);
  54913. /**
  54914. * Dispose and release associated resources.
  54915. */
  54916. dispose(): void;
  54917. }
  54918. }
  54919. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54920. import { Scene, IDisposable } from "babylonjs/scene";
  54921. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54922. /**
  54923. * This class can be used to get instrumentation data from a Babylon engine
  54924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54925. */
  54926. export class SceneInstrumentation implements IDisposable {
  54927. /**
  54928. * Defines the scene to instrument
  54929. */
  54930. scene: Scene;
  54931. private _captureActiveMeshesEvaluationTime;
  54932. private _activeMeshesEvaluationTime;
  54933. private _captureRenderTargetsRenderTime;
  54934. private _renderTargetsRenderTime;
  54935. private _captureFrameTime;
  54936. private _frameTime;
  54937. private _captureRenderTime;
  54938. private _renderTime;
  54939. private _captureInterFrameTime;
  54940. private _interFrameTime;
  54941. private _captureParticlesRenderTime;
  54942. private _particlesRenderTime;
  54943. private _captureSpritesRenderTime;
  54944. private _spritesRenderTime;
  54945. private _capturePhysicsTime;
  54946. private _physicsTime;
  54947. private _captureAnimationsTime;
  54948. private _animationsTime;
  54949. private _captureCameraRenderTime;
  54950. private _cameraRenderTime;
  54951. private _onBeforeActiveMeshesEvaluationObserver;
  54952. private _onAfterActiveMeshesEvaluationObserver;
  54953. private _onBeforeRenderTargetsRenderObserver;
  54954. private _onAfterRenderTargetsRenderObserver;
  54955. private _onAfterRenderObserver;
  54956. private _onBeforeDrawPhaseObserver;
  54957. private _onAfterDrawPhaseObserver;
  54958. private _onBeforeAnimationsObserver;
  54959. private _onBeforeParticlesRenderingObserver;
  54960. private _onAfterParticlesRenderingObserver;
  54961. private _onBeforeSpritesRenderingObserver;
  54962. private _onAfterSpritesRenderingObserver;
  54963. private _onBeforePhysicsObserver;
  54964. private _onAfterPhysicsObserver;
  54965. private _onAfterAnimationsObserver;
  54966. private _onBeforeCameraRenderObserver;
  54967. private _onAfterCameraRenderObserver;
  54968. /**
  54969. * Gets the perf counter used for active meshes evaluation time
  54970. */
  54971. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54972. /**
  54973. * Gets the active meshes evaluation time capture status
  54974. */
  54975. get captureActiveMeshesEvaluationTime(): boolean;
  54976. /**
  54977. * Enable or disable the active meshes evaluation time capture
  54978. */
  54979. set captureActiveMeshesEvaluationTime(value: boolean);
  54980. /**
  54981. * Gets the perf counter used for render targets render time
  54982. */
  54983. get renderTargetsRenderTimeCounter(): PerfCounter;
  54984. /**
  54985. * Gets the render targets render time capture status
  54986. */
  54987. get captureRenderTargetsRenderTime(): boolean;
  54988. /**
  54989. * Enable or disable the render targets render time capture
  54990. */
  54991. set captureRenderTargetsRenderTime(value: boolean);
  54992. /**
  54993. * Gets the perf counter used for particles render time
  54994. */
  54995. get particlesRenderTimeCounter(): PerfCounter;
  54996. /**
  54997. * Gets the particles render time capture status
  54998. */
  54999. get captureParticlesRenderTime(): boolean;
  55000. /**
  55001. * Enable or disable the particles render time capture
  55002. */
  55003. set captureParticlesRenderTime(value: boolean);
  55004. /**
  55005. * Gets the perf counter used for sprites render time
  55006. */
  55007. get spritesRenderTimeCounter(): PerfCounter;
  55008. /**
  55009. * Gets the sprites render time capture status
  55010. */
  55011. get captureSpritesRenderTime(): boolean;
  55012. /**
  55013. * Enable or disable the sprites render time capture
  55014. */
  55015. set captureSpritesRenderTime(value: boolean);
  55016. /**
  55017. * Gets the perf counter used for physics time
  55018. */
  55019. get physicsTimeCounter(): PerfCounter;
  55020. /**
  55021. * Gets the physics time capture status
  55022. */
  55023. get capturePhysicsTime(): boolean;
  55024. /**
  55025. * Enable or disable the physics time capture
  55026. */
  55027. set capturePhysicsTime(value: boolean);
  55028. /**
  55029. * Gets the perf counter used for animations time
  55030. */
  55031. get animationsTimeCounter(): PerfCounter;
  55032. /**
  55033. * Gets the animations time capture status
  55034. */
  55035. get captureAnimationsTime(): boolean;
  55036. /**
  55037. * Enable or disable the animations time capture
  55038. */
  55039. set captureAnimationsTime(value: boolean);
  55040. /**
  55041. * Gets the perf counter used for frame time capture
  55042. */
  55043. get frameTimeCounter(): PerfCounter;
  55044. /**
  55045. * Gets the frame time capture status
  55046. */
  55047. get captureFrameTime(): boolean;
  55048. /**
  55049. * Enable or disable the frame time capture
  55050. */
  55051. set captureFrameTime(value: boolean);
  55052. /**
  55053. * Gets the perf counter used for inter-frames time capture
  55054. */
  55055. get interFrameTimeCounter(): PerfCounter;
  55056. /**
  55057. * Gets the inter-frames time capture status
  55058. */
  55059. get captureInterFrameTime(): boolean;
  55060. /**
  55061. * Enable or disable the inter-frames time capture
  55062. */
  55063. set captureInterFrameTime(value: boolean);
  55064. /**
  55065. * Gets the perf counter used for render time capture
  55066. */
  55067. get renderTimeCounter(): PerfCounter;
  55068. /**
  55069. * Gets the render time capture status
  55070. */
  55071. get captureRenderTime(): boolean;
  55072. /**
  55073. * Enable or disable the render time capture
  55074. */
  55075. set captureRenderTime(value: boolean);
  55076. /**
  55077. * Gets the perf counter used for camera render time capture
  55078. */
  55079. get cameraRenderTimeCounter(): PerfCounter;
  55080. /**
  55081. * Gets the camera render time capture status
  55082. */
  55083. get captureCameraRenderTime(): boolean;
  55084. /**
  55085. * Enable or disable the camera render time capture
  55086. */
  55087. set captureCameraRenderTime(value: boolean);
  55088. /**
  55089. * Gets the perf counter used for draw calls
  55090. */
  55091. get drawCallsCounter(): PerfCounter;
  55092. /**
  55093. * Instantiates a new scene instrumentation.
  55094. * This class can be used to get instrumentation data from a Babylon engine
  55095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55096. * @param scene Defines the scene to instrument
  55097. */
  55098. constructor(
  55099. /**
  55100. * Defines the scene to instrument
  55101. */
  55102. scene: Scene);
  55103. /**
  55104. * Dispose and release associated resources.
  55105. */
  55106. dispose(): void;
  55107. }
  55108. }
  55109. declare module "babylonjs/Instrumentation/index" {
  55110. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55111. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55112. export * from "babylonjs/Instrumentation/timeToken";
  55113. }
  55114. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55115. /** @hidden */
  55116. export var glowMapGenerationPixelShader: {
  55117. name: string;
  55118. shader: string;
  55119. };
  55120. }
  55121. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55122. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55124. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55125. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55126. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55127. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55128. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55129. /** @hidden */
  55130. export var glowMapGenerationVertexShader: {
  55131. name: string;
  55132. shader: string;
  55133. };
  55134. }
  55135. declare module "babylonjs/Layers/effectLayer" {
  55136. import { Observable } from "babylonjs/Misc/observable";
  55137. import { Nullable } from "babylonjs/types";
  55138. import { Camera } from "babylonjs/Cameras/camera";
  55139. import { Scene } from "babylonjs/scene";
  55140. import { ISize } from "babylonjs/Maths/math.size";
  55141. import { Color4 } from "babylonjs/Maths/math.color";
  55142. import { Engine } from "babylonjs/Engines/engine";
  55143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55145. import { Mesh } from "babylonjs/Meshes/mesh";
  55146. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55148. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55149. import { Effect } from "babylonjs/Materials/effect";
  55150. import { Material } from "babylonjs/Materials/material";
  55151. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55152. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55153. /**
  55154. * Effect layer options. This helps customizing the behaviour
  55155. * of the effect layer.
  55156. */
  55157. export interface IEffectLayerOptions {
  55158. /**
  55159. * Multiplication factor apply to the canvas size to compute the render target size
  55160. * used to generated the objects (the smaller the faster).
  55161. */
  55162. mainTextureRatio: number;
  55163. /**
  55164. * Enforces a fixed size texture to ensure effect stability across devices.
  55165. */
  55166. mainTextureFixedSize?: number;
  55167. /**
  55168. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55169. */
  55170. alphaBlendingMode: number;
  55171. /**
  55172. * The camera attached to the layer.
  55173. */
  55174. camera: Nullable<Camera>;
  55175. /**
  55176. * The rendering group to draw the layer in.
  55177. */
  55178. renderingGroupId: number;
  55179. }
  55180. /**
  55181. * The effect layer Helps adding post process effect blended with the main pass.
  55182. *
  55183. * This can be for instance use to generate glow or higlight effects on the scene.
  55184. *
  55185. * The effect layer class can not be used directly and is intented to inherited from to be
  55186. * customized per effects.
  55187. */
  55188. export abstract class EffectLayer {
  55189. private _vertexBuffers;
  55190. private _indexBuffer;
  55191. private _cachedDefines;
  55192. private _effectLayerMapGenerationEffect;
  55193. private _effectLayerOptions;
  55194. private _mergeEffect;
  55195. protected _scene: Scene;
  55196. protected _engine: Engine;
  55197. protected _maxSize: number;
  55198. protected _mainTextureDesiredSize: ISize;
  55199. protected _mainTexture: RenderTargetTexture;
  55200. protected _shouldRender: boolean;
  55201. protected _postProcesses: PostProcess[];
  55202. protected _textures: BaseTexture[];
  55203. protected _emissiveTextureAndColor: {
  55204. texture: Nullable<BaseTexture>;
  55205. color: Color4;
  55206. };
  55207. /**
  55208. * The name of the layer
  55209. */
  55210. name: string;
  55211. /**
  55212. * The clear color of the texture used to generate the glow map.
  55213. */
  55214. neutralColor: Color4;
  55215. /**
  55216. * Specifies whether the highlight layer is enabled or not.
  55217. */
  55218. isEnabled: boolean;
  55219. /**
  55220. * Gets the camera attached to the layer.
  55221. */
  55222. get camera(): Nullable<Camera>;
  55223. /**
  55224. * Gets the rendering group id the layer should render in.
  55225. */
  55226. get renderingGroupId(): number;
  55227. set renderingGroupId(renderingGroupId: number);
  55228. /**
  55229. * An event triggered when the effect layer has been disposed.
  55230. */
  55231. onDisposeObservable: Observable<EffectLayer>;
  55232. /**
  55233. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55234. */
  55235. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55236. /**
  55237. * An event triggered when the generated texture is being merged in the scene.
  55238. */
  55239. onBeforeComposeObservable: Observable<EffectLayer>;
  55240. /**
  55241. * An event triggered when the mesh is rendered into the effect render target.
  55242. */
  55243. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55244. /**
  55245. * An event triggered after the mesh has been rendered into the effect render target.
  55246. */
  55247. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55248. /**
  55249. * An event triggered when the generated texture has been merged in the scene.
  55250. */
  55251. onAfterComposeObservable: Observable<EffectLayer>;
  55252. /**
  55253. * An event triggered when the efffect layer changes its size.
  55254. */
  55255. onSizeChangedObservable: Observable<EffectLayer>;
  55256. /** @hidden */
  55257. static _SceneComponentInitialization: (scene: Scene) => void;
  55258. /**
  55259. * Instantiates a new effect Layer and references it in the scene.
  55260. * @param name The name of the layer
  55261. * @param scene The scene to use the layer in
  55262. */
  55263. constructor(
  55264. /** The Friendly of the effect in the scene */
  55265. name: string, scene: Scene);
  55266. /**
  55267. * Get the effect name of the layer.
  55268. * @return The effect name
  55269. */
  55270. abstract getEffectName(): string;
  55271. /**
  55272. * Checks for the readiness of the element composing the layer.
  55273. * @param subMesh the mesh to check for
  55274. * @param useInstances specify whether or not to use instances to render the mesh
  55275. * @return true if ready otherwise, false
  55276. */
  55277. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55278. /**
  55279. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55280. * @returns true if the effect requires stencil during the main canvas render pass.
  55281. */
  55282. abstract needStencil(): boolean;
  55283. /**
  55284. * Create the merge effect. This is the shader use to blit the information back
  55285. * to the main canvas at the end of the scene rendering.
  55286. * @returns The effect containing the shader used to merge the effect on the main canvas
  55287. */
  55288. protected abstract _createMergeEffect(): Effect;
  55289. /**
  55290. * Creates the render target textures and post processes used in the effect layer.
  55291. */
  55292. protected abstract _createTextureAndPostProcesses(): void;
  55293. /**
  55294. * Implementation specific of rendering the generating effect on the main canvas.
  55295. * @param effect The effect used to render through
  55296. */
  55297. protected abstract _internalRender(effect: Effect): void;
  55298. /**
  55299. * Sets the required values for both the emissive texture and and the main color.
  55300. */
  55301. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55302. /**
  55303. * Free any resources and references associated to a mesh.
  55304. * Internal use
  55305. * @param mesh The mesh to free.
  55306. */
  55307. abstract _disposeMesh(mesh: Mesh): void;
  55308. /**
  55309. * Serializes this layer (Glow or Highlight for example)
  55310. * @returns a serialized layer object
  55311. */
  55312. abstract serialize?(): any;
  55313. /**
  55314. * Initializes the effect layer with the required options.
  55315. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55316. */
  55317. protected _init(options: Partial<IEffectLayerOptions>): void;
  55318. /**
  55319. * Generates the index buffer of the full screen quad blending to the main canvas.
  55320. */
  55321. private _generateIndexBuffer;
  55322. /**
  55323. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55324. */
  55325. private _generateVertexBuffer;
  55326. /**
  55327. * Sets the main texture desired size which is the closest power of two
  55328. * of the engine canvas size.
  55329. */
  55330. private _setMainTextureSize;
  55331. /**
  55332. * Creates the main texture for the effect layer.
  55333. */
  55334. protected _createMainTexture(): void;
  55335. /**
  55336. * Adds specific effects defines.
  55337. * @param defines The defines to add specifics to.
  55338. */
  55339. protected _addCustomEffectDefines(defines: string[]): void;
  55340. /**
  55341. * Checks for the readiness of the element composing the layer.
  55342. * @param subMesh the mesh to check for
  55343. * @param useInstances specify whether or not to use instances to render the mesh
  55344. * @param emissiveTexture the associated emissive texture used to generate the glow
  55345. * @return true if ready otherwise, false
  55346. */
  55347. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55348. /**
  55349. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55350. */
  55351. render(): void;
  55352. /**
  55353. * Determine if a given mesh will be used in the current effect.
  55354. * @param mesh mesh to test
  55355. * @returns true if the mesh will be used
  55356. */
  55357. hasMesh(mesh: AbstractMesh): boolean;
  55358. /**
  55359. * Returns true if the layer contains information to display, otherwise false.
  55360. * @returns true if the glow layer should be rendered
  55361. */
  55362. shouldRender(): boolean;
  55363. /**
  55364. * Returns true if the mesh should render, otherwise false.
  55365. * @param mesh The mesh to render
  55366. * @returns true if it should render otherwise false
  55367. */
  55368. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55369. /**
  55370. * Returns true if the mesh can be rendered, otherwise false.
  55371. * @param mesh The mesh to render
  55372. * @param material The material used on the mesh
  55373. * @returns true if it can be rendered otherwise false
  55374. */
  55375. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55376. /**
  55377. * Returns true if the mesh should render, otherwise false.
  55378. * @param mesh The mesh to render
  55379. * @returns true if it should render otherwise false
  55380. */
  55381. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55382. /**
  55383. * Renders the submesh passed in parameter to the generation map.
  55384. */
  55385. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55386. /**
  55387. * Defines whether the current material of the mesh should be use to render the effect.
  55388. * @param mesh defines the current mesh to render
  55389. */
  55390. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55391. /**
  55392. * Rebuild the required buffers.
  55393. * @hidden Internal use only.
  55394. */
  55395. _rebuild(): void;
  55396. /**
  55397. * Dispose only the render target textures and post process.
  55398. */
  55399. private _disposeTextureAndPostProcesses;
  55400. /**
  55401. * Dispose the highlight layer and free resources.
  55402. */
  55403. dispose(): void;
  55404. /**
  55405. * Gets the class name of the effect layer
  55406. * @returns the string with the class name of the effect layer
  55407. */
  55408. getClassName(): string;
  55409. /**
  55410. * Creates an effect layer from parsed effect layer data
  55411. * @param parsedEffectLayer defines effect layer data
  55412. * @param scene defines the current scene
  55413. * @param rootUrl defines the root URL containing the effect layer information
  55414. * @returns a parsed effect Layer
  55415. */
  55416. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55417. }
  55418. }
  55419. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55420. import { Scene } from "babylonjs/scene";
  55421. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55422. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55423. import { AbstractScene } from "babylonjs/abstractScene";
  55424. module "babylonjs/abstractScene" {
  55425. interface AbstractScene {
  55426. /**
  55427. * The list of effect layers (highlights/glow) added to the scene
  55428. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55429. * @see http://doc.babylonjs.com/how_to/glow_layer
  55430. */
  55431. effectLayers: Array<EffectLayer>;
  55432. /**
  55433. * Removes the given effect layer from this scene.
  55434. * @param toRemove defines the effect layer to remove
  55435. * @returns the index of the removed effect layer
  55436. */
  55437. removeEffectLayer(toRemove: EffectLayer): number;
  55438. /**
  55439. * Adds the given effect layer to this scene
  55440. * @param newEffectLayer defines the effect layer to add
  55441. */
  55442. addEffectLayer(newEffectLayer: EffectLayer): void;
  55443. }
  55444. }
  55445. /**
  55446. * Defines the layer scene component responsible to manage any effect layers
  55447. * in a given scene.
  55448. */
  55449. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55450. /**
  55451. * The component name helpfull to identify the component in the list of scene components.
  55452. */
  55453. readonly name: string;
  55454. /**
  55455. * The scene the component belongs to.
  55456. */
  55457. scene: Scene;
  55458. private _engine;
  55459. private _renderEffects;
  55460. private _needStencil;
  55461. private _previousStencilState;
  55462. /**
  55463. * Creates a new instance of the component for the given scene
  55464. * @param scene Defines the scene to register the component in
  55465. */
  55466. constructor(scene: Scene);
  55467. /**
  55468. * Registers the component in a given scene
  55469. */
  55470. register(): void;
  55471. /**
  55472. * Rebuilds the elements related to this component in case of
  55473. * context lost for instance.
  55474. */
  55475. rebuild(): void;
  55476. /**
  55477. * Serializes the component data to the specified json object
  55478. * @param serializationObject The object to serialize to
  55479. */
  55480. serialize(serializationObject: any): void;
  55481. /**
  55482. * Adds all the elements from the container to the scene
  55483. * @param container the container holding the elements
  55484. */
  55485. addFromContainer(container: AbstractScene): void;
  55486. /**
  55487. * Removes all the elements in the container from the scene
  55488. * @param container contains the elements to remove
  55489. * @param dispose if the removed element should be disposed (default: false)
  55490. */
  55491. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55492. /**
  55493. * Disposes the component and the associated ressources.
  55494. */
  55495. dispose(): void;
  55496. private _isReadyForMesh;
  55497. private _renderMainTexture;
  55498. private _setStencil;
  55499. private _setStencilBack;
  55500. private _draw;
  55501. private _drawCamera;
  55502. private _drawRenderingGroup;
  55503. }
  55504. }
  55505. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55506. /** @hidden */
  55507. export var glowMapMergePixelShader: {
  55508. name: string;
  55509. shader: string;
  55510. };
  55511. }
  55512. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55513. /** @hidden */
  55514. export var glowMapMergeVertexShader: {
  55515. name: string;
  55516. shader: string;
  55517. };
  55518. }
  55519. declare module "babylonjs/Layers/glowLayer" {
  55520. import { Nullable } from "babylonjs/types";
  55521. import { Camera } from "babylonjs/Cameras/camera";
  55522. import { Scene } from "babylonjs/scene";
  55523. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55525. import { Mesh } from "babylonjs/Meshes/mesh";
  55526. import { Texture } from "babylonjs/Materials/Textures/texture";
  55527. import { Effect } from "babylonjs/Materials/effect";
  55528. import { Material } from "babylonjs/Materials/material";
  55529. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55530. import { Color4 } from "babylonjs/Maths/math.color";
  55531. import "babylonjs/Shaders/glowMapMerge.fragment";
  55532. import "babylonjs/Shaders/glowMapMerge.vertex";
  55533. import "babylonjs/Layers/effectLayerSceneComponent";
  55534. module "babylonjs/abstractScene" {
  55535. interface AbstractScene {
  55536. /**
  55537. * Return a the first highlight layer of the scene with a given name.
  55538. * @param name The name of the highlight layer to look for.
  55539. * @return The highlight layer if found otherwise null.
  55540. */
  55541. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55542. }
  55543. }
  55544. /**
  55545. * Glow layer options. This helps customizing the behaviour
  55546. * of the glow layer.
  55547. */
  55548. export interface IGlowLayerOptions {
  55549. /**
  55550. * Multiplication factor apply to the canvas size to compute the render target size
  55551. * used to generated the glowing objects (the smaller the faster).
  55552. */
  55553. mainTextureRatio: number;
  55554. /**
  55555. * Enforces a fixed size texture to ensure resize independant blur.
  55556. */
  55557. mainTextureFixedSize?: number;
  55558. /**
  55559. * How big is the kernel of the blur texture.
  55560. */
  55561. blurKernelSize: number;
  55562. /**
  55563. * The camera attached to the layer.
  55564. */
  55565. camera: Nullable<Camera>;
  55566. /**
  55567. * Enable MSAA by chosing the number of samples.
  55568. */
  55569. mainTextureSamples?: number;
  55570. /**
  55571. * The rendering group to draw the layer in.
  55572. */
  55573. renderingGroupId: number;
  55574. }
  55575. /**
  55576. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55577. *
  55578. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55579. *
  55580. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55581. */
  55582. export class GlowLayer extends EffectLayer {
  55583. /**
  55584. * Effect Name of the layer.
  55585. */
  55586. static readonly EffectName: string;
  55587. /**
  55588. * The default blur kernel size used for the glow.
  55589. */
  55590. static DefaultBlurKernelSize: number;
  55591. /**
  55592. * The default texture size ratio used for the glow.
  55593. */
  55594. static DefaultTextureRatio: number;
  55595. /**
  55596. * Sets the kernel size of the blur.
  55597. */
  55598. set blurKernelSize(value: number);
  55599. /**
  55600. * Gets the kernel size of the blur.
  55601. */
  55602. get blurKernelSize(): number;
  55603. /**
  55604. * Sets the glow intensity.
  55605. */
  55606. set intensity(value: number);
  55607. /**
  55608. * Gets the glow intensity.
  55609. */
  55610. get intensity(): number;
  55611. private _options;
  55612. private _intensity;
  55613. private _horizontalBlurPostprocess1;
  55614. private _verticalBlurPostprocess1;
  55615. private _horizontalBlurPostprocess2;
  55616. private _verticalBlurPostprocess2;
  55617. private _blurTexture1;
  55618. private _blurTexture2;
  55619. private _postProcesses1;
  55620. private _postProcesses2;
  55621. private _includedOnlyMeshes;
  55622. private _excludedMeshes;
  55623. private _meshesUsingTheirOwnMaterials;
  55624. /**
  55625. * Callback used to let the user override the color selection on a per mesh basis
  55626. */
  55627. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55628. /**
  55629. * Callback used to let the user override the texture selection on a per mesh basis
  55630. */
  55631. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55632. /**
  55633. * Instantiates a new glow Layer and references it to the scene.
  55634. * @param name The name of the layer
  55635. * @param scene The scene to use the layer in
  55636. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55637. */
  55638. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55639. /**
  55640. * Get the effect name of the layer.
  55641. * @return The effect name
  55642. */
  55643. getEffectName(): string;
  55644. /**
  55645. * Create the merge effect. This is the shader use to blit the information back
  55646. * to the main canvas at the end of the scene rendering.
  55647. */
  55648. protected _createMergeEffect(): Effect;
  55649. /**
  55650. * Creates the render target textures and post processes used in the glow layer.
  55651. */
  55652. protected _createTextureAndPostProcesses(): void;
  55653. /**
  55654. * Checks for the readiness of the element composing the layer.
  55655. * @param subMesh the mesh to check for
  55656. * @param useInstances specify wether or not to use instances to render the mesh
  55657. * @param emissiveTexture the associated emissive texture used to generate the glow
  55658. * @return true if ready otherwise, false
  55659. */
  55660. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55661. /**
  55662. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55663. */
  55664. needStencil(): boolean;
  55665. /**
  55666. * Returns true if the mesh can be rendered, otherwise false.
  55667. * @param mesh The mesh to render
  55668. * @param material The material used on the mesh
  55669. * @returns true if it can be rendered otherwise false
  55670. */
  55671. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55672. /**
  55673. * Implementation specific of rendering the generating effect on the main canvas.
  55674. * @param effect The effect used to render through
  55675. */
  55676. protected _internalRender(effect: Effect): void;
  55677. /**
  55678. * Sets the required values for both the emissive texture and and the main color.
  55679. */
  55680. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55681. /**
  55682. * Returns true if the mesh should render, otherwise false.
  55683. * @param mesh The mesh to render
  55684. * @returns true if it should render otherwise false
  55685. */
  55686. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55687. /**
  55688. * Adds specific effects defines.
  55689. * @param defines The defines to add specifics to.
  55690. */
  55691. protected _addCustomEffectDefines(defines: string[]): void;
  55692. /**
  55693. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55694. * @param mesh The mesh to exclude from the glow layer
  55695. */
  55696. addExcludedMesh(mesh: Mesh): void;
  55697. /**
  55698. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55699. * @param mesh The mesh to remove
  55700. */
  55701. removeExcludedMesh(mesh: Mesh): void;
  55702. /**
  55703. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55704. * @param mesh The mesh to include in the glow layer
  55705. */
  55706. addIncludedOnlyMesh(mesh: Mesh): void;
  55707. /**
  55708. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55709. * @param mesh The mesh to remove
  55710. */
  55711. removeIncludedOnlyMesh(mesh: Mesh): void;
  55712. /**
  55713. * Determine if a given mesh will be used in the glow layer
  55714. * @param mesh The mesh to test
  55715. * @returns true if the mesh will be highlighted by the current glow layer
  55716. */
  55717. hasMesh(mesh: AbstractMesh): boolean;
  55718. /**
  55719. * Defines whether the current material of the mesh should be use to render the effect.
  55720. * @param mesh defines the current mesh to render
  55721. */
  55722. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55723. /**
  55724. * Add a mesh to be rendered through its own material and not with emissive only.
  55725. * @param mesh The mesh for which we need to use its material
  55726. */
  55727. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55728. /**
  55729. * Remove a mesh from being rendered through its own material and not with emissive only.
  55730. * @param mesh The mesh for which we need to not use its material
  55731. */
  55732. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55733. /**
  55734. * Free any resources and references associated to a mesh.
  55735. * Internal use
  55736. * @param mesh The mesh to free.
  55737. * @hidden
  55738. */
  55739. _disposeMesh(mesh: Mesh): void;
  55740. /**
  55741. * Gets the class name of the effect layer
  55742. * @returns the string with the class name of the effect layer
  55743. */
  55744. getClassName(): string;
  55745. /**
  55746. * Serializes this glow layer
  55747. * @returns a serialized glow layer object
  55748. */
  55749. serialize(): any;
  55750. /**
  55751. * Creates a Glow Layer from parsed glow layer data
  55752. * @param parsedGlowLayer defines glow layer data
  55753. * @param scene defines the current scene
  55754. * @param rootUrl defines the root URL containing the glow layer information
  55755. * @returns a parsed Glow Layer
  55756. */
  55757. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55758. }
  55759. }
  55760. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55761. /** @hidden */
  55762. export var glowBlurPostProcessPixelShader: {
  55763. name: string;
  55764. shader: string;
  55765. };
  55766. }
  55767. declare module "babylonjs/Layers/highlightLayer" {
  55768. import { Observable } from "babylonjs/Misc/observable";
  55769. import { Nullable } from "babylonjs/types";
  55770. import { Camera } from "babylonjs/Cameras/camera";
  55771. import { Scene } from "babylonjs/scene";
  55772. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55774. import { Mesh } from "babylonjs/Meshes/mesh";
  55775. import { Effect } from "babylonjs/Materials/effect";
  55776. import { Material } from "babylonjs/Materials/material";
  55777. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55778. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55779. import "babylonjs/Shaders/glowMapMerge.fragment";
  55780. import "babylonjs/Shaders/glowMapMerge.vertex";
  55781. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55782. module "babylonjs/abstractScene" {
  55783. interface AbstractScene {
  55784. /**
  55785. * Return a the first highlight layer of the scene with a given name.
  55786. * @param name The name of the highlight layer to look for.
  55787. * @return The highlight layer if found otherwise null.
  55788. */
  55789. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55790. }
  55791. }
  55792. /**
  55793. * Highlight layer options. This helps customizing the behaviour
  55794. * of the highlight layer.
  55795. */
  55796. export interface IHighlightLayerOptions {
  55797. /**
  55798. * Multiplication factor apply to the canvas size to compute the render target size
  55799. * used to generated the glowing objects (the smaller the faster).
  55800. */
  55801. mainTextureRatio: number;
  55802. /**
  55803. * Enforces a fixed size texture to ensure resize independant blur.
  55804. */
  55805. mainTextureFixedSize?: number;
  55806. /**
  55807. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55808. * of the picture to blur (the smaller the faster).
  55809. */
  55810. blurTextureSizeRatio: number;
  55811. /**
  55812. * How big in texel of the blur texture is the vertical blur.
  55813. */
  55814. blurVerticalSize: number;
  55815. /**
  55816. * How big in texel of the blur texture is the horizontal blur.
  55817. */
  55818. blurHorizontalSize: number;
  55819. /**
  55820. * Alpha blending mode used to apply the blur. Default is combine.
  55821. */
  55822. alphaBlendingMode: number;
  55823. /**
  55824. * The camera attached to the layer.
  55825. */
  55826. camera: Nullable<Camera>;
  55827. /**
  55828. * Should we display highlight as a solid stroke?
  55829. */
  55830. isStroke?: boolean;
  55831. /**
  55832. * The rendering group to draw the layer in.
  55833. */
  55834. renderingGroupId: number;
  55835. }
  55836. /**
  55837. * The highlight layer Helps adding a glow effect around a mesh.
  55838. *
  55839. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55840. * glowy meshes to your scene.
  55841. *
  55842. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55843. */
  55844. export class HighlightLayer extends EffectLayer {
  55845. name: string;
  55846. /**
  55847. * Effect Name of the highlight layer.
  55848. */
  55849. static readonly EffectName: string;
  55850. /**
  55851. * The neutral color used during the preparation of the glow effect.
  55852. * This is black by default as the blend operation is a blend operation.
  55853. */
  55854. static NeutralColor: Color4;
  55855. /**
  55856. * Stencil value used for glowing meshes.
  55857. */
  55858. static GlowingMeshStencilReference: number;
  55859. /**
  55860. * Stencil value used for the other meshes in the scene.
  55861. */
  55862. static NormalMeshStencilReference: number;
  55863. /**
  55864. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55865. */
  55866. innerGlow: boolean;
  55867. /**
  55868. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55869. */
  55870. outerGlow: boolean;
  55871. /**
  55872. * Specifies the horizontal size of the blur.
  55873. */
  55874. set blurHorizontalSize(value: number);
  55875. /**
  55876. * Specifies the vertical size of the blur.
  55877. */
  55878. set blurVerticalSize(value: number);
  55879. /**
  55880. * Gets the horizontal size of the blur.
  55881. */
  55882. get blurHorizontalSize(): number;
  55883. /**
  55884. * Gets the vertical size of the blur.
  55885. */
  55886. get blurVerticalSize(): number;
  55887. /**
  55888. * An event triggered when the highlight layer is being blurred.
  55889. */
  55890. onBeforeBlurObservable: Observable<HighlightLayer>;
  55891. /**
  55892. * An event triggered when the highlight layer has been blurred.
  55893. */
  55894. onAfterBlurObservable: Observable<HighlightLayer>;
  55895. private _instanceGlowingMeshStencilReference;
  55896. private _options;
  55897. private _downSamplePostprocess;
  55898. private _horizontalBlurPostprocess;
  55899. private _verticalBlurPostprocess;
  55900. private _blurTexture;
  55901. private _meshes;
  55902. private _excludedMeshes;
  55903. /**
  55904. * Instantiates a new highlight Layer and references it to the scene..
  55905. * @param name The name of the layer
  55906. * @param scene The scene to use the layer in
  55907. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55908. */
  55909. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55910. /**
  55911. * Get the effect name of the layer.
  55912. * @return The effect name
  55913. */
  55914. getEffectName(): string;
  55915. /**
  55916. * Create the merge effect. This is the shader use to blit the information back
  55917. * to the main canvas at the end of the scene rendering.
  55918. */
  55919. protected _createMergeEffect(): Effect;
  55920. /**
  55921. * Creates the render target textures and post processes used in the highlight layer.
  55922. */
  55923. protected _createTextureAndPostProcesses(): void;
  55924. /**
  55925. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55926. */
  55927. needStencil(): boolean;
  55928. /**
  55929. * Checks for the readiness of the element composing the layer.
  55930. * @param subMesh the mesh to check for
  55931. * @param useInstances specify wether or not to use instances to render the mesh
  55932. * @param emissiveTexture the associated emissive texture used to generate the glow
  55933. * @return true if ready otherwise, false
  55934. */
  55935. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55936. /**
  55937. * Implementation specific of rendering the generating effect on the main canvas.
  55938. * @param effect The effect used to render through
  55939. */
  55940. protected _internalRender(effect: Effect): void;
  55941. /**
  55942. * Returns true if the layer contains information to display, otherwise false.
  55943. */
  55944. shouldRender(): boolean;
  55945. /**
  55946. * Returns true if the mesh should render, otherwise false.
  55947. * @param mesh The mesh to render
  55948. * @returns true if it should render otherwise false
  55949. */
  55950. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55951. /**
  55952. * Sets the required values for both the emissive texture and and the main color.
  55953. */
  55954. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55955. /**
  55956. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55957. * @param mesh The mesh to exclude from the highlight layer
  55958. */
  55959. addExcludedMesh(mesh: Mesh): void;
  55960. /**
  55961. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55962. * @param mesh The mesh to highlight
  55963. */
  55964. removeExcludedMesh(mesh: Mesh): void;
  55965. /**
  55966. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55967. * @param mesh mesh to test
  55968. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55969. */
  55970. hasMesh(mesh: AbstractMesh): boolean;
  55971. /**
  55972. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55973. * @param mesh The mesh to highlight
  55974. * @param color The color of the highlight
  55975. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55976. */
  55977. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55978. /**
  55979. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55980. * @param mesh The mesh to highlight
  55981. */
  55982. removeMesh(mesh: Mesh): void;
  55983. /**
  55984. * Remove all the meshes currently referenced in the highlight layer
  55985. */
  55986. removeAllMeshes(): void;
  55987. /**
  55988. * Force the stencil to the normal expected value for none glowing parts
  55989. */
  55990. private _defaultStencilReference;
  55991. /**
  55992. * Free any resources and references associated to a mesh.
  55993. * Internal use
  55994. * @param mesh The mesh to free.
  55995. * @hidden
  55996. */
  55997. _disposeMesh(mesh: Mesh): void;
  55998. /**
  55999. * Dispose the highlight layer and free resources.
  56000. */
  56001. dispose(): void;
  56002. /**
  56003. * Gets the class name of the effect layer
  56004. * @returns the string with the class name of the effect layer
  56005. */
  56006. getClassName(): string;
  56007. /**
  56008. * Serializes this Highlight layer
  56009. * @returns a serialized Highlight layer object
  56010. */
  56011. serialize(): any;
  56012. /**
  56013. * Creates a Highlight layer from parsed Highlight layer data
  56014. * @param parsedHightlightLayer defines the Highlight layer data
  56015. * @param scene defines the current scene
  56016. * @param rootUrl defines the root URL containing the Highlight layer information
  56017. * @returns a parsed Highlight layer
  56018. */
  56019. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56020. }
  56021. }
  56022. declare module "babylonjs/Layers/layerSceneComponent" {
  56023. import { Scene } from "babylonjs/scene";
  56024. import { ISceneComponent } from "babylonjs/sceneComponent";
  56025. import { Layer } from "babylonjs/Layers/layer";
  56026. import { AbstractScene } from "babylonjs/abstractScene";
  56027. module "babylonjs/abstractScene" {
  56028. interface AbstractScene {
  56029. /**
  56030. * The list of layers (background and foreground) of the scene
  56031. */
  56032. layers: Array<Layer>;
  56033. }
  56034. }
  56035. /**
  56036. * Defines the layer scene component responsible to manage any layers
  56037. * in a given scene.
  56038. */
  56039. export class LayerSceneComponent implements ISceneComponent {
  56040. /**
  56041. * The component name helpfull to identify the component in the list of scene components.
  56042. */
  56043. readonly name: string;
  56044. /**
  56045. * The scene the component belongs to.
  56046. */
  56047. scene: Scene;
  56048. private _engine;
  56049. /**
  56050. * Creates a new instance of the component for the given scene
  56051. * @param scene Defines the scene to register the component in
  56052. */
  56053. constructor(scene: Scene);
  56054. /**
  56055. * Registers the component in a given scene
  56056. */
  56057. register(): void;
  56058. /**
  56059. * Rebuilds the elements related to this component in case of
  56060. * context lost for instance.
  56061. */
  56062. rebuild(): void;
  56063. /**
  56064. * Disposes the component and the associated ressources.
  56065. */
  56066. dispose(): void;
  56067. private _draw;
  56068. private _drawCameraPredicate;
  56069. private _drawCameraBackground;
  56070. private _drawCameraForeground;
  56071. private _drawRenderTargetPredicate;
  56072. private _drawRenderTargetBackground;
  56073. private _drawRenderTargetForeground;
  56074. /**
  56075. * Adds all the elements from the container to the scene
  56076. * @param container the container holding the elements
  56077. */
  56078. addFromContainer(container: AbstractScene): void;
  56079. /**
  56080. * Removes all the elements in the container from the scene
  56081. * @param container contains the elements to remove
  56082. * @param dispose if the removed element should be disposed (default: false)
  56083. */
  56084. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56085. }
  56086. }
  56087. declare module "babylonjs/Shaders/layer.fragment" {
  56088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56089. /** @hidden */
  56090. export var layerPixelShader: {
  56091. name: string;
  56092. shader: string;
  56093. };
  56094. }
  56095. declare module "babylonjs/Shaders/layer.vertex" {
  56096. /** @hidden */
  56097. export var layerVertexShader: {
  56098. name: string;
  56099. shader: string;
  56100. };
  56101. }
  56102. declare module "babylonjs/Layers/layer" {
  56103. import { Observable } from "babylonjs/Misc/observable";
  56104. import { Nullable } from "babylonjs/types";
  56105. import { Scene } from "babylonjs/scene";
  56106. import { Vector2 } from "babylonjs/Maths/math.vector";
  56107. import { Color4 } from "babylonjs/Maths/math.color";
  56108. import { Texture } from "babylonjs/Materials/Textures/texture";
  56109. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56110. import "babylonjs/Shaders/layer.fragment";
  56111. import "babylonjs/Shaders/layer.vertex";
  56112. /**
  56113. * This represents a full screen 2d layer.
  56114. * This can be useful to display a picture in the background of your scene for instance.
  56115. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56116. */
  56117. export class Layer {
  56118. /**
  56119. * Define the name of the layer.
  56120. */
  56121. name: string;
  56122. /**
  56123. * Define the texture the layer should display.
  56124. */
  56125. texture: Nullable<Texture>;
  56126. /**
  56127. * Is the layer in background or foreground.
  56128. */
  56129. isBackground: boolean;
  56130. /**
  56131. * Define the color of the layer (instead of texture).
  56132. */
  56133. color: Color4;
  56134. /**
  56135. * Define the scale of the layer in order to zoom in out of the texture.
  56136. */
  56137. scale: Vector2;
  56138. /**
  56139. * Define an offset for the layer in order to shift the texture.
  56140. */
  56141. offset: Vector2;
  56142. /**
  56143. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56144. */
  56145. alphaBlendingMode: number;
  56146. /**
  56147. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56148. * Alpha test will not mix with the background color in case of transparency.
  56149. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56150. */
  56151. alphaTest: boolean;
  56152. /**
  56153. * Define a mask to restrict the layer to only some of the scene cameras.
  56154. */
  56155. layerMask: number;
  56156. /**
  56157. * Define the list of render target the layer is visible into.
  56158. */
  56159. renderTargetTextures: RenderTargetTexture[];
  56160. /**
  56161. * Define if the layer is only used in renderTarget or if it also
  56162. * renders in the main frame buffer of the canvas.
  56163. */
  56164. renderOnlyInRenderTargetTextures: boolean;
  56165. private _scene;
  56166. private _vertexBuffers;
  56167. private _indexBuffer;
  56168. private _effect;
  56169. private _previousDefines;
  56170. /**
  56171. * An event triggered when the layer is disposed.
  56172. */
  56173. onDisposeObservable: Observable<Layer>;
  56174. private _onDisposeObserver;
  56175. /**
  56176. * Back compatibility with callback before the onDisposeObservable existed.
  56177. * The set callback will be triggered when the layer has been disposed.
  56178. */
  56179. set onDispose(callback: () => void);
  56180. /**
  56181. * An event triggered before rendering the scene
  56182. */
  56183. onBeforeRenderObservable: Observable<Layer>;
  56184. private _onBeforeRenderObserver;
  56185. /**
  56186. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56187. * The set callback will be triggered just before rendering the layer.
  56188. */
  56189. set onBeforeRender(callback: () => void);
  56190. /**
  56191. * An event triggered after rendering the scene
  56192. */
  56193. onAfterRenderObservable: Observable<Layer>;
  56194. private _onAfterRenderObserver;
  56195. /**
  56196. * Back compatibility with callback before the onAfterRenderObservable existed.
  56197. * The set callback will be triggered just after rendering the layer.
  56198. */
  56199. set onAfterRender(callback: () => void);
  56200. /**
  56201. * Instantiates a new layer.
  56202. * This represents a full screen 2d layer.
  56203. * This can be useful to display a picture in the background of your scene for instance.
  56204. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56205. * @param name Define the name of the layer in the scene
  56206. * @param imgUrl Define the url of the texture to display in the layer
  56207. * @param scene Define the scene the layer belongs to
  56208. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56209. * @param color Defines a color for the layer
  56210. */
  56211. constructor(
  56212. /**
  56213. * Define the name of the layer.
  56214. */
  56215. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56216. private _createIndexBuffer;
  56217. /** @hidden */
  56218. _rebuild(): void;
  56219. /**
  56220. * Renders the layer in the scene.
  56221. */
  56222. render(): void;
  56223. /**
  56224. * Disposes and releases the associated ressources.
  56225. */
  56226. dispose(): void;
  56227. }
  56228. }
  56229. declare module "babylonjs/Layers/index" {
  56230. export * from "babylonjs/Layers/effectLayer";
  56231. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56232. export * from "babylonjs/Layers/glowLayer";
  56233. export * from "babylonjs/Layers/highlightLayer";
  56234. export * from "babylonjs/Layers/layer";
  56235. export * from "babylonjs/Layers/layerSceneComponent";
  56236. }
  56237. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56238. /** @hidden */
  56239. export var lensFlarePixelShader: {
  56240. name: string;
  56241. shader: string;
  56242. };
  56243. }
  56244. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56245. /** @hidden */
  56246. export var lensFlareVertexShader: {
  56247. name: string;
  56248. shader: string;
  56249. };
  56250. }
  56251. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56252. import { Scene } from "babylonjs/scene";
  56253. import { Vector3 } from "babylonjs/Maths/math.vector";
  56254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56255. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56256. import "babylonjs/Shaders/lensFlare.fragment";
  56257. import "babylonjs/Shaders/lensFlare.vertex";
  56258. import { Viewport } from "babylonjs/Maths/math.viewport";
  56259. /**
  56260. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56261. * It is usually composed of several `lensFlare`.
  56262. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56263. */
  56264. export class LensFlareSystem {
  56265. /**
  56266. * Define the name of the lens flare system
  56267. */
  56268. name: string;
  56269. /**
  56270. * List of lens flares used in this system.
  56271. */
  56272. lensFlares: LensFlare[];
  56273. /**
  56274. * Define a limit from the border the lens flare can be visible.
  56275. */
  56276. borderLimit: number;
  56277. /**
  56278. * Define a viewport border we do not want to see the lens flare in.
  56279. */
  56280. viewportBorder: number;
  56281. /**
  56282. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56283. */
  56284. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56285. /**
  56286. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56287. */
  56288. layerMask: number;
  56289. /**
  56290. * Define the id of the lens flare system in the scene.
  56291. * (equal to name by default)
  56292. */
  56293. id: string;
  56294. private _scene;
  56295. private _emitter;
  56296. private _vertexBuffers;
  56297. private _indexBuffer;
  56298. private _effect;
  56299. private _positionX;
  56300. private _positionY;
  56301. private _isEnabled;
  56302. /** @hidden */
  56303. static _SceneComponentInitialization: (scene: Scene) => void;
  56304. /**
  56305. * Instantiates a lens flare system.
  56306. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56307. * It is usually composed of several `lensFlare`.
  56308. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56309. * @param name Define the name of the lens flare system in the scene
  56310. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56311. * @param scene Define the scene the lens flare system belongs to
  56312. */
  56313. constructor(
  56314. /**
  56315. * Define the name of the lens flare system
  56316. */
  56317. name: string, emitter: any, scene: Scene);
  56318. /**
  56319. * Define if the lens flare system is enabled.
  56320. */
  56321. get isEnabled(): boolean;
  56322. set isEnabled(value: boolean);
  56323. /**
  56324. * Get the scene the effects belongs to.
  56325. * @returns the scene holding the lens flare system
  56326. */
  56327. getScene(): Scene;
  56328. /**
  56329. * Get the emitter of the lens flare system.
  56330. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56331. * @returns the emitter of the lens flare system
  56332. */
  56333. getEmitter(): any;
  56334. /**
  56335. * Set the emitter of the lens flare system.
  56336. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56337. * @param newEmitter Define the new emitter of the system
  56338. */
  56339. setEmitter(newEmitter: any): void;
  56340. /**
  56341. * Get the lens flare system emitter position.
  56342. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56343. * @returns the position
  56344. */
  56345. getEmitterPosition(): Vector3;
  56346. /**
  56347. * @hidden
  56348. */
  56349. computeEffectivePosition(globalViewport: Viewport): boolean;
  56350. /** @hidden */
  56351. _isVisible(): boolean;
  56352. /**
  56353. * @hidden
  56354. */
  56355. render(): boolean;
  56356. /**
  56357. * Dispose and release the lens flare with its associated resources.
  56358. */
  56359. dispose(): void;
  56360. /**
  56361. * Parse a lens flare system from a JSON repressentation
  56362. * @param parsedLensFlareSystem Define the JSON to parse
  56363. * @param scene Define the scene the parsed system should be instantiated in
  56364. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56365. * @returns the parsed system
  56366. */
  56367. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56368. /**
  56369. * Serialize the current Lens Flare System into a JSON representation.
  56370. * @returns the serialized JSON
  56371. */
  56372. serialize(): any;
  56373. }
  56374. }
  56375. declare module "babylonjs/LensFlares/lensFlare" {
  56376. import { Nullable } from "babylonjs/types";
  56377. import { Color3 } from "babylonjs/Maths/math.color";
  56378. import { Texture } from "babylonjs/Materials/Textures/texture";
  56379. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56380. /**
  56381. * This represents one of the lens effect in a `lensFlareSystem`.
  56382. * It controls one of the indiviual texture used in the effect.
  56383. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56384. */
  56385. export class LensFlare {
  56386. /**
  56387. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56388. */
  56389. size: number;
  56390. /**
  56391. * 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.
  56392. */
  56393. position: number;
  56394. /**
  56395. * Define the lens color.
  56396. */
  56397. color: Color3;
  56398. /**
  56399. * Define the lens texture.
  56400. */
  56401. texture: Nullable<Texture>;
  56402. /**
  56403. * Define the alpha mode to render this particular lens.
  56404. */
  56405. alphaMode: number;
  56406. private _system;
  56407. /**
  56408. * Creates a new Lens Flare.
  56409. * This represents one of the lens effect in a `lensFlareSystem`.
  56410. * It controls one of the indiviual texture used in the effect.
  56411. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56412. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56413. * @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.
  56414. * @param color Define the lens color
  56415. * @param imgUrl Define the lens texture url
  56416. * @param system Define the `lensFlareSystem` this flare is part of
  56417. * @returns The newly created Lens Flare
  56418. */
  56419. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56420. /**
  56421. * Instantiates a new Lens Flare.
  56422. * This represents one of the lens effect in a `lensFlareSystem`.
  56423. * It controls one of the indiviual texture used in the effect.
  56424. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56425. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56426. * @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.
  56427. * @param color Define the lens color
  56428. * @param imgUrl Define the lens texture url
  56429. * @param system Define the `lensFlareSystem` this flare is part of
  56430. */
  56431. constructor(
  56432. /**
  56433. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56434. */
  56435. size: number,
  56436. /**
  56437. * 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.
  56438. */
  56439. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56440. /**
  56441. * Dispose and release the lens flare with its associated resources.
  56442. */
  56443. dispose(): void;
  56444. }
  56445. }
  56446. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56447. import { Nullable } from "babylonjs/types";
  56448. import { Scene } from "babylonjs/scene";
  56449. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56450. import { AbstractScene } from "babylonjs/abstractScene";
  56451. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56452. module "babylonjs/abstractScene" {
  56453. interface AbstractScene {
  56454. /**
  56455. * The list of lens flare system added to the scene
  56456. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56457. */
  56458. lensFlareSystems: Array<LensFlareSystem>;
  56459. /**
  56460. * Removes the given lens flare system from this scene.
  56461. * @param toRemove The lens flare system to remove
  56462. * @returns The index of the removed lens flare system
  56463. */
  56464. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56465. /**
  56466. * Adds the given lens flare system to this scene
  56467. * @param newLensFlareSystem The lens flare system to add
  56468. */
  56469. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56470. /**
  56471. * Gets a lens flare system using its name
  56472. * @param name defines the name to look for
  56473. * @returns the lens flare system or null if not found
  56474. */
  56475. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56476. /**
  56477. * Gets a lens flare system using its id
  56478. * @param id defines the id to look for
  56479. * @returns the lens flare system or null if not found
  56480. */
  56481. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56482. }
  56483. }
  56484. /**
  56485. * Defines the lens flare scene component responsible to manage any lens flares
  56486. * in a given scene.
  56487. */
  56488. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56489. /**
  56490. * The component name helpfull to identify the component in the list of scene components.
  56491. */
  56492. readonly name: string;
  56493. /**
  56494. * The scene the component belongs to.
  56495. */
  56496. scene: Scene;
  56497. /**
  56498. * Creates a new instance of the component for the given scene
  56499. * @param scene Defines the scene to register the component in
  56500. */
  56501. constructor(scene: Scene);
  56502. /**
  56503. * Registers the component in a given scene
  56504. */
  56505. register(): void;
  56506. /**
  56507. * Rebuilds the elements related to this component in case of
  56508. * context lost for instance.
  56509. */
  56510. rebuild(): void;
  56511. /**
  56512. * Adds all the elements from the container to the scene
  56513. * @param container the container holding the elements
  56514. */
  56515. addFromContainer(container: AbstractScene): void;
  56516. /**
  56517. * Removes all the elements in the container from the scene
  56518. * @param container contains the elements to remove
  56519. * @param dispose if the removed element should be disposed (default: false)
  56520. */
  56521. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56522. /**
  56523. * Serializes the component data to the specified json object
  56524. * @param serializationObject The object to serialize to
  56525. */
  56526. serialize(serializationObject: any): void;
  56527. /**
  56528. * Disposes the component and the associated ressources.
  56529. */
  56530. dispose(): void;
  56531. private _draw;
  56532. }
  56533. }
  56534. declare module "babylonjs/LensFlares/index" {
  56535. export * from "babylonjs/LensFlares/lensFlare";
  56536. export * from "babylonjs/LensFlares/lensFlareSystem";
  56537. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56538. }
  56539. declare module "babylonjs/Shaders/depth.fragment" {
  56540. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56541. /** @hidden */
  56542. export var depthPixelShader: {
  56543. name: string;
  56544. shader: string;
  56545. };
  56546. }
  56547. declare module "babylonjs/Shaders/depth.vertex" {
  56548. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56551. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56553. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56554. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56555. /** @hidden */
  56556. export var depthVertexShader: {
  56557. name: string;
  56558. shader: string;
  56559. };
  56560. }
  56561. declare module "babylonjs/Rendering/depthRenderer" {
  56562. import { Nullable } from "babylonjs/types";
  56563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56564. import { Scene } from "babylonjs/scene";
  56565. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56566. import { Camera } from "babylonjs/Cameras/camera";
  56567. import "babylonjs/Shaders/depth.fragment";
  56568. import "babylonjs/Shaders/depth.vertex";
  56569. /**
  56570. * This represents a depth renderer in Babylon.
  56571. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56572. */
  56573. export class DepthRenderer {
  56574. private _scene;
  56575. private _depthMap;
  56576. private _effect;
  56577. private readonly _storeNonLinearDepth;
  56578. private readonly _clearColor;
  56579. /** Get if the depth renderer is using packed depth or not */
  56580. readonly isPacked: boolean;
  56581. private _cachedDefines;
  56582. private _camera;
  56583. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56584. enabled: boolean;
  56585. /**
  56586. * Specifiess that the depth renderer will only be used within
  56587. * the camera it is created for.
  56588. * This can help forcing its rendering during the camera processing.
  56589. */
  56590. useOnlyInActiveCamera: boolean;
  56591. /** @hidden */
  56592. static _SceneComponentInitialization: (scene: Scene) => void;
  56593. /**
  56594. * Instantiates a depth renderer
  56595. * @param scene The scene the renderer belongs to
  56596. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56597. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56598. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56599. */
  56600. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56601. /**
  56602. * Creates the depth rendering effect and checks if the effect is ready.
  56603. * @param subMesh The submesh to be used to render the depth map of
  56604. * @param useInstances If multiple world instances should be used
  56605. * @returns if the depth renderer is ready to render the depth map
  56606. */
  56607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56608. /**
  56609. * Gets the texture which the depth map will be written to.
  56610. * @returns The depth map texture
  56611. */
  56612. getDepthMap(): RenderTargetTexture;
  56613. /**
  56614. * Disposes of the depth renderer.
  56615. */
  56616. dispose(): void;
  56617. }
  56618. }
  56619. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56620. /** @hidden */
  56621. export var minmaxReduxPixelShader: {
  56622. name: string;
  56623. shader: string;
  56624. };
  56625. }
  56626. declare module "babylonjs/Misc/minMaxReducer" {
  56627. import { Nullable } from "babylonjs/types";
  56628. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56629. import { Camera } from "babylonjs/Cameras/camera";
  56630. import { Observer } from "babylonjs/Misc/observable";
  56631. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56632. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56633. import { Observable } from "babylonjs/Misc/observable";
  56634. import "babylonjs/Shaders/minmaxRedux.fragment";
  56635. /**
  56636. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56637. * and maximum values from all values of the texture.
  56638. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56639. * The source values are read from the red channel of the texture.
  56640. */
  56641. export class MinMaxReducer {
  56642. /**
  56643. * Observable triggered when the computation has been performed
  56644. */
  56645. onAfterReductionPerformed: Observable<{
  56646. min: number;
  56647. max: number;
  56648. }>;
  56649. protected _camera: Camera;
  56650. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56651. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56652. protected _postProcessManager: PostProcessManager;
  56653. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56654. protected _forceFullscreenViewport: boolean;
  56655. /**
  56656. * Creates a min/max reducer
  56657. * @param camera The camera to use for the post processes
  56658. */
  56659. constructor(camera: Camera);
  56660. /**
  56661. * Gets the texture used to read the values from.
  56662. */
  56663. get sourceTexture(): Nullable<RenderTargetTexture>;
  56664. /**
  56665. * Sets the source texture to read the values from.
  56666. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56667. * because in such textures '1' value must not be taken into account to compute the maximum
  56668. * as this value is used to clear the texture.
  56669. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56670. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56671. * @param depthRedux Indicates if the texture is a depth texture or not
  56672. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56673. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56674. */
  56675. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56676. /**
  56677. * Defines the refresh rate of the computation.
  56678. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56679. */
  56680. get refreshRate(): number;
  56681. set refreshRate(value: number);
  56682. protected _activated: boolean;
  56683. /**
  56684. * Gets the activation status of the reducer
  56685. */
  56686. get activated(): boolean;
  56687. /**
  56688. * Activates the reduction computation.
  56689. * When activated, the observers registered in onAfterReductionPerformed are
  56690. * called after the compuation is performed
  56691. */
  56692. activate(): void;
  56693. /**
  56694. * Deactivates the reduction computation.
  56695. */
  56696. deactivate(): void;
  56697. /**
  56698. * Disposes the min/max reducer
  56699. * @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.
  56700. */
  56701. dispose(disposeAll?: boolean): void;
  56702. }
  56703. }
  56704. declare module "babylonjs/Misc/depthReducer" {
  56705. import { Nullable } from "babylonjs/types";
  56706. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56707. import { Camera } from "babylonjs/Cameras/camera";
  56708. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56709. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56710. /**
  56711. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56712. */
  56713. export class DepthReducer extends MinMaxReducer {
  56714. private _depthRenderer;
  56715. private _depthRendererId;
  56716. /**
  56717. * Gets the depth renderer used for the computation.
  56718. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56719. */
  56720. get depthRenderer(): Nullable<DepthRenderer>;
  56721. /**
  56722. * Creates a depth reducer
  56723. * @param camera The camera used to render the depth texture
  56724. */
  56725. constructor(camera: Camera);
  56726. /**
  56727. * Sets the depth renderer to use to generate the depth map
  56728. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56729. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56730. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56731. */
  56732. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56733. /** @hidden */
  56734. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56735. /**
  56736. * Activates the reduction computation.
  56737. * When activated, the observers registered in onAfterReductionPerformed are
  56738. * called after the compuation is performed
  56739. */
  56740. activate(): void;
  56741. /**
  56742. * Deactivates the reduction computation.
  56743. */
  56744. deactivate(): void;
  56745. /**
  56746. * Disposes the depth reducer
  56747. * @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.
  56748. */
  56749. dispose(disposeAll?: boolean): void;
  56750. }
  56751. }
  56752. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56753. import { Nullable } from "babylonjs/types";
  56754. import { Scene } from "babylonjs/scene";
  56755. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56757. import { Effect } from "babylonjs/Materials/effect";
  56758. import "babylonjs/Shaders/shadowMap.fragment";
  56759. import "babylonjs/Shaders/shadowMap.vertex";
  56760. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56761. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56762. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56763. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56764. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56765. /**
  56766. * A CSM implementation allowing casting shadows on large scenes.
  56767. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56768. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56769. */
  56770. export class CascadedShadowGenerator extends ShadowGenerator {
  56771. private static readonly frustumCornersNDCSpace;
  56772. /**
  56773. * Name of the CSM class
  56774. */
  56775. static CLASSNAME: string;
  56776. /**
  56777. * Defines the default number of cascades used by the CSM.
  56778. */
  56779. static readonly DEFAULT_CASCADES_COUNT: number;
  56780. /**
  56781. * Defines the minimum number of cascades used by the CSM.
  56782. */
  56783. static readonly MIN_CASCADES_COUNT: number;
  56784. /**
  56785. * Defines the maximum number of cascades used by the CSM.
  56786. */
  56787. static readonly MAX_CASCADES_COUNT: number;
  56788. protected _validateFilter(filter: number): number;
  56789. /**
  56790. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56791. */
  56792. penumbraDarkness: number;
  56793. private _numCascades;
  56794. /**
  56795. * Gets or set the number of cascades used by the CSM.
  56796. */
  56797. get numCascades(): number;
  56798. set numCascades(value: number);
  56799. /**
  56800. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56801. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56802. */
  56803. stabilizeCascades: boolean;
  56804. private _freezeShadowCastersBoundingInfo;
  56805. private _freezeShadowCastersBoundingInfoObservable;
  56806. /**
  56807. * Enables or disables the shadow casters bounding info computation.
  56808. * If your shadow casters don't move, you can disable this feature.
  56809. * If it is enabled, the bounding box computation is done every frame.
  56810. */
  56811. get freezeShadowCastersBoundingInfo(): boolean;
  56812. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56813. private _scbiMin;
  56814. private _scbiMax;
  56815. protected _computeShadowCastersBoundingInfo(): void;
  56816. protected _shadowCastersBoundingInfo: BoundingInfo;
  56817. /**
  56818. * Gets or sets the shadow casters bounding info.
  56819. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56820. * so that the system won't overwrite the bounds you provide
  56821. */
  56822. get shadowCastersBoundingInfo(): BoundingInfo;
  56823. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56824. protected _breaksAreDirty: boolean;
  56825. protected _minDistance: number;
  56826. protected _maxDistance: number;
  56827. /**
  56828. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56829. *
  56830. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56831. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56832. * @param min minimal distance for the breaks (default to 0.)
  56833. * @param max maximal distance for the breaks (default to 1.)
  56834. */
  56835. setMinMaxDistance(min: number, max: number): void;
  56836. /** Gets the minimal distance used in the cascade break computation */
  56837. get minDistance(): number;
  56838. /** Gets the maximal distance used in the cascade break computation */
  56839. get maxDistance(): number;
  56840. /**
  56841. * Gets the class name of that object
  56842. * @returns "CascadedShadowGenerator"
  56843. */
  56844. getClassName(): string;
  56845. private _cascadeMinExtents;
  56846. private _cascadeMaxExtents;
  56847. /**
  56848. * Gets a cascade minimum extents
  56849. * @param cascadeIndex index of the cascade
  56850. * @returns the minimum cascade extents
  56851. */
  56852. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56853. /**
  56854. * Gets a cascade maximum extents
  56855. * @param cascadeIndex index of the cascade
  56856. * @returns the maximum cascade extents
  56857. */
  56858. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56859. private _cascades;
  56860. private _currentLayer;
  56861. private _viewSpaceFrustumsZ;
  56862. private _viewMatrices;
  56863. private _projectionMatrices;
  56864. private _transformMatrices;
  56865. private _transformMatricesAsArray;
  56866. private _frustumLengths;
  56867. private _lightSizeUVCorrection;
  56868. private _depthCorrection;
  56869. private _frustumCornersWorldSpace;
  56870. private _frustumCenter;
  56871. private _shadowCameraPos;
  56872. private _shadowMaxZ;
  56873. /**
  56874. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56875. * It defaults to camera.maxZ
  56876. */
  56877. get shadowMaxZ(): number;
  56878. /**
  56879. * Sets the shadow max z distance.
  56880. */
  56881. set shadowMaxZ(value: number);
  56882. protected _debug: boolean;
  56883. /**
  56884. * Gets or sets the debug flag.
  56885. * When enabled, the cascades are materialized by different colors on the screen.
  56886. */
  56887. get debug(): boolean;
  56888. set debug(dbg: boolean);
  56889. private _depthClamp;
  56890. /**
  56891. * Gets or sets the depth clamping value.
  56892. *
  56893. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56894. * to account for the shadow casters far away.
  56895. *
  56896. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56897. */
  56898. get depthClamp(): boolean;
  56899. set depthClamp(value: boolean);
  56900. private _cascadeBlendPercentage;
  56901. /**
  56902. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56903. * It defaults to 0.1 (10% blending).
  56904. */
  56905. get cascadeBlendPercentage(): number;
  56906. set cascadeBlendPercentage(value: number);
  56907. private _lambda;
  56908. /**
  56909. * Gets or set the lambda parameter.
  56910. * This parameter is used to split the camera frustum and create the cascades.
  56911. * 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.
  56912. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56913. */
  56914. get lambda(): number;
  56915. set lambda(value: number);
  56916. /**
  56917. * Gets the view matrix corresponding to a given cascade
  56918. * @param cascadeNum cascade to retrieve the view matrix from
  56919. * @returns the cascade view matrix
  56920. */
  56921. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56922. /**
  56923. * Gets the projection matrix corresponding to a given cascade
  56924. * @param cascadeNum cascade to retrieve the projection matrix from
  56925. * @returns the cascade projection matrix
  56926. */
  56927. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56928. /**
  56929. * Gets the transformation matrix corresponding to a given cascade
  56930. * @param cascadeNum cascade to retrieve the transformation matrix from
  56931. * @returns the cascade transformation matrix
  56932. */
  56933. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56934. private _depthRenderer;
  56935. /**
  56936. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56937. *
  56938. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56939. *
  56940. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56941. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56942. * @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
  56943. */
  56944. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56945. private _depthReducer;
  56946. private _autoCalcDepthBounds;
  56947. /**
  56948. * Gets or sets the autoCalcDepthBounds property.
  56949. *
  56950. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56951. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56952. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56953. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56954. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56955. */
  56956. get autoCalcDepthBounds(): boolean;
  56957. set autoCalcDepthBounds(value: boolean);
  56958. /**
  56959. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56960. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56961. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56962. * for setting the refresh rate on the renderer yourself!
  56963. */
  56964. get autoCalcDepthBoundsRefreshRate(): number;
  56965. set autoCalcDepthBoundsRefreshRate(value: number);
  56966. /**
  56967. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56968. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56969. * you change the camera near/far planes!
  56970. */
  56971. splitFrustum(): void;
  56972. private _splitFrustum;
  56973. private _computeMatrices;
  56974. private _computeFrustumInWorldSpace;
  56975. private _computeCascadeFrustum;
  56976. /** @hidden */
  56977. static _SceneComponentInitialization: (scene: Scene) => void;
  56978. /**
  56979. * Creates a Cascaded Shadow Generator object.
  56980. * A ShadowGenerator is the required tool to use the shadows.
  56981. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56982. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56983. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56984. * @param light The directional light object generating the shadows.
  56985. * @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.
  56986. */
  56987. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56988. protected _initializeGenerator(): void;
  56989. protected _createTargetRenderTexture(): void;
  56990. protected _initializeShadowMap(): void;
  56991. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56992. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56993. /**
  56994. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56995. * @param defines Defines of the material we want to update
  56996. * @param lightIndex Index of the light in the enabled light list of the material
  56997. */
  56998. prepareDefines(defines: any, lightIndex: number): void;
  56999. /**
  57000. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57001. * defined in the generator but impacting the effect).
  57002. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57003. * @param effect The effect we are binfing the information for
  57004. */
  57005. bindShadowLight(lightIndex: string, effect: Effect): void;
  57006. /**
  57007. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57008. * (eq to view projection * shadow projection matrices)
  57009. * @returns The transform matrix used to create the shadow map
  57010. */
  57011. getTransformMatrix(): Matrix;
  57012. /**
  57013. * Disposes the ShadowGenerator.
  57014. * Returns nothing.
  57015. */
  57016. dispose(): void;
  57017. /**
  57018. * Serializes the shadow generator setup to a json object.
  57019. * @returns The serialized JSON object
  57020. */
  57021. serialize(): any;
  57022. /**
  57023. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57024. * @param parsedShadowGenerator The JSON object to parse
  57025. * @param scene The scene to create the shadow map for
  57026. * @returns The parsed shadow generator
  57027. */
  57028. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57029. }
  57030. }
  57031. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57032. import { Scene } from "babylonjs/scene";
  57033. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57034. import { AbstractScene } from "babylonjs/abstractScene";
  57035. /**
  57036. * Defines the shadow generator component responsible to manage any shadow generators
  57037. * in a given scene.
  57038. */
  57039. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57040. /**
  57041. * The component name helpfull to identify the component in the list of scene components.
  57042. */
  57043. readonly name: string;
  57044. /**
  57045. * The scene the component belongs to.
  57046. */
  57047. scene: Scene;
  57048. /**
  57049. * Creates a new instance of the component for the given scene
  57050. * @param scene Defines the scene to register the component in
  57051. */
  57052. constructor(scene: Scene);
  57053. /**
  57054. * Registers the component in a given scene
  57055. */
  57056. register(): void;
  57057. /**
  57058. * Rebuilds the elements related to this component in case of
  57059. * context lost for instance.
  57060. */
  57061. rebuild(): void;
  57062. /**
  57063. * Serializes the component data to the specified json object
  57064. * @param serializationObject The object to serialize to
  57065. */
  57066. serialize(serializationObject: any): void;
  57067. /**
  57068. * Adds all the elements from the container to the scene
  57069. * @param container the container holding the elements
  57070. */
  57071. addFromContainer(container: AbstractScene): void;
  57072. /**
  57073. * Removes all the elements in the container from the scene
  57074. * @param container contains the elements to remove
  57075. * @param dispose if the removed element should be disposed (default: false)
  57076. */
  57077. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57078. /**
  57079. * Rebuilds the elements related to this component in case of
  57080. * context lost for instance.
  57081. */
  57082. dispose(): void;
  57083. private _gatherRenderTargets;
  57084. }
  57085. }
  57086. declare module "babylonjs/Lights/Shadows/index" {
  57087. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57088. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57089. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57090. }
  57091. declare module "babylonjs/Lights/pointLight" {
  57092. import { Scene } from "babylonjs/scene";
  57093. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57095. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57096. import { Effect } from "babylonjs/Materials/effect";
  57097. /**
  57098. * A point light is a light defined by an unique point in world space.
  57099. * The light is emitted in every direction from this point.
  57100. * A good example of a point light is a standard light bulb.
  57101. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57102. */
  57103. export class PointLight extends ShadowLight {
  57104. private _shadowAngle;
  57105. /**
  57106. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57107. * This specifies what angle the shadow will use to be created.
  57108. *
  57109. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57110. */
  57111. get shadowAngle(): number;
  57112. /**
  57113. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57114. * This specifies what angle the shadow will use to be created.
  57115. *
  57116. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57117. */
  57118. set shadowAngle(value: number);
  57119. /**
  57120. * Gets the direction if it has been set.
  57121. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57122. */
  57123. get direction(): Vector3;
  57124. /**
  57125. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57126. */
  57127. set direction(value: Vector3);
  57128. /**
  57129. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57130. * A PointLight emits the light in every direction.
  57131. * It can cast shadows.
  57132. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57133. * ```javascript
  57134. * var pointLight = new PointLight("pl", camera.position, scene);
  57135. * ```
  57136. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57137. * @param name The light friendly name
  57138. * @param position The position of the point light in the scene
  57139. * @param scene The scene the lights belongs to
  57140. */
  57141. constructor(name: string, position: Vector3, scene: Scene);
  57142. /**
  57143. * Returns the string "PointLight"
  57144. * @returns the class name
  57145. */
  57146. getClassName(): string;
  57147. /**
  57148. * Returns the integer 0.
  57149. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57150. */
  57151. getTypeID(): number;
  57152. /**
  57153. * Specifies wether or not the shadowmap should be a cube texture.
  57154. * @returns true if the shadowmap needs to be a cube texture.
  57155. */
  57156. needCube(): boolean;
  57157. /**
  57158. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57159. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57160. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57161. */
  57162. getShadowDirection(faceIndex?: number): Vector3;
  57163. /**
  57164. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57165. * - fov = PI / 2
  57166. * - aspect ratio : 1.0
  57167. * - z-near and far equal to the active camera minZ and maxZ.
  57168. * Returns the PointLight.
  57169. */
  57170. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57171. protected _buildUniformLayout(): void;
  57172. /**
  57173. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57174. * @param effect The effect to update
  57175. * @param lightIndex The index of the light in the effect to update
  57176. * @returns The point light
  57177. */
  57178. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57179. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57180. /**
  57181. * Prepares the list of defines specific to the light type.
  57182. * @param defines the list of defines
  57183. * @param lightIndex defines the index of the light for the effect
  57184. */
  57185. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57186. }
  57187. }
  57188. declare module "babylonjs/Lights/index" {
  57189. export * from "babylonjs/Lights/light";
  57190. export * from "babylonjs/Lights/shadowLight";
  57191. export * from "babylonjs/Lights/Shadows/index";
  57192. export * from "babylonjs/Lights/directionalLight";
  57193. export * from "babylonjs/Lights/hemisphericLight";
  57194. export * from "babylonjs/Lights/pointLight";
  57195. export * from "babylonjs/Lights/spotLight";
  57196. }
  57197. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57198. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57199. /**
  57200. * Header information of HDR texture files.
  57201. */
  57202. export interface HDRInfo {
  57203. /**
  57204. * The height of the texture in pixels.
  57205. */
  57206. height: number;
  57207. /**
  57208. * The width of the texture in pixels.
  57209. */
  57210. width: number;
  57211. /**
  57212. * The index of the beginning of the data in the binary file.
  57213. */
  57214. dataPosition: number;
  57215. }
  57216. /**
  57217. * This groups tools to convert HDR texture to native colors array.
  57218. */
  57219. export class HDRTools {
  57220. private static Ldexp;
  57221. private static Rgbe2float;
  57222. private static readStringLine;
  57223. /**
  57224. * Reads header information from an RGBE texture stored in a native array.
  57225. * More information on this format are available here:
  57226. * https://en.wikipedia.org/wiki/RGBE_image_format
  57227. *
  57228. * @param uint8array The binary file stored in native array.
  57229. * @return The header information.
  57230. */
  57231. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57232. /**
  57233. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57234. * This RGBE texture needs to store the information as a panorama.
  57235. *
  57236. * More information on this format are available here:
  57237. * https://en.wikipedia.org/wiki/RGBE_image_format
  57238. *
  57239. * @param buffer The binary file stored in an array buffer.
  57240. * @param size The expected size of the extracted cubemap.
  57241. * @return The Cube Map information.
  57242. */
  57243. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57244. /**
  57245. * Returns the pixels data extracted from an RGBE texture.
  57246. * This pixels will be stored left to right up to down in the R G B order in one array.
  57247. *
  57248. * More information on this format are available here:
  57249. * https://en.wikipedia.org/wiki/RGBE_image_format
  57250. *
  57251. * @param uint8array The binary file stored in an array buffer.
  57252. * @param hdrInfo The header information of the file.
  57253. * @return The pixels data in RGB right to left up to down order.
  57254. */
  57255. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57256. private static RGBE_ReadPixels_RLE;
  57257. }
  57258. }
  57259. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57260. import { Nullable } from "babylonjs/types";
  57261. import { Scene } from "babylonjs/scene";
  57262. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57264. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57265. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57266. /**
  57267. * This represents a texture coming from an HDR input.
  57268. *
  57269. * The only supported format is currently panorama picture stored in RGBE format.
  57270. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57271. */
  57272. export class HDRCubeTexture extends BaseTexture {
  57273. private static _facesMapping;
  57274. private _generateHarmonics;
  57275. private _noMipmap;
  57276. private _textureMatrix;
  57277. private _size;
  57278. private _onLoad;
  57279. private _onError;
  57280. /**
  57281. * The texture URL.
  57282. */
  57283. url: string;
  57284. /**
  57285. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57286. */
  57287. coordinatesMode: number;
  57288. protected _isBlocking: boolean;
  57289. /**
  57290. * Sets wether or not the texture is blocking during loading.
  57291. */
  57292. set isBlocking(value: boolean);
  57293. /**
  57294. * Gets wether or not the texture is blocking during loading.
  57295. */
  57296. get isBlocking(): boolean;
  57297. protected _rotationY: number;
  57298. /**
  57299. * Sets texture matrix rotation angle around Y axis in radians.
  57300. */
  57301. set rotationY(value: number);
  57302. /**
  57303. * Gets texture matrix rotation angle around Y axis radians.
  57304. */
  57305. get rotationY(): number;
  57306. /**
  57307. * Gets or sets the center of the bounding box associated with the cube texture
  57308. * It must define where the camera used to render the texture was set
  57309. */
  57310. boundingBoxPosition: Vector3;
  57311. private _boundingBoxSize;
  57312. /**
  57313. * Gets or sets the size of the bounding box associated with the cube texture
  57314. * When defined, the cubemap will switch to local mode
  57315. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57316. * @example https://www.babylonjs-playground.com/#RNASML
  57317. */
  57318. set boundingBoxSize(value: Vector3);
  57319. get boundingBoxSize(): Vector3;
  57320. /**
  57321. * Instantiates an HDRTexture from the following parameters.
  57322. *
  57323. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57324. * @param scene The scene the texture will be used in
  57325. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57326. * @param noMipmap Forces to not generate the mipmap if true
  57327. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57328. * @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)
  57329. * @param reserved Reserved flag for internal use.
  57330. */
  57331. 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>);
  57332. /**
  57333. * Get the current class name of the texture useful for serialization or dynamic coding.
  57334. * @returns "HDRCubeTexture"
  57335. */
  57336. getClassName(): string;
  57337. /**
  57338. * Occurs when the file is raw .hdr file.
  57339. */
  57340. private loadTexture;
  57341. clone(): HDRCubeTexture;
  57342. delayLoad(): void;
  57343. /**
  57344. * Get the texture reflection matrix used to rotate/transform the reflection.
  57345. * @returns the reflection matrix
  57346. */
  57347. getReflectionTextureMatrix(): Matrix;
  57348. /**
  57349. * Set the texture reflection matrix used to rotate/transform the reflection.
  57350. * @param value Define the reflection matrix to set
  57351. */
  57352. setReflectionTextureMatrix(value: Matrix): void;
  57353. /**
  57354. * Parses a JSON representation of an HDR Texture in order to create the texture
  57355. * @param parsedTexture Define the JSON representation
  57356. * @param scene Define the scene the texture should be created in
  57357. * @param rootUrl Define the root url in case we need to load relative dependencies
  57358. * @returns the newly created texture after parsing
  57359. */
  57360. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57361. serialize(): any;
  57362. }
  57363. }
  57364. declare module "babylonjs/Physics/physicsEngine" {
  57365. import { Nullable } from "babylonjs/types";
  57366. import { Vector3 } from "babylonjs/Maths/math.vector";
  57367. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57368. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57369. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57370. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57371. /**
  57372. * Class used to control physics engine
  57373. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57374. */
  57375. export class PhysicsEngine implements IPhysicsEngine {
  57376. private _physicsPlugin;
  57377. /**
  57378. * Global value used to control the smallest number supported by the simulation
  57379. */
  57380. static Epsilon: number;
  57381. private _impostors;
  57382. private _joints;
  57383. private _subTimeStep;
  57384. /**
  57385. * Gets the gravity vector used by the simulation
  57386. */
  57387. gravity: Vector3;
  57388. /**
  57389. * Factory used to create the default physics plugin.
  57390. * @returns The default physics plugin
  57391. */
  57392. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57393. /**
  57394. * Creates a new Physics Engine
  57395. * @param gravity defines the gravity vector used by the simulation
  57396. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57397. */
  57398. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57399. /**
  57400. * Sets the gravity vector used by the simulation
  57401. * @param gravity defines the gravity vector to use
  57402. */
  57403. setGravity(gravity: Vector3): void;
  57404. /**
  57405. * Set the time step of the physics engine.
  57406. * Default is 1/60.
  57407. * To slow it down, enter 1/600 for example.
  57408. * To speed it up, 1/30
  57409. * @param newTimeStep defines the new timestep to apply to this world.
  57410. */
  57411. setTimeStep(newTimeStep?: number): void;
  57412. /**
  57413. * Get the time step of the physics engine.
  57414. * @returns the current time step
  57415. */
  57416. getTimeStep(): number;
  57417. /**
  57418. * Set the sub time step of the physics engine.
  57419. * Default is 0 meaning there is no sub steps
  57420. * To increase physics resolution precision, set a small value (like 1 ms)
  57421. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57422. */
  57423. setSubTimeStep(subTimeStep?: number): void;
  57424. /**
  57425. * Get the sub time step of the physics engine.
  57426. * @returns the current sub time step
  57427. */
  57428. getSubTimeStep(): number;
  57429. /**
  57430. * Release all resources
  57431. */
  57432. dispose(): void;
  57433. /**
  57434. * Gets the name of the current physics plugin
  57435. * @returns the name of the plugin
  57436. */
  57437. getPhysicsPluginName(): string;
  57438. /**
  57439. * Adding a new impostor for the impostor tracking.
  57440. * This will be done by the impostor itself.
  57441. * @param impostor the impostor to add
  57442. */
  57443. addImpostor(impostor: PhysicsImpostor): void;
  57444. /**
  57445. * Remove an impostor from the engine.
  57446. * This impostor and its mesh will not longer be updated by the physics engine.
  57447. * @param impostor the impostor to remove
  57448. */
  57449. removeImpostor(impostor: PhysicsImpostor): void;
  57450. /**
  57451. * Add a joint to the physics engine
  57452. * @param mainImpostor defines the main impostor to which the joint is added.
  57453. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57454. * @param joint defines the joint that will connect both impostors.
  57455. */
  57456. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57457. /**
  57458. * Removes a joint from the simulation
  57459. * @param mainImpostor defines the impostor used with the joint
  57460. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57461. * @param joint defines the joint to remove
  57462. */
  57463. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57464. /**
  57465. * Called by the scene. No need to call it.
  57466. * @param delta defines the timespam between frames
  57467. */
  57468. _step(delta: number): void;
  57469. /**
  57470. * Gets the current plugin used to run the simulation
  57471. * @returns current plugin
  57472. */
  57473. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57474. /**
  57475. * Gets the list of physic impostors
  57476. * @returns an array of PhysicsImpostor
  57477. */
  57478. getImpostors(): Array<PhysicsImpostor>;
  57479. /**
  57480. * Gets the impostor for a physics enabled object
  57481. * @param object defines the object impersonated by the impostor
  57482. * @returns the PhysicsImpostor or null if not found
  57483. */
  57484. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57485. /**
  57486. * Gets the impostor for a physics body object
  57487. * @param body defines physics body used by the impostor
  57488. * @returns the PhysicsImpostor or null if not found
  57489. */
  57490. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57491. /**
  57492. * Does a raycast in the physics world
  57493. * @param from when should the ray start?
  57494. * @param to when should the ray end?
  57495. * @returns PhysicsRaycastResult
  57496. */
  57497. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57498. }
  57499. }
  57500. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57501. import { Nullable } from "babylonjs/types";
  57502. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57504. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57505. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57506. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57507. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57508. /** @hidden */
  57509. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57510. private _useDeltaForWorldStep;
  57511. world: any;
  57512. name: string;
  57513. private _physicsMaterials;
  57514. private _fixedTimeStep;
  57515. private _cannonRaycastResult;
  57516. private _raycastResult;
  57517. private _physicsBodysToRemoveAfterStep;
  57518. BJSCANNON: any;
  57519. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57520. setGravity(gravity: Vector3): void;
  57521. setTimeStep(timeStep: number): void;
  57522. getTimeStep(): number;
  57523. executeStep(delta: number): void;
  57524. private _removeMarkedPhysicsBodiesFromWorld;
  57525. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57526. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57527. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57528. private _processChildMeshes;
  57529. removePhysicsBody(impostor: PhysicsImpostor): void;
  57530. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57531. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57532. private _addMaterial;
  57533. private _checkWithEpsilon;
  57534. private _createShape;
  57535. private _createHeightmap;
  57536. private _minus90X;
  57537. private _plus90X;
  57538. private _tmpPosition;
  57539. private _tmpDeltaPosition;
  57540. private _tmpUnityRotation;
  57541. private _updatePhysicsBodyTransformation;
  57542. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57544. isSupported(): boolean;
  57545. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57546. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57547. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57548. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57549. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57550. getBodyMass(impostor: PhysicsImpostor): number;
  57551. getBodyFriction(impostor: PhysicsImpostor): number;
  57552. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57553. getBodyRestitution(impostor: PhysicsImpostor): number;
  57554. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57555. sleepBody(impostor: PhysicsImpostor): void;
  57556. wakeUpBody(impostor: PhysicsImpostor): void;
  57557. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57558. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57559. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57560. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57561. getRadius(impostor: PhysicsImpostor): number;
  57562. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57563. dispose(): void;
  57564. private _extendNamespace;
  57565. /**
  57566. * Does a raycast in the physics world
  57567. * @param from when should the ray start?
  57568. * @param to when should the ray end?
  57569. * @returns PhysicsRaycastResult
  57570. */
  57571. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57572. }
  57573. }
  57574. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57575. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57576. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57577. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57579. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57580. import { Nullable } from "babylonjs/types";
  57581. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57582. /** @hidden */
  57583. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57584. world: any;
  57585. name: string;
  57586. BJSOIMO: any;
  57587. private _raycastResult;
  57588. constructor(iterations?: number, oimoInjection?: any);
  57589. setGravity(gravity: Vector3): void;
  57590. setTimeStep(timeStep: number): void;
  57591. getTimeStep(): number;
  57592. private _tmpImpostorsArray;
  57593. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57594. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57595. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57596. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57597. private _tmpPositionVector;
  57598. removePhysicsBody(impostor: PhysicsImpostor): void;
  57599. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57600. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57601. isSupported(): boolean;
  57602. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57603. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57604. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57605. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57606. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57607. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57608. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57609. getBodyMass(impostor: PhysicsImpostor): number;
  57610. getBodyFriction(impostor: PhysicsImpostor): number;
  57611. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57612. getBodyRestitution(impostor: PhysicsImpostor): number;
  57613. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57614. sleepBody(impostor: PhysicsImpostor): void;
  57615. wakeUpBody(impostor: PhysicsImpostor): void;
  57616. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57617. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57618. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57619. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57620. getRadius(impostor: PhysicsImpostor): number;
  57621. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57622. dispose(): void;
  57623. /**
  57624. * Does a raycast in the physics world
  57625. * @param from when should the ray start?
  57626. * @param to when should the ray end?
  57627. * @returns PhysicsRaycastResult
  57628. */
  57629. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57630. }
  57631. }
  57632. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57633. import { Nullable } from "babylonjs/types";
  57634. import { Scene } from "babylonjs/scene";
  57635. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57636. import { Color4 } from "babylonjs/Maths/math.color";
  57637. import { Mesh } from "babylonjs/Meshes/mesh";
  57638. /**
  57639. * Class containing static functions to help procedurally build meshes
  57640. */
  57641. export class RibbonBuilder {
  57642. /**
  57643. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57644. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57645. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57646. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57647. * * 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
  57648. * * 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
  57649. * * 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
  57650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57653. * * 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
  57654. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57655. * * 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
  57656. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57658. * @param name defines the name of the mesh
  57659. * @param options defines the options used to create the mesh
  57660. * @param scene defines the hosting scene
  57661. * @returns the ribbon mesh
  57662. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57664. */
  57665. static CreateRibbon(name: string, options: {
  57666. pathArray: Vector3[][];
  57667. closeArray?: boolean;
  57668. closePath?: boolean;
  57669. offset?: number;
  57670. updatable?: boolean;
  57671. sideOrientation?: number;
  57672. frontUVs?: Vector4;
  57673. backUVs?: Vector4;
  57674. instance?: Mesh;
  57675. invertUV?: boolean;
  57676. uvs?: Vector2[];
  57677. colors?: Color4[];
  57678. }, scene?: Nullable<Scene>): Mesh;
  57679. }
  57680. }
  57681. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57682. import { Nullable } from "babylonjs/types";
  57683. import { Scene } from "babylonjs/scene";
  57684. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57685. import { Mesh } from "babylonjs/Meshes/mesh";
  57686. /**
  57687. * Class containing static functions to help procedurally build meshes
  57688. */
  57689. export class ShapeBuilder {
  57690. /**
  57691. * 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.
  57692. * * 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.
  57693. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57694. * * 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.
  57695. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57696. * * 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
  57697. * * 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
  57698. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57703. * @param name defines the name of the mesh
  57704. * @param options defines the options used to create the mesh
  57705. * @param scene defines the hosting scene
  57706. * @returns the extruded shape mesh
  57707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57709. */
  57710. static ExtrudeShape(name: string, options: {
  57711. shape: Vector3[];
  57712. path: Vector3[];
  57713. scale?: number;
  57714. rotation?: number;
  57715. cap?: number;
  57716. updatable?: boolean;
  57717. sideOrientation?: number;
  57718. frontUVs?: Vector4;
  57719. backUVs?: Vector4;
  57720. instance?: Mesh;
  57721. invertUV?: boolean;
  57722. }, scene?: Nullable<Scene>): Mesh;
  57723. /**
  57724. * Creates an custom extruded shape mesh.
  57725. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57726. * * 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.
  57727. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57728. * * 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
  57729. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57730. * * 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
  57731. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57732. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57733. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57734. * * 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
  57735. * * 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
  57736. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57741. * @param name defines the name of the mesh
  57742. * @param options defines the options used to create the mesh
  57743. * @param scene defines the hosting scene
  57744. * @returns the custom extruded shape mesh
  57745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57746. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57748. */
  57749. static ExtrudeShapeCustom(name: string, options: {
  57750. shape: Vector3[];
  57751. path: Vector3[];
  57752. scaleFunction?: any;
  57753. rotationFunction?: any;
  57754. ribbonCloseArray?: boolean;
  57755. ribbonClosePath?: boolean;
  57756. cap?: number;
  57757. updatable?: boolean;
  57758. sideOrientation?: number;
  57759. frontUVs?: Vector4;
  57760. backUVs?: Vector4;
  57761. instance?: Mesh;
  57762. invertUV?: boolean;
  57763. }, scene?: Nullable<Scene>): Mesh;
  57764. private static _ExtrudeShapeGeneric;
  57765. }
  57766. }
  57767. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57768. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57769. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57770. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57771. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57772. import { Nullable } from "babylonjs/types";
  57773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57774. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57775. /**
  57776. * AmmoJS Physics plugin
  57777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57778. * @see https://github.com/kripken/ammo.js/
  57779. */
  57780. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57781. private _useDeltaForWorldStep;
  57782. /**
  57783. * Reference to the Ammo library
  57784. */
  57785. bjsAMMO: any;
  57786. /**
  57787. * Created ammoJS world which physics bodies are added to
  57788. */
  57789. world: any;
  57790. /**
  57791. * Name of the plugin
  57792. */
  57793. name: string;
  57794. private _timeStep;
  57795. private _fixedTimeStep;
  57796. private _maxSteps;
  57797. private _tmpQuaternion;
  57798. private _tmpAmmoTransform;
  57799. private _tmpAmmoQuaternion;
  57800. private _tmpAmmoConcreteContactResultCallback;
  57801. private _collisionConfiguration;
  57802. private _dispatcher;
  57803. private _overlappingPairCache;
  57804. private _solver;
  57805. private _softBodySolver;
  57806. private _tmpAmmoVectorA;
  57807. private _tmpAmmoVectorB;
  57808. private _tmpAmmoVectorC;
  57809. private _tmpAmmoVectorD;
  57810. private _tmpContactCallbackResult;
  57811. private _tmpAmmoVectorRCA;
  57812. private _tmpAmmoVectorRCB;
  57813. private _raycastResult;
  57814. private static readonly DISABLE_COLLISION_FLAG;
  57815. private static readonly KINEMATIC_FLAG;
  57816. private static readonly DISABLE_DEACTIVATION_FLAG;
  57817. /**
  57818. * Initializes the ammoJS plugin
  57819. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57820. * @param ammoInjection can be used to inject your own ammo reference
  57821. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57822. */
  57823. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57824. /**
  57825. * Sets the gravity of the physics world (m/(s^2))
  57826. * @param gravity Gravity to set
  57827. */
  57828. setGravity(gravity: Vector3): void;
  57829. /**
  57830. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57831. * @param timeStep timestep to use in seconds
  57832. */
  57833. setTimeStep(timeStep: number): void;
  57834. /**
  57835. * 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)
  57836. * @param fixedTimeStep fixedTimeStep to use in seconds
  57837. */
  57838. setFixedTimeStep(fixedTimeStep: number): void;
  57839. /**
  57840. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57841. * @param maxSteps the maximum number of steps by the physics engine per frame
  57842. */
  57843. setMaxSteps(maxSteps: number): void;
  57844. /**
  57845. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57846. * @returns the current timestep in seconds
  57847. */
  57848. getTimeStep(): number;
  57849. /**
  57850. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57851. */
  57852. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57853. private _isImpostorInContact;
  57854. private _isImpostorPairInContact;
  57855. private _stepSimulation;
  57856. /**
  57857. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57858. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57859. * After the step the babylon meshes are set to the position of the physics imposters
  57860. * @param delta amount of time to step forward
  57861. * @param impostors array of imposters to update before/after the step
  57862. */
  57863. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57864. /**
  57865. * Update babylon mesh to match physics world object
  57866. * @param impostor imposter to match
  57867. */
  57868. private _afterSoftStep;
  57869. /**
  57870. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57871. * @param impostor imposter to match
  57872. */
  57873. private _ropeStep;
  57874. /**
  57875. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57876. * @param impostor imposter to match
  57877. */
  57878. private _softbodyOrClothStep;
  57879. private _tmpVector;
  57880. private _tmpMatrix;
  57881. /**
  57882. * Applies an impulse on the imposter
  57883. * @param impostor imposter to apply impulse to
  57884. * @param force amount of force to be applied to the imposter
  57885. * @param contactPoint the location to apply the impulse on the imposter
  57886. */
  57887. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57888. /**
  57889. * Applies a force on the imposter
  57890. * @param impostor imposter to apply force
  57891. * @param force amount of force to be applied to the imposter
  57892. * @param contactPoint the location to apply the force on the imposter
  57893. */
  57894. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57895. /**
  57896. * Creates a physics body using the plugin
  57897. * @param impostor the imposter to create the physics body on
  57898. */
  57899. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57900. /**
  57901. * Removes the physics body from the imposter and disposes of the body's memory
  57902. * @param impostor imposter to remove the physics body from
  57903. */
  57904. removePhysicsBody(impostor: PhysicsImpostor): void;
  57905. /**
  57906. * Generates a joint
  57907. * @param impostorJoint the imposter joint to create the joint with
  57908. */
  57909. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57910. /**
  57911. * Removes a joint
  57912. * @param impostorJoint the imposter joint to remove the joint from
  57913. */
  57914. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57915. private _addMeshVerts;
  57916. /**
  57917. * Initialise the soft body vertices to match its object's (mesh) vertices
  57918. * Softbody vertices (nodes) are in world space and to match this
  57919. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57920. * @param impostor to create the softbody for
  57921. */
  57922. private _softVertexData;
  57923. /**
  57924. * Create an impostor's soft body
  57925. * @param impostor to create the softbody for
  57926. */
  57927. private _createSoftbody;
  57928. /**
  57929. * Create cloth for an impostor
  57930. * @param impostor to create the softbody for
  57931. */
  57932. private _createCloth;
  57933. /**
  57934. * Create rope for an impostor
  57935. * @param impostor to create the softbody for
  57936. */
  57937. private _createRope;
  57938. /**
  57939. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57940. * @param impostor to create the custom physics shape for
  57941. */
  57942. private _createCustom;
  57943. private _addHullVerts;
  57944. private _createShape;
  57945. /**
  57946. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57947. * @param impostor imposter containing the physics body and babylon object
  57948. */
  57949. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57950. /**
  57951. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57952. * @param impostor imposter containing the physics body and babylon object
  57953. * @param newPosition new position
  57954. * @param newRotation new rotation
  57955. */
  57956. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57957. /**
  57958. * If this plugin is supported
  57959. * @returns true if its supported
  57960. */
  57961. isSupported(): boolean;
  57962. /**
  57963. * Sets the linear velocity of the physics body
  57964. * @param impostor imposter to set the velocity on
  57965. * @param velocity velocity to set
  57966. */
  57967. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57968. /**
  57969. * Sets the angular velocity of the physics body
  57970. * @param impostor imposter to set the velocity on
  57971. * @param velocity velocity to set
  57972. */
  57973. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57974. /**
  57975. * gets the linear velocity
  57976. * @param impostor imposter to get linear velocity from
  57977. * @returns linear velocity
  57978. */
  57979. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57980. /**
  57981. * gets the angular velocity
  57982. * @param impostor imposter to get angular velocity from
  57983. * @returns angular velocity
  57984. */
  57985. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57986. /**
  57987. * Sets the mass of physics body
  57988. * @param impostor imposter to set the mass on
  57989. * @param mass mass to set
  57990. */
  57991. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57992. /**
  57993. * Gets the mass of the physics body
  57994. * @param impostor imposter to get the mass from
  57995. * @returns mass
  57996. */
  57997. getBodyMass(impostor: PhysicsImpostor): number;
  57998. /**
  57999. * Gets friction of the impostor
  58000. * @param impostor impostor to get friction from
  58001. * @returns friction value
  58002. */
  58003. getBodyFriction(impostor: PhysicsImpostor): number;
  58004. /**
  58005. * Sets friction of the impostor
  58006. * @param impostor impostor to set friction on
  58007. * @param friction friction value
  58008. */
  58009. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58010. /**
  58011. * Gets restitution of the impostor
  58012. * @param impostor impostor to get restitution from
  58013. * @returns restitution value
  58014. */
  58015. getBodyRestitution(impostor: PhysicsImpostor): number;
  58016. /**
  58017. * Sets resitution of the impostor
  58018. * @param impostor impostor to set resitution on
  58019. * @param restitution resitution value
  58020. */
  58021. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58022. /**
  58023. * Gets pressure inside the impostor
  58024. * @param impostor impostor to get pressure from
  58025. * @returns pressure value
  58026. */
  58027. getBodyPressure(impostor: PhysicsImpostor): number;
  58028. /**
  58029. * Sets pressure inside a soft body impostor
  58030. * Cloth and rope must remain 0 pressure
  58031. * @param impostor impostor to set pressure on
  58032. * @param pressure pressure value
  58033. */
  58034. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58035. /**
  58036. * Gets stiffness of the impostor
  58037. * @param impostor impostor to get stiffness from
  58038. * @returns pressure value
  58039. */
  58040. getBodyStiffness(impostor: PhysicsImpostor): number;
  58041. /**
  58042. * Sets stiffness of the impostor
  58043. * @param impostor impostor to set stiffness on
  58044. * @param stiffness stiffness value from 0 to 1
  58045. */
  58046. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58047. /**
  58048. * Gets velocityIterations of the impostor
  58049. * @param impostor impostor to get velocity iterations from
  58050. * @returns velocityIterations value
  58051. */
  58052. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58053. /**
  58054. * Sets velocityIterations of the impostor
  58055. * @param impostor impostor to set velocity iterations on
  58056. * @param velocityIterations velocityIterations value
  58057. */
  58058. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58059. /**
  58060. * Gets positionIterations of the impostor
  58061. * @param impostor impostor to get position iterations from
  58062. * @returns positionIterations value
  58063. */
  58064. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58065. /**
  58066. * Sets positionIterations of the impostor
  58067. * @param impostor impostor to set position on
  58068. * @param positionIterations positionIterations value
  58069. */
  58070. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58071. /**
  58072. * Append an anchor to a cloth object
  58073. * @param impostor is the cloth impostor to add anchor to
  58074. * @param otherImpostor is the rigid impostor to anchor to
  58075. * @param width ratio across width from 0 to 1
  58076. * @param height ratio up height from 0 to 1
  58077. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58078. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58079. */
  58080. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58081. /**
  58082. * Append an hook to a rope object
  58083. * @param impostor is the rope impostor to add hook to
  58084. * @param otherImpostor is the rigid impostor to hook to
  58085. * @param length ratio along the rope from 0 to 1
  58086. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58088. */
  58089. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58090. /**
  58091. * Sleeps the physics body and stops it from being active
  58092. * @param impostor impostor to sleep
  58093. */
  58094. sleepBody(impostor: PhysicsImpostor): void;
  58095. /**
  58096. * Activates the physics body
  58097. * @param impostor impostor to activate
  58098. */
  58099. wakeUpBody(impostor: PhysicsImpostor): void;
  58100. /**
  58101. * Updates the distance parameters of the joint
  58102. * @param joint joint to update
  58103. * @param maxDistance maximum distance of the joint
  58104. * @param minDistance minimum distance of the joint
  58105. */
  58106. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58107. /**
  58108. * Sets a motor on the joint
  58109. * @param joint joint to set motor on
  58110. * @param speed speed of the motor
  58111. * @param maxForce maximum force of the motor
  58112. * @param motorIndex index of the motor
  58113. */
  58114. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58115. /**
  58116. * Sets the motors limit
  58117. * @param joint joint to set limit on
  58118. * @param upperLimit upper limit
  58119. * @param lowerLimit lower limit
  58120. */
  58121. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58122. /**
  58123. * Syncs the position and rotation of a mesh with the impostor
  58124. * @param mesh mesh to sync
  58125. * @param impostor impostor to update the mesh with
  58126. */
  58127. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58128. /**
  58129. * Gets the radius of the impostor
  58130. * @param impostor impostor to get radius from
  58131. * @returns the radius
  58132. */
  58133. getRadius(impostor: PhysicsImpostor): number;
  58134. /**
  58135. * Gets the box size of the impostor
  58136. * @param impostor impostor to get box size from
  58137. * @param result the resulting box size
  58138. */
  58139. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58140. /**
  58141. * Disposes of the impostor
  58142. */
  58143. dispose(): void;
  58144. /**
  58145. * Does a raycast in the physics world
  58146. * @param from when should the ray start?
  58147. * @param to when should the ray end?
  58148. * @returns PhysicsRaycastResult
  58149. */
  58150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58151. }
  58152. }
  58153. declare module "babylonjs/Probes/reflectionProbe" {
  58154. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58155. import { Vector3 } from "babylonjs/Maths/math.vector";
  58156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58157. import { Nullable } from "babylonjs/types";
  58158. import { Scene } from "babylonjs/scene";
  58159. module "babylonjs/abstractScene" {
  58160. interface AbstractScene {
  58161. /**
  58162. * The list of reflection probes added to the scene
  58163. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58164. */
  58165. reflectionProbes: Array<ReflectionProbe>;
  58166. /**
  58167. * Removes the given reflection probe from this scene.
  58168. * @param toRemove The reflection probe to remove
  58169. * @returns The index of the removed reflection probe
  58170. */
  58171. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58172. /**
  58173. * Adds the given reflection probe to this scene.
  58174. * @param newReflectionProbe The reflection probe to add
  58175. */
  58176. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58177. }
  58178. }
  58179. /**
  58180. * Class used to generate realtime reflection / refraction cube textures
  58181. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58182. */
  58183. export class ReflectionProbe {
  58184. /** defines the name of the probe */
  58185. name: string;
  58186. private _scene;
  58187. private _renderTargetTexture;
  58188. private _projectionMatrix;
  58189. private _viewMatrix;
  58190. private _target;
  58191. private _add;
  58192. private _attachedMesh;
  58193. private _invertYAxis;
  58194. /** Gets or sets probe position (center of the cube map) */
  58195. position: Vector3;
  58196. /**
  58197. * Creates a new reflection probe
  58198. * @param name defines the name of the probe
  58199. * @param size defines the texture resolution (for each face)
  58200. * @param scene defines the hosting scene
  58201. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58202. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58203. */
  58204. constructor(
  58205. /** defines the name of the probe */
  58206. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58207. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58208. get samples(): number;
  58209. set samples(value: number);
  58210. /** Gets or sets the refresh rate to use (on every frame by default) */
  58211. get refreshRate(): number;
  58212. set refreshRate(value: number);
  58213. /**
  58214. * Gets the hosting scene
  58215. * @returns a Scene
  58216. */
  58217. getScene(): Scene;
  58218. /** Gets the internal CubeTexture used to render to */
  58219. get cubeTexture(): RenderTargetTexture;
  58220. /** Gets the list of meshes to render */
  58221. get renderList(): Nullable<AbstractMesh[]>;
  58222. /**
  58223. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58224. * @param mesh defines the mesh to attach to
  58225. */
  58226. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58227. /**
  58228. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58229. * @param renderingGroupId The rendering group id corresponding to its index
  58230. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58231. */
  58232. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58233. /**
  58234. * Clean all associated resources
  58235. */
  58236. dispose(): void;
  58237. /**
  58238. * Converts the reflection probe information to a readable string for debug purpose.
  58239. * @param fullDetails Supports for multiple levels of logging within scene loading
  58240. * @returns the human readable reflection probe info
  58241. */
  58242. toString(fullDetails?: boolean): string;
  58243. /**
  58244. * Get the class name of the relfection probe.
  58245. * @returns "ReflectionProbe"
  58246. */
  58247. getClassName(): string;
  58248. /**
  58249. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58250. * @returns The JSON representation of the texture
  58251. */
  58252. serialize(): any;
  58253. /**
  58254. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58255. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58256. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58257. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58258. * @returns The parsed reflection probe if successful
  58259. */
  58260. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58261. }
  58262. }
  58263. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58264. /** @hidden */
  58265. export var _BabylonLoaderRegistered: boolean;
  58266. /**
  58267. * Helps setting up some configuration for the babylon file loader.
  58268. */
  58269. export class BabylonFileLoaderConfiguration {
  58270. /**
  58271. * The loader does not allow injecting custom physix engine into the plugins.
  58272. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58273. * So you could set this variable to your engine import to make it work.
  58274. */
  58275. static LoaderInjectedPhysicsEngine: any;
  58276. }
  58277. }
  58278. declare module "babylonjs/Loading/Plugins/index" {
  58279. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58280. }
  58281. declare module "babylonjs/Loading/index" {
  58282. export * from "babylonjs/Loading/loadingScreen";
  58283. export * from "babylonjs/Loading/Plugins/index";
  58284. export * from "babylonjs/Loading/sceneLoader";
  58285. export * from "babylonjs/Loading/sceneLoaderFlags";
  58286. }
  58287. declare module "babylonjs/Materials/Background/index" {
  58288. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58289. }
  58290. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58291. import { Scene } from "babylonjs/scene";
  58292. import { Color3 } from "babylonjs/Maths/math.color";
  58293. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58295. /**
  58296. * The Physically based simple base material of BJS.
  58297. *
  58298. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58299. * It is used as the base class for both the specGloss and metalRough conventions.
  58300. */
  58301. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58302. /**
  58303. * Number of Simultaneous lights allowed on the material.
  58304. */
  58305. maxSimultaneousLights: number;
  58306. /**
  58307. * If sets to true, disables all the lights affecting the material.
  58308. */
  58309. disableLighting: boolean;
  58310. /**
  58311. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58312. */
  58313. environmentTexture: BaseTexture;
  58314. /**
  58315. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58316. */
  58317. invertNormalMapX: boolean;
  58318. /**
  58319. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58320. */
  58321. invertNormalMapY: boolean;
  58322. /**
  58323. * Normal map used in the model.
  58324. */
  58325. normalTexture: BaseTexture;
  58326. /**
  58327. * Emissivie color used to self-illuminate the model.
  58328. */
  58329. emissiveColor: Color3;
  58330. /**
  58331. * Emissivie texture used to self-illuminate the model.
  58332. */
  58333. emissiveTexture: BaseTexture;
  58334. /**
  58335. * Occlusion Channel Strenght.
  58336. */
  58337. occlusionStrength: number;
  58338. /**
  58339. * Occlusion Texture of the material (adding extra occlusion effects).
  58340. */
  58341. occlusionTexture: BaseTexture;
  58342. /**
  58343. * Defines the alpha limits in alpha test mode.
  58344. */
  58345. alphaCutOff: number;
  58346. /**
  58347. * Gets the current double sided mode.
  58348. */
  58349. get doubleSided(): boolean;
  58350. /**
  58351. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58352. */
  58353. set doubleSided(value: boolean);
  58354. /**
  58355. * Stores the pre-calculated light information of a mesh in a texture.
  58356. */
  58357. lightmapTexture: BaseTexture;
  58358. /**
  58359. * If true, the light map contains occlusion information instead of lighting info.
  58360. */
  58361. useLightmapAsShadowmap: boolean;
  58362. /**
  58363. * Instantiates a new PBRMaterial instance.
  58364. *
  58365. * @param name The material name
  58366. * @param scene The scene the material will be use in.
  58367. */
  58368. constructor(name: string, scene: Scene);
  58369. getClassName(): string;
  58370. }
  58371. }
  58372. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58373. import { Scene } from "babylonjs/scene";
  58374. import { Color3 } from "babylonjs/Maths/math.color";
  58375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58376. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58377. /**
  58378. * The PBR material of BJS following the metal roughness convention.
  58379. *
  58380. * This fits to the PBR convention in the GLTF definition:
  58381. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58382. */
  58383. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58384. /**
  58385. * The base color has two different interpretations depending on the value of metalness.
  58386. * When the material is a metal, the base color is the specific measured reflectance value
  58387. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58388. * of the material.
  58389. */
  58390. baseColor: Color3;
  58391. /**
  58392. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58393. * well as opacity information in the alpha channel.
  58394. */
  58395. baseTexture: BaseTexture;
  58396. /**
  58397. * Specifies the metallic scalar value of the material.
  58398. * Can also be used to scale the metalness values of the metallic texture.
  58399. */
  58400. metallic: number;
  58401. /**
  58402. * Specifies the roughness scalar value of the material.
  58403. * Can also be used to scale the roughness values of the metallic texture.
  58404. */
  58405. roughness: number;
  58406. /**
  58407. * Texture containing both the metallic value in the B channel and the
  58408. * roughness value in the G channel to keep better precision.
  58409. */
  58410. metallicRoughnessTexture: BaseTexture;
  58411. /**
  58412. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58413. *
  58414. * @param name The material name
  58415. * @param scene The scene the material will be use in.
  58416. */
  58417. constructor(name: string, scene: Scene);
  58418. /**
  58419. * Return the currrent class name of the material.
  58420. */
  58421. getClassName(): string;
  58422. /**
  58423. * Makes a duplicate of the current material.
  58424. * @param name - name to use for the new material.
  58425. */
  58426. clone(name: string): PBRMetallicRoughnessMaterial;
  58427. /**
  58428. * Serialize the material to a parsable JSON object.
  58429. */
  58430. serialize(): any;
  58431. /**
  58432. * Parses a JSON object correponding to the serialize function.
  58433. */
  58434. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58435. }
  58436. }
  58437. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58438. import { Scene } from "babylonjs/scene";
  58439. import { Color3 } from "babylonjs/Maths/math.color";
  58440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58441. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58442. /**
  58443. * The PBR material of BJS following the specular glossiness convention.
  58444. *
  58445. * This fits to the PBR convention in the GLTF definition:
  58446. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58447. */
  58448. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58449. /**
  58450. * Specifies the diffuse color of the material.
  58451. */
  58452. diffuseColor: Color3;
  58453. /**
  58454. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58455. * channel.
  58456. */
  58457. diffuseTexture: BaseTexture;
  58458. /**
  58459. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58460. */
  58461. specularColor: Color3;
  58462. /**
  58463. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58464. */
  58465. glossiness: number;
  58466. /**
  58467. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58468. */
  58469. specularGlossinessTexture: BaseTexture;
  58470. /**
  58471. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58472. *
  58473. * @param name The material name
  58474. * @param scene The scene the material will be use in.
  58475. */
  58476. constructor(name: string, scene: Scene);
  58477. /**
  58478. * Return the currrent class name of the material.
  58479. */
  58480. getClassName(): string;
  58481. /**
  58482. * Makes a duplicate of the current material.
  58483. * @param name - name to use for the new material.
  58484. */
  58485. clone(name: string): PBRSpecularGlossinessMaterial;
  58486. /**
  58487. * Serialize the material to a parsable JSON object.
  58488. */
  58489. serialize(): any;
  58490. /**
  58491. * Parses a JSON object correponding to the serialize function.
  58492. */
  58493. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58494. }
  58495. }
  58496. declare module "babylonjs/Materials/PBR/index" {
  58497. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58498. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58499. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58500. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58501. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58502. }
  58503. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58504. import { Nullable } from "babylonjs/types";
  58505. import { Scene } from "babylonjs/scene";
  58506. import { Matrix } from "babylonjs/Maths/math.vector";
  58507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58508. /**
  58509. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58510. * It can help converting any input color in a desired output one. This can then be used to create effects
  58511. * from sepia, black and white to sixties or futuristic rendering...
  58512. *
  58513. * The only supported format is currently 3dl.
  58514. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58515. */
  58516. export class ColorGradingTexture extends BaseTexture {
  58517. /**
  58518. * The current texture matrix. (will always be identity in color grading texture)
  58519. */
  58520. private _textureMatrix;
  58521. /**
  58522. * The texture URL.
  58523. */
  58524. url: string;
  58525. /**
  58526. * Empty line regex stored for GC.
  58527. */
  58528. private static _noneEmptyLineRegex;
  58529. private _engine;
  58530. /**
  58531. * Instantiates a ColorGradingTexture from the following parameters.
  58532. *
  58533. * @param url The location of the color gradind data (currently only supporting 3dl)
  58534. * @param scene The scene the texture will be used in
  58535. */
  58536. constructor(url: string, scene: Scene);
  58537. /**
  58538. * Returns the texture matrix used in most of the material.
  58539. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58540. */
  58541. getTextureMatrix(): Matrix;
  58542. /**
  58543. * Occurs when the file being loaded is a .3dl LUT file.
  58544. */
  58545. private load3dlTexture;
  58546. /**
  58547. * Starts the loading process of the texture.
  58548. */
  58549. private loadTexture;
  58550. /**
  58551. * Clones the color gradind texture.
  58552. */
  58553. clone(): ColorGradingTexture;
  58554. /**
  58555. * Called during delayed load for textures.
  58556. */
  58557. delayLoad(): void;
  58558. /**
  58559. * Parses a color grading texture serialized by Babylon.
  58560. * @param parsedTexture The texture information being parsedTexture
  58561. * @param scene The scene to load the texture in
  58562. * @param rootUrl The root url of the data assets to load
  58563. * @return A color gradind texture
  58564. */
  58565. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58566. /**
  58567. * Serializes the LUT texture to json format.
  58568. */
  58569. serialize(): any;
  58570. }
  58571. }
  58572. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58574. import { Scene } from "babylonjs/scene";
  58575. import { Nullable } from "babylonjs/types";
  58576. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58577. /**
  58578. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58579. */
  58580. export class EquiRectangularCubeTexture extends BaseTexture {
  58581. /** The six faces of the cube. */
  58582. private static _FacesMapping;
  58583. private _noMipmap;
  58584. private _onLoad;
  58585. private _onError;
  58586. /** The size of the cubemap. */
  58587. private _size;
  58588. /** The buffer of the image. */
  58589. private _buffer;
  58590. /** The width of the input image. */
  58591. private _width;
  58592. /** The height of the input image. */
  58593. private _height;
  58594. /** The URL to the image. */
  58595. url: string;
  58596. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58597. coordinatesMode: number;
  58598. /**
  58599. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58600. * @param url The location of the image
  58601. * @param scene The scene the texture will be used in
  58602. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58603. * @param noMipmap Forces to not generate the mipmap if true
  58604. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58605. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58606. * @param onLoad — defines a callback called when texture is loaded
  58607. * @param onError — defines a callback called if there is an error
  58608. */
  58609. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58610. /**
  58611. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58612. */
  58613. private loadImage;
  58614. /**
  58615. * Convert the image buffer into a cubemap and create a CubeTexture.
  58616. */
  58617. private loadTexture;
  58618. /**
  58619. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58620. * @param buffer The ArrayBuffer that should be converted.
  58621. * @returns The buffer as Float32Array.
  58622. */
  58623. private getFloat32ArrayFromArrayBuffer;
  58624. /**
  58625. * Get the current class name of the texture useful for serialization or dynamic coding.
  58626. * @returns "EquiRectangularCubeTexture"
  58627. */
  58628. getClassName(): string;
  58629. /**
  58630. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58631. * @returns A clone of the current EquiRectangularCubeTexture.
  58632. */
  58633. clone(): EquiRectangularCubeTexture;
  58634. }
  58635. }
  58636. declare module "babylonjs/Misc/tga" {
  58637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58638. /**
  58639. * Based on jsTGALoader - Javascript loader for TGA file
  58640. * By Vincent Thibault
  58641. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58642. */
  58643. export class TGATools {
  58644. private static _TYPE_INDEXED;
  58645. private static _TYPE_RGB;
  58646. private static _TYPE_GREY;
  58647. private static _TYPE_RLE_INDEXED;
  58648. private static _TYPE_RLE_RGB;
  58649. private static _TYPE_RLE_GREY;
  58650. private static _ORIGIN_MASK;
  58651. private static _ORIGIN_SHIFT;
  58652. private static _ORIGIN_BL;
  58653. private static _ORIGIN_BR;
  58654. private static _ORIGIN_UL;
  58655. private static _ORIGIN_UR;
  58656. /**
  58657. * Gets the header of a TGA file
  58658. * @param data defines the TGA data
  58659. * @returns the header
  58660. */
  58661. static GetTGAHeader(data: Uint8Array): any;
  58662. /**
  58663. * Uploads TGA content to a Babylon Texture
  58664. * @hidden
  58665. */
  58666. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58667. /** @hidden */
  58668. 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;
  58669. /** @hidden */
  58670. 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;
  58671. /** @hidden */
  58672. 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;
  58673. /** @hidden */
  58674. 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;
  58675. /** @hidden */
  58676. 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;
  58677. /** @hidden */
  58678. 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;
  58679. }
  58680. }
  58681. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58682. import { Nullable } from "babylonjs/types";
  58683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58684. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58685. /**
  58686. * Implementation of the TGA Texture Loader.
  58687. * @hidden
  58688. */
  58689. export class _TGATextureLoader implements IInternalTextureLoader {
  58690. /**
  58691. * Defines wether the loader supports cascade loading the different faces.
  58692. */
  58693. readonly supportCascades: boolean;
  58694. /**
  58695. * This returns if the loader support the current file information.
  58696. * @param extension defines the file extension of the file being loaded
  58697. * @returns true if the loader can load the specified file
  58698. */
  58699. canLoad(extension: string): boolean;
  58700. /**
  58701. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58702. * @param data contains the texture data
  58703. * @param texture defines the BabylonJS internal texture
  58704. * @param createPolynomials will be true if polynomials have been requested
  58705. * @param onLoad defines the callback to trigger once the texture is ready
  58706. * @param onError defines the callback to trigger in case of error
  58707. */
  58708. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58709. /**
  58710. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58711. * @param data contains the texture data
  58712. * @param texture defines the BabylonJS internal texture
  58713. * @param callback defines the method to call once ready to upload
  58714. */
  58715. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58716. }
  58717. }
  58718. declare module "babylonjs/Misc/basis" {
  58719. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58720. /**
  58721. * Info about the .basis files
  58722. */
  58723. class BasisFileInfo {
  58724. /**
  58725. * If the file has alpha
  58726. */
  58727. hasAlpha: boolean;
  58728. /**
  58729. * Info about each image of the basis file
  58730. */
  58731. images: Array<{
  58732. levels: Array<{
  58733. width: number;
  58734. height: number;
  58735. transcodedPixels: ArrayBufferView;
  58736. }>;
  58737. }>;
  58738. }
  58739. /**
  58740. * Result of transcoding a basis file
  58741. */
  58742. class TranscodeResult {
  58743. /**
  58744. * Info about the .basis file
  58745. */
  58746. fileInfo: BasisFileInfo;
  58747. /**
  58748. * Format to use when loading the file
  58749. */
  58750. format: number;
  58751. }
  58752. /**
  58753. * Configuration options for the Basis transcoder
  58754. */
  58755. export class BasisTranscodeConfiguration {
  58756. /**
  58757. * Supported compression formats used to determine the supported output format of the transcoder
  58758. */
  58759. supportedCompressionFormats?: {
  58760. /**
  58761. * etc1 compression format
  58762. */
  58763. etc1?: boolean;
  58764. /**
  58765. * s3tc compression format
  58766. */
  58767. s3tc?: boolean;
  58768. /**
  58769. * pvrtc compression format
  58770. */
  58771. pvrtc?: boolean;
  58772. /**
  58773. * etc2 compression format
  58774. */
  58775. etc2?: boolean;
  58776. };
  58777. /**
  58778. * If mipmap levels should be loaded for transcoded images (Default: true)
  58779. */
  58780. loadMipmapLevels?: boolean;
  58781. /**
  58782. * Index of a single image to load (Default: all images)
  58783. */
  58784. loadSingleImage?: number;
  58785. }
  58786. /**
  58787. * Used to load .Basis files
  58788. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58789. */
  58790. export class BasisTools {
  58791. private static _IgnoreSupportedFormats;
  58792. /**
  58793. * URL to use when loading the basis transcoder
  58794. */
  58795. static JSModuleURL: string;
  58796. /**
  58797. * URL to use when loading the wasm module for the transcoder
  58798. */
  58799. static WasmModuleURL: string;
  58800. /**
  58801. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58802. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58803. * @returns internal format corresponding to the Basis format
  58804. */
  58805. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58806. private static _WorkerPromise;
  58807. private static _Worker;
  58808. private static _actionId;
  58809. private static _CreateWorkerAsync;
  58810. /**
  58811. * Transcodes a loaded image file to compressed pixel data
  58812. * @param data image data to transcode
  58813. * @param config configuration options for the transcoding
  58814. * @returns a promise resulting in the transcoded image
  58815. */
  58816. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58817. /**
  58818. * Loads a texture from the transcode result
  58819. * @param texture texture load to
  58820. * @param transcodeResult the result of transcoding the basis file to load from
  58821. */
  58822. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58823. }
  58824. }
  58825. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58826. import { Nullable } from "babylonjs/types";
  58827. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58828. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58829. /**
  58830. * Loader for .basis file format
  58831. */
  58832. export class _BasisTextureLoader implements IInternalTextureLoader {
  58833. /**
  58834. * Defines whether the loader supports cascade loading the different faces.
  58835. */
  58836. readonly supportCascades: boolean;
  58837. /**
  58838. * This returns if the loader support the current file information.
  58839. * @param extension defines the file extension of the file being loaded
  58840. * @returns true if the loader can load the specified file
  58841. */
  58842. canLoad(extension: string): boolean;
  58843. /**
  58844. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58845. * @param data contains the texture data
  58846. * @param texture defines the BabylonJS internal texture
  58847. * @param createPolynomials will be true if polynomials have been requested
  58848. * @param onLoad defines the callback to trigger once the texture is ready
  58849. * @param onError defines the callback to trigger in case of error
  58850. */
  58851. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58852. /**
  58853. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58854. * @param data contains the texture data
  58855. * @param texture defines the BabylonJS internal texture
  58856. * @param callback defines the method to call once ready to upload
  58857. */
  58858. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58859. }
  58860. }
  58861. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58862. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58863. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58864. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58865. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58866. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58867. }
  58868. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58869. import { Scene } from "babylonjs/scene";
  58870. import { Texture } from "babylonjs/Materials/Textures/texture";
  58871. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58872. /**
  58873. * 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.
  58874. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58876. */
  58877. export class CustomProceduralTexture extends ProceduralTexture {
  58878. private _animate;
  58879. private _time;
  58880. private _config;
  58881. private _texturePath;
  58882. /**
  58883. * Instantiates a new Custom Procedural Texture.
  58884. * 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.
  58885. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58886. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58887. * @param name Define the name of the texture
  58888. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58889. * @param size Define the size of the texture to create
  58890. * @param scene Define the scene the texture belongs to
  58891. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58892. * @param generateMipMaps Define if the texture should creates mip maps or not
  58893. */
  58894. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58895. private _loadJson;
  58896. /**
  58897. * Is the texture ready to be used ? (rendered at least once)
  58898. * @returns true if ready, otherwise, false.
  58899. */
  58900. isReady(): boolean;
  58901. /**
  58902. * Render the texture to its associated render target.
  58903. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58904. */
  58905. render(useCameraPostProcess?: boolean): void;
  58906. /**
  58907. * Update the list of dependant textures samplers in the shader.
  58908. */
  58909. updateTextures(): void;
  58910. /**
  58911. * Update the uniform values of the procedural texture in the shader.
  58912. */
  58913. updateShaderUniforms(): void;
  58914. /**
  58915. * Define if the texture animates or not.
  58916. */
  58917. get animate(): boolean;
  58918. set animate(value: boolean);
  58919. }
  58920. }
  58921. declare module "babylonjs/Shaders/noise.fragment" {
  58922. /** @hidden */
  58923. export var noisePixelShader: {
  58924. name: string;
  58925. shader: string;
  58926. };
  58927. }
  58928. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58929. import { Nullable } from "babylonjs/types";
  58930. import { Scene } from "babylonjs/scene";
  58931. import { Texture } from "babylonjs/Materials/Textures/texture";
  58932. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58933. import "babylonjs/Shaders/noise.fragment";
  58934. /**
  58935. * Class used to generate noise procedural textures
  58936. */
  58937. export class NoiseProceduralTexture extends ProceduralTexture {
  58938. private _time;
  58939. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58940. brightness: number;
  58941. /** Defines the number of octaves to process */
  58942. octaves: number;
  58943. /** Defines the level of persistence (0.8 by default) */
  58944. persistence: number;
  58945. /** Gets or sets animation speed factor (default is 1) */
  58946. animationSpeedFactor: number;
  58947. /**
  58948. * Creates a new NoiseProceduralTexture
  58949. * @param name defines the name fo the texture
  58950. * @param size defines the size of the texture (default is 256)
  58951. * @param scene defines the hosting scene
  58952. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58953. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58954. */
  58955. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58956. private _updateShaderUniforms;
  58957. protected _getDefines(): string;
  58958. /** Generate the current state of the procedural texture */
  58959. render(useCameraPostProcess?: boolean): void;
  58960. /**
  58961. * Serializes this noise procedural texture
  58962. * @returns a serialized noise procedural texture object
  58963. */
  58964. serialize(): any;
  58965. /**
  58966. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58967. * @param parsedTexture defines parsed texture data
  58968. * @param scene defines the current scene
  58969. * @param rootUrl defines the root URL containing noise procedural texture information
  58970. * @returns a parsed NoiseProceduralTexture
  58971. */
  58972. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58973. }
  58974. }
  58975. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58976. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58977. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58978. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58979. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58980. }
  58981. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58982. import { Nullable } from "babylonjs/types";
  58983. import { Scene } from "babylonjs/scene";
  58984. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58985. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58986. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58987. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58988. /**
  58989. * Raw cube texture where the raw buffers are passed in
  58990. */
  58991. export class RawCubeTexture extends CubeTexture {
  58992. /**
  58993. * Creates a cube texture where the raw buffers are passed in.
  58994. * @param scene defines the scene the texture is attached to
  58995. * @param data defines the array of data to use to create each face
  58996. * @param size defines the size of the textures
  58997. * @param format defines the format of the data
  58998. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58999. * @param generateMipMaps defines if the engine should generate the mip levels
  59000. * @param invertY defines if data must be stored with Y axis inverted
  59001. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59002. * @param compression defines the compression used (null by default)
  59003. */
  59004. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59005. /**
  59006. * Updates the raw cube texture.
  59007. * @param data defines the data to store
  59008. * @param format defines the data format
  59009. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59010. * @param invertY defines if data must be stored with Y axis inverted
  59011. * @param compression defines the compression used (null by default)
  59012. * @param level defines which level of the texture to update
  59013. */
  59014. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59015. /**
  59016. * Updates a raw cube texture with RGBD encoded data.
  59017. * @param data defines the array of data [mipmap][face] to use to create each face
  59018. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59019. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59020. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59021. * @returns a promsie that resolves when the operation is complete
  59022. */
  59023. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59024. /**
  59025. * Clones the raw cube texture.
  59026. * @return a new cube texture
  59027. */
  59028. clone(): CubeTexture;
  59029. /** @hidden */
  59030. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59031. }
  59032. }
  59033. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59034. import { Scene } from "babylonjs/scene";
  59035. import { Texture } from "babylonjs/Materials/Textures/texture";
  59036. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59037. /**
  59038. * Class used to store 3D textures containing user data
  59039. */
  59040. export class RawTexture3D extends Texture {
  59041. /** Gets or sets the texture format to use */
  59042. format: number;
  59043. private _engine;
  59044. /**
  59045. * Create a new RawTexture3D
  59046. * @param data defines the data of the texture
  59047. * @param width defines the width of the texture
  59048. * @param height defines the height of the texture
  59049. * @param depth defines the depth of the texture
  59050. * @param format defines the texture format to use
  59051. * @param scene defines the hosting scene
  59052. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59053. * @param invertY defines if texture must be stored with Y axis inverted
  59054. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59055. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59056. */
  59057. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59058. /** Gets or sets the texture format to use */
  59059. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59060. /**
  59061. * Update the texture with new data
  59062. * @param data defines the data to store in the texture
  59063. */
  59064. update(data: ArrayBufferView): void;
  59065. }
  59066. }
  59067. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59068. import { Scene } from "babylonjs/scene";
  59069. import { Texture } from "babylonjs/Materials/Textures/texture";
  59070. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59071. /**
  59072. * Class used to store 2D array textures containing user data
  59073. */
  59074. export class RawTexture2DArray extends Texture {
  59075. /** Gets or sets the texture format to use */
  59076. format: number;
  59077. private _engine;
  59078. /**
  59079. * Create a new RawTexture2DArray
  59080. * @param data defines the data of the texture
  59081. * @param width defines the width of the texture
  59082. * @param height defines the height of the texture
  59083. * @param depth defines the number of layers of the texture
  59084. * @param format defines the texture format to use
  59085. * @param scene defines the hosting scene
  59086. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59087. * @param invertY defines if texture must be stored with Y axis inverted
  59088. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59089. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59090. */
  59091. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59092. /** Gets or sets the texture format to use */
  59093. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59094. /**
  59095. * Update the texture with new data
  59096. * @param data defines the data to store in the texture
  59097. */
  59098. update(data: ArrayBufferView): void;
  59099. }
  59100. }
  59101. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59102. import { Scene } from "babylonjs/scene";
  59103. import { Plane } from "babylonjs/Maths/math.plane";
  59104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59105. /**
  59106. * Creates a refraction texture used by refraction channel of the standard material.
  59107. * It is like a mirror but to see through a material.
  59108. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59109. */
  59110. export class RefractionTexture extends RenderTargetTexture {
  59111. /**
  59112. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59113. * 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.
  59114. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59115. */
  59116. refractionPlane: Plane;
  59117. /**
  59118. * Define how deep under the surface we should see.
  59119. */
  59120. depth: number;
  59121. /**
  59122. * Creates a refraction texture used by refraction channel of the standard material.
  59123. * It is like a mirror but to see through a material.
  59124. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59125. * @param name Define the texture name
  59126. * @param size Define the size of the underlying texture
  59127. * @param scene Define the scene the refraction belongs to
  59128. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59129. */
  59130. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59131. /**
  59132. * Clone the refraction texture.
  59133. * @returns the cloned texture
  59134. */
  59135. clone(): RefractionTexture;
  59136. /**
  59137. * Serialize the texture to a JSON representation you could use in Parse later on
  59138. * @returns the serialized JSON representation
  59139. */
  59140. serialize(): any;
  59141. }
  59142. }
  59143. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59144. import { Nullable } from "babylonjs/types";
  59145. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59146. import { Matrix } from "babylonjs/Maths/math.vector";
  59147. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59148. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59149. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59150. import { Scene } from "babylonjs/scene";
  59151. /**
  59152. * Defines the options related to the creation of an HtmlElementTexture
  59153. */
  59154. export interface IHtmlElementTextureOptions {
  59155. /**
  59156. * Defines wether mip maps should be created or not.
  59157. */
  59158. generateMipMaps?: boolean;
  59159. /**
  59160. * Defines the sampling mode of the texture.
  59161. */
  59162. samplingMode?: number;
  59163. /**
  59164. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59165. */
  59166. engine: Nullable<ThinEngine>;
  59167. /**
  59168. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59169. */
  59170. scene: Nullable<Scene>;
  59171. }
  59172. /**
  59173. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59174. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59175. * is automatically managed.
  59176. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59177. * in your application.
  59178. *
  59179. * As the update is not automatic, you need to call them manually.
  59180. */
  59181. export class HtmlElementTexture extends BaseTexture {
  59182. /**
  59183. * The texture URL.
  59184. */
  59185. element: HTMLVideoElement | HTMLCanvasElement;
  59186. private static readonly DefaultOptions;
  59187. private _textureMatrix;
  59188. private _engine;
  59189. private _isVideo;
  59190. private _generateMipMaps;
  59191. private _samplingMode;
  59192. /**
  59193. * Instantiates a HtmlElementTexture from the following parameters.
  59194. *
  59195. * @param name Defines the name of the texture
  59196. * @param element Defines the video or canvas the texture is filled with
  59197. * @param options Defines the other none mandatory texture creation options
  59198. */
  59199. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59200. private _createInternalTexture;
  59201. /**
  59202. * Returns the texture matrix used in most of the material.
  59203. */
  59204. getTextureMatrix(): Matrix;
  59205. /**
  59206. * Updates the content of the texture.
  59207. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59208. */
  59209. update(invertY?: Nullable<boolean>): void;
  59210. }
  59211. }
  59212. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59213. import { Vector2 } from "babylonjs/Maths/math.vector";
  59214. /**
  59215. * Defines the basic options interface of a TexturePacker Frame
  59216. */
  59217. export interface ITexturePackerFrame {
  59218. /**
  59219. * The frame ID
  59220. */
  59221. id: number;
  59222. /**
  59223. * The frames Scale
  59224. */
  59225. scale: Vector2;
  59226. /**
  59227. * The Frames offset
  59228. */
  59229. offset: Vector2;
  59230. }
  59231. /**
  59232. * This is a support class for frame Data on texture packer sets.
  59233. */
  59234. export class TexturePackerFrame implements ITexturePackerFrame {
  59235. /**
  59236. * The frame ID
  59237. */
  59238. id: number;
  59239. /**
  59240. * The frames Scale
  59241. */
  59242. scale: Vector2;
  59243. /**
  59244. * The Frames offset
  59245. */
  59246. offset: Vector2;
  59247. /**
  59248. * Initializes a texture package frame.
  59249. * @param id The numerical frame identifier
  59250. * @param scale Scalar Vector2 for UV frame
  59251. * @param offset Vector2 for the frame position in UV units.
  59252. * @returns TexturePackerFrame
  59253. */
  59254. constructor(id: number, scale: Vector2, offset: Vector2);
  59255. }
  59256. }
  59257. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59259. import { Scene } from "babylonjs/scene";
  59260. import { Nullable } from "babylonjs/types";
  59261. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59262. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59263. /**
  59264. * Defines the basic options interface of a TexturePacker
  59265. */
  59266. export interface ITexturePackerOptions {
  59267. /**
  59268. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59269. */
  59270. map?: string[];
  59271. /**
  59272. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59273. */
  59274. uvsIn?: string;
  59275. /**
  59276. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59277. */
  59278. uvsOut?: string;
  59279. /**
  59280. * number representing the layout style. Defaults to LAYOUT_STRIP
  59281. */
  59282. layout?: number;
  59283. /**
  59284. * number of columns if using custom column count layout(2). This defaults to 4.
  59285. */
  59286. colnum?: number;
  59287. /**
  59288. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59289. */
  59290. updateInputMeshes?: boolean;
  59291. /**
  59292. * boolean flag to dispose all the source textures. Defaults to true.
  59293. */
  59294. disposeSources?: boolean;
  59295. /**
  59296. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59297. */
  59298. fillBlanks?: boolean;
  59299. /**
  59300. * string value representing the context fill style color. Defaults to 'black'.
  59301. */
  59302. customFillColor?: string;
  59303. /**
  59304. * Width and Height Value of each Frame in the TexturePacker Sets
  59305. */
  59306. frameSize?: number;
  59307. /**
  59308. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59309. */
  59310. paddingRatio?: number;
  59311. /**
  59312. * Number that declares the fill method for the padding gutter.
  59313. */
  59314. paddingMode?: number;
  59315. /**
  59316. * If in SUBUV_COLOR padding mode what color to use.
  59317. */
  59318. paddingColor?: Color3 | Color4;
  59319. }
  59320. /**
  59321. * Defines the basic interface of a TexturePacker JSON File
  59322. */
  59323. export interface ITexturePackerJSON {
  59324. /**
  59325. * The frame ID
  59326. */
  59327. name: string;
  59328. /**
  59329. * The base64 channel data
  59330. */
  59331. sets: any;
  59332. /**
  59333. * The options of the Packer
  59334. */
  59335. options: ITexturePackerOptions;
  59336. /**
  59337. * The frame data of the Packer
  59338. */
  59339. frames: Array<number>;
  59340. }
  59341. /**
  59342. * This is a support class that generates a series of packed texture sets.
  59343. * @see https://doc.babylonjs.com/babylon101/materials
  59344. */
  59345. export class TexturePacker {
  59346. /** Packer Layout Constant 0 */
  59347. static readonly LAYOUT_STRIP: number;
  59348. /** Packer Layout Constant 1 */
  59349. static readonly LAYOUT_POWER2: number;
  59350. /** Packer Layout Constant 2 */
  59351. static readonly LAYOUT_COLNUM: number;
  59352. /** Packer Layout Constant 0 */
  59353. static readonly SUBUV_WRAP: number;
  59354. /** Packer Layout Constant 1 */
  59355. static readonly SUBUV_EXTEND: number;
  59356. /** Packer Layout Constant 2 */
  59357. static readonly SUBUV_COLOR: number;
  59358. /** The Name of the Texture Package */
  59359. name: string;
  59360. /** The scene scope of the TexturePacker */
  59361. scene: Scene;
  59362. /** The Meshes to target */
  59363. meshes: AbstractMesh[];
  59364. /** Arguments passed with the Constructor */
  59365. options: ITexturePackerOptions;
  59366. /** The promise that is started upon initialization */
  59367. promise: Nullable<Promise<TexturePacker | string>>;
  59368. /** The Container object for the channel sets that are generated */
  59369. sets: object;
  59370. /** The Container array for the frames that are generated */
  59371. frames: TexturePackerFrame[];
  59372. /** The expected number of textures the system is parsing. */
  59373. private _expecting;
  59374. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59375. private _paddingValue;
  59376. /**
  59377. * Initializes a texture package series from an array of meshes or a single mesh.
  59378. * @param name The name of the package
  59379. * @param meshes The target meshes to compose the package from
  59380. * @param options The arguments that texture packer should follow while building.
  59381. * @param scene The scene which the textures are scoped to.
  59382. * @returns TexturePacker
  59383. */
  59384. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59385. /**
  59386. * Starts the package process
  59387. * @param resolve The promises resolution function
  59388. * @returns TexturePacker
  59389. */
  59390. private _createFrames;
  59391. /**
  59392. * Calculates the Size of the Channel Sets
  59393. * @returns Vector2
  59394. */
  59395. private _calculateSize;
  59396. /**
  59397. * Calculates the UV data for the frames.
  59398. * @param baseSize the base frameSize
  59399. * @param padding the base frame padding
  59400. * @param dtSize size of the Dynamic Texture for that channel
  59401. * @param dtUnits is 1/dtSize
  59402. * @param update flag to update the input meshes
  59403. */
  59404. private _calculateMeshUVFrames;
  59405. /**
  59406. * Calculates the frames Offset.
  59407. * @param index of the frame
  59408. * @returns Vector2
  59409. */
  59410. private _getFrameOffset;
  59411. /**
  59412. * Updates a Mesh to the frame data
  59413. * @param mesh that is the target
  59414. * @param frameID or the frame index
  59415. */
  59416. private _updateMeshUV;
  59417. /**
  59418. * Updates a Meshes materials to use the texture packer channels
  59419. * @param m is the mesh to target
  59420. * @param force all channels on the packer to be set.
  59421. */
  59422. private _updateTextureReferences;
  59423. /**
  59424. * Public method to set a Mesh to a frame
  59425. * @param m that is the target
  59426. * @param frameID or the frame index
  59427. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59428. */
  59429. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59430. /**
  59431. * Starts the async promise to compile the texture packer.
  59432. * @returns Promise<void>
  59433. */
  59434. processAsync(): Promise<void>;
  59435. /**
  59436. * Disposes all textures associated with this packer
  59437. */
  59438. dispose(): void;
  59439. /**
  59440. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59441. * @param imageType is the image type to use.
  59442. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59443. */
  59444. download(imageType?: string, quality?: number): void;
  59445. /**
  59446. * Public method to load a texturePacker JSON file.
  59447. * @param data of the JSON file in string format.
  59448. */
  59449. updateFromJSON(data: string): void;
  59450. }
  59451. }
  59452. declare module "babylonjs/Materials/Textures/Packer/index" {
  59453. export * from "babylonjs/Materials/Textures/Packer/packer";
  59454. export * from "babylonjs/Materials/Textures/Packer/frame";
  59455. }
  59456. declare module "babylonjs/Materials/Textures/index" {
  59457. export * from "babylonjs/Materials/Textures/baseTexture";
  59458. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59459. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59460. export * from "babylonjs/Materials/Textures/cubeTexture";
  59461. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59462. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59463. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59464. export * from "babylonjs/Materials/Textures/internalTexture";
  59465. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59466. export * from "babylonjs/Materials/Textures/Loaders/index";
  59467. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59468. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59469. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59470. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59471. export * from "babylonjs/Materials/Textures/rawTexture";
  59472. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59473. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59474. export * from "babylonjs/Materials/Textures/refractionTexture";
  59475. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59476. export * from "babylonjs/Materials/Textures/texture";
  59477. export * from "babylonjs/Materials/Textures/videoTexture";
  59478. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59479. export * from "babylonjs/Materials/Textures/Packer/index";
  59480. }
  59481. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59482. /**
  59483. * Enum used to define the target of a block
  59484. */
  59485. export enum NodeMaterialBlockTargets {
  59486. /** Vertex shader */
  59487. Vertex = 1,
  59488. /** Fragment shader */
  59489. Fragment = 2,
  59490. /** Neutral */
  59491. Neutral = 4,
  59492. /** Vertex and Fragment */
  59493. VertexAndFragment = 3
  59494. }
  59495. }
  59496. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59497. /**
  59498. * Defines the kind of connection point for node based material
  59499. */
  59500. export enum NodeMaterialBlockConnectionPointTypes {
  59501. /** Float */
  59502. Float = 1,
  59503. /** Int */
  59504. Int = 2,
  59505. /** Vector2 */
  59506. Vector2 = 4,
  59507. /** Vector3 */
  59508. Vector3 = 8,
  59509. /** Vector4 */
  59510. Vector4 = 16,
  59511. /** Color3 */
  59512. Color3 = 32,
  59513. /** Color4 */
  59514. Color4 = 64,
  59515. /** Matrix */
  59516. Matrix = 128,
  59517. /** Detect type based on connection */
  59518. AutoDetect = 1024,
  59519. /** Output type that will be defined by input type */
  59520. BasedOnInput = 2048
  59521. }
  59522. }
  59523. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59524. /**
  59525. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59526. */
  59527. export enum NodeMaterialBlockConnectionPointMode {
  59528. /** Value is an uniform */
  59529. Uniform = 0,
  59530. /** Value is a mesh attribute */
  59531. Attribute = 1,
  59532. /** Value is a varying between vertex and fragment shaders */
  59533. Varying = 2,
  59534. /** Mode is undefined */
  59535. Undefined = 3
  59536. }
  59537. }
  59538. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59539. /**
  59540. * Enum used to define system values e.g. values automatically provided by the system
  59541. */
  59542. export enum NodeMaterialSystemValues {
  59543. /** World */
  59544. World = 1,
  59545. /** View */
  59546. View = 2,
  59547. /** Projection */
  59548. Projection = 3,
  59549. /** ViewProjection */
  59550. ViewProjection = 4,
  59551. /** WorldView */
  59552. WorldView = 5,
  59553. /** WorldViewProjection */
  59554. WorldViewProjection = 6,
  59555. /** CameraPosition */
  59556. CameraPosition = 7,
  59557. /** Fog Color */
  59558. FogColor = 8,
  59559. /** Delta time */
  59560. DeltaTime = 9
  59561. }
  59562. }
  59563. declare module "babylonjs/Materials/Node/Enums/index" {
  59564. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59565. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59566. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59567. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59568. }
  59569. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59571. /**
  59572. * Root class for all node material optimizers
  59573. */
  59574. export class NodeMaterialOptimizer {
  59575. /**
  59576. * Function used to optimize a NodeMaterial graph
  59577. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59578. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59579. */
  59580. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59581. }
  59582. }
  59583. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59587. import { Scene } from "babylonjs/scene";
  59588. /**
  59589. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59590. */
  59591. export class TransformBlock extends NodeMaterialBlock {
  59592. /**
  59593. * Defines the value to use to complement W value to transform it to a Vector4
  59594. */
  59595. complementW: number;
  59596. /**
  59597. * Defines the value to use to complement z value to transform it to a Vector4
  59598. */
  59599. complementZ: number;
  59600. /**
  59601. * Creates a new TransformBlock
  59602. * @param name defines the block name
  59603. */
  59604. constructor(name: string);
  59605. /**
  59606. * Gets the current class name
  59607. * @returns the class name
  59608. */
  59609. getClassName(): string;
  59610. /**
  59611. * Gets the vector input
  59612. */
  59613. get vector(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the output component
  59616. */
  59617. get output(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the xyz output component
  59620. */
  59621. get xyz(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the matrix transform input
  59624. */
  59625. get transform(): NodeMaterialConnectionPoint;
  59626. protected _buildBlock(state: NodeMaterialBuildState): this;
  59627. serialize(): any;
  59628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59629. protected _dumpPropertiesCode(): string;
  59630. }
  59631. }
  59632. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59636. /**
  59637. * Block used to output the vertex position
  59638. */
  59639. export class VertexOutputBlock extends NodeMaterialBlock {
  59640. /**
  59641. * Creates a new VertexOutputBlock
  59642. * @param name defines the block name
  59643. */
  59644. constructor(name: string);
  59645. /**
  59646. * Gets the current class name
  59647. * @returns the class name
  59648. */
  59649. getClassName(): string;
  59650. /**
  59651. * Gets the vector input component
  59652. */
  59653. get vector(): NodeMaterialConnectionPoint;
  59654. protected _buildBlock(state: NodeMaterialBuildState): this;
  59655. }
  59656. }
  59657. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59661. /**
  59662. * Block used to output the final color
  59663. */
  59664. export class FragmentOutputBlock extends NodeMaterialBlock {
  59665. /**
  59666. * Create a new FragmentOutputBlock
  59667. * @param name defines the block name
  59668. */
  59669. constructor(name: string);
  59670. /**
  59671. * Gets the current class name
  59672. * @returns the class name
  59673. */
  59674. getClassName(): string;
  59675. /**
  59676. * Gets the rgba input component
  59677. */
  59678. get rgba(): NodeMaterialConnectionPoint;
  59679. /**
  59680. * Gets the rgb input component
  59681. */
  59682. get rgb(): NodeMaterialConnectionPoint;
  59683. /**
  59684. * Gets the a input component
  59685. */
  59686. get a(): NodeMaterialConnectionPoint;
  59687. protected _buildBlock(state: NodeMaterialBuildState): this;
  59688. }
  59689. }
  59690. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59696. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59697. import { Effect } from "babylonjs/Materials/effect";
  59698. import { Mesh } from "babylonjs/Meshes/mesh";
  59699. import { Nullable } from "babylonjs/types";
  59700. import { Scene } from "babylonjs/scene";
  59701. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59702. /**
  59703. * Block used to read a reflection texture from a sampler
  59704. */
  59705. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59706. private _define3DName;
  59707. private _defineCubicName;
  59708. private _defineExplicitName;
  59709. private _defineProjectionName;
  59710. private _defineLocalCubicName;
  59711. private _defineSphericalName;
  59712. private _definePlanarName;
  59713. private _defineEquirectangularName;
  59714. private _defineMirroredEquirectangularFixedName;
  59715. private _defineEquirectangularFixedName;
  59716. private _defineSkyboxName;
  59717. private _cubeSamplerName;
  59718. private _2DSamplerName;
  59719. private _positionUVWName;
  59720. private _directionWName;
  59721. private _reflectionCoordsName;
  59722. private _reflection2DCoordsName;
  59723. private _reflectionColorName;
  59724. private _reflectionMatrixName;
  59725. /**
  59726. * Gets or sets the texture associated with the node
  59727. */
  59728. texture: Nullable<BaseTexture>;
  59729. /**
  59730. * Create a new TextureBlock
  59731. * @param name defines the block name
  59732. */
  59733. constructor(name: string);
  59734. /**
  59735. * Gets the current class name
  59736. * @returns the class name
  59737. */
  59738. getClassName(): string;
  59739. /**
  59740. * Gets the world position input component
  59741. */
  59742. get position(): NodeMaterialConnectionPoint;
  59743. /**
  59744. * Gets the world position input component
  59745. */
  59746. get worldPosition(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the world normal input component
  59749. */
  59750. get worldNormal(): NodeMaterialConnectionPoint;
  59751. /**
  59752. * Gets the world input component
  59753. */
  59754. get world(): NodeMaterialConnectionPoint;
  59755. /**
  59756. * Gets the camera (or eye) position component
  59757. */
  59758. get cameraPosition(): NodeMaterialConnectionPoint;
  59759. /**
  59760. * Gets the view input component
  59761. */
  59762. get view(): NodeMaterialConnectionPoint;
  59763. /**
  59764. * Gets the rgb output component
  59765. */
  59766. get rgb(): NodeMaterialConnectionPoint;
  59767. /**
  59768. * Gets the r output component
  59769. */
  59770. get r(): NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the g output component
  59773. */
  59774. get g(): NodeMaterialConnectionPoint;
  59775. /**
  59776. * Gets the b output component
  59777. */
  59778. get b(): NodeMaterialConnectionPoint;
  59779. autoConfigure(material: NodeMaterial): void;
  59780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59781. isReady(): boolean;
  59782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59783. private _injectVertexCode;
  59784. private _writeOutput;
  59785. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59786. protected _dumpPropertiesCode(): string;
  59787. serialize(): any;
  59788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59789. }
  59790. }
  59791. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59793. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59794. import { Scene } from "babylonjs/scene";
  59795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59796. import { Matrix } from "babylonjs/Maths/math.vector";
  59797. import { Mesh } from "babylonjs/Meshes/mesh";
  59798. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59799. import { Observable } from "babylonjs/Misc/observable";
  59800. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59801. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59802. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59803. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59804. import { Nullable } from "babylonjs/types";
  59805. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59806. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59807. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59808. /**
  59809. * Interface used to configure the node material editor
  59810. */
  59811. export interface INodeMaterialEditorOptions {
  59812. /** Define the URl to load node editor script */
  59813. editorURL?: string;
  59814. }
  59815. /** @hidden */
  59816. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59817. NORMAL: boolean;
  59818. TANGENT: boolean;
  59819. UV1: boolean;
  59820. /** BONES */
  59821. NUM_BONE_INFLUENCERS: number;
  59822. BonesPerMesh: number;
  59823. BONETEXTURE: boolean;
  59824. /** MORPH TARGETS */
  59825. MORPHTARGETS: boolean;
  59826. MORPHTARGETS_NORMAL: boolean;
  59827. MORPHTARGETS_TANGENT: boolean;
  59828. MORPHTARGETS_UV: boolean;
  59829. NUM_MORPH_INFLUENCERS: number;
  59830. /** IMAGE PROCESSING */
  59831. IMAGEPROCESSING: boolean;
  59832. VIGNETTE: boolean;
  59833. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59834. VIGNETTEBLENDMODEOPAQUE: boolean;
  59835. TONEMAPPING: boolean;
  59836. TONEMAPPING_ACES: boolean;
  59837. CONTRAST: boolean;
  59838. EXPOSURE: boolean;
  59839. COLORCURVES: boolean;
  59840. COLORGRADING: boolean;
  59841. COLORGRADING3D: boolean;
  59842. SAMPLER3DGREENDEPTH: boolean;
  59843. SAMPLER3DBGRMAP: boolean;
  59844. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59845. /** MISC. */
  59846. BUMPDIRECTUV: number;
  59847. constructor();
  59848. setValue(name: string, value: boolean): void;
  59849. }
  59850. /**
  59851. * Class used to configure NodeMaterial
  59852. */
  59853. export interface INodeMaterialOptions {
  59854. /**
  59855. * Defines if blocks should emit comments
  59856. */
  59857. emitComments: boolean;
  59858. }
  59859. /**
  59860. * Class used to create a node based material built by assembling shader blocks
  59861. */
  59862. export class NodeMaterial extends PushMaterial {
  59863. private static _BuildIdGenerator;
  59864. private _options;
  59865. private _vertexCompilationState;
  59866. private _fragmentCompilationState;
  59867. private _sharedData;
  59868. private _buildId;
  59869. private _buildWasSuccessful;
  59870. private _cachedWorldViewMatrix;
  59871. private _cachedWorldViewProjectionMatrix;
  59872. private _optimizers;
  59873. private _animationFrame;
  59874. /** Define the Url to load node editor script */
  59875. static EditorURL: string;
  59876. /** Define the Url to load snippets */
  59877. static SnippetUrl: string;
  59878. private BJSNODEMATERIALEDITOR;
  59879. /** Get the inspector from bundle or global */
  59880. private _getGlobalNodeMaterialEditor;
  59881. /**
  59882. * Gets or sets data used by visual editor
  59883. * @see https://nme.babylonjs.com
  59884. */
  59885. editorData: any;
  59886. /**
  59887. * 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)
  59888. */
  59889. ignoreAlpha: boolean;
  59890. /**
  59891. * Defines the maximum number of lights that can be used in the material
  59892. */
  59893. maxSimultaneousLights: number;
  59894. /**
  59895. * Observable raised when the material is built
  59896. */
  59897. onBuildObservable: Observable<NodeMaterial>;
  59898. /**
  59899. * Gets or sets the root nodes of the material vertex shader
  59900. */
  59901. _vertexOutputNodes: NodeMaterialBlock[];
  59902. /**
  59903. * Gets or sets the root nodes of the material fragment (pixel) shader
  59904. */
  59905. _fragmentOutputNodes: NodeMaterialBlock[];
  59906. /** Gets or sets options to control the node material overall behavior */
  59907. get options(): INodeMaterialOptions;
  59908. set options(options: INodeMaterialOptions);
  59909. /**
  59910. * Default configuration related to image processing available in the standard Material.
  59911. */
  59912. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59913. /**
  59914. * Gets the image processing configuration used either in this material.
  59915. */
  59916. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59917. /**
  59918. * Sets the Default image processing configuration used either in the this material.
  59919. *
  59920. * If sets to null, the scene one is in use.
  59921. */
  59922. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59923. /**
  59924. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59925. */
  59926. attachedBlocks: NodeMaterialBlock[];
  59927. /**
  59928. * Create a new node based material
  59929. * @param name defines the material name
  59930. * @param scene defines the hosting scene
  59931. * @param options defines creation option
  59932. */
  59933. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59934. /**
  59935. * Gets the current class name of the material e.g. "NodeMaterial"
  59936. * @returns the class name
  59937. */
  59938. getClassName(): string;
  59939. /**
  59940. * Keep track of the image processing observer to allow dispose and replace.
  59941. */
  59942. private _imageProcessingObserver;
  59943. /**
  59944. * Attaches a new image processing configuration to the Standard Material.
  59945. * @param configuration
  59946. */
  59947. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59948. /**
  59949. * Get a block by its name
  59950. * @param name defines the name of the block to retrieve
  59951. * @returns the required block or null if not found
  59952. */
  59953. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59954. /**
  59955. * Get a block by its name
  59956. * @param predicate defines the predicate used to find the good candidate
  59957. * @returns the required block or null if not found
  59958. */
  59959. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59960. /**
  59961. * Get an input block by its name
  59962. * @param predicate defines the predicate used to find the good candidate
  59963. * @returns the required input block or null if not found
  59964. */
  59965. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59966. /**
  59967. * Gets the list of input blocks attached to this material
  59968. * @returns an array of InputBlocks
  59969. */
  59970. getInputBlocks(): InputBlock[];
  59971. /**
  59972. * Adds a new optimizer to the list of optimizers
  59973. * @param optimizer defines the optimizers to add
  59974. * @returns the current material
  59975. */
  59976. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59977. /**
  59978. * Remove an optimizer from the list of optimizers
  59979. * @param optimizer defines the optimizers to remove
  59980. * @returns the current material
  59981. */
  59982. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59983. /**
  59984. * Add a new block to the list of output nodes
  59985. * @param node defines the node to add
  59986. * @returns the current material
  59987. */
  59988. addOutputNode(node: NodeMaterialBlock): this;
  59989. /**
  59990. * Remove a block from the list of root nodes
  59991. * @param node defines the node to remove
  59992. * @returns the current material
  59993. */
  59994. removeOutputNode(node: NodeMaterialBlock): this;
  59995. private _addVertexOutputNode;
  59996. private _removeVertexOutputNode;
  59997. private _addFragmentOutputNode;
  59998. private _removeFragmentOutputNode;
  59999. /**
  60000. * Specifies if the material will require alpha blending
  60001. * @returns a boolean specifying if alpha blending is needed
  60002. */
  60003. needAlphaBlending(): boolean;
  60004. /**
  60005. * Specifies if this material should be rendered in alpha test mode
  60006. * @returns a boolean specifying if an alpha test is needed.
  60007. */
  60008. needAlphaTesting(): boolean;
  60009. private _initializeBlock;
  60010. private _resetDualBlocks;
  60011. /**
  60012. * Remove a block from the current node material
  60013. * @param block defines the block to remove
  60014. */
  60015. removeBlock(block: NodeMaterialBlock): void;
  60016. /**
  60017. * Build the material and generates the inner effect
  60018. * @param verbose defines if the build should log activity
  60019. */
  60020. build(verbose?: boolean): void;
  60021. /**
  60022. * Runs an otpimization phase to try to improve the shader code
  60023. */
  60024. optimize(): void;
  60025. private _prepareDefinesForAttributes;
  60026. /**
  60027. * Get if the submesh is ready to be used and all its information available.
  60028. * Child classes can use it to update shaders
  60029. * @param mesh defines the mesh to check
  60030. * @param subMesh defines which submesh to check
  60031. * @param useInstances specifies that instances should be used
  60032. * @returns a boolean indicating that the submesh is ready or not
  60033. */
  60034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60035. /**
  60036. * Get a string representing the shaders built by the current node graph
  60037. */
  60038. get compiledShaders(): string;
  60039. /**
  60040. * Binds the world matrix to the material
  60041. * @param world defines the world transformation matrix
  60042. */
  60043. bindOnlyWorldMatrix(world: Matrix): void;
  60044. /**
  60045. * Binds the submesh to this material by preparing the effect and shader to draw
  60046. * @param world defines the world transformation matrix
  60047. * @param mesh defines the mesh containing the submesh
  60048. * @param subMesh defines the submesh to bind the material to
  60049. */
  60050. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60051. /**
  60052. * Gets the active textures from the material
  60053. * @returns an array of textures
  60054. */
  60055. getActiveTextures(): BaseTexture[];
  60056. /**
  60057. * Gets the list of texture blocks
  60058. * @returns an array of texture blocks
  60059. */
  60060. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60061. /**
  60062. * Specifies if the material uses a texture
  60063. * @param texture defines the texture to check against the material
  60064. * @returns a boolean specifying if the material uses the texture
  60065. */
  60066. hasTexture(texture: BaseTexture): boolean;
  60067. /**
  60068. * Disposes the material
  60069. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60070. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60071. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60072. */
  60073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60074. /** Creates the node editor window. */
  60075. private _createNodeEditor;
  60076. /**
  60077. * Launch the node material editor
  60078. * @param config Define the configuration of the editor
  60079. * @return a promise fulfilled when the node editor is visible
  60080. */
  60081. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60082. /**
  60083. * Clear the current material
  60084. */
  60085. clear(): void;
  60086. /**
  60087. * Clear the current material and set it to a default state
  60088. */
  60089. setToDefault(): void;
  60090. /**
  60091. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60092. * @param url defines the url to load from
  60093. * @returns a promise that will fullfil when the material is fully loaded
  60094. */
  60095. loadAsync(url: string): Promise<void>;
  60096. private _gatherBlocks;
  60097. /**
  60098. * Generate a string containing the code declaration required to create an equivalent of this material
  60099. * @returns a string
  60100. */
  60101. generateCode(): string;
  60102. /**
  60103. * Serializes this material in a JSON representation
  60104. * @returns the serialized material object
  60105. */
  60106. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60107. private _restoreConnections;
  60108. /**
  60109. * Clear the current graph and load a new one from a serialization object
  60110. * @param source defines the JSON representation of the material
  60111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60112. */
  60113. loadFromSerialization(source: any, rootUrl?: string): void;
  60114. /**
  60115. * Creates a node material from parsed material data
  60116. * @param source defines the JSON representation of the material
  60117. * @param scene defines the hosting scene
  60118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60119. * @returns a new node material
  60120. */
  60121. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60122. /**
  60123. * Creates a node material from a snippet saved in a remote file
  60124. * @param name defines the name of the material to create
  60125. * @param url defines the url to load from
  60126. * @param scene defines the hosting scene
  60127. * @returns a promise that will resolve to the new node material
  60128. */
  60129. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60130. /**
  60131. * Creates a node material from a snippet saved by the node material editor
  60132. * @param snippetId defines the snippet to load
  60133. * @param scene defines the hosting scene
  60134. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60135. * @returns a promise that will resolve to the new node material
  60136. */
  60137. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  60138. /**
  60139. * Creates a new node material set to default basic configuration
  60140. * @param name defines the name of the material
  60141. * @param scene defines the hosting scene
  60142. * @returns a new NodeMaterial
  60143. */
  60144. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60145. }
  60146. }
  60147. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60150. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60151. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60153. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60154. import { Effect } from "babylonjs/Materials/effect";
  60155. import { Mesh } from "babylonjs/Meshes/mesh";
  60156. import { Nullable } from "babylonjs/types";
  60157. import { Texture } from "babylonjs/Materials/Textures/texture";
  60158. import { Scene } from "babylonjs/scene";
  60159. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60160. /**
  60161. * Block used to read a texture from a sampler
  60162. */
  60163. export class TextureBlock extends NodeMaterialBlock {
  60164. private _defineName;
  60165. private _linearDefineName;
  60166. private _tempTextureRead;
  60167. private _samplerName;
  60168. private _transformedUVName;
  60169. private _textureTransformName;
  60170. private _textureInfoName;
  60171. private _mainUVName;
  60172. private _mainUVDefineName;
  60173. /**
  60174. * Gets or sets the texture associated with the node
  60175. */
  60176. texture: Nullable<Texture>;
  60177. /**
  60178. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60179. */
  60180. convertToGammaSpace: boolean;
  60181. /**
  60182. * Create a new TextureBlock
  60183. * @param name defines the block name
  60184. */
  60185. constructor(name: string);
  60186. /**
  60187. * Gets the current class name
  60188. * @returns the class name
  60189. */
  60190. getClassName(): string;
  60191. /**
  60192. * Gets the uv input component
  60193. */
  60194. get uv(): NodeMaterialConnectionPoint;
  60195. /**
  60196. * Gets the rgba output component
  60197. */
  60198. get rgba(): NodeMaterialConnectionPoint;
  60199. /**
  60200. * Gets the rgb output component
  60201. */
  60202. get rgb(): NodeMaterialConnectionPoint;
  60203. /**
  60204. * Gets the r output component
  60205. */
  60206. get r(): NodeMaterialConnectionPoint;
  60207. /**
  60208. * Gets the g output component
  60209. */
  60210. get g(): NodeMaterialConnectionPoint;
  60211. /**
  60212. * Gets the b output component
  60213. */
  60214. get b(): NodeMaterialConnectionPoint;
  60215. /**
  60216. * Gets the a output component
  60217. */
  60218. get a(): NodeMaterialConnectionPoint;
  60219. get target(): NodeMaterialBlockTargets;
  60220. autoConfigure(material: NodeMaterial): void;
  60221. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60223. isReady(): boolean;
  60224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60225. private get _isMixed();
  60226. private _injectVertexCode;
  60227. private _writeTextureRead;
  60228. private _writeOutput;
  60229. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60230. protected _dumpPropertiesCode(): string;
  60231. serialize(): any;
  60232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60233. }
  60234. }
  60235. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60238. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60239. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60240. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60241. import { Scene } from "babylonjs/scene";
  60242. /**
  60243. * Class used to store shared data between 2 NodeMaterialBuildState
  60244. */
  60245. export class NodeMaterialBuildStateSharedData {
  60246. /**
  60247. * Gets the list of emitted varyings
  60248. */
  60249. temps: string[];
  60250. /**
  60251. * Gets the list of emitted varyings
  60252. */
  60253. varyings: string[];
  60254. /**
  60255. * Gets the varying declaration string
  60256. */
  60257. varyingDeclaration: string;
  60258. /**
  60259. * Input blocks
  60260. */
  60261. inputBlocks: InputBlock[];
  60262. /**
  60263. * Input blocks
  60264. */
  60265. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60266. /**
  60267. * Bindable blocks (Blocks that need to set data to the effect)
  60268. */
  60269. bindableBlocks: NodeMaterialBlock[];
  60270. /**
  60271. * List of blocks that can provide a compilation fallback
  60272. */
  60273. blocksWithFallbacks: NodeMaterialBlock[];
  60274. /**
  60275. * List of blocks that can provide a define update
  60276. */
  60277. blocksWithDefines: NodeMaterialBlock[];
  60278. /**
  60279. * List of blocks that can provide a repeatable content
  60280. */
  60281. repeatableContentBlocks: NodeMaterialBlock[];
  60282. /**
  60283. * List of blocks that can provide a dynamic list of uniforms
  60284. */
  60285. dynamicUniformBlocks: NodeMaterialBlock[];
  60286. /**
  60287. * List of blocks that can block the isReady function for the material
  60288. */
  60289. blockingBlocks: NodeMaterialBlock[];
  60290. /**
  60291. * Gets the list of animated inputs
  60292. */
  60293. animatedInputs: InputBlock[];
  60294. /**
  60295. * Build Id used to avoid multiple recompilations
  60296. */
  60297. buildId: number;
  60298. /** List of emitted variables */
  60299. variableNames: {
  60300. [key: string]: number;
  60301. };
  60302. /** List of emitted defines */
  60303. defineNames: {
  60304. [key: string]: number;
  60305. };
  60306. /** Should emit comments? */
  60307. emitComments: boolean;
  60308. /** Emit build activity */
  60309. verbose: boolean;
  60310. /** Gets or sets the hosting scene */
  60311. scene: Scene;
  60312. /**
  60313. * Gets the compilation hints emitted at compilation time
  60314. */
  60315. hints: {
  60316. needWorldViewMatrix: boolean;
  60317. needWorldViewProjectionMatrix: boolean;
  60318. needAlphaBlending: boolean;
  60319. needAlphaTesting: boolean;
  60320. };
  60321. /**
  60322. * List of compilation checks
  60323. */
  60324. checks: {
  60325. emitVertex: boolean;
  60326. emitFragment: boolean;
  60327. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60328. };
  60329. /** Creates a new shared data */
  60330. constructor();
  60331. /**
  60332. * Emits console errors and exceptions if there is a failing check
  60333. */
  60334. emitErrors(): void;
  60335. }
  60336. }
  60337. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60338. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60339. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60340. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60341. /**
  60342. * Class used to store node based material build state
  60343. */
  60344. export class NodeMaterialBuildState {
  60345. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60346. supportUniformBuffers: boolean;
  60347. /**
  60348. * Gets the list of emitted attributes
  60349. */
  60350. attributes: string[];
  60351. /**
  60352. * Gets the list of emitted uniforms
  60353. */
  60354. uniforms: string[];
  60355. /**
  60356. * Gets the list of emitted constants
  60357. */
  60358. constants: string[];
  60359. /**
  60360. * Gets the list of emitted samplers
  60361. */
  60362. samplers: string[];
  60363. /**
  60364. * Gets the list of emitted functions
  60365. */
  60366. functions: {
  60367. [key: string]: string;
  60368. };
  60369. /**
  60370. * Gets the list of emitted extensions
  60371. */
  60372. extensions: {
  60373. [key: string]: string;
  60374. };
  60375. /**
  60376. * Gets the target of the compilation state
  60377. */
  60378. target: NodeMaterialBlockTargets;
  60379. /**
  60380. * Gets the list of emitted counters
  60381. */
  60382. counters: {
  60383. [key: string]: number;
  60384. };
  60385. /**
  60386. * Shared data between multiple NodeMaterialBuildState instances
  60387. */
  60388. sharedData: NodeMaterialBuildStateSharedData;
  60389. /** @hidden */
  60390. _vertexState: NodeMaterialBuildState;
  60391. /** @hidden */
  60392. _attributeDeclaration: string;
  60393. /** @hidden */
  60394. _uniformDeclaration: string;
  60395. /** @hidden */
  60396. _constantDeclaration: string;
  60397. /** @hidden */
  60398. _samplerDeclaration: string;
  60399. /** @hidden */
  60400. _varyingTransfer: string;
  60401. private _repeatableContentAnchorIndex;
  60402. /** @hidden */
  60403. _builtCompilationString: string;
  60404. /**
  60405. * Gets the emitted compilation strings
  60406. */
  60407. compilationString: string;
  60408. /**
  60409. * Finalize the compilation strings
  60410. * @param state defines the current compilation state
  60411. */
  60412. finalize(state: NodeMaterialBuildState): void;
  60413. /** @hidden */
  60414. get _repeatableContentAnchor(): string;
  60415. /** @hidden */
  60416. _getFreeVariableName(prefix: string): string;
  60417. /** @hidden */
  60418. _getFreeDefineName(prefix: string): string;
  60419. /** @hidden */
  60420. _excludeVariableName(name: string): void;
  60421. /** @hidden */
  60422. _emit2DSampler(name: string): void;
  60423. /** @hidden */
  60424. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60425. /** @hidden */
  60426. _emitExtension(name: string, extension: string): void;
  60427. /** @hidden */
  60428. _emitFunction(name: string, code: string, comments: string): void;
  60429. /** @hidden */
  60430. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60431. replaceStrings?: {
  60432. search: RegExp;
  60433. replace: string;
  60434. }[];
  60435. repeatKey?: string;
  60436. }): string;
  60437. /** @hidden */
  60438. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60439. repeatKey?: string;
  60440. removeAttributes?: boolean;
  60441. removeUniforms?: boolean;
  60442. removeVaryings?: boolean;
  60443. removeIfDef?: boolean;
  60444. replaceStrings?: {
  60445. search: RegExp;
  60446. replace: string;
  60447. }[];
  60448. }, storeKey?: string): void;
  60449. /** @hidden */
  60450. _registerTempVariable(name: string): boolean;
  60451. /** @hidden */
  60452. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60453. /** @hidden */
  60454. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60455. /** @hidden */
  60456. _emitFloat(value: number): string;
  60457. }
  60458. }
  60459. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60460. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60462. import { Nullable } from "babylonjs/types";
  60463. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60464. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60465. import { Effect } from "babylonjs/Materials/effect";
  60466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60467. import { Mesh } from "babylonjs/Meshes/mesh";
  60468. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60469. import { Scene } from "babylonjs/scene";
  60470. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60471. /**
  60472. * Defines a block that can be used inside a node based material
  60473. */
  60474. export class NodeMaterialBlock {
  60475. private _buildId;
  60476. private _buildTarget;
  60477. private _target;
  60478. private _isFinalMerger;
  60479. private _isInput;
  60480. protected _isUnique: boolean;
  60481. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60482. inputsAreExclusive: boolean;
  60483. /** @hidden */
  60484. _codeVariableName: string;
  60485. /** @hidden */
  60486. _inputs: NodeMaterialConnectionPoint[];
  60487. /** @hidden */
  60488. _outputs: NodeMaterialConnectionPoint[];
  60489. /** @hidden */
  60490. _preparationId: number;
  60491. /**
  60492. * Gets or sets the name of the block
  60493. */
  60494. name: string;
  60495. /**
  60496. * Gets or sets the unique id of the node
  60497. */
  60498. uniqueId: number;
  60499. /**
  60500. * Gets or sets the comments associated with this block
  60501. */
  60502. comments: string;
  60503. /**
  60504. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60505. */
  60506. get isUnique(): boolean;
  60507. /**
  60508. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60509. */
  60510. get isFinalMerger(): boolean;
  60511. /**
  60512. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60513. */
  60514. get isInput(): boolean;
  60515. /**
  60516. * Gets or sets the build Id
  60517. */
  60518. get buildId(): number;
  60519. set buildId(value: number);
  60520. /**
  60521. * Gets or sets the target of the block
  60522. */
  60523. get target(): NodeMaterialBlockTargets;
  60524. set target(value: NodeMaterialBlockTargets);
  60525. /**
  60526. * Gets the list of input points
  60527. */
  60528. get inputs(): NodeMaterialConnectionPoint[];
  60529. /** Gets the list of output points */
  60530. get outputs(): NodeMaterialConnectionPoint[];
  60531. /**
  60532. * Find an input by its name
  60533. * @param name defines the name of the input to look for
  60534. * @returns the input or null if not found
  60535. */
  60536. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60537. /**
  60538. * Find an output by its name
  60539. * @param name defines the name of the outputto look for
  60540. * @returns the output or null if not found
  60541. */
  60542. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60543. /**
  60544. * Creates a new NodeMaterialBlock
  60545. * @param name defines the block name
  60546. * @param target defines the target of that block (Vertex by default)
  60547. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60548. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60549. */
  60550. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60551. /**
  60552. * Initialize the block and prepare the context for build
  60553. * @param state defines the state that will be used for the build
  60554. */
  60555. initialize(state: NodeMaterialBuildState): void;
  60556. /**
  60557. * Bind data to effect. Will only be called for blocks with isBindable === true
  60558. * @param effect defines the effect to bind data to
  60559. * @param nodeMaterial defines the hosting NodeMaterial
  60560. * @param mesh defines the mesh that will be rendered
  60561. */
  60562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60563. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60564. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60565. protected _writeFloat(value: number): string;
  60566. /**
  60567. * Gets the current class name e.g. "NodeMaterialBlock"
  60568. * @returns the class name
  60569. */
  60570. getClassName(): string;
  60571. /**
  60572. * Register a new input. Must be called inside a block constructor
  60573. * @param name defines the connection point name
  60574. * @param type defines the connection point type
  60575. * @param isOptional defines a boolean indicating that this input can be omitted
  60576. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60577. * @returns the current block
  60578. */
  60579. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60580. /**
  60581. * Register a new output. Must be called inside a block constructor
  60582. * @param name defines the connection point name
  60583. * @param type defines the connection point type
  60584. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60585. * @returns the current block
  60586. */
  60587. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60588. /**
  60589. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60590. * @param forOutput defines an optional connection point to check compatibility with
  60591. * @returns the first available input or null
  60592. */
  60593. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60594. /**
  60595. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60596. * @param forBlock defines an optional block to check compatibility with
  60597. * @returns the first available input or null
  60598. */
  60599. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60600. /**
  60601. * Gets the sibling of the given output
  60602. * @param current defines the current output
  60603. * @returns the next output in the list or null
  60604. */
  60605. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60606. /**
  60607. * Connect current block with another block
  60608. * @param other defines the block to connect with
  60609. * @param options define the various options to help pick the right connections
  60610. * @returns the current block
  60611. */
  60612. connectTo(other: NodeMaterialBlock, options?: {
  60613. input?: string;
  60614. output?: string;
  60615. outputSwizzle?: string;
  60616. }): this | undefined;
  60617. protected _buildBlock(state: NodeMaterialBuildState): void;
  60618. /**
  60619. * Add uniforms, samplers and uniform buffers at compilation time
  60620. * @param state defines the state to update
  60621. * @param nodeMaterial defines the node material requesting the update
  60622. * @param defines defines the material defines to update
  60623. * @param uniformBuffers defines the list of uniform buffer names
  60624. */
  60625. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60626. /**
  60627. * Add potential fallbacks if shader compilation fails
  60628. * @param mesh defines the mesh to be rendered
  60629. * @param fallbacks defines the current prioritized list of fallbacks
  60630. */
  60631. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60632. /**
  60633. * Initialize defines for shader compilation
  60634. * @param mesh defines the mesh to be rendered
  60635. * @param nodeMaterial defines the node material requesting the update
  60636. * @param defines defines the material defines to update
  60637. * @param useInstances specifies that instances should be used
  60638. */
  60639. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60640. /**
  60641. * Update defines for shader compilation
  60642. * @param mesh defines the mesh to be rendered
  60643. * @param nodeMaterial defines the node material requesting the update
  60644. * @param defines defines the material defines to update
  60645. * @param useInstances specifies that instances should be used
  60646. */
  60647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60648. /**
  60649. * Lets the block try to connect some inputs automatically
  60650. * @param material defines the hosting NodeMaterial
  60651. */
  60652. autoConfigure(material: NodeMaterial): void;
  60653. /**
  60654. * Function called when a block is declared as repeatable content generator
  60655. * @param vertexShaderState defines the current compilation state for the vertex shader
  60656. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60657. * @param mesh defines the mesh to be rendered
  60658. * @param defines defines the material defines to update
  60659. */
  60660. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60661. /**
  60662. * Checks if the block is ready
  60663. * @param mesh defines the mesh to be rendered
  60664. * @param nodeMaterial defines the node material requesting the update
  60665. * @param defines defines the material defines to update
  60666. * @param useInstances specifies that instances should be used
  60667. * @returns true if the block is ready
  60668. */
  60669. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60670. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60671. private _processBuild;
  60672. /**
  60673. * Compile the current node and generate the shader code
  60674. * @param state defines the current compilation state (uniforms, samplers, current string)
  60675. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60676. * @returns true if already built
  60677. */
  60678. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60679. protected _inputRename(name: string): string;
  60680. protected _outputRename(name: string): string;
  60681. protected _dumpPropertiesCode(): string;
  60682. /** @hidden */
  60683. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60684. /** @hidden */
  60685. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60686. /**
  60687. * Clone the current block to a new identical block
  60688. * @param scene defines the hosting scene
  60689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60690. * @returns a copy of the current block
  60691. */
  60692. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60693. /**
  60694. * Serializes this block in a JSON representation
  60695. * @returns the serialized block object
  60696. */
  60697. serialize(): any;
  60698. /** @hidden */
  60699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60700. /**
  60701. * Release resources
  60702. */
  60703. dispose(): void;
  60704. }
  60705. }
  60706. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60707. /**
  60708. * Enum defining the type of animations supported by InputBlock
  60709. */
  60710. export enum AnimatedInputBlockTypes {
  60711. /** No animation */
  60712. None = 0,
  60713. /** Time based animation. Will only work for floats */
  60714. Time = 1
  60715. }
  60716. }
  60717. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60719. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60720. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60721. import { Nullable } from "babylonjs/types";
  60722. import { Effect } from "babylonjs/Materials/effect";
  60723. import { Matrix } from "babylonjs/Maths/math.vector";
  60724. import { Scene } from "babylonjs/scene";
  60725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60727. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60728. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60729. import { Observable } from "babylonjs/Misc/observable";
  60730. /**
  60731. * Block used to expose an input value
  60732. */
  60733. export class InputBlock extends NodeMaterialBlock {
  60734. private _mode;
  60735. private _associatedVariableName;
  60736. private _storedValue;
  60737. private _valueCallback;
  60738. private _type;
  60739. private _animationType;
  60740. /** Gets or set a value used to limit the range of float values */
  60741. min: number;
  60742. /** Gets or set a value used to limit the range of float values */
  60743. max: number;
  60744. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60745. isBoolean: boolean;
  60746. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60747. matrixMode: number;
  60748. /** @hidden */
  60749. _systemValue: Nullable<NodeMaterialSystemValues>;
  60750. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60751. visibleInInspector: boolean;
  60752. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60753. isConstant: boolean;
  60754. /** Gets or sets the group to use to display this block in the Inspector */
  60755. groupInInspector: string;
  60756. /** Gets an observable raised when the value is changed */
  60757. onValueChangedObservable: Observable<InputBlock>;
  60758. /**
  60759. * Gets or sets the connection point type (default is float)
  60760. */
  60761. get type(): NodeMaterialBlockConnectionPointTypes;
  60762. /**
  60763. * Creates a new InputBlock
  60764. * @param name defines the block name
  60765. * @param target defines the target of that block (Vertex by default)
  60766. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60767. */
  60768. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60769. /**
  60770. * Gets the output component
  60771. */
  60772. get output(): NodeMaterialConnectionPoint;
  60773. /**
  60774. * Set the source of this connection point to a vertex attribute
  60775. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60776. * @returns the current connection point
  60777. */
  60778. setAsAttribute(attributeName?: string): InputBlock;
  60779. /**
  60780. * Set the source of this connection point to a system value
  60781. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60782. * @returns the current connection point
  60783. */
  60784. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60785. /**
  60786. * Gets or sets the value of that point.
  60787. * Please note that this value will be ignored if valueCallback is defined
  60788. */
  60789. get value(): any;
  60790. set value(value: any);
  60791. /**
  60792. * Gets or sets a callback used to get the value of that point.
  60793. * Please note that setting this value will force the connection point to ignore the value property
  60794. */
  60795. get valueCallback(): () => any;
  60796. set valueCallback(value: () => any);
  60797. /**
  60798. * Gets or sets the associated variable name in the shader
  60799. */
  60800. get associatedVariableName(): string;
  60801. set associatedVariableName(value: string);
  60802. /** Gets or sets the type of animation applied to the input */
  60803. get animationType(): AnimatedInputBlockTypes;
  60804. set animationType(value: AnimatedInputBlockTypes);
  60805. /**
  60806. * Gets a boolean indicating that this connection point not defined yet
  60807. */
  60808. get isUndefined(): boolean;
  60809. /**
  60810. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60811. * In this case the connection point name must be the name of the uniform to use.
  60812. * Can only be set on inputs
  60813. */
  60814. get isUniform(): boolean;
  60815. set isUniform(value: boolean);
  60816. /**
  60817. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60818. * In this case the connection point name must be the name of the attribute to use
  60819. * Can only be set on inputs
  60820. */
  60821. get isAttribute(): boolean;
  60822. set isAttribute(value: boolean);
  60823. /**
  60824. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60825. * Can only be set on exit points
  60826. */
  60827. get isVarying(): boolean;
  60828. set isVarying(value: boolean);
  60829. /**
  60830. * Gets a boolean indicating that the current connection point is a system value
  60831. */
  60832. get isSystemValue(): boolean;
  60833. /**
  60834. * Gets or sets the current well known value or null if not defined as a system value
  60835. */
  60836. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60837. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60838. /**
  60839. * Gets the current class name
  60840. * @returns the class name
  60841. */
  60842. getClassName(): string;
  60843. /**
  60844. * Animate the input if animationType !== None
  60845. * @param scene defines the rendering scene
  60846. */
  60847. animate(scene: Scene): void;
  60848. private _emitDefine;
  60849. initialize(state: NodeMaterialBuildState): void;
  60850. /**
  60851. * Set the input block to its default value (based on its type)
  60852. */
  60853. setDefaultValue(): void;
  60854. private _emitConstant;
  60855. private _emit;
  60856. /** @hidden */
  60857. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60858. /** @hidden */
  60859. _transmit(effect: Effect, scene: Scene): void;
  60860. protected _buildBlock(state: NodeMaterialBuildState): void;
  60861. protected _dumpPropertiesCode(): string;
  60862. dispose(): void;
  60863. serialize(): any;
  60864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60865. }
  60866. }
  60867. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60868. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60869. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60870. import { Nullable } from "babylonjs/types";
  60871. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60872. import { Observable } from "babylonjs/Misc/observable";
  60873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60874. /**
  60875. * Enum used to define the compatibility state between two connection points
  60876. */
  60877. export enum NodeMaterialConnectionPointCompatibilityStates {
  60878. /** Points are compatibles */
  60879. Compatible = 0,
  60880. /** Points are incompatible because of their types */
  60881. TypeIncompatible = 1,
  60882. /** Points are incompatible because of their targets (vertex vs fragment) */
  60883. TargetIncompatible = 2
  60884. }
  60885. /**
  60886. * Defines the direction of a connection point
  60887. */
  60888. export enum NodeMaterialConnectionPointDirection {
  60889. /** Input */
  60890. Input = 0,
  60891. /** Output */
  60892. Output = 1
  60893. }
  60894. /**
  60895. * Defines a connection point for a block
  60896. */
  60897. export class NodeMaterialConnectionPoint {
  60898. /** @hidden */
  60899. _ownerBlock: NodeMaterialBlock;
  60900. /** @hidden */
  60901. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60902. private _endpoints;
  60903. private _associatedVariableName;
  60904. private _direction;
  60905. /** @hidden */
  60906. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60907. /** @hidden */
  60908. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60909. private _type;
  60910. /** @hidden */
  60911. _enforceAssociatedVariableName: boolean;
  60912. /** Gets the direction of the point */
  60913. get direction(): NodeMaterialConnectionPointDirection;
  60914. /**
  60915. * Gets or sets the additional types supported by this connection point
  60916. */
  60917. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60918. /**
  60919. * Gets or sets the additional types excluded by this connection point
  60920. */
  60921. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60922. /**
  60923. * Observable triggered when this point is connected
  60924. */
  60925. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60926. /**
  60927. * Gets or sets the associated variable name in the shader
  60928. */
  60929. get associatedVariableName(): string;
  60930. set associatedVariableName(value: string);
  60931. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60932. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60933. /**
  60934. * Gets or sets the connection point type (default is float)
  60935. */
  60936. get type(): NodeMaterialBlockConnectionPointTypes;
  60937. set type(value: NodeMaterialBlockConnectionPointTypes);
  60938. /**
  60939. * Gets or sets the connection point name
  60940. */
  60941. name: string;
  60942. /**
  60943. * Gets or sets a boolean indicating that this connection point can be omitted
  60944. */
  60945. isOptional: boolean;
  60946. /**
  60947. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60948. */
  60949. define: string;
  60950. /** @hidden */
  60951. _prioritizeVertex: boolean;
  60952. private _target;
  60953. /** Gets or sets the target of that connection point */
  60954. get target(): NodeMaterialBlockTargets;
  60955. set target(value: NodeMaterialBlockTargets);
  60956. /**
  60957. * Gets a boolean indicating that the current point is connected
  60958. */
  60959. get isConnected(): boolean;
  60960. /**
  60961. * Gets a boolean indicating that the current point is connected to an input block
  60962. */
  60963. get isConnectedToInputBlock(): boolean;
  60964. /**
  60965. * Gets a the connected input block (if any)
  60966. */
  60967. get connectInputBlock(): Nullable<InputBlock>;
  60968. /** Get the other side of the connection (if any) */
  60969. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60970. /** Get the block that owns this connection point */
  60971. get ownerBlock(): NodeMaterialBlock;
  60972. /** Get the block connected on the other side of this connection (if any) */
  60973. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60974. /** Get the block connected on the endpoints of this connection (if any) */
  60975. get connectedBlocks(): Array<NodeMaterialBlock>;
  60976. /** Gets the list of connected endpoints */
  60977. get endpoints(): NodeMaterialConnectionPoint[];
  60978. /** Gets a boolean indicating if that output point is connected to at least one input */
  60979. get hasEndpoints(): boolean;
  60980. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60981. get isConnectedInVertexShader(): boolean;
  60982. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60983. get isConnectedInFragmentShader(): boolean;
  60984. /**
  60985. * Creates a new connection point
  60986. * @param name defines the connection point name
  60987. * @param ownerBlock defines the block hosting this connection point
  60988. * @param direction defines the direction of the connection point
  60989. */
  60990. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60991. /**
  60992. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60993. * @returns the class name
  60994. */
  60995. getClassName(): string;
  60996. /**
  60997. * Gets a boolean indicating if the current point can be connected to another point
  60998. * @param connectionPoint defines the other connection point
  60999. * @returns a boolean
  61000. */
  61001. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61002. /**
  61003. * Gets a number indicating if the current point can be connected to another point
  61004. * @param connectionPoint defines the other connection point
  61005. * @returns a number defining the compatibility state
  61006. */
  61007. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61008. /**
  61009. * Connect this point to another connection point
  61010. * @param connectionPoint defines the other connection point
  61011. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61012. * @returns the current connection point
  61013. */
  61014. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61015. /**
  61016. * Disconnect this point from one of his endpoint
  61017. * @param endpoint defines the other connection point
  61018. * @returns the current connection point
  61019. */
  61020. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61021. /**
  61022. * Serializes this point in a JSON representation
  61023. * @returns the serialized point object
  61024. */
  61025. serialize(): any;
  61026. /**
  61027. * Release resources
  61028. */
  61029. dispose(): void;
  61030. }
  61031. }
  61032. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61036. import { Mesh } from "babylonjs/Meshes/mesh";
  61037. import { Effect } from "babylonjs/Materials/effect";
  61038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61039. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61040. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61041. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61042. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61043. /**
  61044. * Block used to add support for vertex skinning (bones)
  61045. */
  61046. export class BonesBlock extends NodeMaterialBlock {
  61047. /**
  61048. * Creates a new BonesBlock
  61049. * @param name defines the block name
  61050. */
  61051. constructor(name: string);
  61052. /**
  61053. * Initialize the block and prepare the context for build
  61054. * @param state defines the state that will be used for the build
  61055. */
  61056. initialize(state: NodeMaterialBuildState): void;
  61057. /**
  61058. * Gets the current class name
  61059. * @returns the class name
  61060. */
  61061. getClassName(): string;
  61062. /**
  61063. * Gets the matrix indices input component
  61064. */
  61065. get matricesIndices(): NodeMaterialConnectionPoint;
  61066. /**
  61067. * Gets the matrix weights input component
  61068. */
  61069. get matricesWeights(): NodeMaterialConnectionPoint;
  61070. /**
  61071. * Gets the extra matrix indices input component
  61072. */
  61073. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61074. /**
  61075. * Gets the extra matrix weights input component
  61076. */
  61077. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the world input component
  61080. */
  61081. get world(): NodeMaterialConnectionPoint;
  61082. /**
  61083. * Gets the output component
  61084. */
  61085. get output(): NodeMaterialConnectionPoint;
  61086. autoConfigure(material: NodeMaterial): void;
  61087. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61090. protected _buildBlock(state: NodeMaterialBuildState): this;
  61091. }
  61092. }
  61093. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61098. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61099. /**
  61100. * Block used to add support for instances
  61101. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61102. */
  61103. export class InstancesBlock extends NodeMaterialBlock {
  61104. /**
  61105. * Creates a new InstancesBlock
  61106. * @param name defines the block name
  61107. */
  61108. constructor(name: string);
  61109. /**
  61110. * Gets the current class name
  61111. * @returns the class name
  61112. */
  61113. getClassName(): string;
  61114. /**
  61115. * Gets the first world row input component
  61116. */
  61117. get world0(): NodeMaterialConnectionPoint;
  61118. /**
  61119. * Gets the second world row input component
  61120. */
  61121. get world1(): NodeMaterialConnectionPoint;
  61122. /**
  61123. * Gets the third world row input component
  61124. */
  61125. get world2(): NodeMaterialConnectionPoint;
  61126. /**
  61127. * Gets the forth world row input component
  61128. */
  61129. get world3(): NodeMaterialConnectionPoint;
  61130. /**
  61131. * Gets the world input component
  61132. */
  61133. get world(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the output component
  61136. */
  61137. get output(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the isntanceID component
  61140. */
  61141. get instanceID(): NodeMaterialConnectionPoint;
  61142. autoConfigure(material: NodeMaterial): void;
  61143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61144. protected _buildBlock(state: NodeMaterialBuildState): this;
  61145. }
  61146. }
  61147. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61152. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61153. import { Effect } from "babylonjs/Materials/effect";
  61154. import { Mesh } from "babylonjs/Meshes/mesh";
  61155. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61156. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61157. /**
  61158. * Block used to add morph targets support to vertex shader
  61159. */
  61160. export class MorphTargetsBlock extends NodeMaterialBlock {
  61161. private _repeatableContentAnchor;
  61162. /**
  61163. * Create a new MorphTargetsBlock
  61164. * @param name defines the block name
  61165. */
  61166. constructor(name: string);
  61167. /**
  61168. * Gets the current class name
  61169. * @returns the class name
  61170. */
  61171. getClassName(): string;
  61172. /**
  61173. * Gets the position input component
  61174. */
  61175. get position(): NodeMaterialConnectionPoint;
  61176. /**
  61177. * Gets the normal input component
  61178. */
  61179. get normal(): NodeMaterialConnectionPoint;
  61180. /**
  61181. * Gets the tangent input component
  61182. */
  61183. get tangent(): NodeMaterialConnectionPoint;
  61184. /**
  61185. * Gets the tangent input component
  61186. */
  61187. get uv(): NodeMaterialConnectionPoint;
  61188. /**
  61189. * Gets the position output component
  61190. */
  61191. get positionOutput(): NodeMaterialConnectionPoint;
  61192. /**
  61193. * Gets the normal output component
  61194. */
  61195. get normalOutput(): NodeMaterialConnectionPoint;
  61196. /**
  61197. * Gets the tangent output component
  61198. */
  61199. get tangentOutput(): NodeMaterialConnectionPoint;
  61200. /**
  61201. * Gets the tangent output component
  61202. */
  61203. get uvOutput(): NodeMaterialConnectionPoint;
  61204. initialize(state: NodeMaterialBuildState): void;
  61205. autoConfigure(material: NodeMaterial): void;
  61206. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61207. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61208. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61209. protected _buildBlock(state: NodeMaterialBuildState): this;
  61210. }
  61211. }
  61212. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61216. import { Nullable } from "babylonjs/types";
  61217. import { Scene } from "babylonjs/scene";
  61218. import { Effect } from "babylonjs/Materials/effect";
  61219. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61220. import { Mesh } from "babylonjs/Meshes/mesh";
  61221. import { Light } from "babylonjs/Lights/light";
  61222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61223. /**
  61224. * Block used to get data information from a light
  61225. */
  61226. export class LightInformationBlock extends NodeMaterialBlock {
  61227. private _lightDataUniformName;
  61228. private _lightColorUniformName;
  61229. private _lightTypeDefineName;
  61230. /**
  61231. * Gets or sets the light associated with this block
  61232. */
  61233. light: Nullable<Light>;
  61234. /**
  61235. * Creates a new LightInformationBlock
  61236. * @param name defines the block name
  61237. */
  61238. constructor(name: string);
  61239. /**
  61240. * Gets the current class name
  61241. * @returns the class name
  61242. */
  61243. getClassName(): string;
  61244. /**
  61245. * Gets the world position input component
  61246. */
  61247. get worldPosition(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the direction output component
  61250. */
  61251. get direction(): NodeMaterialConnectionPoint;
  61252. /**
  61253. * Gets the direction output component
  61254. */
  61255. get color(): NodeMaterialConnectionPoint;
  61256. /**
  61257. * Gets the direction output component
  61258. */
  61259. get intensity(): NodeMaterialConnectionPoint;
  61260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61261. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61262. protected _buildBlock(state: NodeMaterialBuildState): this;
  61263. serialize(): any;
  61264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61265. }
  61266. }
  61267. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61268. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61269. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61270. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61271. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61272. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61273. }
  61274. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61279. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61280. import { Effect } from "babylonjs/Materials/effect";
  61281. import { Mesh } from "babylonjs/Meshes/mesh";
  61282. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61283. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61284. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61285. /**
  61286. * Block used to add image processing support to fragment shader
  61287. */
  61288. export class ImageProcessingBlock extends NodeMaterialBlock {
  61289. /**
  61290. * Create a new ImageProcessingBlock
  61291. * @param name defines the block name
  61292. */
  61293. constructor(name: string);
  61294. /**
  61295. * Gets the current class name
  61296. * @returns the class name
  61297. */
  61298. getClassName(): string;
  61299. /**
  61300. * Gets the color input component
  61301. */
  61302. get color(): NodeMaterialConnectionPoint;
  61303. /**
  61304. * Gets the output component
  61305. */
  61306. get output(): NodeMaterialConnectionPoint;
  61307. /**
  61308. * Initialize the block and prepare the context for build
  61309. * @param state defines the state that will be used for the build
  61310. */
  61311. initialize(state: NodeMaterialBuildState): void;
  61312. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61315. protected _buildBlock(state: NodeMaterialBuildState): this;
  61316. }
  61317. }
  61318. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61322. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61324. import { Effect } from "babylonjs/Materials/effect";
  61325. import { Mesh } from "babylonjs/Meshes/mesh";
  61326. import { Scene } from "babylonjs/scene";
  61327. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61328. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61329. /**
  61330. * Block used to pertub normals based on a normal map
  61331. */
  61332. export class PerturbNormalBlock extends NodeMaterialBlock {
  61333. private _tangentSpaceParameterName;
  61334. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61335. invertX: boolean;
  61336. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61337. invertY: boolean;
  61338. /**
  61339. * Create a new PerturbNormalBlock
  61340. * @param name defines the block name
  61341. */
  61342. constructor(name: string);
  61343. /**
  61344. * Gets the current class name
  61345. * @returns the class name
  61346. */
  61347. getClassName(): string;
  61348. /**
  61349. * Gets the world position input component
  61350. */
  61351. get worldPosition(): NodeMaterialConnectionPoint;
  61352. /**
  61353. * Gets the world normal input component
  61354. */
  61355. get worldNormal(): NodeMaterialConnectionPoint;
  61356. /**
  61357. * Gets the world tangent input component
  61358. */
  61359. get worldTangent(): NodeMaterialConnectionPoint;
  61360. /**
  61361. * Gets the uv input component
  61362. */
  61363. get uv(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the normal map color input component
  61366. */
  61367. get normalMapColor(): NodeMaterialConnectionPoint;
  61368. /**
  61369. * Gets the strength input component
  61370. */
  61371. get strength(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the output component
  61374. */
  61375. get output(): NodeMaterialConnectionPoint;
  61376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61378. autoConfigure(material: NodeMaterial): void;
  61379. protected _buildBlock(state: NodeMaterialBuildState): this;
  61380. protected _dumpPropertiesCode(): string;
  61381. serialize(): any;
  61382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61383. }
  61384. }
  61385. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61389. /**
  61390. * Block used to discard a pixel if a value is smaller than a cutoff
  61391. */
  61392. export class DiscardBlock extends NodeMaterialBlock {
  61393. /**
  61394. * Create a new DiscardBlock
  61395. * @param name defines the block name
  61396. */
  61397. constructor(name: string);
  61398. /**
  61399. * Gets the current class name
  61400. * @returns the class name
  61401. */
  61402. getClassName(): string;
  61403. /**
  61404. * Gets the color input component
  61405. */
  61406. get value(): NodeMaterialConnectionPoint;
  61407. /**
  61408. * Gets the cutoff input component
  61409. */
  61410. get cutoff(): NodeMaterialConnectionPoint;
  61411. protected _buildBlock(state: NodeMaterialBuildState): this;
  61412. }
  61413. }
  61414. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61418. /**
  61419. * Block used to test if the fragment shader is front facing
  61420. */
  61421. export class FrontFacingBlock extends NodeMaterialBlock {
  61422. /**
  61423. * Creates a new FrontFacingBlock
  61424. * @param name defines the block name
  61425. */
  61426. constructor(name: string);
  61427. /**
  61428. * Gets the current class name
  61429. * @returns the class name
  61430. */
  61431. getClassName(): string;
  61432. /**
  61433. * Gets the output component
  61434. */
  61435. get output(): NodeMaterialConnectionPoint;
  61436. protected _buildBlock(state: NodeMaterialBuildState): this;
  61437. }
  61438. }
  61439. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61443. /**
  61444. * Block used to get the derivative value on x and y of a given input
  61445. */
  61446. export class DerivativeBlock extends NodeMaterialBlock {
  61447. /**
  61448. * Create a new DerivativeBlock
  61449. * @param name defines the block name
  61450. */
  61451. constructor(name: string);
  61452. /**
  61453. * Gets the current class name
  61454. * @returns the class name
  61455. */
  61456. getClassName(): string;
  61457. /**
  61458. * Gets the input component
  61459. */
  61460. get input(): NodeMaterialConnectionPoint;
  61461. /**
  61462. * Gets the derivative output on x
  61463. */
  61464. get dx(): NodeMaterialConnectionPoint;
  61465. /**
  61466. * Gets the derivative output on y
  61467. */
  61468. get dy(): NodeMaterialConnectionPoint;
  61469. protected _buildBlock(state: NodeMaterialBuildState): this;
  61470. }
  61471. }
  61472. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61473. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61474. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61475. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61476. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61477. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61478. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61479. }
  61480. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61483. import { Mesh } from "babylonjs/Meshes/mesh";
  61484. import { Effect } from "babylonjs/Materials/effect";
  61485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61488. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61489. /**
  61490. * Block used to add support for scene fog
  61491. */
  61492. export class FogBlock extends NodeMaterialBlock {
  61493. private _fogDistanceName;
  61494. private _fogParameters;
  61495. /**
  61496. * Create a new FogBlock
  61497. * @param name defines the block name
  61498. */
  61499. constructor(name: string);
  61500. /**
  61501. * Gets the current class name
  61502. * @returns the class name
  61503. */
  61504. getClassName(): string;
  61505. /**
  61506. * Gets the world position input component
  61507. */
  61508. get worldPosition(): NodeMaterialConnectionPoint;
  61509. /**
  61510. * Gets the view input component
  61511. */
  61512. get view(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the color input component
  61515. */
  61516. get input(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the fog color input component
  61519. */
  61520. get fogColor(): NodeMaterialConnectionPoint;
  61521. /**
  61522. * Gets the output component
  61523. */
  61524. get output(): NodeMaterialConnectionPoint;
  61525. autoConfigure(material: NodeMaterial): void;
  61526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61528. protected _buildBlock(state: NodeMaterialBuildState): this;
  61529. }
  61530. }
  61531. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61536. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61537. import { Effect } from "babylonjs/Materials/effect";
  61538. import { Mesh } from "babylonjs/Meshes/mesh";
  61539. import { Light } from "babylonjs/Lights/light";
  61540. import { Nullable } from "babylonjs/types";
  61541. import { Scene } from "babylonjs/scene";
  61542. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61543. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61544. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61545. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61546. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61547. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61548. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61549. /**
  61550. * Block used to add light in the fragment shader
  61551. */
  61552. export class LightBlock extends NodeMaterialBlock {
  61553. private _lightId;
  61554. /**
  61555. * Gets or sets the light associated with this block
  61556. */
  61557. light: Nullable<Light>;
  61558. /**
  61559. * Create a new LightBlock
  61560. * @param name defines the block name
  61561. */
  61562. constructor(name: string);
  61563. /**
  61564. * Gets the current class name
  61565. * @returns the class name
  61566. */
  61567. getClassName(): string;
  61568. /**
  61569. * Gets the world position input component
  61570. */
  61571. get worldPosition(): NodeMaterialConnectionPoint;
  61572. /**
  61573. * Gets the world normal input component
  61574. */
  61575. get worldNormal(): NodeMaterialConnectionPoint;
  61576. /**
  61577. * Gets the camera (or eye) position component
  61578. */
  61579. get cameraPosition(): NodeMaterialConnectionPoint;
  61580. /**
  61581. * Gets the glossiness component
  61582. */
  61583. get glossiness(): NodeMaterialConnectionPoint;
  61584. /**
  61585. * Gets the glossinness power component
  61586. */
  61587. get glossPower(): NodeMaterialConnectionPoint;
  61588. /**
  61589. * Gets the diffuse color component
  61590. */
  61591. get diffuseColor(): NodeMaterialConnectionPoint;
  61592. /**
  61593. * Gets the specular color component
  61594. */
  61595. get specularColor(): NodeMaterialConnectionPoint;
  61596. /**
  61597. * Gets the diffuse output component
  61598. */
  61599. get diffuseOutput(): NodeMaterialConnectionPoint;
  61600. /**
  61601. * Gets the specular output component
  61602. */
  61603. get specularOutput(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the shadow output component
  61606. */
  61607. get shadow(): NodeMaterialConnectionPoint;
  61608. autoConfigure(material: NodeMaterial): void;
  61609. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61610. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61611. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61612. private _injectVertexCode;
  61613. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61614. serialize(): any;
  61615. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61616. }
  61617. }
  61618. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61619. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61620. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61621. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61622. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61623. }
  61624. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61625. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61626. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61627. }
  61628. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61632. /**
  61633. * Block used to multiply 2 values
  61634. */
  61635. export class MultiplyBlock extends NodeMaterialBlock {
  61636. /**
  61637. * Creates a new MultiplyBlock
  61638. * @param name defines the block name
  61639. */
  61640. constructor(name: string);
  61641. /**
  61642. * Gets the current class name
  61643. * @returns the class name
  61644. */
  61645. getClassName(): string;
  61646. /**
  61647. * Gets the left operand input component
  61648. */
  61649. get left(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the right operand input component
  61652. */
  61653. get right(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the output component
  61656. */
  61657. get output(): NodeMaterialConnectionPoint;
  61658. protected _buildBlock(state: NodeMaterialBuildState): this;
  61659. }
  61660. }
  61661. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61665. /**
  61666. * Block used to add 2 vectors
  61667. */
  61668. export class AddBlock extends NodeMaterialBlock {
  61669. /**
  61670. * Creates a new AddBlock
  61671. * @param name defines the block name
  61672. */
  61673. constructor(name: string);
  61674. /**
  61675. * Gets the current class name
  61676. * @returns the class name
  61677. */
  61678. getClassName(): string;
  61679. /**
  61680. * Gets the left operand input component
  61681. */
  61682. get left(): NodeMaterialConnectionPoint;
  61683. /**
  61684. * Gets the right operand input component
  61685. */
  61686. get right(): NodeMaterialConnectionPoint;
  61687. /**
  61688. * Gets the output component
  61689. */
  61690. get output(): NodeMaterialConnectionPoint;
  61691. protected _buildBlock(state: NodeMaterialBuildState): this;
  61692. }
  61693. }
  61694. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61698. /**
  61699. * Block used to scale a vector by a float
  61700. */
  61701. export class ScaleBlock extends NodeMaterialBlock {
  61702. /**
  61703. * Creates a new ScaleBlock
  61704. * @param name defines the block name
  61705. */
  61706. constructor(name: string);
  61707. /**
  61708. * Gets the current class name
  61709. * @returns the class name
  61710. */
  61711. getClassName(): string;
  61712. /**
  61713. * Gets the input component
  61714. */
  61715. get input(): NodeMaterialConnectionPoint;
  61716. /**
  61717. * Gets the factor input component
  61718. */
  61719. get factor(): NodeMaterialConnectionPoint;
  61720. /**
  61721. * Gets the output component
  61722. */
  61723. get output(): NodeMaterialConnectionPoint;
  61724. protected _buildBlock(state: NodeMaterialBuildState): this;
  61725. }
  61726. }
  61727. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61731. import { Scene } from "babylonjs/scene";
  61732. /**
  61733. * Block used to clamp a float
  61734. */
  61735. export class ClampBlock extends NodeMaterialBlock {
  61736. /** Gets or sets the minimum range */
  61737. minimum: number;
  61738. /** Gets or sets the maximum range */
  61739. maximum: number;
  61740. /**
  61741. * Creates a new ClampBlock
  61742. * @param name defines the block name
  61743. */
  61744. constructor(name: string);
  61745. /**
  61746. * Gets the current class name
  61747. * @returns the class name
  61748. */
  61749. getClassName(): string;
  61750. /**
  61751. * Gets the value input component
  61752. */
  61753. get value(): NodeMaterialConnectionPoint;
  61754. /**
  61755. * Gets the output component
  61756. */
  61757. get output(): NodeMaterialConnectionPoint;
  61758. protected _buildBlock(state: NodeMaterialBuildState): this;
  61759. protected _dumpPropertiesCode(): string;
  61760. serialize(): any;
  61761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61762. }
  61763. }
  61764. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61768. /**
  61769. * Block used to apply a cross product between 2 vectors
  61770. */
  61771. export class CrossBlock extends NodeMaterialBlock {
  61772. /**
  61773. * Creates a new CrossBlock
  61774. * @param name defines the block name
  61775. */
  61776. constructor(name: string);
  61777. /**
  61778. * Gets the current class name
  61779. * @returns the class name
  61780. */
  61781. getClassName(): string;
  61782. /**
  61783. * Gets the left operand input component
  61784. */
  61785. get left(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the right operand input component
  61788. */
  61789. get right(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the output component
  61792. */
  61793. get output(): NodeMaterialConnectionPoint;
  61794. protected _buildBlock(state: NodeMaterialBuildState): this;
  61795. }
  61796. }
  61797. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61801. /**
  61802. * Block used to apply a dot product between 2 vectors
  61803. */
  61804. export class DotBlock extends NodeMaterialBlock {
  61805. /**
  61806. * Creates a new DotBlock
  61807. * @param name defines the block name
  61808. */
  61809. constructor(name: string);
  61810. /**
  61811. * Gets the current class name
  61812. * @returns the class name
  61813. */
  61814. getClassName(): string;
  61815. /**
  61816. * Gets the left operand input component
  61817. */
  61818. get left(): NodeMaterialConnectionPoint;
  61819. /**
  61820. * Gets the right operand input component
  61821. */
  61822. get right(): NodeMaterialConnectionPoint;
  61823. /**
  61824. * Gets the output component
  61825. */
  61826. get output(): NodeMaterialConnectionPoint;
  61827. protected _buildBlock(state: NodeMaterialBuildState): this;
  61828. }
  61829. }
  61830. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61834. import { Vector2 } from "babylonjs/Maths/math.vector";
  61835. import { Scene } from "babylonjs/scene";
  61836. /**
  61837. * Block used to remap a float from a range to a new one
  61838. */
  61839. export class RemapBlock extends NodeMaterialBlock {
  61840. /**
  61841. * Gets or sets the source range
  61842. */
  61843. sourceRange: Vector2;
  61844. /**
  61845. * Gets or sets the target range
  61846. */
  61847. targetRange: Vector2;
  61848. /**
  61849. * Creates a new RemapBlock
  61850. * @param name defines the block name
  61851. */
  61852. constructor(name: string);
  61853. /**
  61854. * Gets the current class name
  61855. * @returns the class name
  61856. */
  61857. getClassName(): string;
  61858. /**
  61859. * Gets the input component
  61860. */
  61861. get input(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the source min input component
  61864. */
  61865. get sourceMin(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the source max input component
  61868. */
  61869. get sourceMax(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the target min input component
  61872. */
  61873. get targetMin(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the target max input component
  61876. */
  61877. get targetMax(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the output component
  61880. */
  61881. get output(): NodeMaterialConnectionPoint;
  61882. protected _buildBlock(state: NodeMaterialBuildState): this;
  61883. protected _dumpPropertiesCode(): string;
  61884. serialize(): any;
  61885. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61886. }
  61887. }
  61888. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61892. /**
  61893. * Block used to normalize a vector
  61894. */
  61895. export class NormalizeBlock extends NodeMaterialBlock {
  61896. /**
  61897. * Creates a new NormalizeBlock
  61898. * @param name defines the block name
  61899. */
  61900. constructor(name: string);
  61901. /**
  61902. * Gets the current class name
  61903. * @returns the class name
  61904. */
  61905. getClassName(): string;
  61906. /**
  61907. * Gets the input component
  61908. */
  61909. get input(): NodeMaterialConnectionPoint;
  61910. /**
  61911. * Gets the output component
  61912. */
  61913. get output(): NodeMaterialConnectionPoint;
  61914. protected _buildBlock(state: NodeMaterialBuildState): this;
  61915. }
  61916. }
  61917. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61921. import { Scene } from "babylonjs/scene";
  61922. /**
  61923. * Operations supported by the Trigonometry block
  61924. */
  61925. export enum TrigonometryBlockOperations {
  61926. /** Cos */
  61927. Cos = 0,
  61928. /** Sin */
  61929. Sin = 1,
  61930. /** Abs */
  61931. Abs = 2,
  61932. /** Exp */
  61933. Exp = 3,
  61934. /** Exp2 */
  61935. Exp2 = 4,
  61936. /** Round */
  61937. Round = 5,
  61938. /** Floor */
  61939. Floor = 6,
  61940. /** Ceiling */
  61941. Ceiling = 7,
  61942. /** Square root */
  61943. Sqrt = 8,
  61944. /** Log */
  61945. Log = 9,
  61946. /** Tangent */
  61947. Tan = 10,
  61948. /** Arc tangent */
  61949. ArcTan = 11,
  61950. /** Arc cosinus */
  61951. ArcCos = 12,
  61952. /** Arc sinus */
  61953. ArcSin = 13,
  61954. /** Fraction */
  61955. Fract = 14,
  61956. /** Sign */
  61957. Sign = 15,
  61958. /** To radians (from degrees) */
  61959. Radians = 16,
  61960. /** To degrees (from radians) */
  61961. Degrees = 17
  61962. }
  61963. /**
  61964. * Block used to apply trigonometry operation to floats
  61965. */
  61966. export class TrigonometryBlock extends NodeMaterialBlock {
  61967. /**
  61968. * Gets or sets the operation applied by the block
  61969. */
  61970. operation: TrigonometryBlockOperations;
  61971. /**
  61972. * Creates a new TrigonometryBlock
  61973. * @param name defines the block name
  61974. */
  61975. constructor(name: string);
  61976. /**
  61977. * Gets the current class name
  61978. * @returns the class name
  61979. */
  61980. getClassName(): string;
  61981. /**
  61982. * Gets the input component
  61983. */
  61984. get input(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the output component
  61987. */
  61988. get output(): NodeMaterialConnectionPoint;
  61989. protected _buildBlock(state: NodeMaterialBuildState): this;
  61990. serialize(): any;
  61991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61992. protected _dumpPropertiesCode(): string;
  61993. }
  61994. }
  61995. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61999. /**
  62000. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62001. */
  62002. export class ColorMergerBlock extends NodeMaterialBlock {
  62003. /**
  62004. * Create a new ColorMergerBlock
  62005. * @param name defines the block name
  62006. */
  62007. constructor(name: string);
  62008. /**
  62009. * Gets the current class name
  62010. * @returns the class name
  62011. */
  62012. getClassName(): string;
  62013. /**
  62014. * Gets the rgb component (input)
  62015. */
  62016. get rgbIn(): NodeMaterialConnectionPoint;
  62017. /**
  62018. * Gets the r component (input)
  62019. */
  62020. get r(): NodeMaterialConnectionPoint;
  62021. /**
  62022. * Gets the g component (input)
  62023. */
  62024. get g(): NodeMaterialConnectionPoint;
  62025. /**
  62026. * Gets the b component (input)
  62027. */
  62028. get b(): NodeMaterialConnectionPoint;
  62029. /**
  62030. * Gets the a component (input)
  62031. */
  62032. get a(): NodeMaterialConnectionPoint;
  62033. /**
  62034. * Gets the rgba component (output)
  62035. */
  62036. get rgba(): NodeMaterialConnectionPoint;
  62037. /**
  62038. * Gets the rgb component (output)
  62039. */
  62040. get rgbOut(): NodeMaterialConnectionPoint;
  62041. /**
  62042. * Gets the rgb component (output)
  62043. * @deprecated Please use rgbOut instead.
  62044. */
  62045. get rgb(): NodeMaterialConnectionPoint;
  62046. protected _buildBlock(state: NodeMaterialBuildState): this;
  62047. }
  62048. }
  62049. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62053. /**
  62054. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62055. */
  62056. export class VectorMergerBlock extends NodeMaterialBlock {
  62057. /**
  62058. * Create a new VectorMergerBlock
  62059. * @param name defines the block name
  62060. */
  62061. constructor(name: string);
  62062. /**
  62063. * Gets the current class name
  62064. * @returns the class name
  62065. */
  62066. getClassName(): string;
  62067. /**
  62068. * Gets the xyz component (input)
  62069. */
  62070. get xyzIn(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the xy component (input)
  62073. */
  62074. get xyIn(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the x component (input)
  62077. */
  62078. get x(): NodeMaterialConnectionPoint;
  62079. /**
  62080. * Gets the y component (input)
  62081. */
  62082. get y(): NodeMaterialConnectionPoint;
  62083. /**
  62084. * Gets the z component (input)
  62085. */
  62086. get z(): NodeMaterialConnectionPoint;
  62087. /**
  62088. * Gets the w component (input)
  62089. */
  62090. get w(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the xyzw component (output)
  62093. */
  62094. get xyzw(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the xyz component (output)
  62097. */
  62098. get xyzOut(): NodeMaterialConnectionPoint;
  62099. /**
  62100. * Gets the xy component (output)
  62101. */
  62102. get xyOut(): NodeMaterialConnectionPoint;
  62103. /**
  62104. * Gets the xy component (output)
  62105. * @deprecated Please use xyOut instead.
  62106. */
  62107. get xy(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the xyz component (output)
  62110. * @deprecated Please use xyzOut instead.
  62111. */
  62112. get xyz(): NodeMaterialConnectionPoint;
  62113. protected _buildBlock(state: NodeMaterialBuildState): this;
  62114. }
  62115. }
  62116. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62120. /**
  62121. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62122. */
  62123. export class ColorSplitterBlock extends NodeMaterialBlock {
  62124. /**
  62125. * Create a new ColorSplitterBlock
  62126. * @param name defines the block name
  62127. */
  62128. constructor(name: string);
  62129. /**
  62130. * Gets the current class name
  62131. * @returns the class name
  62132. */
  62133. getClassName(): string;
  62134. /**
  62135. * Gets the rgba component (input)
  62136. */
  62137. get rgba(): NodeMaterialConnectionPoint;
  62138. /**
  62139. * Gets the rgb component (input)
  62140. */
  62141. get rgbIn(): NodeMaterialConnectionPoint;
  62142. /**
  62143. * Gets the rgb component (output)
  62144. */
  62145. get rgbOut(): NodeMaterialConnectionPoint;
  62146. /**
  62147. * Gets the r component (output)
  62148. */
  62149. get r(): NodeMaterialConnectionPoint;
  62150. /**
  62151. * Gets the g component (output)
  62152. */
  62153. get g(): NodeMaterialConnectionPoint;
  62154. /**
  62155. * Gets the b component (output)
  62156. */
  62157. get b(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the a component (output)
  62160. */
  62161. get a(): NodeMaterialConnectionPoint;
  62162. protected _inputRename(name: string): string;
  62163. protected _outputRename(name: string): string;
  62164. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62165. }
  62166. }
  62167. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62171. /**
  62172. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62173. */
  62174. export class VectorSplitterBlock extends NodeMaterialBlock {
  62175. /**
  62176. * Create a new VectorSplitterBlock
  62177. * @param name defines the block name
  62178. */
  62179. constructor(name: string);
  62180. /**
  62181. * Gets the current class name
  62182. * @returns the class name
  62183. */
  62184. getClassName(): string;
  62185. /**
  62186. * Gets the xyzw component (input)
  62187. */
  62188. get xyzw(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the xyz component (input)
  62191. */
  62192. get xyzIn(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the xy component (input)
  62195. */
  62196. get xyIn(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the xyz component (output)
  62199. */
  62200. get xyzOut(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the xy component (output)
  62203. */
  62204. get xyOut(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the x component (output)
  62207. */
  62208. get x(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the y component (output)
  62211. */
  62212. get y(): NodeMaterialConnectionPoint;
  62213. /**
  62214. * Gets the z component (output)
  62215. */
  62216. get z(): NodeMaterialConnectionPoint;
  62217. /**
  62218. * Gets the w component (output)
  62219. */
  62220. get w(): NodeMaterialConnectionPoint;
  62221. protected _inputRename(name: string): string;
  62222. protected _outputRename(name: string): string;
  62223. protected _buildBlock(state: NodeMaterialBuildState): this;
  62224. }
  62225. }
  62226. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62230. /**
  62231. * Block used to lerp between 2 values
  62232. */
  62233. export class LerpBlock extends NodeMaterialBlock {
  62234. /**
  62235. * Creates a new LerpBlock
  62236. * @param name defines the block name
  62237. */
  62238. constructor(name: string);
  62239. /**
  62240. * Gets the current class name
  62241. * @returns the class name
  62242. */
  62243. getClassName(): string;
  62244. /**
  62245. * Gets the left operand input component
  62246. */
  62247. get left(): NodeMaterialConnectionPoint;
  62248. /**
  62249. * Gets the right operand input component
  62250. */
  62251. get right(): NodeMaterialConnectionPoint;
  62252. /**
  62253. * Gets the gradient operand input component
  62254. */
  62255. get gradient(): NodeMaterialConnectionPoint;
  62256. /**
  62257. * Gets the output component
  62258. */
  62259. get output(): NodeMaterialConnectionPoint;
  62260. protected _buildBlock(state: NodeMaterialBuildState): this;
  62261. }
  62262. }
  62263. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62267. /**
  62268. * Block used to divide 2 vectors
  62269. */
  62270. export class DivideBlock extends NodeMaterialBlock {
  62271. /**
  62272. * Creates a new DivideBlock
  62273. * @param name defines the block name
  62274. */
  62275. constructor(name: string);
  62276. /**
  62277. * Gets the current class name
  62278. * @returns the class name
  62279. */
  62280. getClassName(): string;
  62281. /**
  62282. * Gets the left operand input component
  62283. */
  62284. get left(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the right operand input component
  62287. */
  62288. get right(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the output component
  62291. */
  62292. get output(): NodeMaterialConnectionPoint;
  62293. protected _buildBlock(state: NodeMaterialBuildState): this;
  62294. }
  62295. }
  62296. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62300. /**
  62301. * Block used to subtract 2 vectors
  62302. */
  62303. export class SubtractBlock extends NodeMaterialBlock {
  62304. /**
  62305. * Creates a new SubtractBlock
  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 left operand input component
  62316. */
  62317. get left(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the right operand input component
  62320. */
  62321. get right(): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Gets the output component
  62324. */
  62325. get output(): NodeMaterialConnectionPoint;
  62326. protected _buildBlock(state: NodeMaterialBuildState): this;
  62327. }
  62328. }
  62329. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62333. /**
  62334. * Block used to step a value
  62335. */
  62336. export class StepBlock extends NodeMaterialBlock {
  62337. /**
  62338. * Creates a new StepBlock
  62339. * @param name defines the block name
  62340. */
  62341. constructor(name: string);
  62342. /**
  62343. * Gets the current class name
  62344. * @returns the class name
  62345. */
  62346. getClassName(): string;
  62347. /**
  62348. * Gets the value operand input component
  62349. */
  62350. get value(): NodeMaterialConnectionPoint;
  62351. /**
  62352. * Gets the edge operand input component
  62353. */
  62354. get edge(): NodeMaterialConnectionPoint;
  62355. /**
  62356. * Gets the output component
  62357. */
  62358. get output(): NodeMaterialConnectionPoint;
  62359. protected _buildBlock(state: NodeMaterialBuildState): this;
  62360. }
  62361. }
  62362. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62366. /**
  62367. * Block used to get the opposite (1 - x) of a value
  62368. */
  62369. export class OneMinusBlock extends NodeMaterialBlock {
  62370. /**
  62371. * Creates a new OneMinusBlock
  62372. * @param name defines the block name
  62373. */
  62374. constructor(name: string);
  62375. /**
  62376. * Gets the current class name
  62377. * @returns the class name
  62378. */
  62379. getClassName(): string;
  62380. /**
  62381. * Gets the input component
  62382. */
  62383. get input(): NodeMaterialConnectionPoint;
  62384. /**
  62385. * Gets the output component
  62386. */
  62387. get output(): NodeMaterialConnectionPoint;
  62388. protected _buildBlock(state: NodeMaterialBuildState): this;
  62389. }
  62390. }
  62391. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62395. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62396. /**
  62397. * Block used to get the view direction
  62398. */
  62399. export class ViewDirectionBlock extends NodeMaterialBlock {
  62400. /**
  62401. * Creates a new ViewDirectionBlock
  62402. * @param name defines the block name
  62403. */
  62404. constructor(name: string);
  62405. /**
  62406. * Gets the current class name
  62407. * @returns the class name
  62408. */
  62409. getClassName(): string;
  62410. /**
  62411. * Gets the world position component
  62412. */
  62413. get worldPosition(): NodeMaterialConnectionPoint;
  62414. /**
  62415. * Gets the camera position component
  62416. */
  62417. get cameraPosition(): NodeMaterialConnectionPoint;
  62418. /**
  62419. * Gets the output component
  62420. */
  62421. get output(): NodeMaterialConnectionPoint;
  62422. autoConfigure(material: NodeMaterial): void;
  62423. protected _buildBlock(state: NodeMaterialBuildState): this;
  62424. }
  62425. }
  62426. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62430. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62431. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62432. /**
  62433. * Block used to compute fresnel value
  62434. */
  62435. export class FresnelBlock extends NodeMaterialBlock {
  62436. /**
  62437. * Create a new FresnelBlock
  62438. * @param name defines the block name
  62439. */
  62440. constructor(name: string);
  62441. /**
  62442. * Gets the current class name
  62443. * @returns the class name
  62444. */
  62445. getClassName(): string;
  62446. /**
  62447. * Gets the world normal input component
  62448. */
  62449. get worldNormal(): NodeMaterialConnectionPoint;
  62450. /**
  62451. * Gets the view direction input component
  62452. */
  62453. get viewDirection(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the bias input component
  62456. */
  62457. get bias(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the camera (or eye) position component
  62460. */
  62461. get power(): NodeMaterialConnectionPoint;
  62462. /**
  62463. * Gets the fresnel output component
  62464. */
  62465. get fresnel(): NodeMaterialConnectionPoint;
  62466. autoConfigure(material: NodeMaterial): void;
  62467. protected _buildBlock(state: NodeMaterialBuildState): this;
  62468. }
  62469. }
  62470. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62474. /**
  62475. * Block used to get the max of 2 values
  62476. */
  62477. export class MaxBlock extends NodeMaterialBlock {
  62478. /**
  62479. * Creates a new MaxBlock
  62480. * @param name defines the block name
  62481. */
  62482. constructor(name: string);
  62483. /**
  62484. * Gets the current class name
  62485. * @returns the class name
  62486. */
  62487. getClassName(): string;
  62488. /**
  62489. * Gets the left operand input component
  62490. */
  62491. get left(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the right operand input component
  62494. */
  62495. get right(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the output component
  62498. */
  62499. get output(): NodeMaterialConnectionPoint;
  62500. protected _buildBlock(state: NodeMaterialBuildState): this;
  62501. }
  62502. }
  62503. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62507. /**
  62508. * Block used to get the min of 2 values
  62509. */
  62510. export class MinBlock extends NodeMaterialBlock {
  62511. /**
  62512. * Creates a new MinBlock
  62513. * @param name defines the block name
  62514. */
  62515. constructor(name: string);
  62516. /**
  62517. * Gets the current class name
  62518. * @returns the class name
  62519. */
  62520. getClassName(): string;
  62521. /**
  62522. * Gets the left operand input component
  62523. */
  62524. get left(): NodeMaterialConnectionPoint;
  62525. /**
  62526. * Gets the right operand input component
  62527. */
  62528. get right(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the output component
  62531. */
  62532. get output(): NodeMaterialConnectionPoint;
  62533. protected _buildBlock(state: NodeMaterialBuildState): this;
  62534. }
  62535. }
  62536. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62540. /**
  62541. * Block used to get the distance between 2 values
  62542. */
  62543. export class DistanceBlock extends NodeMaterialBlock {
  62544. /**
  62545. * Creates a new DistanceBlock
  62546. * @param name defines the block name
  62547. */
  62548. constructor(name: string);
  62549. /**
  62550. * Gets the current class name
  62551. * @returns the class name
  62552. */
  62553. getClassName(): string;
  62554. /**
  62555. * Gets the left operand input component
  62556. */
  62557. get left(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the right operand input component
  62560. */
  62561. get right(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the output component
  62564. */
  62565. get output(): NodeMaterialConnectionPoint;
  62566. protected _buildBlock(state: NodeMaterialBuildState): this;
  62567. }
  62568. }
  62569. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62573. /**
  62574. * Block used to get the length of a vector
  62575. */
  62576. export class LengthBlock extends NodeMaterialBlock {
  62577. /**
  62578. * Creates a new LengthBlock
  62579. * @param name defines the block name
  62580. */
  62581. constructor(name: string);
  62582. /**
  62583. * Gets the current class name
  62584. * @returns the class name
  62585. */
  62586. getClassName(): string;
  62587. /**
  62588. * Gets the value input component
  62589. */
  62590. get value(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the output component
  62593. */
  62594. get output(): NodeMaterialConnectionPoint;
  62595. protected _buildBlock(state: NodeMaterialBuildState): this;
  62596. }
  62597. }
  62598. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62602. /**
  62603. * Block used to get negative version of a value (i.e. x * -1)
  62604. */
  62605. export class NegateBlock extends NodeMaterialBlock {
  62606. /**
  62607. * Creates a new NegateBlock
  62608. * @param name defines the block name
  62609. */
  62610. constructor(name: string);
  62611. /**
  62612. * Gets the current class name
  62613. * @returns the class name
  62614. */
  62615. getClassName(): string;
  62616. /**
  62617. * Gets the value input component
  62618. */
  62619. get value(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the output component
  62622. */
  62623. get output(): NodeMaterialConnectionPoint;
  62624. protected _buildBlock(state: NodeMaterialBuildState): this;
  62625. }
  62626. }
  62627. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62631. /**
  62632. * Block used to get the value of the first parameter raised to the power of the second
  62633. */
  62634. export class PowBlock extends NodeMaterialBlock {
  62635. /**
  62636. * Creates a new PowBlock
  62637. * @param name defines the block name
  62638. */
  62639. constructor(name: string);
  62640. /**
  62641. * Gets the current class name
  62642. * @returns the class name
  62643. */
  62644. getClassName(): string;
  62645. /**
  62646. * Gets the value operand input component
  62647. */
  62648. get value(): NodeMaterialConnectionPoint;
  62649. /**
  62650. * Gets the power operand input component
  62651. */
  62652. get power(): NodeMaterialConnectionPoint;
  62653. /**
  62654. * Gets the output component
  62655. */
  62656. get output(): NodeMaterialConnectionPoint;
  62657. protected _buildBlock(state: NodeMaterialBuildState): this;
  62658. }
  62659. }
  62660. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62664. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62665. /**
  62666. * Block used to get a random number
  62667. */
  62668. export class RandomNumberBlock extends NodeMaterialBlock {
  62669. /**
  62670. * Creates a new RandomNumberBlock
  62671. * @param name defines the block name
  62672. */
  62673. constructor(name: string);
  62674. /**
  62675. * Gets the current class name
  62676. * @returns the class name
  62677. */
  62678. getClassName(): string;
  62679. /**
  62680. * Gets the seed input component
  62681. */
  62682. get seed(): 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/arcTan2Block" {
  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 compute arc tangent of 2 values
  62696. */
  62697. export class ArcTan2Block extends NodeMaterialBlock {
  62698. /**
  62699. * Creates a new ArcTan2Block
  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 x operand input component
  62710. */
  62711. get x(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the y operand input component
  62714. */
  62715. get y(): 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/smoothStepBlock" {
  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 smooth step a value
  62729. */
  62730. export class SmoothStepBlock extends NodeMaterialBlock {
  62731. /**
  62732. * Creates a new SmoothStepBlock
  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 value operand input component
  62743. */
  62744. get value(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the first edge operand input component
  62747. */
  62748. get edge0(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the second edge operand input component
  62751. */
  62752. get edge1(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the output component
  62755. */
  62756. get output(): NodeMaterialConnectionPoint;
  62757. protected _buildBlock(state: NodeMaterialBuildState): this;
  62758. }
  62759. }
  62760. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62764. /**
  62765. * Block used to get the reciprocal (1 / x) of a value
  62766. */
  62767. export class ReciprocalBlock extends NodeMaterialBlock {
  62768. /**
  62769. * Creates a new ReciprocalBlock
  62770. * @param name defines the block name
  62771. */
  62772. constructor(name: string);
  62773. /**
  62774. * Gets the current class name
  62775. * @returns the class name
  62776. */
  62777. getClassName(): string;
  62778. /**
  62779. * Gets the input component
  62780. */
  62781. get input(): NodeMaterialConnectionPoint;
  62782. /**
  62783. * Gets the output component
  62784. */
  62785. get output(): NodeMaterialConnectionPoint;
  62786. protected _buildBlock(state: NodeMaterialBuildState): this;
  62787. }
  62788. }
  62789. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62793. /**
  62794. * Block used to replace a color by another one
  62795. */
  62796. export class ReplaceColorBlock extends NodeMaterialBlock {
  62797. /**
  62798. * Creates a new ReplaceColorBlock
  62799. * @param name defines the block name
  62800. */
  62801. constructor(name: string);
  62802. /**
  62803. * Gets the current class name
  62804. * @returns the class name
  62805. */
  62806. getClassName(): string;
  62807. /**
  62808. * Gets the value input component
  62809. */
  62810. get value(): NodeMaterialConnectionPoint;
  62811. /**
  62812. * Gets the reference input component
  62813. */
  62814. get reference(): NodeMaterialConnectionPoint;
  62815. /**
  62816. * Gets the distance input component
  62817. */
  62818. get distance(): NodeMaterialConnectionPoint;
  62819. /**
  62820. * Gets the replacement input component
  62821. */
  62822. get replacement(): NodeMaterialConnectionPoint;
  62823. /**
  62824. * Gets the output component
  62825. */
  62826. get output(): NodeMaterialConnectionPoint;
  62827. protected _buildBlock(state: NodeMaterialBuildState): this;
  62828. }
  62829. }
  62830. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62834. /**
  62835. * Block used to posterize a value
  62836. * @see https://en.wikipedia.org/wiki/Posterization
  62837. */
  62838. export class PosterizeBlock extends NodeMaterialBlock {
  62839. /**
  62840. * Creates a new PosterizeBlock
  62841. * @param name defines the block name
  62842. */
  62843. constructor(name: string);
  62844. /**
  62845. * Gets the current class name
  62846. * @returns the class name
  62847. */
  62848. getClassName(): string;
  62849. /**
  62850. * Gets the value input component
  62851. */
  62852. get value(): NodeMaterialConnectionPoint;
  62853. /**
  62854. * Gets the steps input component
  62855. */
  62856. get steps(): NodeMaterialConnectionPoint;
  62857. /**
  62858. * Gets the output component
  62859. */
  62860. get output(): NodeMaterialConnectionPoint;
  62861. protected _buildBlock(state: NodeMaterialBuildState): this;
  62862. }
  62863. }
  62864. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62868. import { Scene } from "babylonjs/scene";
  62869. /**
  62870. * Operations supported by the Wave block
  62871. */
  62872. export enum WaveBlockKind {
  62873. /** SawTooth */
  62874. SawTooth = 0,
  62875. /** Square */
  62876. Square = 1,
  62877. /** Triangle */
  62878. Triangle = 2
  62879. }
  62880. /**
  62881. * Block used to apply wave operation to floats
  62882. */
  62883. export class WaveBlock extends NodeMaterialBlock {
  62884. /**
  62885. * Gets or sets the kibnd of wave to be applied by the block
  62886. */
  62887. kind: WaveBlockKind;
  62888. /**
  62889. * Creates a new WaveBlock
  62890. * @param name defines the block name
  62891. */
  62892. constructor(name: string);
  62893. /**
  62894. * Gets the current class name
  62895. * @returns the class name
  62896. */
  62897. getClassName(): string;
  62898. /**
  62899. * Gets the input component
  62900. */
  62901. get input(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the output component
  62904. */
  62905. get output(): NodeMaterialConnectionPoint;
  62906. protected _buildBlock(state: NodeMaterialBuildState): this;
  62907. serialize(): any;
  62908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62909. }
  62910. }
  62911. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62915. import { Color3 } from "babylonjs/Maths/math.color";
  62916. import { Scene } from "babylonjs/scene";
  62917. /**
  62918. * Class used to store a color step for the GradientBlock
  62919. */
  62920. export class GradientBlockColorStep {
  62921. /**
  62922. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62923. */
  62924. step: number;
  62925. /**
  62926. * Gets or sets the color associated with this step
  62927. */
  62928. color: Color3;
  62929. /**
  62930. * Creates a new GradientBlockColorStep
  62931. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62932. * @param color defines the color associated with this step
  62933. */
  62934. constructor(
  62935. /**
  62936. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62937. */
  62938. step: number,
  62939. /**
  62940. * Gets or sets the color associated with this step
  62941. */
  62942. color: Color3);
  62943. }
  62944. /**
  62945. * Block used to return a color from a gradient based on an input value between 0 and 1
  62946. */
  62947. export class GradientBlock extends NodeMaterialBlock {
  62948. /**
  62949. * Gets or sets the list of color steps
  62950. */
  62951. colorSteps: GradientBlockColorStep[];
  62952. /**
  62953. * Creates a new GradientBlock
  62954. * @param name defines the block name
  62955. */
  62956. constructor(name: string);
  62957. /**
  62958. * Gets the current class name
  62959. * @returns the class name
  62960. */
  62961. getClassName(): string;
  62962. /**
  62963. * Gets the gradient input component
  62964. */
  62965. get gradient(): NodeMaterialConnectionPoint;
  62966. /**
  62967. * Gets the output component
  62968. */
  62969. get output(): NodeMaterialConnectionPoint;
  62970. private _writeColorConstant;
  62971. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62972. serialize(): any;
  62973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62974. protected _dumpPropertiesCode(): string;
  62975. }
  62976. }
  62977. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62981. /**
  62982. * Block used to normalize lerp between 2 values
  62983. */
  62984. export class NLerpBlock extends NodeMaterialBlock {
  62985. /**
  62986. * Creates a new NLerpBlock
  62987. * @param name defines the block name
  62988. */
  62989. constructor(name: string);
  62990. /**
  62991. * Gets the current class name
  62992. * @returns the class name
  62993. */
  62994. getClassName(): string;
  62995. /**
  62996. * Gets the left operand input component
  62997. */
  62998. get left(): NodeMaterialConnectionPoint;
  62999. /**
  63000. * Gets the right operand input component
  63001. */
  63002. get right(): NodeMaterialConnectionPoint;
  63003. /**
  63004. * Gets the gradient operand input component
  63005. */
  63006. get gradient(): NodeMaterialConnectionPoint;
  63007. /**
  63008. * Gets the output component
  63009. */
  63010. get output(): NodeMaterialConnectionPoint;
  63011. protected _buildBlock(state: NodeMaterialBuildState): this;
  63012. }
  63013. }
  63014. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63018. import { Scene } from "babylonjs/scene";
  63019. /**
  63020. * block used to Generate a Worley Noise 3D Noise Pattern
  63021. */
  63022. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63023. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63024. manhattanDistance: boolean;
  63025. /**
  63026. * Creates a new WorleyNoise3DBlock
  63027. * @param name defines the block name
  63028. */
  63029. constructor(name: string);
  63030. /**
  63031. * Gets the current class name
  63032. * @returns the class name
  63033. */
  63034. getClassName(): string;
  63035. /**
  63036. * Gets the seed input component
  63037. */
  63038. get seed(): NodeMaterialConnectionPoint;
  63039. /**
  63040. * Gets the jitter input component
  63041. */
  63042. get jitter(): NodeMaterialConnectionPoint;
  63043. /**
  63044. * Gets the output component
  63045. */
  63046. get output(): NodeMaterialConnectionPoint;
  63047. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63048. /**
  63049. * Exposes the properties to the UI?
  63050. */
  63051. protected _dumpPropertiesCode(): string;
  63052. /**
  63053. * Exposes the properties to the Seralize?
  63054. */
  63055. serialize(): any;
  63056. /**
  63057. * Exposes the properties to the deseralize?
  63058. */
  63059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63060. }
  63061. }
  63062. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63066. /**
  63067. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63068. */
  63069. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63070. /**
  63071. * Creates a new SimplexPerlin3DBlock
  63072. * @param name defines the block name
  63073. */
  63074. constructor(name: string);
  63075. /**
  63076. * Gets the current class name
  63077. * @returns the class name
  63078. */
  63079. getClassName(): string;
  63080. /**
  63081. * Gets the seed operand input component
  63082. */
  63083. get seed(): NodeMaterialConnectionPoint;
  63084. /**
  63085. * Gets the output component
  63086. */
  63087. get output(): NodeMaterialConnectionPoint;
  63088. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63089. }
  63090. }
  63091. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63095. /**
  63096. * Block used to blend normals
  63097. */
  63098. export class NormalBlendBlock extends NodeMaterialBlock {
  63099. /**
  63100. * Creates a new NormalBlendBlock
  63101. * @param name defines the block name
  63102. */
  63103. constructor(name: string);
  63104. /**
  63105. * Gets the current class name
  63106. * @returns the class name
  63107. */
  63108. getClassName(): string;
  63109. /**
  63110. * Gets the first input component
  63111. */
  63112. get normalMap0(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the second input component
  63115. */
  63116. get normalMap1(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the output component
  63119. */
  63120. get output(): NodeMaterialConnectionPoint;
  63121. protected _buildBlock(state: NodeMaterialBuildState): this;
  63122. }
  63123. }
  63124. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63128. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63129. /**
  63130. * Block used to rotate a 2d vector by a given angle
  63131. */
  63132. export class Rotate2dBlock extends NodeMaterialBlock {
  63133. /**
  63134. * Creates a new Rotate2dBlock
  63135. * @param name defines the block name
  63136. */
  63137. constructor(name: string);
  63138. /**
  63139. * Gets the current class name
  63140. * @returns the class name
  63141. */
  63142. getClassName(): string;
  63143. /**
  63144. * Gets the input vector
  63145. */
  63146. get input(): NodeMaterialConnectionPoint;
  63147. /**
  63148. * Gets the input angle
  63149. */
  63150. get angle(): NodeMaterialConnectionPoint;
  63151. /**
  63152. * Gets the output component
  63153. */
  63154. get output(): NodeMaterialConnectionPoint;
  63155. autoConfigure(material: NodeMaterial): void;
  63156. protected _buildBlock(state: NodeMaterialBuildState): this;
  63157. }
  63158. }
  63159. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63163. /**
  63164. * Block used to get the reflected vector from a direction and a normal
  63165. */
  63166. export class ReflectBlock extends NodeMaterialBlock {
  63167. /**
  63168. * Creates a new ReflectBlock
  63169. * @param name defines the block name
  63170. */
  63171. constructor(name: string);
  63172. /**
  63173. * Gets the current class name
  63174. * @returns the class name
  63175. */
  63176. getClassName(): string;
  63177. /**
  63178. * Gets the incident component
  63179. */
  63180. get incident(): NodeMaterialConnectionPoint;
  63181. /**
  63182. * Gets the normal component
  63183. */
  63184. get normal(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the output component
  63187. */
  63188. get output(): NodeMaterialConnectionPoint;
  63189. protected _buildBlock(state: NodeMaterialBuildState): this;
  63190. }
  63191. }
  63192. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63196. /**
  63197. * Block used to get the refracted vector from a direction and a normal
  63198. */
  63199. export class RefractBlock extends NodeMaterialBlock {
  63200. /**
  63201. * Creates a new RefractBlock
  63202. * @param name defines the block name
  63203. */
  63204. constructor(name: string);
  63205. /**
  63206. * Gets the current class name
  63207. * @returns the class name
  63208. */
  63209. getClassName(): string;
  63210. /**
  63211. * Gets the incident component
  63212. */
  63213. get incident(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the normal component
  63216. */
  63217. get normal(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the index of refraction component
  63220. */
  63221. get ior(): NodeMaterialConnectionPoint;
  63222. /**
  63223. * Gets the output component
  63224. */
  63225. get output(): NodeMaterialConnectionPoint;
  63226. protected _buildBlock(state: NodeMaterialBuildState): this;
  63227. }
  63228. }
  63229. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63233. /**
  63234. * Block used to desaturate a color
  63235. */
  63236. export class DesaturateBlock extends NodeMaterialBlock {
  63237. /**
  63238. * Creates a new DesaturateBlock
  63239. * @param name defines the block name
  63240. */
  63241. constructor(name: string);
  63242. /**
  63243. * Gets the current class name
  63244. * @returns the class name
  63245. */
  63246. getClassName(): string;
  63247. /**
  63248. * Gets the color operand input component
  63249. */
  63250. get color(): NodeMaterialConnectionPoint;
  63251. /**
  63252. * Gets the level operand input component
  63253. */
  63254. get level(): NodeMaterialConnectionPoint;
  63255. /**
  63256. * Gets the output component
  63257. */
  63258. get output(): NodeMaterialConnectionPoint;
  63259. protected _buildBlock(state: NodeMaterialBuildState): this;
  63260. }
  63261. }
  63262. declare module "babylonjs/Materials/Node/Blocks/index" {
  63263. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63264. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63265. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63266. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63267. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63268. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63269. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63270. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63271. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63272. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63273. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63274. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63275. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63276. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63277. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63278. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63279. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63280. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63281. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63282. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63283. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63284. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63285. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63286. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63287. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63288. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63289. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63290. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63291. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63292. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63293. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63294. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63295. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63296. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63297. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63298. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63299. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63300. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63301. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63302. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63303. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63304. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63305. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63306. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63307. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63308. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63309. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63310. }
  63311. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63312. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63313. }
  63314. declare module "babylonjs/Materials/Node/index" {
  63315. export * from "babylonjs/Materials/Node/Enums/index";
  63316. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63317. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63318. export * from "babylonjs/Materials/Node/nodeMaterial";
  63319. export * from "babylonjs/Materials/Node/Blocks/index";
  63320. export * from "babylonjs/Materials/Node/Optimizers/index";
  63321. }
  63322. declare module "babylonjs/Materials/effectRenderer" {
  63323. import { Nullable } from "babylonjs/types";
  63324. import { Texture } from "babylonjs/Materials/Textures/texture";
  63325. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63326. import { Viewport } from "babylonjs/Maths/math.viewport";
  63327. import { Observable } from "babylonjs/Misc/observable";
  63328. import { Effect } from "babylonjs/Materials/effect";
  63329. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63330. import "babylonjs/Shaders/postprocess.vertex";
  63331. /**
  63332. * Effect Render Options
  63333. */
  63334. export interface IEffectRendererOptions {
  63335. /**
  63336. * Defines the vertices positions.
  63337. */
  63338. positions?: number[];
  63339. /**
  63340. * Defines the indices.
  63341. */
  63342. indices?: number[];
  63343. }
  63344. /**
  63345. * Helper class to render one or more effects
  63346. */
  63347. export class EffectRenderer {
  63348. private engine;
  63349. private static _DefaultOptions;
  63350. private _vertexBuffers;
  63351. private _indexBuffer;
  63352. private _ringBufferIndex;
  63353. private _ringScreenBuffer;
  63354. private _fullscreenViewport;
  63355. private _getNextFrameBuffer;
  63356. /**
  63357. * Creates an effect renderer
  63358. * @param engine the engine to use for rendering
  63359. * @param options defines the options of the effect renderer
  63360. */
  63361. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63362. /**
  63363. * Sets the current viewport in normalized coordinates 0-1
  63364. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63365. */
  63366. setViewport(viewport?: Viewport): void;
  63367. /**
  63368. * Binds the embedded attributes buffer to the effect.
  63369. * @param effect Defines the effect to bind the attributes for
  63370. */
  63371. bindBuffers(effect: Effect): void;
  63372. /**
  63373. * Sets the current effect wrapper to use during draw.
  63374. * The effect needs to be ready before calling this api.
  63375. * This also sets the default full screen position attribute.
  63376. * @param effectWrapper Defines the effect to draw with
  63377. */
  63378. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63379. /**
  63380. * Draws a full screen quad.
  63381. */
  63382. draw(): void;
  63383. /**
  63384. * renders one or more effects to a specified texture
  63385. * @param effectWrappers list of effects to renderer
  63386. * @param outputTexture texture to draw to, if null it will render to the screen
  63387. */
  63388. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63389. /**
  63390. * Disposes of the effect renderer
  63391. */
  63392. dispose(): void;
  63393. }
  63394. /**
  63395. * Options to create an EffectWrapper
  63396. */
  63397. interface EffectWrapperCreationOptions {
  63398. /**
  63399. * Engine to use to create the effect
  63400. */
  63401. engine: ThinEngine;
  63402. /**
  63403. * Fragment shader for the effect
  63404. */
  63405. fragmentShader: string;
  63406. /**
  63407. * Vertex shader for the effect
  63408. */
  63409. vertexShader?: string;
  63410. /**
  63411. * Attributes to use in the shader
  63412. */
  63413. attributeNames?: Array<string>;
  63414. /**
  63415. * Uniforms to use in the shader
  63416. */
  63417. uniformNames?: Array<string>;
  63418. /**
  63419. * Texture sampler names to use in the shader
  63420. */
  63421. samplerNames?: Array<string>;
  63422. /**
  63423. * The friendly name of the effect displayed in Spector.
  63424. */
  63425. name?: string;
  63426. }
  63427. /**
  63428. * Wraps an effect to be used for rendering
  63429. */
  63430. export class EffectWrapper {
  63431. /**
  63432. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63433. */
  63434. onApplyObservable: Observable<{}>;
  63435. /**
  63436. * The underlying effect
  63437. */
  63438. effect: Effect;
  63439. /**
  63440. * Creates an effect to be renderer
  63441. * @param creationOptions options to create the effect
  63442. */
  63443. constructor(creationOptions: EffectWrapperCreationOptions);
  63444. /**
  63445. * Disposes of the effect wrapper
  63446. */
  63447. dispose(): void;
  63448. }
  63449. }
  63450. declare module "babylonjs/Materials/index" {
  63451. export * from "babylonjs/Materials/Background/index";
  63452. export * from "babylonjs/Materials/colorCurves";
  63453. export * from "babylonjs/Materials/iEffectFallbacks";
  63454. export * from "babylonjs/Materials/effectFallbacks";
  63455. export * from "babylonjs/Materials/effect";
  63456. export * from "babylonjs/Materials/fresnelParameters";
  63457. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63458. export * from "babylonjs/Materials/material";
  63459. export * from "babylonjs/Materials/materialDefines";
  63460. export * from "babylonjs/Materials/materialHelper";
  63461. export * from "babylonjs/Materials/multiMaterial";
  63462. export * from "babylonjs/Materials/PBR/index";
  63463. export * from "babylonjs/Materials/pushMaterial";
  63464. export * from "babylonjs/Materials/shaderMaterial";
  63465. export * from "babylonjs/Materials/standardMaterial";
  63466. export * from "babylonjs/Materials/Textures/index";
  63467. export * from "babylonjs/Materials/uniformBuffer";
  63468. export * from "babylonjs/Materials/materialFlags";
  63469. export * from "babylonjs/Materials/Node/index";
  63470. export * from "babylonjs/Materials/effectRenderer";
  63471. }
  63472. declare module "babylonjs/Maths/index" {
  63473. export * from "babylonjs/Maths/math.scalar";
  63474. export * from "babylonjs/Maths/math";
  63475. export * from "babylonjs/Maths/sphericalPolynomial";
  63476. }
  63477. declare module "babylonjs/Misc/workerPool" {
  63478. import { IDisposable } from "babylonjs/scene";
  63479. /**
  63480. * Helper class to push actions to a pool of workers.
  63481. */
  63482. export class WorkerPool implements IDisposable {
  63483. private _workerInfos;
  63484. private _pendingActions;
  63485. /**
  63486. * Constructor
  63487. * @param workers Array of workers to use for actions
  63488. */
  63489. constructor(workers: Array<Worker>);
  63490. /**
  63491. * Terminates all workers and clears any pending actions.
  63492. */
  63493. dispose(): void;
  63494. /**
  63495. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63496. * pended until a worker has completed its action.
  63497. * @param action The action to perform. Call onComplete when the action is complete.
  63498. */
  63499. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63500. private _execute;
  63501. }
  63502. }
  63503. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63504. import { IDisposable } from "babylonjs/scene";
  63505. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63506. /**
  63507. * Configuration for Draco compression
  63508. */
  63509. export interface IDracoCompressionConfiguration {
  63510. /**
  63511. * Configuration for the decoder.
  63512. */
  63513. decoder: {
  63514. /**
  63515. * The url to the WebAssembly module.
  63516. */
  63517. wasmUrl?: string;
  63518. /**
  63519. * The url to the WebAssembly binary.
  63520. */
  63521. wasmBinaryUrl?: string;
  63522. /**
  63523. * The url to the fallback JavaScript module.
  63524. */
  63525. fallbackUrl?: string;
  63526. };
  63527. }
  63528. /**
  63529. * Draco compression (https://google.github.io/draco/)
  63530. *
  63531. * This class wraps the Draco module.
  63532. *
  63533. * **Encoder**
  63534. *
  63535. * The encoder is not currently implemented.
  63536. *
  63537. * **Decoder**
  63538. *
  63539. * 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.
  63540. *
  63541. * To update the configuration, use the following code:
  63542. * ```javascript
  63543. * DracoCompression.Configuration = {
  63544. * decoder: {
  63545. * wasmUrl: "<url to the WebAssembly library>",
  63546. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63547. * fallbackUrl: "<url to the fallback JavaScript library>",
  63548. * }
  63549. * };
  63550. * ```
  63551. *
  63552. * 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.
  63553. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63554. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63555. *
  63556. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63557. * ```javascript
  63558. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63559. * ```
  63560. *
  63561. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63562. */
  63563. export class DracoCompression implements IDisposable {
  63564. private _workerPoolPromise?;
  63565. private _decoderModulePromise?;
  63566. /**
  63567. * The configuration. Defaults to the following urls:
  63568. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63569. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63570. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63571. */
  63572. static Configuration: IDracoCompressionConfiguration;
  63573. /**
  63574. * Returns true if the decoder configuration is available.
  63575. */
  63576. static get DecoderAvailable(): boolean;
  63577. /**
  63578. * Default number of workers to create when creating the draco compression object.
  63579. */
  63580. static DefaultNumWorkers: number;
  63581. private static GetDefaultNumWorkers;
  63582. private static _Default;
  63583. /**
  63584. * Default instance for the draco compression object.
  63585. */
  63586. static get Default(): DracoCompression;
  63587. /**
  63588. * Constructor
  63589. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63590. */
  63591. constructor(numWorkers?: number);
  63592. /**
  63593. * Stop all async operations and release resources.
  63594. */
  63595. dispose(): void;
  63596. /**
  63597. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63598. * @returns a promise that resolves when ready
  63599. */
  63600. whenReadyAsync(): Promise<void>;
  63601. /**
  63602. * Decode Draco compressed mesh data to vertex data.
  63603. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63604. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63605. * @returns A promise that resolves with the decoded vertex data
  63606. */
  63607. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63608. [kind: string]: number;
  63609. }): Promise<VertexData>;
  63610. }
  63611. }
  63612. declare module "babylonjs/Meshes/Compression/index" {
  63613. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63614. }
  63615. declare module "babylonjs/Meshes/csg" {
  63616. import { Nullable } from "babylonjs/types";
  63617. import { Scene } from "babylonjs/scene";
  63618. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63619. import { Mesh } from "babylonjs/Meshes/mesh";
  63620. import { Material } from "babylonjs/Materials/material";
  63621. /**
  63622. * Class for building Constructive Solid Geometry
  63623. */
  63624. export class CSG {
  63625. private polygons;
  63626. /**
  63627. * The world matrix
  63628. */
  63629. matrix: Matrix;
  63630. /**
  63631. * Stores the position
  63632. */
  63633. position: Vector3;
  63634. /**
  63635. * Stores the rotation
  63636. */
  63637. rotation: Vector3;
  63638. /**
  63639. * Stores the rotation quaternion
  63640. */
  63641. rotationQuaternion: Nullable<Quaternion>;
  63642. /**
  63643. * Stores the scaling vector
  63644. */
  63645. scaling: Vector3;
  63646. /**
  63647. * Convert the Mesh to CSG
  63648. * @param mesh The Mesh to convert to CSG
  63649. * @returns A new CSG from the Mesh
  63650. */
  63651. static FromMesh(mesh: Mesh): CSG;
  63652. /**
  63653. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63654. * @param polygons Polygons used to construct a CSG solid
  63655. */
  63656. private static FromPolygons;
  63657. /**
  63658. * Clones, or makes a deep copy, of the CSG
  63659. * @returns A new CSG
  63660. */
  63661. clone(): CSG;
  63662. /**
  63663. * Unions this CSG with another CSG
  63664. * @param csg The CSG to union against this CSG
  63665. * @returns The unioned CSG
  63666. */
  63667. union(csg: CSG): CSG;
  63668. /**
  63669. * Unions this CSG with another CSG in place
  63670. * @param csg The CSG to union against this CSG
  63671. */
  63672. unionInPlace(csg: CSG): void;
  63673. /**
  63674. * Subtracts this CSG with another CSG
  63675. * @param csg The CSG to subtract against this CSG
  63676. * @returns A new CSG
  63677. */
  63678. subtract(csg: CSG): CSG;
  63679. /**
  63680. * Subtracts this CSG with another CSG in place
  63681. * @param csg The CSG to subtact against this CSG
  63682. */
  63683. subtractInPlace(csg: CSG): void;
  63684. /**
  63685. * Intersect this CSG with another CSG
  63686. * @param csg The CSG to intersect against this CSG
  63687. * @returns A new CSG
  63688. */
  63689. intersect(csg: CSG): CSG;
  63690. /**
  63691. * Intersects this CSG with another CSG in place
  63692. * @param csg The CSG to intersect against this CSG
  63693. */
  63694. intersectInPlace(csg: CSG): void;
  63695. /**
  63696. * Return a new CSG solid with solid and empty space switched. This solid is
  63697. * not modified.
  63698. * @returns A new CSG solid with solid and empty space switched
  63699. */
  63700. inverse(): CSG;
  63701. /**
  63702. * Inverses the CSG in place
  63703. */
  63704. inverseInPlace(): void;
  63705. /**
  63706. * This is used to keep meshes transformations so they can be restored
  63707. * when we build back a Babylon Mesh
  63708. * NB : All CSG operations are performed in world coordinates
  63709. * @param csg The CSG to copy the transform attributes from
  63710. * @returns This CSG
  63711. */
  63712. copyTransformAttributes(csg: CSG): CSG;
  63713. /**
  63714. * Build Raw mesh from CSG
  63715. * Coordinates here are in world space
  63716. * @param name The name of the mesh geometry
  63717. * @param scene The Scene
  63718. * @param keepSubMeshes Specifies if the submeshes should be kept
  63719. * @returns A new Mesh
  63720. */
  63721. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63722. /**
  63723. * Build Mesh from CSG taking material and transforms into account
  63724. * @param name The name of the Mesh
  63725. * @param material The material of the Mesh
  63726. * @param scene The Scene
  63727. * @param keepSubMeshes Specifies if submeshes should be kept
  63728. * @returns The new Mesh
  63729. */
  63730. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63731. }
  63732. }
  63733. declare module "babylonjs/Meshes/trailMesh" {
  63734. import { Mesh } from "babylonjs/Meshes/mesh";
  63735. import { Scene } from "babylonjs/scene";
  63736. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63737. /**
  63738. * Class used to create a trail following a mesh
  63739. */
  63740. export class TrailMesh extends Mesh {
  63741. private _generator;
  63742. private _autoStart;
  63743. private _running;
  63744. private _diameter;
  63745. private _length;
  63746. private _sectionPolygonPointsCount;
  63747. private _sectionVectors;
  63748. private _sectionNormalVectors;
  63749. private _beforeRenderObserver;
  63750. /**
  63751. * @constructor
  63752. * @param name The value used by scene.getMeshByName() to do a lookup.
  63753. * @param generator The mesh or transform node to generate a trail.
  63754. * @param scene The scene to add this mesh to.
  63755. * @param diameter Diameter of trailing mesh. Default is 1.
  63756. * @param length Length of trailing mesh. Default is 60.
  63757. * @param autoStart Automatically start trailing mesh. Default true.
  63758. */
  63759. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63760. /**
  63761. * "TrailMesh"
  63762. * @returns "TrailMesh"
  63763. */
  63764. getClassName(): string;
  63765. private _createMesh;
  63766. /**
  63767. * Start trailing mesh.
  63768. */
  63769. start(): void;
  63770. /**
  63771. * Stop trailing mesh.
  63772. */
  63773. stop(): void;
  63774. /**
  63775. * Update trailing mesh geometry.
  63776. */
  63777. update(): void;
  63778. /**
  63779. * Returns a new TrailMesh object.
  63780. * @param name is a string, the name given to the new mesh
  63781. * @param newGenerator use new generator object for cloned trail mesh
  63782. * @returns a new mesh
  63783. */
  63784. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63785. /**
  63786. * Serializes this trail mesh
  63787. * @param serializationObject object to write serialization to
  63788. */
  63789. serialize(serializationObject: any): void;
  63790. /**
  63791. * Parses a serialized trail mesh
  63792. * @param parsedMesh the serialized mesh
  63793. * @param scene the scene to create the trail mesh in
  63794. * @returns the created trail mesh
  63795. */
  63796. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63797. }
  63798. }
  63799. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63800. import { Nullable } from "babylonjs/types";
  63801. import { Scene } from "babylonjs/scene";
  63802. import { Vector4 } from "babylonjs/Maths/math.vector";
  63803. import { Color4 } from "babylonjs/Maths/math.color";
  63804. import { Mesh } from "babylonjs/Meshes/mesh";
  63805. /**
  63806. * Class containing static functions to help procedurally build meshes
  63807. */
  63808. export class TiledBoxBuilder {
  63809. /**
  63810. * Creates a box mesh
  63811. * 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)
  63812. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63816. * @param name defines the name of the mesh
  63817. * @param options defines the options used to create the mesh
  63818. * @param scene defines the hosting scene
  63819. * @returns the box mesh
  63820. */
  63821. static CreateTiledBox(name: string, options: {
  63822. pattern?: number;
  63823. width?: number;
  63824. height?: number;
  63825. depth?: number;
  63826. tileSize?: number;
  63827. tileWidth?: number;
  63828. tileHeight?: number;
  63829. alignHorizontal?: number;
  63830. alignVertical?: number;
  63831. faceUV?: Vector4[];
  63832. faceColors?: Color4[];
  63833. sideOrientation?: number;
  63834. updatable?: boolean;
  63835. }, scene?: Nullable<Scene>): Mesh;
  63836. }
  63837. }
  63838. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63839. import { Vector4 } from "babylonjs/Maths/math.vector";
  63840. import { Mesh } from "babylonjs/Meshes/mesh";
  63841. /**
  63842. * Class containing static functions to help procedurally build meshes
  63843. */
  63844. export class TorusKnotBuilder {
  63845. /**
  63846. * Creates a torus knot mesh
  63847. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63848. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63849. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63850. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63854. * @param name defines the name of the mesh
  63855. * @param options defines the options used to create the mesh
  63856. * @param scene defines the hosting scene
  63857. * @returns the torus knot mesh
  63858. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63859. */
  63860. static CreateTorusKnot(name: string, options: {
  63861. radius?: number;
  63862. tube?: number;
  63863. radialSegments?: number;
  63864. tubularSegments?: number;
  63865. p?: number;
  63866. q?: number;
  63867. updatable?: boolean;
  63868. sideOrientation?: number;
  63869. frontUVs?: Vector4;
  63870. backUVs?: Vector4;
  63871. }, scene: any): Mesh;
  63872. }
  63873. }
  63874. declare module "babylonjs/Meshes/polygonMesh" {
  63875. import { Scene } from "babylonjs/scene";
  63876. import { Vector2 } from "babylonjs/Maths/math.vector";
  63877. import { Mesh } from "babylonjs/Meshes/mesh";
  63878. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63879. import { Path2 } from "babylonjs/Maths/math.path";
  63880. /**
  63881. * Polygon
  63882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63883. */
  63884. export class Polygon {
  63885. /**
  63886. * Creates a rectangle
  63887. * @param xmin bottom X coord
  63888. * @param ymin bottom Y coord
  63889. * @param xmax top X coord
  63890. * @param ymax top Y coord
  63891. * @returns points that make the resulting rectation
  63892. */
  63893. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63894. /**
  63895. * Creates a circle
  63896. * @param radius radius of circle
  63897. * @param cx scale in x
  63898. * @param cy scale in y
  63899. * @param numberOfSides number of sides that make up the circle
  63900. * @returns points that make the resulting circle
  63901. */
  63902. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63903. /**
  63904. * Creates a polygon from input string
  63905. * @param input Input polygon data
  63906. * @returns the parsed points
  63907. */
  63908. static Parse(input: string): Vector2[];
  63909. /**
  63910. * Starts building a polygon from x and y coordinates
  63911. * @param x x coordinate
  63912. * @param y y coordinate
  63913. * @returns the started path2
  63914. */
  63915. static StartingAt(x: number, y: number): Path2;
  63916. }
  63917. /**
  63918. * Builds a polygon
  63919. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63920. */
  63921. export class PolygonMeshBuilder {
  63922. private _points;
  63923. private _outlinepoints;
  63924. private _holes;
  63925. private _name;
  63926. private _scene;
  63927. private _epoints;
  63928. private _eholes;
  63929. private _addToepoint;
  63930. /**
  63931. * Babylon reference to the earcut plugin.
  63932. */
  63933. bjsEarcut: any;
  63934. /**
  63935. * Creates a PolygonMeshBuilder
  63936. * @param name name of the builder
  63937. * @param contours Path of the polygon
  63938. * @param scene scene to add to when creating the mesh
  63939. * @param earcutInjection can be used to inject your own earcut reference
  63940. */
  63941. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63942. /**
  63943. * Adds a whole within the polygon
  63944. * @param hole Array of points defining the hole
  63945. * @returns this
  63946. */
  63947. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63948. /**
  63949. * Creates the polygon
  63950. * @param updatable If the mesh should be updatable
  63951. * @param depth The depth of the mesh created
  63952. * @returns the created mesh
  63953. */
  63954. build(updatable?: boolean, depth?: number): Mesh;
  63955. /**
  63956. * Creates the polygon
  63957. * @param depth The depth of the mesh created
  63958. * @returns the created VertexData
  63959. */
  63960. buildVertexData(depth?: number): VertexData;
  63961. /**
  63962. * Adds a side to the polygon
  63963. * @param positions points that make the polygon
  63964. * @param normals normals of the polygon
  63965. * @param uvs uvs of the polygon
  63966. * @param indices indices of the polygon
  63967. * @param bounds bounds of the polygon
  63968. * @param points points of the polygon
  63969. * @param depth depth of the polygon
  63970. * @param flip flip of the polygon
  63971. */
  63972. private addSide;
  63973. }
  63974. }
  63975. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63976. import { Scene } from "babylonjs/scene";
  63977. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63978. import { Color4 } from "babylonjs/Maths/math.color";
  63979. import { Mesh } from "babylonjs/Meshes/mesh";
  63980. import { Nullable } from "babylonjs/types";
  63981. /**
  63982. * Class containing static functions to help procedurally build meshes
  63983. */
  63984. export class PolygonBuilder {
  63985. /**
  63986. * Creates a polygon mesh
  63987. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63988. * * 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
  63989. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63992. * * Remember you can only change the shape positions, not their number when updating a polygon
  63993. * @param name defines the name of the mesh
  63994. * @param options defines the options used to create the mesh
  63995. * @param scene defines the hosting scene
  63996. * @param earcutInjection can be used to inject your own earcut reference
  63997. * @returns the polygon mesh
  63998. */
  63999. static CreatePolygon(name: string, options: {
  64000. shape: Vector3[];
  64001. holes?: Vector3[][];
  64002. depth?: number;
  64003. faceUV?: Vector4[];
  64004. faceColors?: Color4[];
  64005. updatable?: boolean;
  64006. sideOrientation?: number;
  64007. frontUVs?: Vector4;
  64008. backUVs?: Vector4;
  64009. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64010. /**
  64011. * Creates an extruded polygon mesh, with depth in the Y direction.
  64012. * * 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)
  64013. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64014. * @param name defines the name of the mesh
  64015. * @param options defines the options used to create the mesh
  64016. * @param scene defines the hosting scene
  64017. * @param earcutInjection can be used to inject your own earcut reference
  64018. * @returns the polygon mesh
  64019. */
  64020. static ExtrudePolygon(name: string, options: {
  64021. shape: Vector3[];
  64022. holes?: Vector3[][];
  64023. depth?: number;
  64024. faceUV?: Vector4[];
  64025. faceColors?: Color4[];
  64026. updatable?: boolean;
  64027. sideOrientation?: number;
  64028. frontUVs?: Vector4;
  64029. backUVs?: Vector4;
  64030. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64031. }
  64032. }
  64033. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64034. import { Scene } from "babylonjs/scene";
  64035. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64036. import { Mesh } from "babylonjs/Meshes/mesh";
  64037. import { Nullable } from "babylonjs/types";
  64038. /**
  64039. * Class containing static functions to help procedurally build meshes
  64040. */
  64041. export class LatheBuilder {
  64042. /**
  64043. * Creates lathe mesh.
  64044. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64045. * * 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
  64046. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64047. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64048. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64049. * * 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
  64050. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64051. * * 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
  64052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64056. * @param name defines the name of the mesh
  64057. * @param options defines the options used to create the mesh
  64058. * @param scene defines the hosting scene
  64059. * @returns the lathe mesh
  64060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64061. */
  64062. static CreateLathe(name: string, options: {
  64063. shape: Vector3[];
  64064. radius?: number;
  64065. tessellation?: number;
  64066. clip?: number;
  64067. arc?: number;
  64068. closed?: boolean;
  64069. updatable?: boolean;
  64070. sideOrientation?: number;
  64071. frontUVs?: Vector4;
  64072. backUVs?: Vector4;
  64073. cap?: number;
  64074. invertUV?: boolean;
  64075. }, scene?: Nullable<Scene>): Mesh;
  64076. }
  64077. }
  64078. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64079. import { Nullable } from "babylonjs/types";
  64080. import { Scene } from "babylonjs/scene";
  64081. import { Vector4 } from "babylonjs/Maths/math.vector";
  64082. import { Mesh } from "babylonjs/Meshes/mesh";
  64083. /**
  64084. * Class containing static functions to help procedurally build meshes
  64085. */
  64086. export class TiledPlaneBuilder {
  64087. /**
  64088. * Creates a tiled plane mesh
  64089. * * The parameter `pattern` will, depending on value, do nothing or
  64090. * * * flip (reflect about central vertical) alternate tiles across and up
  64091. * * * flip every tile on alternate rows
  64092. * * * rotate (180 degs) alternate tiles across and up
  64093. * * * rotate every tile on alternate rows
  64094. * * * flip and rotate alternate tiles across and up
  64095. * * * flip and rotate every tile on alternate rows
  64096. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64097. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64100. * * 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)
  64101. * * 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)
  64102. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64103. * @param name defines the name of the mesh
  64104. * @param options defines the options used to create the mesh
  64105. * @param scene defines the hosting scene
  64106. * @returns the box mesh
  64107. */
  64108. static CreateTiledPlane(name: string, options: {
  64109. pattern?: number;
  64110. tileSize?: number;
  64111. tileWidth?: number;
  64112. tileHeight?: number;
  64113. size?: number;
  64114. width?: number;
  64115. height?: number;
  64116. alignHorizontal?: number;
  64117. alignVertical?: number;
  64118. sideOrientation?: number;
  64119. frontUVs?: Vector4;
  64120. backUVs?: Vector4;
  64121. updatable?: boolean;
  64122. }, scene?: Nullable<Scene>): Mesh;
  64123. }
  64124. }
  64125. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64126. import { Nullable } from "babylonjs/types";
  64127. import { Scene } from "babylonjs/scene";
  64128. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64129. import { Mesh } from "babylonjs/Meshes/mesh";
  64130. /**
  64131. * Class containing static functions to help procedurally build meshes
  64132. */
  64133. export class TubeBuilder {
  64134. /**
  64135. * Creates a tube mesh.
  64136. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64137. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64138. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64139. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64140. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64141. * * 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)
  64142. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64143. * * 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
  64144. * * 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
  64145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64147. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64149. * @param name defines the name of the mesh
  64150. * @param options defines the options used to create the mesh
  64151. * @param scene defines the hosting scene
  64152. * @returns the tube mesh
  64153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64154. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64155. */
  64156. static CreateTube(name: string, options: {
  64157. path: Vector3[];
  64158. radius?: number;
  64159. tessellation?: number;
  64160. radiusFunction?: {
  64161. (i: number, distance: number): number;
  64162. };
  64163. cap?: number;
  64164. arc?: number;
  64165. updatable?: boolean;
  64166. sideOrientation?: number;
  64167. frontUVs?: Vector4;
  64168. backUVs?: Vector4;
  64169. instance?: Mesh;
  64170. invertUV?: boolean;
  64171. }, scene?: Nullable<Scene>): Mesh;
  64172. }
  64173. }
  64174. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64175. import { Scene } from "babylonjs/scene";
  64176. import { Vector4 } from "babylonjs/Maths/math.vector";
  64177. import { Mesh } from "babylonjs/Meshes/mesh";
  64178. import { Nullable } from "babylonjs/types";
  64179. /**
  64180. * Class containing static functions to help procedurally build meshes
  64181. */
  64182. export class IcoSphereBuilder {
  64183. /**
  64184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64186. * * 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`)
  64187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64188. * * 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
  64189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64192. * @param name defines the name of the mesh
  64193. * @param options defines the options used to create the mesh
  64194. * @param scene defines the hosting scene
  64195. * @returns the icosahedron mesh
  64196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64197. */
  64198. static CreateIcoSphere(name: string, options: {
  64199. radius?: number;
  64200. radiusX?: number;
  64201. radiusY?: number;
  64202. radiusZ?: number;
  64203. flat?: boolean;
  64204. subdivisions?: number;
  64205. sideOrientation?: number;
  64206. frontUVs?: Vector4;
  64207. backUVs?: Vector4;
  64208. updatable?: boolean;
  64209. }, scene?: Nullable<Scene>): Mesh;
  64210. }
  64211. }
  64212. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64213. import { Vector3 } from "babylonjs/Maths/math.vector";
  64214. import { Mesh } from "babylonjs/Meshes/mesh";
  64215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64216. /**
  64217. * Class containing static functions to help procedurally build meshes
  64218. */
  64219. export class DecalBuilder {
  64220. /**
  64221. * Creates a decal mesh.
  64222. * 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
  64223. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64224. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64225. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64226. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64227. * @param name defines the name of the mesh
  64228. * @param sourceMesh defines the mesh where the decal must be applied
  64229. * @param options defines the options used to create the mesh
  64230. * @param scene defines the hosting scene
  64231. * @returns the decal mesh
  64232. * @see https://doc.babylonjs.com/how_to/decals
  64233. */
  64234. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64235. position?: Vector3;
  64236. normal?: Vector3;
  64237. size?: Vector3;
  64238. angle?: number;
  64239. }): Mesh;
  64240. }
  64241. }
  64242. declare module "babylonjs/Meshes/meshBuilder" {
  64243. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64244. import { Nullable } from "babylonjs/types";
  64245. import { Scene } from "babylonjs/scene";
  64246. import { Mesh } from "babylonjs/Meshes/mesh";
  64247. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64248. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64250. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64251. import { Plane } from "babylonjs/Maths/math.plane";
  64252. /**
  64253. * Class containing static functions to help procedurally build meshes
  64254. */
  64255. export class MeshBuilder {
  64256. /**
  64257. * Creates a box mesh
  64258. * * The parameter `size` sets the size (float) of each box side (default 1)
  64259. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64260. * * 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)
  64261. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64265. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64266. * @param name defines the name of the mesh
  64267. * @param options defines the options used to create the mesh
  64268. * @param scene defines the hosting scene
  64269. * @returns the box mesh
  64270. */
  64271. static CreateBox(name: string, options: {
  64272. size?: number;
  64273. width?: number;
  64274. height?: number;
  64275. depth?: number;
  64276. faceUV?: Vector4[];
  64277. faceColors?: Color4[];
  64278. sideOrientation?: number;
  64279. frontUVs?: Vector4;
  64280. backUVs?: Vector4;
  64281. updatable?: boolean;
  64282. }, scene?: Nullable<Scene>): Mesh;
  64283. /**
  64284. * Creates a tiled box mesh
  64285. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64287. * @param name defines the name of the mesh
  64288. * @param options defines the options used to create the mesh
  64289. * @param scene defines the hosting scene
  64290. * @returns the tiled box mesh
  64291. */
  64292. static CreateTiledBox(name: string, options: {
  64293. pattern?: number;
  64294. size?: number;
  64295. width?: number;
  64296. height?: number;
  64297. depth: number;
  64298. tileSize?: number;
  64299. tileWidth?: number;
  64300. tileHeight?: number;
  64301. faceUV?: Vector4[];
  64302. faceColors?: Color4[];
  64303. alignHorizontal?: number;
  64304. alignVertical?: number;
  64305. sideOrientation?: number;
  64306. updatable?: boolean;
  64307. }, scene?: Nullable<Scene>): Mesh;
  64308. /**
  64309. * Creates a sphere mesh
  64310. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64311. * * 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`)
  64312. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64313. * * 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
  64314. * * 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)
  64315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64318. * @param name defines the name of the mesh
  64319. * @param options defines the options used to create the mesh
  64320. * @param scene defines the hosting scene
  64321. * @returns the sphere mesh
  64322. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64323. */
  64324. static CreateSphere(name: string, options: {
  64325. segments?: number;
  64326. diameter?: number;
  64327. diameterX?: number;
  64328. diameterY?: number;
  64329. diameterZ?: number;
  64330. arc?: number;
  64331. slice?: number;
  64332. sideOrientation?: number;
  64333. frontUVs?: Vector4;
  64334. backUVs?: Vector4;
  64335. updatable?: boolean;
  64336. }, scene?: Nullable<Scene>): Mesh;
  64337. /**
  64338. * Creates a plane polygonal mesh. By default, this is a disc
  64339. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64340. * * 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
  64341. * * 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
  64342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64345. * @param name defines the name of the mesh
  64346. * @param options defines the options used to create the mesh
  64347. * @param scene defines the hosting scene
  64348. * @returns the plane polygonal mesh
  64349. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64350. */
  64351. static CreateDisc(name: string, options: {
  64352. radius?: number;
  64353. tessellation?: number;
  64354. arc?: number;
  64355. updatable?: boolean;
  64356. sideOrientation?: number;
  64357. frontUVs?: Vector4;
  64358. backUVs?: Vector4;
  64359. }, scene?: Nullable<Scene>): Mesh;
  64360. /**
  64361. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64362. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64363. * * 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`)
  64364. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64365. * * 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
  64366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64369. * @param name defines the name of the mesh
  64370. * @param options defines the options used to create the mesh
  64371. * @param scene defines the hosting scene
  64372. * @returns the icosahedron mesh
  64373. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64374. */
  64375. static CreateIcoSphere(name: string, options: {
  64376. radius?: number;
  64377. radiusX?: number;
  64378. radiusY?: number;
  64379. radiusZ?: number;
  64380. flat?: boolean;
  64381. subdivisions?: number;
  64382. sideOrientation?: number;
  64383. frontUVs?: Vector4;
  64384. backUVs?: Vector4;
  64385. updatable?: boolean;
  64386. }, scene?: Nullable<Scene>): Mesh;
  64387. /**
  64388. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64389. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64390. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64391. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64392. * * 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
  64393. * * 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
  64394. * * 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
  64395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64398. * * 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
  64399. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64400. * * 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
  64401. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64403. * @param name defines the name of the mesh
  64404. * @param options defines the options used to create the mesh
  64405. * @param scene defines the hosting scene
  64406. * @returns the ribbon mesh
  64407. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64408. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64409. */
  64410. static CreateRibbon(name: string, options: {
  64411. pathArray: Vector3[][];
  64412. closeArray?: boolean;
  64413. closePath?: boolean;
  64414. offset?: number;
  64415. updatable?: boolean;
  64416. sideOrientation?: number;
  64417. frontUVs?: Vector4;
  64418. backUVs?: Vector4;
  64419. instance?: Mesh;
  64420. invertUV?: boolean;
  64421. uvs?: Vector2[];
  64422. colors?: Color4[];
  64423. }, scene?: Nullable<Scene>): Mesh;
  64424. /**
  64425. * Creates a cylinder or a cone mesh
  64426. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64427. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64428. * * 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.
  64429. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64430. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64431. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64432. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64433. * * 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).
  64434. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64435. * * 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).
  64436. * * 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
  64437. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64438. * * 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
  64439. * * 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.
  64440. * * If `enclose` is false, a ring surface is one element.
  64441. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64442. * * 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
  64443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64446. * @param name defines the name of the mesh
  64447. * @param options defines the options used to create the mesh
  64448. * @param scene defines the hosting scene
  64449. * @returns the cylinder mesh
  64450. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64451. */
  64452. static CreateCylinder(name: string, options: {
  64453. height?: number;
  64454. diameterTop?: number;
  64455. diameterBottom?: number;
  64456. diameter?: number;
  64457. tessellation?: number;
  64458. subdivisions?: number;
  64459. arc?: number;
  64460. faceColors?: Color4[];
  64461. faceUV?: Vector4[];
  64462. updatable?: boolean;
  64463. hasRings?: boolean;
  64464. enclose?: boolean;
  64465. cap?: number;
  64466. sideOrientation?: number;
  64467. frontUVs?: Vector4;
  64468. backUVs?: Vector4;
  64469. }, scene?: Nullable<Scene>): Mesh;
  64470. /**
  64471. * Creates a torus mesh
  64472. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64473. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64474. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64476. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64478. * @param name defines the name of the mesh
  64479. * @param options defines the options used to create the mesh
  64480. * @param scene defines the hosting scene
  64481. * @returns the torus mesh
  64482. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64483. */
  64484. static CreateTorus(name: string, options: {
  64485. diameter?: number;
  64486. thickness?: number;
  64487. tessellation?: number;
  64488. updatable?: boolean;
  64489. sideOrientation?: number;
  64490. frontUVs?: Vector4;
  64491. backUVs?: Vector4;
  64492. }, scene?: Nullable<Scene>): Mesh;
  64493. /**
  64494. * Creates a torus knot mesh
  64495. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64496. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64497. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64498. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64502. * @param name defines the name of the mesh
  64503. * @param options defines the options used to create the mesh
  64504. * @param scene defines the hosting scene
  64505. * @returns the torus knot mesh
  64506. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64507. */
  64508. static CreateTorusKnot(name: string, options: {
  64509. radius?: number;
  64510. tube?: number;
  64511. radialSegments?: number;
  64512. tubularSegments?: number;
  64513. p?: number;
  64514. q?: number;
  64515. updatable?: boolean;
  64516. sideOrientation?: number;
  64517. frontUVs?: Vector4;
  64518. backUVs?: Vector4;
  64519. }, scene?: Nullable<Scene>): Mesh;
  64520. /**
  64521. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64522. * * 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
  64523. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64524. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64525. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64526. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64527. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64528. * * 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
  64529. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64532. * @param name defines the name of the new line system
  64533. * @param options defines the options used to create the line system
  64534. * @param scene defines the hosting scene
  64535. * @returns a new line system mesh
  64536. */
  64537. static CreateLineSystem(name: string, options: {
  64538. lines: Vector3[][];
  64539. updatable?: boolean;
  64540. instance?: Nullable<LinesMesh>;
  64541. colors?: Nullable<Color4[][]>;
  64542. useVertexAlpha?: boolean;
  64543. }, scene: Nullable<Scene>): LinesMesh;
  64544. /**
  64545. * Creates a line mesh
  64546. * 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
  64547. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64548. * * The parameter `points` is an array successive Vector3
  64549. * * 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
  64550. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64551. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64552. * * When updating an instance, remember that only point positions can change, not the number of points
  64553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64555. * @param name defines the name of the new line system
  64556. * @param options defines the options used to create the line system
  64557. * @param scene defines the hosting scene
  64558. * @returns a new line mesh
  64559. */
  64560. static CreateLines(name: string, options: {
  64561. points: Vector3[];
  64562. updatable?: boolean;
  64563. instance?: Nullable<LinesMesh>;
  64564. colors?: Color4[];
  64565. useVertexAlpha?: boolean;
  64566. }, scene?: Nullable<Scene>): LinesMesh;
  64567. /**
  64568. * Creates a dashed line mesh
  64569. * * 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
  64570. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64571. * * The parameter `points` is an array successive Vector3
  64572. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64573. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64574. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64575. * * 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
  64576. * * When updating an instance, remember that only point positions can change, not the number of points
  64577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64578. * @param name defines the name of the mesh
  64579. * @param options defines the options used to create the mesh
  64580. * @param scene defines the hosting scene
  64581. * @returns the dashed line mesh
  64582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64583. */
  64584. static CreateDashedLines(name: string, options: {
  64585. points: Vector3[];
  64586. dashSize?: number;
  64587. gapSize?: number;
  64588. dashNb?: number;
  64589. updatable?: boolean;
  64590. instance?: LinesMesh;
  64591. }, scene?: Nullable<Scene>): LinesMesh;
  64592. /**
  64593. * 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.
  64594. * * 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.
  64595. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64596. * * 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.
  64597. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64598. * * 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
  64599. * * 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
  64600. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64605. * @param name defines the name of the mesh
  64606. * @param options defines the options used to create the mesh
  64607. * @param scene defines the hosting scene
  64608. * @returns the extruded shape mesh
  64609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64611. */
  64612. static ExtrudeShape(name: string, options: {
  64613. shape: Vector3[];
  64614. path: Vector3[];
  64615. scale?: number;
  64616. rotation?: number;
  64617. cap?: number;
  64618. updatable?: boolean;
  64619. sideOrientation?: number;
  64620. frontUVs?: Vector4;
  64621. backUVs?: Vector4;
  64622. instance?: Mesh;
  64623. invertUV?: boolean;
  64624. }, scene?: Nullable<Scene>): Mesh;
  64625. /**
  64626. * Creates an custom extruded shape mesh.
  64627. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64628. * * 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.
  64629. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64630. * * 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
  64631. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64632. * * 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
  64633. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64634. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64635. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64636. * * 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
  64637. * * 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
  64638. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64643. * @param name defines the name of the mesh
  64644. * @param options defines the options used to create the mesh
  64645. * @param scene defines the hosting scene
  64646. * @returns the custom extruded shape mesh
  64647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64648. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64650. */
  64651. static ExtrudeShapeCustom(name: string, options: {
  64652. shape: Vector3[];
  64653. path: Vector3[];
  64654. scaleFunction?: any;
  64655. rotationFunction?: any;
  64656. ribbonCloseArray?: boolean;
  64657. ribbonClosePath?: boolean;
  64658. cap?: number;
  64659. updatable?: boolean;
  64660. sideOrientation?: number;
  64661. frontUVs?: Vector4;
  64662. backUVs?: Vector4;
  64663. instance?: Mesh;
  64664. invertUV?: boolean;
  64665. }, scene?: Nullable<Scene>): Mesh;
  64666. /**
  64667. * Creates lathe mesh.
  64668. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64669. * * 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
  64670. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64671. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64672. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64673. * * 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
  64674. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64675. * * 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
  64676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64680. * @param name defines the name of the mesh
  64681. * @param options defines the options used to create the mesh
  64682. * @param scene defines the hosting scene
  64683. * @returns the lathe mesh
  64684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64685. */
  64686. static CreateLathe(name: string, options: {
  64687. shape: Vector3[];
  64688. radius?: number;
  64689. tessellation?: number;
  64690. clip?: number;
  64691. arc?: number;
  64692. closed?: boolean;
  64693. updatable?: boolean;
  64694. sideOrientation?: number;
  64695. frontUVs?: Vector4;
  64696. backUVs?: Vector4;
  64697. cap?: number;
  64698. invertUV?: boolean;
  64699. }, scene?: Nullable<Scene>): Mesh;
  64700. /**
  64701. * Creates a tiled plane mesh
  64702. * * You can set a limited pattern arrangement with the tiles
  64703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64706. * @param name defines the name of the mesh
  64707. * @param options defines the options used to create the mesh
  64708. * @param scene defines the hosting scene
  64709. * @returns the plane mesh
  64710. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64711. */
  64712. static CreateTiledPlane(name: string, options: {
  64713. pattern?: number;
  64714. tileSize?: number;
  64715. tileWidth?: number;
  64716. tileHeight?: number;
  64717. size?: number;
  64718. width?: number;
  64719. height?: number;
  64720. alignHorizontal?: number;
  64721. alignVertical?: number;
  64722. sideOrientation?: number;
  64723. frontUVs?: Vector4;
  64724. backUVs?: Vector4;
  64725. updatable?: boolean;
  64726. }, scene?: Nullable<Scene>): Mesh;
  64727. /**
  64728. * Creates a plane mesh
  64729. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64730. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64731. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64735. * @param name defines the name of the mesh
  64736. * @param options defines the options used to create the mesh
  64737. * @param scene defines the hosting scene
  64738. * @returns the plane mesh
  64739. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64740. */
  64741. static CreatePlane(name: string, options: {
  64742. size?: number;
  64743. width?: number;
  64744. height?: number;
  64745. sideOrientation?: number;
  64746. frontUVs?: Vector4;
  64747. backUVs?: Vector4;
  64748. updatable?: boolean;
  64749. sourcePlane?: Plane;
  64750. }, scene?: Nullable<Scene>): Mesh;
  64751. /**
  64752. * Creates a ground mesh
  64753. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64754. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64756. * @param name defines the name of the mesh
  64757. * @param options defines the options used to create the mesh
  64758. * @param scene defines the hosting scene
  64759. * @returns the ground mesh
  64760. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64761. */
  64762. static CreateGround(name: string, options: {
  64763. width?: number;
  64764. height?: number;
  64765. subdivisions?: number;
  64766. subdivisionsX?: number;
  64767. subdivisionsY?: number;
  64768. updatable?: boolean;
  64769. }, scene?: Nullable<Scene>): Mesh;
  64770. /**
  64771. * Creates a tiled ground mesh
  64772. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64773. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64774. * * 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
  64775. * * 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
  64776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64777. * @param name defines the name of the mesh
  64778. * @param options defines the options used to create the mesh
  64779. * @param scene defines the hosting scene
  64780. * @returns the tiled ground mesh
  64781. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64782. */
  64783. static CreateTiledGround(name: string, options: {
  64784. xmin: number;
  64785. zmin: number;
  64786. xmax: number;
  64787. zmax: number;
  64788. subdivisions?: {
  64789. w: number;
  64790. h: number;
  64791. };
  64792. precision?: {
  64793. w: number;
  64794. h: number;
  64795. };
  64796. updatable?: boolean;
  64797. }, scene?: Nullable<Scene>): Mesh;
  64798. /**
  64799. * Creates a ground mesh from a height map
  64800. * * The parameter `url` sets the URL of the height map image resource.
  64801. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64802. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64803. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64804. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64805. * * 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.
  64806. * * 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).
  64807. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64809. * @param name defines the name of the mesh
  64810. * @param url defines the url to the height map
  64811. * @param options defines the options used to create the mesh
  64812. * @param scene defines the hosting scene
  64813. * @returns the ground mesh
  64814. * @see https://doc.babylonjs.com/babylon101/height_map
  64815. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64816. */
  64817. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64818. width?: number;
  64819. height?: number;
  64820. subdivisions?: number;
  64821. minHeight?: number;
  64822. maxHeight?: number;
  64823. colorFilter?: Color3;
  64824. alphaFilter?: number;
  64825. updatable?: boolean;
  64826. onReady?: (mesh: GroundMesh) => void;
  64827. }, scene?: Nullable<Scene>): GroundMesh;
  64828. /**
  64829. * Creates a polygon mesh
  64830. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64831. * * 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
  64832. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64835. * * Remember you can only change the shape positions, not their number when updating a polygon
  64836. * @param name defines the name of the mesh
  64837. * @param options defines the options used to create the mesh
  64838. * @param scene defines the hosting scene
  64839. * @param earcutInjection can be used to inject your own earcut reference
  64840. * @returns the polygon mesh
  64841. */
  64842. static CreatePolygon(name: string, options: {
  64843. shape: Vector3[];
  64844. holes?: Vector3[][];
  64845. depth?: number;
  64846. faceUV?: Vector4[];
  64847. faceColors?: Color4[];
  64848. updatable?: boolean;
  64849. sideOrientation?: number;
  64850. frontUVs?: Vector4;
  64851. backUVs?: Vector4;
  64852. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64853. /**
  64854. * Creates an extruded polygon mesh, with depth in the Y direction.
  64855. * * 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)
  64856. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64857. * @param name defines the name of the mesh
  64858. * @param options defines the options used to create the mesh
  64859. * @param scene defines the hosting scene
  64860. * @param earcutInjection can be used to inject your own earcut reference
  64861. * @returns the polygon mesh
  64862. */
  64863. static ExtrudePolygon(name: string, options: {
  64864. shape: Vector3[];
  64865. holes?: Vector3[][];
  64866. depth?: number;
  64867. faceUV?: Vector4[];
  64868. faceColors?: Color4[];
  64869. updatable?: boolean;
  64870. sideOrientation?: number;
  64871. frontUVs?: Vector4;
  64872. backUVs?: Vector4;
  64873. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64874. /**
  64875. * Creates a tube mesh.
  64876. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64877. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64878. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64879. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64880. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64881. * * 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)
  64882. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64883. * * 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
  64884. * * 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
  64885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64889. * @param name defines the name of the mesh
  64890. * @param options defines the options used to create the mesh
  64891. * @param scene defines the hosting scene
  64892. * @returns the tube mesh
  64893. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64894. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64895. */
  64896. static CreateTube(name: string, options: {
  64897. path: Vector3[];
  64898. radius?: number;
  64899. tessellation?: number;
  64900. radiusFunction?: {
  64901. (i: number, distance: number): number;
  64902. };
  64903. cap?: number;
  64904. arc?: number;
  64905. updatable?: boolean;
  64906. sideOrientation?: number;
  64907. frontUVs?: Vector4;
  64908. backUVs?: Vector4;
  64909. instance?: Mesh;
  64910. invertUV?: boolean;
  64911. }, scene?: Nullable<Scene>): Mesh;
  64912. /**
  64913. * Creates a polyhedron mesh
  64914. * * 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
  64915. * * The parameter `size` (positive float, default 1) sets the polygon size
  64916. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64917. * * 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`
  64918. * * 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
  64919. * * 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)`)
  64920. * * 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
  64921. * * 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
  64922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64925. * @param name defines the name of the mesh
  64926. * @param options defines the options used to create the mesh
  64927. * @param scene defines the hosting scene
  64928. * @returns the polyhedron mesh
  64929. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64930. */
  64931. static CreatePolyhedron(name: string, options: {
  64932. type?: number;
  64933. size?: number;
  64934. sizeX?: number;
  64935. sizeY?: number;
  64936. sizeZ?: number;
  64937. custom?: any;
  64938. faceUV?: Vector4[];
  64939. faceColors?: Color4[];
  64940. flat?: boolean;
  64941. updatable?: boolean;
  64942. sideOrientation?: number;
  64943. frontUVs?: Vector4;
  64944. backUVs?: Vector4;
  64945. }, scene?: Nullable<Scene>): Mesh;
  64946. /**
  64947. * Creates a decal mesh.
  64948. * 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
  64949. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64950. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64951. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64952. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64953. * @param name defines the name of the mesh
  64954. * @param sourceMesh defines the mesh where the decal must be applied
  64955. * @param options defines the options used to create the mesh
  64956. * @param scene defines the hosting scene
  64957. * @returns the decal mesh
  64958. * @see https://doc.babylonjs.com/how_to/decals
  64959. */
  64960. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64961. position?: Vector3;
  64962. normal?: Vector3;
  64963. size?: Vector3;
  64964. angle?: number;
  64965. }): Mesh;
  64966. }
  64967. }
  64968. declare module "babylonjs/Meshes/meshSimplification" {
  64969. import { Mesh } from "babylonjs/Meshes/mesh";
  64970. /**
  64971. * A simplifier interface for future simplification implementations
  64972. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64973. */
  64974. export interface ISimplifier {
  64975. /**
  64976. * Simplification of a given mesh according to the given settings.
  64977. * Since this requires computation, it is assumed that the function runs async.
  64978. * @param settings The settings of the simplification, including quality and distance
  64979. * @param successCallback A callback that will be called after the mesh was simplified.
  64980. * @param errorCallback in case of an error, this callback will be called. optional.
  64981. */
  64982. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64983. }
  64984. /**
  64985. * Expected simplification settings.
  64986. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64987. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64988. */
  64989. export interface ISimplificationSettings {
  64990. /**
  64991. * Gets or sets the expected quality
  64992. */
  64993. quality: number;
  64994. /**
  64995. * Gets or sets the distance when this optimized version should be used
  64996. */
  64997. distance: number;
  64998. /**
  64999. * Gets an already optimized mesh
  65000. */
  65001. optimizeMesh?: boolean;
  65002. }
  65003. /**
  65004. * Class used to specify simplification options
  65005. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65006. */
  65007. export class SimplificationSettings implements ISimplificationSettings {
  65008. /** expected quality */
  65009. quality: number;
  65010. /** distance when this optimized version should be used */
  65011. distance: number;
  65012. /** already optimized mesh */
  65013. optimizeMesh?: boolean | undefined;
  65014. /**
  65015. * Creates a SimplificationSettings
  65016. * @param quality expected quality
  65017. * @param distance distance when this optimized version should be used
  65018. * @param optimizeMesh already optimized mesh
  65019. */
  65020. constructor(
  65021. /** expected quality */
  65022. quality: number,
  65023. /** distance when this optimized version should be used */
  65024. distance: number,
  65025. /** already optimized mesh */
  65026. optimizeMesh?: boolean | undefined);
  65027. }
  65028. /**
  65029. * Interface used to define a simplification task
  65030. */
  65031. export interface ISimplificationTask {
  65032. /**
  65033. * Array of settings
  65034. */
  65035. settings: Array<ISimplificationSettings>;
  65036. /**
  65037. * Simplification type
  65038. */
  65039. simplificationType: SimplificationType;
  65040. /**
  65041. * Mesh to simplify
  65042. */
  65043. mesh: Mesh;
  65044. /**
  65045. * Callback called on success
  65046. */
  65047. successCallback?: () => void;
  65048. /**
  65049. * Defines if parallel processing can be used
  65050. */
  65051. parallelProcessing: boolean;
  65052. }
  65053. /**
  65054. * Queue used to order the simplification tasks
  65055. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65056. */
  65057. export class SimplificationQueue {
  65058. private _simplificationArray;
  65059. /**
  65060. * Gets a boolean indicating that the process is still running
  65061. */
  65062. running: boolean;
  65063. /**
  65064. * Creates a new queue
  65065. */
  65066. constructor();
  65067. /**
  65068. * Adds a new simplification task
  65069. * @param task defines a task to add
  65070. */
  65071. addTask(task: ISimplificationTask): void;
  65072. /**
  65073. * Execute next task
  65074. */
  65075. executeNext(): void;
  65076. /**
  65077. * Execute a simplification task
  65078. * @param task defines the task to run
  65079. */
  65080. runSimplification(task: ISimplificationTask): void;
  65081. private getSimplifier;
  65082. }
  65083. /**
  65084. * The implemented types of simplification
  65085. * At the moment only Quadratic Error Decimation is implemented
  65086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65087. */
  65088. export enum SimplificationType {
  65089. /** Quadratic error decimation */
  65090. QUADRATIC = 0
  65091. }
  65092. /**
  65093. * An implementation of the Quadratic Error simplification algorithm.
  65094. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65095. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65096. * @author RaananW
  65097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65098. */
  65099. export class QuadraticErrorSimplification implements ISimplifier {
  65100. private _mesh;
  65101. private triangles;
  65102. private vertices;
  65103. private references;
  65104. private _reconstructedMesh;
  65105. /** Gets or sets the number pf sync interations */
  65106. syncIterations: number;
  65107. /** Gets or sets the aggressiveness of the simplifier */
  65108. aggressiveness: number;
  65109. /** Gets or sets the number of allowed iterations for decimation */
  65110. decimationIterations: number;
  65111. /** Gets or sets the espilon to use for bounding box computation */
  65112. boundingBoxEpsilon: number;
  65113. /**
  65114. * Creates a new QuadraticErrorSimplification
  65115. * @param _mesh defines the target mesh
  65116. */
  65117. constructor(_mesh: Mesh);
  65118. /**
  65119. * Simplification of a given mesh according to the given settings.
  65120. * Since this requires computation, it is assumed that the function runs async.
  65121. * @param settings The settings of the simplification, including quality and distance
  65122. * @param successCallback A callback that will be called after the mesh was simplified.
  65123. */
  65124. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65125. private runDecimation;
  65126. private initWithMesh;
  65127. private init;
  65128. private reconstructMesh;
  65129. private initDecimatedMesh;
  65130. private isFlipped;
  65131. private updateTriangles;
  65132. private identifyBorder;
  65133. private updateMesh;
  65134. private vertexError;
  65135. private calculateError;
  65136. }
  65137. }
  65138. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65139. import { Scene } from "babylonjs/scene";
  65140. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65141. import { ISceneComponent } from "babylonjs/sceneComponent";
  65142. module "babylonjs/scene" {
  65143. interface Scene {
  65144. /** @hidden (Backing field) */
  65145. _simplificationQueue: SimplificationQueue;
  65146. /**
  65147. * Gets or sets the simplification queue attached to the scene
  65148. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65149. */
  65150. simplificationQueue: SimplificationQueue;
  65151. }
  65152. }
  65153. module "babylonjs/Meshes/mesh" {
  65154. interface Mesh {
  65155. /**
  65156. * Simplify the mesh according to the given array of settings.
  65157. * Function will return immediately and will simplify async
  65158. * @param settings a collection of simplification settings
  65159. * @param parallelProcessing should all levels calculate parallel or one after the other
  65160. * @param simplificationType the type of simplification to run
  65161. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65162. * @returns the current mesh
  65163. */
  65164. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65165. }
  65166. }
  65167. /**
  65168. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65169. * created in a scene
  65170. */
  65171. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65172. /**
  65173. * The component name helpfull to identify the component in the list of scene components.
  65174. */
  65175. readonly name: string;
  65176. /**
  65177. * The scene the component belongs to.
  65178. */
  65179. scene: Scene;
  65180. /**
  65181. * Creates a new instance of the component for the given scene
  65182. * @param scene Defines the scene to register the component in
  65183. */
  65184. constructor(scene: Scene);
  65185. /**
  65186. * Registers the component in a given scene
  65187. */
  65188. register(): void;
  65189. /**
  65190. * Rebuilds the elements related to this component in case of
  65191. * context lost for instance.
  65192. */
  65193. rebuild(): void;
  65194. /**
  65195. * Disposes the component and the associated ressources
  65196. */
  65197. dispose(): void;
  65198. private _beforeCameraUpdate;
  65199. }
  65200. }
  65201. declare module "babylonjs/Meshes/Builders/index" {
  65202. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65203. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65204. export * from "babylonjs/Meshes/Builders/discBuilder";
  65205. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65206. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65207. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65208. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65209. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65210. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65211. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65212. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65213. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65214. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65215. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65216. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65217. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65218. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65219. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65220. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65221. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65222. }
  65223. declare module "babylonjs/Meshes/index" {
  65224. export * from "babylonjs/Meshes/abstractMesh";
  65225. export * from "babylonjs/Meshes/buffer";
  65226. export * from "babylonjs/Meshes/Compression/index";
  65227. export * from "babylonjs/Meshes/csg";
  65228. export * from "babylonjs/Meshes/geometry";
  65229. export * from "babylonjs/Meshes/groundMesh";
  65230. export * from "babylonjs/Meshes/trailMesh";
  65231. export * from "babylonjs/Meshes/instancedMesh";
  65232. export * from "babylonjs/Meshes/linesMesh";
  65233. export * from "babylonjs/Meshes/mesh";
  65234. export * from "babylonjs/Meshes/mesh.vertexData";
  65235. export * from "babylonjs/Meshes/meshBuilder";
  65236. export * from "babylonjs/Meshes/meshSimplification";
  65237. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65238. export * from "babylonjs/Meshes/polygonMesh";
  65239. export * from "babylonjs/Meshes/subMesh";
  65240. export * from "babylonjs/Meshes/meshLODLevel";
  65241. export * from "babylonjs/Meshes/transformNode";
  65242. export * from "babylonjs/Meshes/Builders/index";
  65243. export * from "babylonjs/Meshes/dataBuffer";
  65244. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65245. }
  65246. declare module "babylonjs/Morph/index" {
  65247. export * from "babylonjs/Morph/morphTarget";
  65248. export * from "babylonjs/Morph/morphTargetManager";
  65249. }
  65250. declare module "babylonjs/Navigation/INavigationEngine" {
  65251. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65252. import { Vector3 } from "babylonjs/Maths/math";
  65253. import { Mesh } from "babylonjs/Meshes/mesh";
  65254. import { Scene } from "babylonjs/scene";
  65255. /**
  65256. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65257. */
  65258. export interface INavigationEnginePlugin {
  65259. /**
  65260. * plugin name
  65261. */
  65262. name: string;
  65263. /**
  65264. * Creates a navigation mesh
  65265. * @param meshes array of all the geometry used to compute the navigatio mesh
  65266. * @param parameters bunch of parameters used to filter geometry
  65267. */
  65268. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65269. /**
  65270. * Create a navigation mesh debug mesh
  65271. * @param scene is where the mesh will be added
  65272. * @returns debug display mesh
  65273. */
  65274. createDebugNavMesh(scene: Scene): Mesh;
  65275. /**
  65276. * Get a navigation mesh constrained position, closest to the parameter position
  65277. * @param position world position
  65278. * @returns the closest point to position constrained by the navigation mesh
  65279. */
  65280. getClosestPoint(position: Vector3): Vector3;
  65281. /**
  65282. * Get a navigation mesh constrained position, within a particular radius
  65283. * @param position world position
  65284. * @param maxRadius the maximum distance to the constrained world position
  65285. * @returns the closest point to position constrained by the navigation mesh
  65286. */
  65287. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65288. /**
  65289. * Compute the final position from a segment made of destination-position
  65290. * @param position world position
  65291. * @param destination world position
  65292. * @returns the resulting point along the navmesh
  65293. */
  65294. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65295. /**
  65296. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65297. * @param start world position
  65298. * @param end world position
  65299. * @returns array containing world position composing the path
  65300. */
  65301. computePath(start: Vector3, end: Vector3): Vector3[];
  65302. /**
  65303. * If this plugin is supported
  65304. * @returns true if plugin is supported
  65305. */
  65306. isSupported(): boolean;
  65307. /**
  65308. * Create a new Crowd so you can add agents
  65309. * @param maxAgents the maximum agent count in the crowd
  65310. * @param maxAgentRadius the maximum radius an agent can have
  65311. * @param scene to attach the crowd to
  65312. * @returns the crowd you can add agents to
  65313. */
  65314. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65315. /**
  65316. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65317. * The queries will try to find a solution within those bounds
  65318. * default is (1,1,1)
  65319. * @param extent x,y,z value that define the extent around the queries point of reference
  65320. */
  65321. setDefaultQueryExtent(extent: Vector3): void;
  65322. /**
  65323. * Get the Bounding box extent specified by setDefaultQueryExtent
  65324. * @returns the box extent values
  65325. */
  65326. getDefaultQueryExtent(): Vector3;
  65327. /**
  65328. * Release all resources
  65329. */
  65330. dispose(): void;
  65331. }
  65332. /**
  65333. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65334. */
  65335. export interface ICrowd {
  65336. /**
  65337. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65338. * You can attach anything to that node. The node position is updated in the scene update tick.
  65339. * @param pos world position that will be constrained by the navigation mesh
  65340. * @param parameters agent parameters
  65341. * @param transform hooked to the agent that will be update by the scene
  65342. * @returns agent index
  65343. */
  65344. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65345. /**
  65346. * Returns the agent position in world space
  65347. * @param index agent index returned by addAgent
  65348. * @returns world space position
  65349. */
  65350. getAgentPosition(index: number): Vector3;
  65351. /**
  65352. * Gets the agent velocity in world space
  65353. * @param index agent index returned by addAgent
  65354. * @returns world space velocity
  65355. */
  65356. getAgentVelocity(index: number): Vector3;
  65357. /**
  65358. * remove a particular agent previously created
  65359. * @param index agent index returned by addAgent
  65360. */
  65361. removeAgent(index: number): void;
  65362. /**
  65363. * get the list of all agents attached to this crowd
  65364. * @returns list of agent indices
  65365. */
  65366. getAgents(): number[];
  65367. /**
  65368. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65369. * @param deltaTime in seconds
  65370. */
  65371. update(deltaTime: number): void;
  65372. /**
  65373. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65374. * @param index agent index returned by addAgent
  65375. * @param destination targeted world position
  65376. */
  65377. agentGoto(index: number, destination: Vector3): void;
  65378. /**
  65379. * Teleport the agent to a new position
  65380. * @param index agent index returned by addAgent
  65381. * @param destination targeted world position
  65382. */
  65383. agentTeleport(index: number, destination: Vector3): void;
  65384. /**
  65385. * Update agent parameters
  65386. * @param index agent index returned by addAgent
  65387. * @param parameters agent parameters
  65388. */
  65389. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65390. /**
  65391. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65392. * The queries will try to find a solution within those bounds
  65393. * default is (1,1,1)
  65394. * @param extent x,y,z value that define the extent around the queries point of reference
  65395. */
  65396. setDefaultQueryExtent(extent: Vector3): void;
  65397. /**
  65398. * Get the Bounding box extent specified by setDefaultQueryExtent
  65399. * @returns the box extent values
  65400. */
  65401. getDefaultQueryExtent(): Vector3;
  65402. /**
  65403. * Release all resources
  65404. */
  65405. dispose(): void;
  65406. }
  65407. /**
  65408. * Configures an agent
  65409. */
  65410. export interface IAgentParameters {
  65411. /**
  65412. * Agent radius. [Limit: >= 0]
  65413. */
  65414. radius: number;
  65415. /**
  65416. * Agent height. [Limit: > 0]
  65417. */
  65418. height: number;
  65419. /**
  65420. * Maximum allowed acceleration. [Limit: >= 0]
  65421. */
  65422. maxAcceleration: number;
  65423. /**
  65424. * Maximum allowed speed. [Limit: >= 0]
  65425. */
  65426. maxSpeed: number;
  65427. /**
  65428. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65429. */
  65430. collisionQueryRange: number;
  65431. /**
  65432. * The path visibility optimization range. [Limit: > 0]
  65433. */
  65434. pathOptimizationRange: number;
  65435. /**
  65436. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65437. */
  65438. separationWeight: number;
  65439. }
  65440. /**
  65441. * Configures the navigation mesh creation
  65442. */
  65443. export interface INavMeshParameters {
  65444. /**
  65445. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65446. */
  65447. cs: number;
  65448. /**
  65449. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65450. */
  65451. ch: number;
  65452. /**
  65453. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65454. */
  65455. walkableSlopeAngle: number;
  65456. /**
  65457. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65458. * be considered walkable. [Limit: >= 3] [Units: vx]
  65459. */
  65460. walkableHeight: number;
  65461. /**
  65462. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65463. */
  65464. walkableClimb: number;
  65465. /**
  65466. * The distance to erode/shrink the walkable area of the heightfield away from
  65467. * obstructions. [Limit: >=0] [Units: vx]
  65468. */
  65469. walkableRadius: number;
  65470. /**
  65471. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65472. */
  65473. maxEdgeLen: number;
  65474. /**
  65475. * The maximum distance a simplfied contour's border edges should deviate
  65476. * the original raw contour. [Limit: >=0] [Units: vx]
  65477. */
  65478. maxSimplificationError: number;
  65479. /**
  65480. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65481. */
  65482. minRegionArea: number;
  65483. /**
  65484. * Any regions with a span count smaller than this value will, if possible,
  65485. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65486. */
  65487. mergeRegionArea: number;
  65488. /**
  65489. * The maximum number of vertices allowed for polygons generated during the
  65490. * contour to polygon conversion process. [Limit: >= 3]
  65491. */
  65492. maxVertsPerPoly: number;
  65493. /**
  65494. * Sets the sampling distance to use when generating the detail mesh.
  65495. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65496. */
  65497. detailSampleDist: number;
  65498. /**
  65499. * The maximum distance the detail mesh surface should deviate from heightfield
  65500. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65501. */
  65502. detailSampleMaxError: number;
  65503. }
  65504. }
  65505. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65506. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65507. import { Mesh } from "babylonjs/Meshes/mesh";
  65508. import { Scene } from "babylonjs/scene";
  65509. import { Vector3 } from "babylonjs/Maths/math";
  65510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65511. /**
  65512. * RecastJS navigation plugin
  65513. */
  65514. export class RecastJSPlugin implements INavigationEnginePlugin {
  65515. /**
  65516. * Reference to the Recast library
  65517. */
  65518. bjsRECAST: any;
  65519. /**
  65520. * plugin name
  65521. */
  65522. name: string;
  65523. /**
  65524. * the first navmesh created. We might extend this to support multiple navmeshes
  65525. */
  65526. navMesh: any;
  65527. /**
  65528. * Initializes the recastJS plugin
  65529. * @param recastInjection can be used to inject your own recast reference
  65530. */
  65531. constructor(recastInjection?: any);
  65532. /**
  65533. * Creates a navigation mesh
  65534. * @param meshes array of all the geometry used to compute the navigatio mesh
  65535. * @param parameters bunch of parameters used to filter geometry
  65536. */
  65537. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65538. /**
  65539. * Create a navigation mesh debug mesh
  65540. * @param scene is where the mesh will be added
  65541. * @returns debug display mesh
  65542. */
  65543. createDebugNavMesh(scene: Scene): Mesh;
  65544. /**
  65545. * Get a navigation mesh constrained position, closest to the parameter position
  65546. * @param position world position
  65547. * @returns the closest point to position constrained by the navigation mesh
  65548. */
  65549. getClosestPoint(position: Vector3): Vector3;
  65550. /**
  65551. * Get a navigation mesh constrained position, within a particular radius
  65552. * @param position world position
  65553. * @param maxRadius the maximum distance to the constrained world position
  65554. * @returns the closest point to position constrained by the navigation mesh
  65555. */
  65556. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65557. /**
  65558. * Compute the final position from a segment made of destination-position
  65559. * @param position world position
  65560. * @param destination world position
  65561. * @returns the resulting point along the navmesh
  65562. */
  65563. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65564. /**
  65565. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65566. * @param start world position
  65567. * @param end world position
  65568. * @returns array containing world position composing the path
  65569. */
  65570. computePath(start: Vector3, end: Vector3): Vector3[];
  65571. /**
  65572. * Create a new Crowd so you can add agents
  65573. * @param maxAgents the maximum agent count in the crowd
  65574. * @param maxAgentRadius the maximum radius an agent can have
  65575. * @param scene to attach the crowd to
  65576. * @returns the crowd you can add agents to
  65577. */
  65578. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65579. /**
  65580. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65581. * The queries will try to find a solution within those bounds
  65582. * default is (1,1,1)
  65583. * @param extent x,y,z value that define the extent around the queries point of reference
  65584. */
  65585. setDefaultQueryExtent(extent: Vector3): void;
  65586. /**
  65587. * Get the Bounding box extent specified by setDefaultQueryExtent
  65588. * @returns the box extent values
  65589. */
  65590. getDefaultQueryExtent(): Vector3;
  65591. /**
  65592. * Disposes
  65593. */
  65594. dispose(): void;
  65595. /**
  65596. * If this plugin is supported
  65597. * @returns true if plugin is supported
  65598. */
  65599. isSupported(): boolean;
  65600. }
  65601. /**
  65602. * Recast detour crowd implementation
  65603. */
  65604. export class RecastJSCrowd implements ICrowd {
  65605. /**
  65606. * Recast/detour plugin
  65607. */
  65608. bjsRECASTPlugin: RecastJSPlugin;
  65609. /**
  65610. * Link to the detour crowd
  65611. */
  65612. recastCrowd: any;
  65613. /**
  65614. * One transform per agent
  65615. */
  65616. transforms: TransformNode[];
  65617. /**
  65618. * All agents created
  65619. */
  65620. agents: number[];
  65621. /**
  65622. * Link to the scene is kept to unregister the crowd from the scene
  65623. */
  65624. private _scene;
  65625. /**
  65626. * Observer for crowd updates
  65627. */
  65628. private _onBeforeAnimationsObserver;
  65629. /**
  65630. * Constructor
  65631. * @param plugin recastJS plugin
  65632. * @param maxAgents the maximum agent count in the crowd
  65633. * @param maxAgentRadius the maximum radius an agent can have
  65634. * @param scene to attach the crowd to
  65635. * @returns the crowd you can add agents to
  65636. */
  65637. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65638. /**
  65639. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65640. * You can attach anything to that node. The node position is updated in the scene update tick.
  65641. * @param pos world position that will be constrained by the navigation mesh
  65642. * @param parameters agent parameters
  65643. * @param transform hooked to the agent that will be update by the scene
  65644. * @returns agent index
  65645. */
  65646. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65647. /**
  65648. * Returns the agent position in world space
  65649. * @param index agent index returned by addAgent
  65650. * @returns world space position
  65651. */
  65652. getAgentPosition(index: number): Vector3;
  65653. /**
  65654. * Returns the agent velocity in world space
  65655. * @param index agent index returned by addAgent
  65656. * @returns world space velocity
  65657. */
  65658. getAgentVelocity(index: number): Vector3;
  65659. /**
  65660. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65661. * @param index agent index returned by addAgent
  65662. * @param destination targeted world position
  65663. */
  65664. agentGoto(index: number, destination: Vector3): void;
  65665. /**
  65666. * Teleport the agent to a new position
  65667. * @param index agent index returned by addAgent
  65668. * @param destination targeted world position
  65669. */
  65670. agentTeleport(index: number, destination: Vector3): void;
  65671. /**
  65672. * Update agent parameters
  65673. * @param index agent index returned by addAgent
  65674. * @param parameters agent parameters
  65675. */
  65676. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65677. /**
  65678. * remove a particular agent previously created
  65679. * @param index agent index returned by addAgent
  65680. */
  65681. removeAgent(index: number): void;
  65682. /**
  65683. * get the list of all agents attached to this crowd
  65684. * @returns list of agent indices
  65685. */
  65686. getAgents(): number[];
  65687. /**
  65688. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65689. * @param deltaTime in seconds
  65690. */
  65691. update(deltaTime: number): void;
  65692. /**
  65693. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65694. * The queries will try to find a solution within those bounds
  65695. * default is (1,1,1)
  65696. * @param extent x,y,z value that define the extent around the queries point of reference
  65697. */
  65698. setDefaultQueryExtent(extent: Vector3): void;
  65699. /**
  65700. * Get the Bounding box extent specified by setDefaultQueryExtent
  65701. * @returns the box extent values
  65702. */
  65703. getDefaultQueryExtent(): Vector3;
  65704. /**
  65705. * Release all resources
  65706. */
  65707. dispose(): void;
  65708. }
  65709. }
  65710. declare module "babylonjs/Navigation/Plugins/index" {
  65711. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65712. }
  65713. declare module "babylonjs/Navigation/index" {
  65714. export * from "babylonjs/Navigation/INavigationEngine";
  65715. export * from "babylonjs/Navigation/Plugins/index";
  65716. }
  65717. declare module "babylonjs/Offline/database" {
  65718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65719. /**
  65720. * Class used to enable access to IndexedDB
  65721. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65722. */
  65723. export class Database implements IOfflineProvider {
  65724. private _callbackManifestChecked;
  65725. private _currentSceneUrl;
  65726. private _db;
  65727. private _enableSceneOffline;
  65728. private _enableTexturesOffline;
  65729. private _manifestVersionFound;
  65730. private _mustUpdateRessources;
  65731. private _hasReachedQuota;
  65732. private _isSupported;
  65733. private _idbFactory;
  65734. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65735. private static IsUASupportingBlobStorage;
  65736. /**
  65737. * Gets a boolean indicating if Database storate is enabled (off by default)
  65738. */
  65739. static IDBStorageEnabled: boolean;
  65740. /**
  65741. * Gets a boolean indicating if scene must be saved in the database
  65742. */
  65743. get enableSceneOffline(): boolean;
  65744. /**
  65745. * Gets a boolean indicating if textures must be saved in the database
  65746. */
  65747. get enableTexturesOffline(): boolean;
  65748. /**
  65749. * Creates a new Database
  65750. * @param urlToScene defines the url to load the scene
  65751. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65752. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65753. */
  65754. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65755. private static _ParseURL;
  65756. private static _ReturnFullUrlLocation;
  65757. private _checkManifestFile;
  65758. /**
  65759. * Open the database and make it available
  65760. * @param successCallback defines the callback to call on success
  65761. * @param errorCallback defines the callback to call on error
  65762. */
  65763. open(successCallback: () => void, errorCallback: () => void): void;
  65764. /**
  65765. * Loads an image from the database
  65766. * @param url defines the url to load from
  65767. * @param image defines the target DOM image
  65768. */
  65769. loadImage(url: string, image: HTMLImageElement): void;
  65770. private _loadImageFromDBAsync;
  65771. private _saveImageIntoDBAsync;
  65772. private _checkVersionFromDB;
  65773. private _loadVersionFromDBAsync;
  65774. private _saveVersionIntoDBAsync;
  65775. /**
  65776. * Loads a file from database
  65777. * @param url defines the URL to load from
  65778. * @param sceneLoaded defines a callback to call on success
  65779. * @param progressCallBack defines a callback to call when progress changed
  65780. * @param errorCallback defines a callback to call on error
  65781. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65782. */
  65783. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65784. private _loadFileAsync;
  65785. private _saveFileAsync;
  65786. /**
  65787. * Validates if xhr data is correct
  65788. * @param xhr defines the request to validate
  65789. * @param dataType defines the expected data type
  65790. * @returns true if data is correct
  65791. */
  65792. private static _ValidateXHRData;
  65793. }
  65794. }
  65795. declare module "babylonjs/Offline/index" {
  65796. export * from "babylonjs/Offline/database";
  65797. export * from "babylonjs/Offline/IOfflineProvider";
  65798. }
  65799. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65800. /** @hidden */
  65801. export var gpuUpdateParticlesPixelShader: {
  65802. name: string;
  65803. shader: string;
  65804. };
  65805. }
  65806. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65807. /** @hidden */
  65808. export var gpuUpdateParticlesVertexShader: {
  65809. name: string;
  65810. shader: string;
  65811. };
  65812. }
  65813. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65814. /** @hidden */
  65815. export var clipPlaneFragmentDeclaration2: {
  65816. name: string;
  65817. shader: string;
  65818. };
  65819. }
  65820. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65821. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65822. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65824. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65826. /** @hidden */
  65827. export var gpuRenderParticlesPixelShader: {
  65828. name: string;
  65829. shader: string;
  65830. };
  65831. }
  65832. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65833. /** @hidden */
  65834. export var clipPlaneVertexDeclaration2: {
  65835. name: string;
  65836. shader: string;
  65837. };
  65838. }
  65839. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65840. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65842. /** @hidden */
  65843. export var gpuRenderParticlesVertexShader: {
  65844. name: string;
  65845. shader: string;
  65846. };
  65847. }
  65848. declare module "babylonjs/Particles/gpuParticleSystem" {
  65849. import { Nullable } from "babylonjs/types";
  65850. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65851. import { Observable } from "babylonjs/Misc/observable";
  65852. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65853. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65854. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65855. import { Scene, IDisposable } from "babylonjs/scene";
  65856. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65857. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65858. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65859. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65860. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65861. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65862. /**
  65863. * This represents a GPU particle system in Babylon
  65864. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65865. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65866. */
  65867. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65868. /**
  65869. * The layer mask we are rendering the particles through.
  65870. */
  65871. layerMask: number;
  65872. private _capacity;
  65873. private _activeCount;
  65874. private _currentActiveCount;
  65875. private _accumulatedCount;
  65876. private _renderEffect;
  65877. private _updateEffect;
  65878. private _buffer0;
  65879. private _buffer1;
  65880. private _spriteBuffer;
  65881. private _updateVAO;
  65882. private _renderVAO;
  65883. private _targetIndex;
  65884. private _sourceBuffer;
  65885. private _targetBuffer;
  65886. private _engine;
  65887. private _currentRenderId;
  65888. private _started;
  65889. private _stopped;
  65890. private _timeDelta;
  65891. private _randomTexture;
  65892. private _randomTexture2;
  65893. private _attributesStrideSize;
  65894. private _updateEffectOptions;
  65895. private _randomTextureSize;
  65896. private _actualFrame;
  65897. private readonly _rawTextureWidth;
  65898. /**
  65899. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65900. */
  65901. static get IsSupported(): boolean;
  65902. /**
  65903. * An event triggered when the system is disposed.
  65904. */
  65905. onDisposeObservable: Observable<GPUParticleSystem>;
  65906. /**
  65907. * Gets the maximum number of particles active at the same time.
  65908. * @returns The max number of active particles.
  65909. */
  65910. getCapacity(): number;
  65911. /**
  65912. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65913. * to override the particles.
  65914. */
  65915. forceDepthWrite: boolean;
  65916. /**
  65917. * Gets or set the number of active particles
  65918. */
  65919. get activeParticleCount(): number;
  65920. set activeParticleCount(value: number);
  65921. private _preWarmDone;
  65922. /**
  65923. * Specifies if the particles are updated in emitter local space or world space.
  65924. * This is always false for GPU particles
  65925. */
  65926. get isLocal(): boolean;
  65927. set isLocal(value: boolean);
  65928. /**
  65929. * Is this system ready to be used/rendered
  65930. * @return true if the system is ready
  65931. */
  65932. isReady(): boolean;
  65933. /**
  65934. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65935. * @returns True if it has been started, otherwise false.
  65936. */
  65937. isStarted(): boolean;
  65938. /**
  65939. * Starts the particle system and begins to emit
  65940. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65941. */
  65942. start(delay?: number): void;
  65943. /**
  65944. * Stops the particle system.
  65945. */
  65946. stop(): void;
  65947. /**
  65948. * Remove all active particles
  65949. */
  65950. reset(): void;
  65951. /**
  65952. * Returns the string "GPUParticleSystem"
  65953. * @returns a string containing the class name
  65954. */
  65955. getClassName(): string;
  65956. private _colorGradientsTexture;
  65957. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65958. /**
  65959. * Adds a new color gradient
  65960. * @param gradient defines the gradient to use (between 0 and 1)
  65961. * @param color1 defines the color to affect to the specified gradient
  65962. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65963. * @returns the current particle system
  65964. */
  65965. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65966. /**
  65967. * Remove a specific color gradient
  65968. * @param gradient defines the gradient to remove
  65969. * @returns the current particle system
  65970. */
  65971. removeColorGradient(gradient: number): GPUParticleSystem;
  65972. private _angularSpeedGradientsTexture;
  65973. private _sizeGradientsTexture;
  65974. private _velocityGradientsTexture;
  65975. private _limitVelocityGradientsTexture;
  65976. private _dragGradientsTexture;
  65977. private _addFactorGradient;
  65978. /**
  65979. * Adds a new size gradient
  65980. * @param gradient defines the gradient to use (between 0 and 1)
  65981. * @param factor defines the size factor to affect to the specified gradient
  65982. * @returns the current particle system
  65983. */
  65984. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65985. /**
  65986. * Remove a specific size gradient
  65987. * @param gradient defines the gradient to remove
  65988. * @returns the current particle system
  65989. */
  65990. removeSizeGradient(gradient: number): GPUParticleSystem;
  65991. /**
  65992. * Adds a new angular speed gradient
  65993. * @param gradient defines the gradient to use (between 0 and 1)
  65994. * @param factor defines the angular speed to affect to the specified gradient
  65995. * @returns the current particle system
  65996. */
  65997. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65998. /**
  65999. * Remove a specific angular speed gradient
  66000. * @param gradient defines the gradient to remove
  66001. * @returns the current particle system
  66002. */
  66003. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66004. /**
  66005. * Adds a new velocity gradient
  66006. * @param gradient defines the gradient to use (between 0 and 1)
  66007. * @param factor defines the velocity to affect to the specified gradient
  66008. * @returns the current particle system
  66009. */
  66010. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66011. /**
  66012. * Remove a specific velocity gradient
  66013. * @param gradient defines the gradient to remove
  66014. * @returns the current particle system
  66015. */
  66016. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66017. /**
  66018. * Adds a new limit velocity gradient
  66019. * @param gradient defines the gradient to use (between 0 and 1)
  66020. * @param factor defines the limit velocity value to affect to the specified gradient
  66021. * @returns the current particle system
  66022. */
  66023. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66024. /**
  66025. * Remove a specific limit velocity gradient
  66026. * @param gradient defines the gradient to remove
  66027. * @returns the current particle system
  66028. */
  66029. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66030. /**
  66031. * Adds a new drag gradient
  66032. * @param gradient defines the gradient to use (between 0 and 1)
  66033. * @param factor defines the drag value to affect to the specified gradient
  66034. * @returns the current particle system
  66035. */
  66036. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66037. /**
  66038. * Remove a specific drag gradient
  66039. * @param gradient defines the gradient to remove
  66040. * @returns the current particle system
  66041. */
  66042. removeDragGradient(gradient: number): GPUParticleSystem;
  66043. /**
  66044. * Not supported by GPUParticleSystem
  66045. * @param gradient defines the gradient to use (between 0 and 1)
  66046. * @param factor defines the emit rate value to affect to the specified gradient
  66047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66048. * @returns the current particle system
  66049. */
  66050. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66051. /**
  66052. * Not supported by GPUParticleSystem
  66053. * @param gradient defines the gradient to remove
  66054. * @returns the current particle system
  66055. */
  66056. removeEmitRateGradient(gradient: number): IParticleSystem;
  66057. /**
  66058. * Not supported by GPUParticleSystem
  66059. * @param gradient defines the gradient to use (between 0 and 1)
  66060. * @param factor defines the start size value to affect to the specified gradient
  66061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66062. * @returns the current particle system
  66063. */
  66064. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66065. /**
  66066. * Not supported by GPUParticleSystem
  66067. * @param gradient defines the gradient to remove
  66068. * @returns the current particle system
  66069. */
  66070. removeStartSizeGradient(gradient: number): IParticleSystem;
  66071. /**
  66072. * Not supported by GPUParticleSystem
  66073. * @param gradient defines the gradient to use (between 0 and 1)
  66074. * @param min defines the color remap minimal range
  66075. * @param max defines the color remap maximal range
  66076. * @returns the current particle system
  66077. */
  66078. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66079. /**
  66080. * Not supported by GPUParticleSystem
  66081. * @param gradient defines the gradient to remove
  66082. * @returns the current particle system
  66083. */
  66084. removeColorRemapGradient(): IParticleSystem;
  66085. /**
  66086. * Not supported by GPUParticleSystem
  66087. * @param gradient defines the gradient to use (between 0 and 1)
  66088. * @param min defines the alpha remap minimal range
  66089. * @param max defines the alpha remap maximal range
  66090. * @returns the current particle system
  66091. */
  66092. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66093. /**
  66094. * Not supported by GPUParticleSystem
  66095. * @param gradient defines the gradient to remove
  66096. * @returns the current particle system
  66097. */
  66098. removeAlphaRemapGradient(): IParticleSystem;
  66099. /**
  66100. * Not supported by GPUParticleSystem
  66101. * @param gradient defines the gradient to use (between 0 and 1)
  66102. * @param color defines the color to affect to the specified gradient
  66103. * @returns the current particle system
  66104. */
  66105. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66106. /**
  66107. * Not supported by GPUParticleSystem
  66108. * @param gradient defines the gradient to remove
  66109. * @returns the current particle system
  66110. */
  66111. removeRampGradient(): IParticleSystem;
  66112. /**
  66113. * Not supported by GPUParticleSystem
  66114. * @returns the list of ramp gradients
  66115. */
  66116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66117. /**
  66118. * Not supported by GPUParticleSystem
  66119. * Gets or sets a boolean indicating that ramp gradients must be used
  66120. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66121. */
  66122. get useRampGradients(): boolean;
  66123. set useRampGradients(value: boolean);
  66124. /**
  66125. * Not supported by GPUParticleSystem
  66126. * @param gradient defines the gradient to use (between 0 and 1)
  66127. * @param factor defines the life time factor to affect to the specified gradient
  66128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66129. * @returns the current particle system
  66130. */
  66131. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66132. /**
  66133. * Not supported by GPUParticleSystem
  66134. * @param gradient defines the gradient to remove
  66135. * @returns the current particle system
  66136. */
  66137. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66138. /**
  66139. * Instantiates a GPU particle system.
  66140. * 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.
  66141. * @param name The name of the particle system
  66142. * @param options The options used to create the system
  66143. * @param scene The scene the particle system belongs to
  66144. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66145. */
  66146. constructor(name: string, options: Partial<{
  66147. capacity: number;
  66148. randomTextureSize: number;
  66149. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66150. protected _reset(): void;
  66151. private _createUpdateVAO;
  66152. private _createRenderVAO;
  66153. private _initialize;
  66154. /** @hidden */
  66155. _recreateUpdateEffect(): void;
  66156. /** @hidden */
  66157. _recreateRenderEffect(): void;
  66158. /**
  66159. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66160. * @param preWarm defines if we are in the pre-warmimg phase
  66161. */
  66162. animate(preWarm?: boolean): void;
  66163. private _createFactorGradientTexture;
  66164. private _createSizeGradientTexture;
  66165. private _createAngularSpeedGradientTexture;
  66166. private _createVelocityGradientTexture;
  66167. private _createLimitVelocityGradientTexture;
  66168. private _createDragGradientTexture;
  66169. private _createColorGradientTexture;
  66170. /**
  66171. * Renders the particle system in its current state
  66172. * @param preWarm defines if the system should only update the particles but not render them
  66173. * @returns the current number of particles
  66174. */
  66175. render(preWarm?: boolean): number;
  66176. /**
  66177. * Rebuilds the particle system
  66178. */
  66179. rebuild(): void;
  66180. private _releaseBuffers;
  66181. private _releaseVAOs;
  66182. /**
  66183. * Disposes the particle system and free the associated resources
  66184. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66185. */
  66186. dispose(disposeTexture?: boolean): void;
  66187. /**
  66188. * Clones the particle system.
  66189. * @param name The name of the cloned object
  66190. * @param newEmitter The new emitter to use
  66191. * @returns the cloned particle system
  66192. */
  66193. clone(name: string, newEmitter: any): GPUParticleSystem;
  66194. /**
  66195. * Serializes the particle system to a JSON object.
  66196. * @returns the JSON object
  66197. */
  66198. serialize(): any;
  66199. /**
  66200. * Parses a JSON object to create a GPU particle system.
  66201. * @param parsedParticleSystem The JSON object to parse
  66202. * @param scene The scene to create the particle system in
  66203. * @param rootUrl The root url to use to load external dependencies like texture
  66204. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66205. * @returns the parsed GPU particle system
  66206. */
  66207. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66208. }
  66209. }
  66210. declare module "babylonjs/Particles/particleSystemSet" {
  66211. import { Nullable } from "babylonjs/types";
  66212. import { Color3 } from "babylonjs/Maths/math.color";
  66213. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66215. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66216. import { Scene, IDisposable } from "babylonjs/scene";
  66217. /**
  66218. * Represents a set of particle systems working together to create a specific effect
  66219. */
  66220. export class ParticleSystemSet implements IDisposable {
  66221. /**
  66222. * Gets or sets base Assets URL
  66223. */
  66224. static BaseAssetsUrl: string;
  66225. private _emitterCreationOptions;
  66226. private _emitterNode;
  66227. /**
  66228. * Gets the particle system list
  66229. */
  66230. systems: IParticleSystem[];
  66231. /**
  66232. * Gets the emitter node used with this set
  66233. */
  66234. get emitterNode(): Nullable<TransformNode>;
  66235. /**
  66236. * Creates a new emitter mesh as a sphere
  66237. * @param options defines the options used to create the sphere
  66238. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66239. * @param scene defines the hosting scene
  66240. */
  66241. setEmitterAsSphere(options: {
  66242. diameter: number;
  66243. segments: number;
  66244. color: Color3;
  66245. }, renderingGroupId: number, scene: Scene): void;
  66246. /**
  66247. * Starts all particle systems of the set
  66248. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66249. */
  66250. start(emitter?: AbstractMesh): void;
  66251. /**
  66252. * Release all associated resources
  66253. */
  66254. dispose(): void;
  66255. /**
  66256. * Serialize the set into a JSON compatible object
  66257. * @returns a JSON compatible representation of the set
  66258. */
  66259. serialize(): any;
  66260. /**
  66261. * Parse a new ParticleSystemSet from a serialized source
  66262. * @param data defines a JSON compatible representation of the set
  66263. * @param scene defines the hosting scene
  66264. * @param gpu defines if we want GPU particles or CPU particles
  66265. * @returns a new ParticleSystemSet
  66266. */
  66267. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66268. }
  66269. }
  66270. declare module "babylonjs/Particles/particleHelper" {
  66271. import { Nullable } from "babylonjs/types";
  66272. import { Scene } from "babylonjs/scene";
  66273. import { Vector3 } from "babylonjs/Maths/math.vector";
  66274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66275. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66276. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66277. /**
  66278. * This class is made for on one-liner static method to help creating particle system set.
  66279. */
  66280. export class ParticleHelper {
  66281. /**
  66282. * Gets or sets base Assets URL
  66283. */
  66284. static BaseAssetsUrl: string;
  66285. /**
  66286. * Create a default particle system that you can tweak
  66287. * @param emitter defines the emitter to use
  66288. * @param capacity defines the system capacity (default is 500 particles)
  66289. * @param scene defines the hosting scene
  66290. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66291. * @returns the new Particle system
  66292. */
  66293. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66294. /**
  66295. * This is the main static method (one-liner) of this helper to create different particle systems
  66296. * @param type This string represents the type to the particle system to create
  66297. * @param scene The scene where the particle system should live
  66298. * @param gpu If the system will use gpu
  66299. * @returns the ParticleSystemSet created
  66300. */
  66301. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66302. /**
  66303. * Static function used to export a particle system to a ParticleSystemSet variable.
  66304. * Please note that the emitter shape is not exported
  66305. * @param systems defines the particle systems to export
  66306. * @returns the created particle system set
  66307. */
  66308. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66309. }
  66310. }
  66311. declare module "babylonjs/Particles/particleSystemComponent" {
  66312. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66313. import { Effect } from "babylonjs/Materials/effect";
  66314. import "babylonjs/Shaders/particles.vertex";
  66315. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66316. module "babylonjs/Engines/engine" {
  66317. interface Engine {
  66318. /**
  66319. * Create an effect to use with particle systems.
  66320. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66321. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66322. * @param uniformsNames defines a list of attribute names
  66323. * @param samplers defines an array of string used to represent textures
  66324. * @param defines defines the string containing the defines to use to compile the shaders
  66325. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66326. * @param onCompiled defines a function to call when the effect creation is successful
  66327. * @param onError defines a function to call when the effect creation has failed
  66328. * @returns the new Effect
  66329. */
  66330. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66331. }
  66332. }
  66333. module "babylonjs/Meshes/mesh" {
  66334. interface Mesh {
  66335. /**
  66336. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66337. * @returns an array of IParticleSystem
  66338. */
  66339. getEmittedParticleSystems(): IParticleSystem[];
  66340. /**
  66341. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66342. * @returns an array of IParticleSystem
  66343. */
  66344. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66345. }
  66346. }
  66347. /**
  66348. * @hidden
  66349. */
  66350. export var _IDoNeedToBeInTheBuild: number;
  66351. }
  66352. declare module "babylonjs/Particles/pointsCloudSystem" {
  66353. import { Color4 } from "babylonjs/Maths/math";
  66354. import { Mesh } from "babylonjs/Meshes/mesh";
  66355. import { Scene, IDisposable } from "babylonjs/scene";
  66356. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66357. /** Defines the 4 color options */
  66358. export enum PointColor {
  66359. /** color value */
  66360. Color = 2,
  66361. /** uv value */
  66362. UV = 1,
  66363. /** random value */
  66364. Random = 0,
  66365. /** stated value */
  66366. Stated = 3
  66367. }
  66368. /**
  66369. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66370. * 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.
  66371. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66372. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66373. *
  66374. * Full documentation here : TO BE ENTERED
  66375. */
  66376. export class PointsCloudSystem implements IDisposable {
  66377. /**
  66378. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66379. * Example : var p = SPS.particles[i];
  66380. */
  66381. particles: CloudPoint[];
  66382. /**
  66383. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66384. */
  66385. nbParticles: number;
  66386. /**
  66387. * This a counter for your own usage. It's not set by any SPS functions.
  66388. */
  66389. counter: number;
  66390. /**
  66391. * The PCS name. This name is also given to the underlying mesh.
  66392. */
  66393. name: string;
  66394. /**
  66395. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66396. */
  66397. mesh: Mesh;
  66398. /**
  66399. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66400. * Please read :
  66401. */
  66402. vars: any;
  66403. /**
  66404. * @hidden
  66405. */
  66406. _size: number;
  66407. private _scene;
  66408. private _promises;
  66409. private _positions;
  66410. private _indices;
  66411. private _normals;
  66412. private _colors;
  66413. private _uvs;
  66414. private _indices32;
  66415. private _positions32;
  66416. private _colors32;
  66417. private _uvs32;
  66418. private _updatable;
  66419. private _isVisibilityBoxLocked;
  66420. private _alwaysVisible;
  66421. private _groups;
  66422. private _groupCounter;
  66423. private _computeParticleColor;
  66424. private _computeParticleTexture;
  66425. private _computeParticleRotation;
  66426. private _computeBoundingBox;
  66427. private _isReady;
  66428. /**
  66429. * Creates a PCS (Points Cloud System) object
  66430. * @param name (String) is the PCS name, this will be the underlying mesh name
  66431. * @param pointSize (number) is the size for each point
  66432. * @param scene (Scene) is the scene in which the PCS is added
  66433. * @param options defines the options of the PCS e.g.
  66434. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66435. */
  66436. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66437. updatable?: boolean;
  66438. });
  66439. /**
  66440. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66441. * If no points were added to the PCS, the returned mesh is just a single point.
  66442. * @returns a promise for the created mesh
  66443. */
  66444. buildMeshAsync(): Promise<Mesh>;
  66445. /**
  66446. * @hidden
  66447. */
  66448. private _buildMesh;
  66449. private _addParticle;
  66450. private _randomUnitVector;
  66451. private _getColorIndicesForCoord;
  66452. private _setPointsColorOrUV;
  66453. private _colorFromTexture;
  66454. private _calculateDensity;
  66455. /**
  66456. * Adds points to the PCS in random positions within a unit sphere
  66457. * @param nb (positive integer) the number of particles to be created from this model
  66458. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66459. * @returns the number of groups in the system
  66460. */
  66461. addPoints(nb: number, pointFunction?: any): number;
  66462. /**
  66463. * Adds points to the PCS from the surface of the model shape
  66464. * @param mesh is any Mesh object that will be used as a surface model for the points
  66465. * @param nb (positive integer) the number of particles to be created from this model
  66466. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66467. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66468. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66469. * @returns the number of groups in the system
  66470. */
  66471. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66472. /**
  66473. * Adds points to the PCS inside the model shape
  66474. * @param mesh is any Mesh object that will be used as a surface model for the points
  66475. * @param nb (positive integer) the number of particles to be created from this model
  66476. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66477. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66478. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66479. * @returns the number of groups in the system
  66480. */
  66481. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66482. /**
  66483. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66484. * This method calls `updateParticle()` for each particle of the SPS.
  66485. * For an animated SPS, it is usually called within the render loop.
  66486. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66487. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66488. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66489. * @returns the PCS.
  66490. */
  66491. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66492. /**
  66493. * Disposes the PCS.
  66494. */
  66495. dispose(): void;
  66496. /**
  66497. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66498. * doc :
  66499. * @returns the PCS.
  66500. */
  66501. refreshVisibleSize(): PointsCloudSystem;
  66502. /**
  66503. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66504. * @param size the size (float) of the visibility box
  66505. * note : this doesn't lock the PCS mesh bounding box.
  66506. * doc :
  66507. */
  66508. setVisibilityBox(size: number): void;
  66509. /**
  66510. * Gets whether the PCS is always visible or not
  66511. * doc :
  66512. */
  66513. get isAlwaysVisible(): boolean;
  66514. /**
  66515. * Sets the PCS as always visible or not
  66516. * doc :
  66517. */
  66518. set isAlwaysVisible(val: boolean);
  66519. /**
  66520. * Tells to `setParticles()` to compute the particle rotations or not
  66521. * Default value : false. The PCS is faster when it's set to false
  66522. * Note : particle rotations are only applied to parent particles
  66523. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66524. */
  66525. set computeParticleRotation(val: boolean);
  66526. /**
  66527. * Tells to `setParticles()` to compute the particle colors or not.
  66528. * Default value : true. The PCS is faster when it's set to false.
  66529. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66530. */
  66531. set computeParticleColor(val: boolean);
  66532. set computeParticleTexture(val: boolean);
  66533. /**
  66534. * Gets if `setParticles()` computes the particle colors or not.
  66535. * Default value : false. The PCS is faster when it's set to false.
  66536. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66537. */
  66538. get computeParticleColor(): boolean;
  66539. /**
  66540. * Gets if `setParticles()` computes the particle textures or not.
  66541. * Default value : false. The PCS is faster when it's set to false.
  66542. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66543. */
  66544. get computeParticleTexture(): boolean;
  66545. /**
  66546. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66547. */
  66548. set computeBoundingBox(val: boolean);
  66549. /**
  66550. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66551. */
  66552. get computeBoundingBox(): boolean;
  66553. /**
  66554. * This function does nothing. It may be overwritten to set all the particle first values.
  66555. * The PCS doesn't call this function, you may have to call it by your own.
  66556. * doc :
  66557. */
  66558. initParticles(): void;
  66559. /**
  66560. * This function does nothing. It may be overwritten to recycle a particle
  66561. * The PCS doesn't call this function, you can to call it
  66562. * doc :
  66563. * @param particle The particle to recycle
  66564. * @returns the recycled particle
  66565. */
  66566. recycleParticle(particle: CloudPoint): CloudPoint;
  66567. /**
  66568. * Updates a particle : this function should be overwritten by the user.
  66569. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66570. * doc :
  66571. * @example : just set a particle position or velocity and recycle conditions
  66572. * @param particle The particle to update
  66573. * @returns the updated particle
  66574. */
  66575. updateParticle(particle: CloudPoint): CloudPoint;
  66576. /**
  66577. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66578. * This does nothing and may be overwritten by the user.
  66579. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66580. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66581. * @param update the boolean update value actually passed to setParticles()
  66582. */
  66583. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66584. /**
  66585. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66586. * This will be passed three parameters.
  66587. * This does nothing and may be overwritten by the user.
  66588. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66589. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66590. * @param update the boolean update value actually passed to setParticles()
  66591. */
  66592. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66593. }
  66594. }
  66595. declare module "babylonjs/Particles/cloudPoint" {
  66596. import { Nullable } from "babylonjs/types";
  66597. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66598. import { Mesh } from "babylonjs/Meshes/mesh";
  66599. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66600. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66601. /**
  66602. * Represents one particle of a points cloud system.
  66603. */
  66604. export class CloudPoint {
  66605. /**
  66606. * particle global index
  66607. */
  66608. idx: number;
  66609. /**
  66610. * The color of the particle
  66611. */
  66612. color: Nullable<Color4>;
  66613. /**
  66614. * The world space position of the particle.
  66615. */
  66616. position: Vector3;
  66617. /**
  66618. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66619. */
  66620. rotation: Vector3;
  66621. /**
  66622. * The world space rotation quaternion of the particle.
  66623. */
  66624. rotationQuaternion: Nullable<Quaternion>;
  66625. /**
  66626. * The uv of the particle.
  66627. */
  66628. uv: Nullable<Vector2>;
  66629. /**
  66630. * The current speed of the particle.
  66631. */
  66632. velocity: Vector3;
  66633. /**
  66634. * The pivot point in the particle local space.
  66635. */
  66636. pivot: Vector3;
  66637. /**
  66638. * Must the particle be translated from its pivot point in its local space ?
  66639. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66640. * Default : false
  66641. */
  66642. translateFromPivot: boolean;
  66643. /**
  66644. * Index of this particle in the global "positions" array (Internal use)
  66645. * @hidden
  66646. */
  66647. _pos: number;
  66648. /**
  66649. * @hidden Index of this particle in the global "indices" array (Internal use)
  66650. */
  66651. _ind: number;
  66652. /**
  66653. * Group this particle belongs to
  66654. */
  66655. _group: PointsGroup;
  66656. /**
  66657. * Group id of this particle
  66658. */
  66659. groupId: number;
  66660. /**
  66661. * Index of the particle in its group id (Internal use)
  66662. */
  66663. idxInGroup: number;
  66664. /**
  66665. * @hidden Particle BoundingInfo object (Internal use)
  66666. */
  66667. _boundingInfo: BoundingInfo;
  66668. /**
  66669. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66670. */
  66671. _pcs: PointsCloudSystem;
  66672. /**
  66673. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66674. */
  66675. _stillInvisible: boolean;
  66676. /**
  66677. * @hidden Last computed particle rotation matrix
  66678. */
  66679. _rotationMatrix: number[];
  66680. /**
  66681. * Parent particle Id, if any.
  66682. * Default null.
  66683. */
  66684. parentId: Nullable<number>;
  66685. /**
  66686. * @hidden Internal global position in the PCS.
  66687. */
  66688. _globalPosition: Vector3;
  66689. /**
  66690. * Creates a Point Cloud object.
  66691. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66692. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66693. * @param group (PointsGroup) is the group the particle belongs to
  66694. * @param groupId (integer) is the group identifier in the PCS.
  66695. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66696. * @param pcs defines the PCS it is associated to
  66697. */
  66698. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66699. /**
  66700. * get point size
  66701. */
  66702. get size(): Vector3;
  66703. /**
  66704. * Set point size
  66705. */
  66706. set size(scale: Vector3);
  66707. /**
  66708. * Legacy support, changed quaternion to rotationQuaternion
  66709. */
  66710. get quaternion(): Nullable<Quaternion>;
  66711. /**
  66712. * Legacy support, changed quaternion to rotationQuaternion
  66713. */
  66714. set quaternion(q: Nullable<Quaternion>);
  66715. /**
  66716. * Returns a boolean. True if the particle intersects a mesh, else false
  66717. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66718. * @param target is the object (point or mesh) what the intersection is computed against
  66719. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66720. * @returns true if it intersects
  66721. */
  66722. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66723. /**
  66724. * get the rotation matrix of the particle
  66725. * @hidden
  66726. */
  66727. getRotationMatrix(m: Matrix): void;
  66728. }
  66729. /**
  66730. * Represents a group of points in a points cloud system
  66731. * * PCS internal tool, don't use it manually.
  66732. */
  66733. export class PointsGroup {
  66734. /**
  66735. * The group id
  66736. * @hidden
  66737. */
  66738. groupID: number;
  66739. /**
  66740. * image data for group (internal use)
  66741. * @hidden
  66742. */
  66743. _groupImageData: Nullable<ArrayBufferView>;
  66744. /**
  66745. * Image Width (internal use)
  66746. * @hidden
  66747. */
  66748. _groupImgWidth: number;
  66749. /**
  66750. * Image Height (internal use)
  66751. * @hidden
  66752. */
  66753. _groupImgHeight: number;
  66754. /**
  66755. * Custom position function (internal use)
  66756. * @hidden
  66757. */
  66758. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66759. /**
  66760. * density per facet for surface points
  66761. * @hidden
  66762. */
  66763. _groupDensity: number[];
  66764. /**
  66765. * Only when points are colored by texture carries pointer to texture list array
  66766. * @hidden
  66767. */
  66768. _textureNb: number;
  66769. /**
  66770. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66771. * PCS internal tool, don't use it manually.
  66772. * @hidden
  66773. */
  66774. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66775. }
  66776. }
  66777. declare module "babylonjs/Particles/index" {
  66778. export * from "babylonjs/Particles/baseParticleSystem";
  66779. export * from "babylonjs/Particles/EmitterTypes/index";
  66780. export * from "babylonjs/Particles/gpuParticleSystem";
  66781. export * from "babylonjs/Particles/IParticleSystem";
  66782. export * from "babylonjs/Particles/particle";
  66783. export * from "babylonjs/Particles/particleHelper";
  66784. export * from "babylonjs/Particles/particleSystem";
  66785. export * from "babylonjs/Particles/particleSystemComponent";
  66786. export * from "babylonjs/Particles/particleSystemSet";
  66787. export * from "babylonjs/Particles/solidParticle";
  66788. export * from "babylonjs/Particles/solidParticleSystem";
  66789. export * from "babylonjs/Particles/cloudPoint";
  66790. export * from "babylonjs/Particles/pointsCloudSystem";
  66791. export * from "babylonjs/Particles/subEmitter";
  66792. }
  66793. declare module "babylonjs/Physics/physicsEngineComponent" {
  66794. import { Nullable } from "babylonjs/types";
  66795. import { Observable, Observer } from "babylonjs/Misc/observable";
  66796. import { Vector3 } from "babylonjs/Maths/math.vector";
  66797. import { Mesh } from "babylonjs/Meshes/mesh";
  66798. import { ISceneComponent } from "babylonjs/sceneComponent";
  66799. import { Scene } from "babylonjs/scene";
  66800. import { Node } from "babylonjs/node";
  66801. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66802. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66803. module "babylonjs/scene" {
  66804. interface Scene {
  66805. /** @hidden (Backing field) */
  66806. _physicsEngine: Nullable<IPhysicsEngine>;
  66807. /** @hidden */
  66808. _physicsTimeAccumulator: number;
  66809. /**
  66810. * Gets the current physics engine
  66811. * @returns a IPhysicsEngine or null if none attached
  66812. */
  66813. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66814. /**
  66815. * Enables physics to the current scene
  66816. * @param gravity defines the scene's gravity for the physics engine
  66817. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66818. * @return a boolean indicating if the physics engine was initialized
  66819. */
  66820. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66821. /**
  66822. * Disables and disposes the physics engine associated with the scene
  66823. */
  66824. disablePhysicsEngine(): void;
  66825. /**
  66826. * Gets a boolean indicating if there is an active physics engine
  66827. * @returns a boolean indicating if there is an active physics engine
  66828. */
  66829. isPhysicsEnabled(): boolean;
  66830. /**
  66831. * Deletes a physics compound impostor
  66832. * @param compound defines the compound to delete
  66833. */
  66834. deleteCompoundImpostor(compound: any): void;
  66835. /**
  66836. * An event triggered when physic simulation is about to be run
  66837. */
  66838. onBeforePhysicsObservable: Observable<Scene>;
  66839. /**
  66840. * An event triggered when physic simulation has been done
  66841. */
  66842. onAfterPhysicsObservable: Observable<Scene>;
  66843. }
  66844. }
  66845. module "babylonjs/Meshes/abstractMesh" {
  66846. interface AbstractMesh {
  66847. /** @hidden */
  66848. _physicsImpostor: Nullable<PhysicsImpostor>;
  66849. /**
  66850. * Gets or sets impostor used for physic simulation
  66851. * @see http://doc.babylonjs.com/features/physics_engine
  66852. */
  66853. physicsImpostor: Nullable<PhysicsImpostor>;
  66854. /**
  66855. * Gets the current physics impostor
  66856. * @see http://doc.babylonjs.com/features/physics_engine
  66857. * @returns a physics impostor or null
  66858. */
  66859. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66860. /** Apply a physic impulse to the mesh
  66861. * @param force defines the force to apply
  66862. * @param contactPoint defines where to apply the force
  66863. * @returns the current mesh
  66864. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66865. */
  66866. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66867. /**
  66868. * Creates a physic joint between two meshes
  66869. * @param otherMesh defines the other mesh to use
  66870. * @param pivot1 defines the pivot to use on this mesh
  66871. * @param pivot2 defines the pivot to use on the other mesh
  66872. * @param options defines additional options (can be plugin dependent)
  66873. * @returns the current mesh
  66874. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66875. */
  66876. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66877. /** @hidden */
  66878. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66879. }
  66880. }
  66881. /**
  66882. * Defines the physics engine scene component responsible to manage a physics engine
  66883. */
  66884. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66885. /**
  66886. * The component name helpful to identify the component in the list of scene components.
  66887. */
  66888. readonly name: string;
  66889. /**
  66890. * The scene the component belongs to.
  66891. */
  66892. scene: Scene;
  66893. /**
  66894. * Creates a new instance of the component for the given scene
  66895. * @param scene Defines the scene to register the component in
  66896. */
  66897. constructor(scene: Scene);
  66898. /**
  66899. * Registers the component in a given scene
  66900. */
  66901. register(): void;
  66902. /**
  66903. * Rebuilds the elements related to this component in case of
  66904. * context lost for instance.
  66905. */
  66906. rebuild(): void;
  66907. /**
  66908. * Disposes the component and the associated ressources
  66909. */
  66910. dispose(): void;
  66911. }
  66912. }
  66913. declare module "babylonjs/Physics/physicsHelper" {
  66914. import { Nullable } from "babylonjs/types";
  66915. import { Vector3 } from "babylonjs/Maths/math.vector";
  66916. import { Mesh } from "babylonjs/Meshes/mesh";
  66917. import { Scene } from "babylonjs/scene";
  66918. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66919. /**
  66920. * A helper for physics simulations
  66921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66922. */
  66923. export class PhysicsHelper {
  66924. private _scene;
  66925. private _physicsEngine;
  66926. /**
  66927. * Initializes the Physics helper
  66928. * @param scene Babylon.js scene
  66929. */
  66930. constructor(scene: Scene);
  66931. /**
  66932. * Applies a radial explosion impulse
  66933. * @param origin the origin of the explosion
  66934. * @param radiusOrEventOptions the radius or the options of radial explosion
  66935. * @param strength the explosion strength
  66936. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66937. * @returns A physics radial explosion event, or null
  66938. */
  66939. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66940. /**
  66941. * Applies a radial explosion force
  66942. * @param origin the origin of the explosion
  66943. * @param radiusOrEventOptions the radius or the options of radial explosion
  66944. * @param strength the explosion strength
  66945. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66946. * @returns A physics radial explosion event, or null
  66947. */
  66948. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66949. /**
  66950. * Creates a gravitational field
  66951. * @param origin the origin of the explosion
  66952. * @param radiusOrEventOptions the radius or the options of radial explosion
  66953. * @param strength the explosion strength
  66954. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66955. * @returns A physics gravitational field event, or null
  66956. */
  66957. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66958. /**
  66959. * Creates a physics updraft event
  66960. * @param origin the origin of the updraft
  66961. * @param radiusOrEventOptions the radius or the options of the updraft
  66962. * @param strength the strength of the updraft
  66963. * @param height the height of the updraft
  66964. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66965. * @returns A physics updraft event, or null
  66966. */
  66967. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66968. /**
  66969. * Creates a physics vortex event
  66970. * @param origin the of the vortex
  66971. * @param radiusOrEventOptions the radius or the options of the vortex
  66972. * @param strength the strength of the vortex
  66973. * @param height the height of the vortex
  66974. * @returns a Physics vortex event, or null
  66975. * A physics vortex event or null
  66976. */
  66977. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66978. }
  66979. /**
  66980. * Represents a physics radial explosion event
  66981. */
  66982. class PhysicsRadialExplosionEvent {
  66983. private _scene;
  66984. private _options;
  66985. private _sphere;
  66986. private _dataFetched;
  66987. /**
  66988. * Initializes a radial explosioin event
  66989. * @param _scene BabylonJS scene
  66990. * @param _options The options for the vortex event
  66991. */
  66992. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66993. /**
  66994. * Returns the data related to the radial explosion event (sphere).
  66995. * @returns The radial explosion event data
  66996. */
  66997. getData(): PhysicsRadialExplosionEventData;
  66998. /**
  66999. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67000. * @param impostor A physics imposter
  67001. * @param origin the origin of the explosion
  67002. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67003. */
  67004. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67005. /**
  67006. * Triggers affecterd impostors callbacks
  67007. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67008. */
  67009. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67010. /**
  67011. * Disposes the sphere.
  67012. * @param force Specifies if the sphere should be disposed by force
  67013. */
  67014. dispose(force?: boolean): void;
  67015. /*** Helpers ***/
  67016. private _prepareSphere;
  67017. private _intersectsWithSphere;
  67018. }
  67019. /**
  67020. * Represents a gravitational field event
  67021. */
  67022. class PhysicsGravitationalFieldEvent {
  67023. private _physicsHelper;
  67024. private _scene;
  67025. private _origin;
  67026. private _options;
  67027. private _tickCallback;
  67028. private _sphere;
  67029. private _dataFetched;
  67030. /**
  67031. * Initializes the physics gravitational field event
  67032. * @param _physicsHelper A physics helper
  67033. * @param _scene BabylonJS scene
  67034. * @param _origin The origin position of the gravitational field event
  67035. * @param _options The options for the vortex event
  67036. */
  67037. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67038. /**
  67039. * Returns the data related to the gravitational field event (sphere).
  67040. * @returns A gravitational field event
  67041. */
  67042. getData(): PhysicsGravitationalFieldEventData;
  67043. /**
  67044. * Enables the gravitational field.
  67045. */
  67046. enable(): void;
  67047. /**
  67048. * Disables the gravitational field.
  67049. */
  67050. disable(): void;
  67051. /**
  67052. * Disposes the sphere.
  67053. * @param force The force to dispose from the gravitational field event
  67054. */
  67055. dispose(force?: boolean): void;
  67056. private _tick;
  67057. }
  67058. /**
  67059. * Represents a physics updraft event
  67060. */
  67061. class PhysicsUpdraftEvent {
  67062. private _scene;
  67063. private _origin;
  67064. private _options;
  67065. private _physicsEngine;
  67066. private _originTop;
  67067. private _originDirection;
  67068. private _tickCallback;
  67069. private _cylinder;
  67070. private _cylinderPosition;
  67071. private _dataFetched;
  67072. /**
  67073. * Initializes the physics updraft event
  67074. * @param _scene BabylonJS scene
  67075. * @param _origin The origin position of the updraft
  67076. * @param _options The options for the updraft event
  67077. */
  67078. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67079. /**
  67080. * Returns the data related to the updraft event (cylinder).
  67081. * @returns A physics updraft event
  67082. */
  67083. getData(): PhysicsUpdraftEventData;
  67084. /**
  67085. * Enables the updraft.
  67086. */
  67087. enable(): void;
  67088. /**
  67089. * Disables the updraft.
  67090. */
  67091. disable(): void;
  67092. /**
  67093. * Disposes the cylinder.
  67094. * @param force Specifies if the updraft should be disposed by force
  67095. */
  67096. dispose(force?: boolean): void;
  67097. private getImpostorHitData;
  67098. private _tick;
  67099. /*** Helpers ***/
  67100. private _prepareCylinder;
  67101. private _intersectsWithCylinder;
  67102. }
  67103. /**
  67104. * Represents a physics vortex event
  67105. */
  67106. class PhysicsVortexEvent {
  67107. private _scene;
  67108. private _origin;
  67109. private _options;
  67110. private _physicsEngine;
  67111. private _originTop;
  67112. private _tickCallback;
  67113. private _cylinder;
  67114. private _cylinderPosition;
  67115. private _dataFetched;
  67116. /**
  67117. * Initializes the physics vortex event
  67118. * @param _scene The BabylonJS scene
  67119. * @param _origin The origin position of the vortex
  67120. * @param _options The options for the vortex event
  67121. */
  67122. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67123. /**
  67124. * Returns the data related to the vortex event (cylinder).
  67125. * @returns The physics vortex event data
  67126. */
  67127. getData(): PhysicsVortexEventData;
  67128. /**
  67129. * Enables the vortex.
  67130. */
  67131. enable(): void;
  67132. /**
  67133. * Disables the cortex.
  67134. */
  67135. disable(): void;
  67136. /**
  67137. * Disposes the sphere.
  67138. * @param force
  67139. */
  67140. dispose(force?: boolean): void;
  67141. private getImpostorHitData;
  67142. private _tick;
  67143. /*** Helpers ***/
  67144. private _prepareCylinder;
  67145. private _intersectsWithCylinder;
  67146. }
  67147. /**
  67148. * Options fot the radial explosion event
  67149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67150. */
  67151. export class PhysicsRadialExplosionEventOptions {
  67152. /**
  67153. * The radius of the sphere for the radial explosion.
  67154. */
  67155. radius: number;
  67156. /**
  67157. * The strenth of the explosion.
  67158. */
  67159. strength: number;
  67160. /**
  67161. * The strenght of the force in correspondence to the distance of the affected object
  67162. */
  67163. falloff: PhysicsRadialImpulseFalloff;
  67164. /**
  67165. * Sphere options for the radial explosion.
  67166. */
  67167. sphere: {
  67168. segments: number;
  67169. diameter: number;
  67170. };
  67171. /**
  67172. * Sphere options for the radial explosion.
  67173. */
  67174. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67175. }
  67176. /**
  67177. * Options fot the updraft event
  67178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67179. */
  67180. export class PhysicsUpdraftEventOptions {
  67181. /**
  67182. * The radius of the cylinder for the vortex
  67183. */
  67184. radius: number;
  67185. /**
  67186. * The strenth of the updraft.
  67187. */
  67188. strength: number;
  67189. /**
  67190. * The height of the cylinder for the updraft.
  67191. */
  67192. height: number;
  67193. /**
  67194. * The mode for the the updraft.
  67195. */
  67196. updraftMode: PhysicsUpdraftMode;
  67197. }
  67198. /**
  67199. * Options fot the vortex event
  67200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67201. */
  67202. export class PhysicsVortexEventOptions {
  67203. /**
  67204. * The radius of the cylinder for the vortex
  67205. */
  67206. radius: number;
  67207. /**
  67208. * The strenth of the vortex.
  67209. */
  67210. strength: number;
  67211. /**
  67212. * The height of the cylinder for the vortex.
  67213. */
  67214. height: number;
  67215. /**
  67216. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67217. */
  67218. centripetalForceThreshold: number;
  67219. /**
  67220. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67221. */
  67222. centripetalForceMultiplier: number;
  67223. /**
  67224. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67225. */
  67226. centrifugalForceMultiplier: number;
  67227. /**
  67228. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67229. */
  67230. updraftForceMultiplier: number;
  67231. }
  67232. /**
  67233. * The strenght of the force in correspondence to the distance of the affected object
  67234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67235. */
  67236. export enum PhysicsRadialImpulseFalloff {
  67237. /** Defines that impulse is constant in strength across it's whole radius */
  67238. Constant = 0,
  67239. /** Defines that impulse gets weaker if it's further from the origin */
  67240. Linear = 1
  67241. }
  67242. /**
  67243. * The strength of the force in correspondence to the distance of the affected object
  67244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67245. */
  67246. export enum PhysicsUpdraftMode {
  67247. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67248. Center = 0,
  67249. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67250. Perpendicular = 1
  67251. }
  67252. /**
  67253. * Interface for a physics hit data
  67254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67255. */
  67256. export interface PhysicsHitData {
  67257. /**
  67258. * The force applied at the contact point
  67259. */
  67260. force: Vector3;
  67261. /**
  67262. * The contact point
  67263. */
  67264. contactPoint: Vector3;
  67265. /**
  67266. * The distance from the origin to the contact point
  67267. */
  67268. distanceFromOrigin: number;
  67269. }
  67270. /**
  67271. * Interface for radial explosion event data
  67272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67273. */
  67274. export interface PhysicsRadialExplosionEventData {
  67275. /**
  67276. * A sphere used for the radial explosion event
  67277. */
  67278. sphere: Mesh;
  67279. }
  67280. /**
  67281. * Interface for gravitational field event data
  67282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67283. */
  67284. export interface PhysicsGravitationalFieldEventData {
  67285. /**
  67286. * A sphere mesh used for the gravitational field event
  67287. */
  67288. sphere: Mesh;
  67289. }
  67290. /**
  67291. * Interface for updraft event data
  67292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67293. */
  67294. export interface PhysicsUpdraftEventData {
  67295. /**
  67296. * A cylinder used for the updraft event
  67297. */
  67298. cylinder: Mesh;
  67299. }
  67300. /**
  67301. * Interface for vortex event data
  67302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67303. */
  67304. export interface PhysicsVortexEventData {
  67305. /**
  67306. * A cylinder used for the vortex event
  67307. */
  67308. cylinder: Mesh;
  67309. }
  67310. /**
  67311. * Interface for an affected physics impostor
  67312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67313. */
  67314. export interface PhysicsAffectedImpostorWithData {
  67315. /**
  67316. * The impostor affected by the effect
  67317. */
  67318. impostor: PhysicsImpostor;
  67319. /**
  67320. * The data about the hit/horce from the explosion
  67321. */
  67322. hitData: PhysicsHitData;
  67323. }
  67324. }
  67325. declare module "babylonjs/Physics/Plugins/index" {
  67326. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67327. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67328. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67329. }
  67330. declare module "babylonjs/Physics/index" {
  67331. export * from "babylonjs/Physics/IPhysicsEngine";
  67332. export * from "babylonjs/Physics/physicsEngine";
  67333. export * from "babylonjs/Physics/physicsEngineComponent";
  67334. export * from "babylonjs/Physics/physicsHelper";
  67335. export * from "babylonjs/Physics/physicsImpostor";
  67336. export * from "babylonjs/Physics/physicsJoint";
  67337. export * from "babylonjs/Physics/Plugins/index";
  67338. }
  67339. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67340. /** @hidden */
  67341. export var blackAndWhitePixelShader: {
  67342. name: string;
  67343. shader: string;
  67344. };
  67345. }
  67346. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67348. import { Camera } from "babylonjs/Cameras/camera";
  67349. import { Engine } from "babylonjs/Engines/engine";
  67350. import "babylonjs/Shaders/blackAndWhite.fragment";
  67351. /**
  67352. * Post process used to render in black and white
  67353. */
  67354. export class BlackAndWhitePostProcess extends PostProcess {
  67355. /**
  67356. * Linear about to convert he result to black and white (default: 1)
  67357. */
  67358. degree: number;
  67359. /**
  67360. * Creates a black and white post process
  67361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67362. * @param name The name of the effect.
  67363. * @param options The required width/height ratio to downsize to before computing the render pass.
  67364. * @param camera The camera to apply the render pass to.
  67365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67366. * @param engine The engine which the post process will be applied. (default: current engine)
  67367. * @param reusable If the post process can be reused on the same frame. (default: false)
  67368. */
  67369. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67370. }
  67371. }
  67372. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67373. import { Nullable } from "babylonjs/types";
  67374. import { Camera } from "babylonjs/Cameras/camera";
  67375. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67376. import { Engine } from "babylonjs/Engines/engine";
  67377. /**
  67378. * This represents a set of one or more post processes in Babylon.
  67379. * A post process can be used to apply a shader to a texture after it is rendered.
  67380. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67381. */
  67382. export class PostProcessRenderEffect {
  67383. private _postProcesses;
  67384. private _getPostProcesses;
  67385. private _singleInstance;
  67386. private _cameras;
  67387. private _indicesForCamera;
  67388. /**
  67389. * Name of the effect
  67390. * @hidden
  67391. */
  67392. _name: string;
  67393. /**
  67394. * Instantiates a post process render effect.
  67395. * A post process can be used to apply a shader to a texture after it is rendered.
  67396. * @param engine The engine the effect is tied to
  67397. * @param name The name of the effect
  67398. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67399. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67400. */
  67401. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67402. /**
  67403. * Checks if all the post processes in the effect are supported.
  67404. */
  67405. get isSupported(): boolean;
  67406. /**
  67407. * Updates the current state of the effect
  67408. * @hidden
  67409. */
  67410. _update(): void;
  67411. /**
  67412. * Attaches the effect on cameras
  67413. * @param cameras The camera to attach to.
  67414. * @hidden
  67415. */
  67416. _attachCameras(cameras: Camera): void;
  67417. /**
  67418. * Attaches the effect on cameras
  67419. * @param cameras The camera to attach to.
  67420. * @hidden
  67421. */
  67422. _attachCameras(cameras: Camera[]): void;
  67423. /**
  67424. * Detaches the effect on cameras
  67425. * @param cameras The camera to detatch from.
  67426. * @hidden
  67427. */
  67428. _detachCameras(cameras: Camera): void;
  67429. /**
  67430. * Detatches the effect on cameras
  67431. * @param cameras The camera to detatch from.
  67432. * @hidden
  67433. */
  67434. _detachCameras(cameras: Camera[]): void;
  67435. /**
  67436. * Enables the effect on given cameras
  67437. * @param cameras The camera to enable.
  67438. * @hidden
  67439. */
  67440. _enable(cameras: Camera): void;
  67441. /**
  67442. * Enables the effect on given cameras
  67443. * @param cameras The camera to enable.
  67444. * @hidden
  67445. */
  67446. _enable(cameras: Nullable<Camera[]>): void;
  67447. /**
  67448. * Disables the effect on the given cameras
  67449. * @param cameras The camera to disable.
  67450. * @hidden
  67451. */
  67452. _disable(cameras: Camera): void;
  67453. /**
  67454. * Disables the effect on the given cameras
  67455. * @param cameras The camera to disable.
  67456. * @hidden
  67457. */
  67458. _disable(cameras: Nullable<Camera[]>): void;
  67459. /**
  67460. * Gets a list of the post processes contained in the effect.
  67461. * @param camera The camera to get the post processes on.
  67462. * @returns The list of the post processes in the effect.
  67463. */
  67464. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67465. }
  67466. }
  67467. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67468. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67469. /** @hidden */
  67470. export var extractHighlightsPixelShader: {
  67471. name: string;
  67472. shader: string;
  67473. };
  67474. }
  67475. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67476. import { Nullable } from "babylonjs/types";
  67477. import { Camera } from "babylonjs/Cameras/camera";
  67478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67479. import { Engine } from "babylonjs/Engines/engine";
  67480. import "babylonjs/Shaders/extractHighlights.fragment";
  67481. /**
  67482. * 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.
  67483. */
  67484. export class ExtractHighlightsPostProcess extends PostProcess {
  67485. /**
  67486. * The luminance threshold, pixels below this value will be set to black.
  67487. */
  67488. threshold: number;
  67489. /** @hidden */
  67490. _exposure: number;
  67491. /**
  67492. * Post process which has the input texture to be used when performing highlight extraction
  67493. * @hidden
  67494. */
  67495. _inputPostProcess: Nullable<PostProcess>;
  67496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67497. }
  67498. }
  67499. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67500. /** @hidden */
  67501. export var bloomMergePixelShader: {
  67502. name: string;
  67503. shader: string;
  67504. };
  67505. }
  67506. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67508. import { Nullable } from "babylonjs/types";
  67509. import { Engine } from "babylonjs/Engines/engine";
  67510. import { Camera } from "babylonjs/Cameras/camera";
  67511. import "babylonjs/Shaders/bloomMerge.fragment";
  67512. /**
  67513. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67514. */
  67515. export class BloomMergePostProcess extends PostProcess {
  67516. /** Weight of the bloom to be added to the original input. */
  67517. weight: number;
  67518. /**
  67519. * Creates a new instance of @see BloomMergePostProcess
  67520. * @param name The name of the effect.
  67521. * @param originalFromInput Post process which's input will be used for the merge.
  67522. * @param blurred Blurred highlights post process which's output will be used.
  67523. * @param weight Weight of the bloom to be added to the original input.
  67524. * @param options The required width/height ratio to downsize to before computing the render pass.
  67525. * @param camera The camera to apply the render pass to.
  67526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67527. * @param engine The engine which the post process will be applied. (default: current engine)
  67528. * @param reusable If the post process can be reused on the same frame. (default: false)
  67529. * @param textureType Type of textures used when performing the post process. (default: 0)
  67530. * @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)
  67531. */
  67532. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67533. /** Weight of the bloom to be added to the original input. */
  67534. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67535. }
  67536. }
  67537. declare module "babylonjs/PostProcesses/bloomEffect" {
  67538. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67539. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67540. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67541. import { Camera } from "babylonjs/Cameras/camera";
  67542. import { Scene } from "babylonjs/scene";
  67543. /**
  67544. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67545. */
  67546. export class BloomEffect extends PostProcessRenderEffect {
  67547. private bloomScale;
  67548. /**
  67549. * @hidden Internal
  67550. */
  67551. _effects: Array<PostProcess>;
  67552. /**
  67553. * @hidden Internal
  67554. */
  67555. _downscale: ExtractHighlightsPostProcess;
  67556. private _blurX;
  67557. private _blurY;
  67558. private _merge;
  67559. /**
  67560. * The luminance threshold to find bright areas of the image to bloom.
  67561. */
  67562. get threshold(): number;
  67563. set threshold(value: number);
  67564. /**
  67565. * The strength of the bloom.
  67566. */
  67567. get weight(): number;
  67568. set weight(value: number);
  67569. /**
  67570. * Specifies the size of the bloom blur kernel, relative to the final output size
  67571. */
  67572. get kernel(): number;
  67573. set kernel(value: number);
  67574. /**
  67575. * Creates a new instance of @see BloomEffect
  67576. * @param scene The scene the effect belongs to.
  67577. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67578. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67579. * @param bloomWeight The the strength of bloom.
  67580. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67581. * @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)
  67582. */
  67583. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67584. /**
  67585. * Disposes each of the internal effects for a given camera.
  67586. * @param camera The camera to dispose the effect on.
  67587. */
  67588. disposeEffects(camera: Camera): void;
  67589. /**
  67590. * @hidden Internal
  67591. */
  67592. _updateEffects(): void;
  67593. /**
  67594. * Internal
  67595. * @returns if all the contained post processes are ready.
  67596. * @hidden
  67597. */
  67598. _isReady(): boolean;
  67599. }
  67600. }
  67601. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67602. /** @hidden */
  67603. export var chromaticAberrationPixelShader: {
  67604. name: string;
  67605. shader: string;
  67606. };
  67607. }
  67608. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67609. import { Vector2 } from "babylonjs/Maths/math.vector";
  67610. import { Nullable } from "babylonjs/types";
  67611. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67612. import { Camera } from "babylonjs/Cameras/camera";
  67613. import { Engine } from "babylonjs/Engines/engine";
  67614. import "babylonjs/Shaders/chromaticAberration.fragment";
  67615. /**
  67616. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67617. */
  67618. export class ChromaticAberrationPostProcess extends PostProcess {
  67619. /**
  67620. * The amount of seperation of rgb channels (default: 30)
  67621. */
  67622. aberrationAmount: number;
  67623. /**
  67624. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67625. */
  67626. radialIntensity: number;
  67627. /**
  67628. * 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))
  67629. */
  67630. direction: Vector2;
  67631. /**
  67632. * 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))
  67633. */
  67634. centerPosition: Vector2;
  67635. /**
  67636. * Creates a new instance ChromaticAberrationPostProcess
  67637. * @param name The name of the effect.
  67638. * @param screenWidth The width of the screen to apply the effect on.
  67639. * @param screenHeight The height of the screen to apply the effect on.
  67640. * @param options The required width/height ratio to downsize to before computing the render pass.
  67641. * @param camera The camera to apply the render pass to.
  67642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67643. * @param engine The engine which the post process will be applied. (default: current engine)
  67644. * @param reusable If the post process can be reused on the same frame. (default: false)
  67645. * @param textureType Type of textures used when performing the post process. (default: 0)
  67646. * @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)
  67647. */
  67648. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67649. }
  67650. }
  67651. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67652. /** @hidden */
  67653. export var circleOfConfusionPixelShader: {
  67654. name: string;
  67655. shader: string;
  67656. };
  67657. }
  67658. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67659. import { Nullable } from "babylonjs/types";
  67660. import { Engine } from "babylonjs/Engines/engine";
  67661. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67662. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67663. import { Camera } from "babylonjs/Cameras/camera";
  67664. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67665. /**
  67666. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67667. */
  67668. export class CircleOfConfusionPostProcess extends PostProcess {
  67669. /**
  67670. * 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.
  67671. */
  67672. lensSize: number;
  67673. /**
  67674. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67675. */
  67676. fStop: number;
  67677. /**
  67678. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67679. */
  67680. focusDistance: number;
  67681. /**
  67682. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67683. */
  67684. focalLength: number;
  67685. private _depthTexture;
  67686. /**
  67687. * Creates a new instance CircleOfConfusionPostProcess
  67688. * @param name The name of the effect.
  67689. * @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.
  67690. * @param options The required width/height ratio to downsize to before computing the render pass.
  67691. * @param camera The camera to apply the render pass to.
  67692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67693. * @param engine The engine which the post process will be applied. (default: current engine)
  67694. * @param reusable If the post process can be reused on the same frame. (default: false)
  67695. * @param textureType Type of textures used when performing the post process. (default: 0)
  67696. * @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)
  67697. */
  67698. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67699. /**
  67700. * 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.
  67701. */
  67702. set depthTexture(value: RenderTargetTexture);
  67703. }
  67704. }
  67705. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67706. /** @hidden */
  67707. export var colorCorrectionPixelShader: {
  67708. name: string;
  67709. shader: string;
  67710. };
  67711. }
  67712. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67714. import { Engine } from "babylonjs/Engines/engine";
  67715. import { Camera } from "babylonjs/Cameras/camera";
  67716. import "babylonjs/Shaders/colorCorrection.fragment";
  67717. /**
  67718. *
  67719. * This post-process allows the modification of rendered colors by using
  67720. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67721. *
  67722. * The object needs to be provided an url to a texture containing the color
  67723. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67724. * Use an image editing software to tweak the LUT to match your needs.
  67725. *
  67726. * For an example of a color LUT, see here:
  67727. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67728. * For explanations on color grading, see here:
  67729. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67730. *
  67731. */
  67732. export class ColorCorrectionPostProcess extends PostProcess {
  67733. private _colorTableTexture;
  67734. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67735. }
  67736. }
  67737. declare module "babylonjs/Shaders/convolution.fragment" {
  67738. /** @hidden */
  67739. export var convolutionPixelShader: {
  67740. name: string;
  67741. shader: string;
  67742. };
  67743. }
  67744. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67746. import { Nullable } from "babylonjs/types";
  67747. import { Camera } from "babylonjs/Cameras/camera";
  67748. import { Engine } from "babylonjs/Engines/engine";
  67749. import "babylonjs/Shaders/convolution.fragment";
  67750. /**
  67751. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67752. * input texture to perform effects such as edge detection or sharpening
  67753. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67754. */
  67755. export class ConvolutionPostProcess extends PostProcess {
  67756. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67757. kernel: number[];
  67758. /**
  67759. * Creates a new instance ConvolutionPostProcess
  67760. * @param name The name of the effect.
  67761. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67762. * @param options The required width/height ratio to downsize to before computing the render pass.
  67763. * @param camera The camera to apply the render pass to.
  67764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67765. * @param engine The engine which the post process will be applied. (default: current engine)
  67766. * @param reusable If the post process can be reused on the same frame. (default: false)
  67767. * @param textureType Type of textures used when performing the post process. (default: 0)
  67768. */
  67769. constructor(name: string,
  67770. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67771. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67772. /**
  67773. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67774. */
  67775. static EdgeDetect0Kernel: number[];
  67776. /**
  67777. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67778. */
  67779. static EdgeDetect1Kernel: number[];
  67780. /**
  67781. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67782. */
  67783. static EdgeDetect2Kernel: number[];
  67784. /**
  67785. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67786. */
  67787. static SharpenKernel: number[];
  67788. /**
  67789. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67790. */
  67791. static EmbossKernel: number[];
  67792. /**
  67793. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67794. */
  67795. static GaussianKernel: number[];
  67796. }
  67797. }
  67798. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67799. import { Nullable } from "babylonjs/types";
  67800. import { Vector2 } from "babylonjs/Maths/math.vector";
  67801. import { Camera } from "babylonjs/Cameras/camera";
  67802. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67803. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67804. import { Engine } from "babylonjs/Engines/engine";
  67805. import { Scene } from "babylonjs/scene";
  67806. /**
  67807. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67808. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67809. * based on samples that have a large difference in distance than the center pixel.
  67810. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67811. */
  67812. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67813. direction: Vector2;
  67814. /**
  67815. * Creates a new instance CircleOfConfusionPostProcess
  67816. * @param name The name of the effect.
  67817. * @param scene The scene the effect belongs to.
  67818. * @param direction The direction the blur should be applied.
  67819. * @param kernel The size of the kernel used to blur.
  67820. * @param options The required width/height ratio to downsize to before computing the render pass.
  67821. * @param camera The camera to apply the render pass to.
  67822. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67823. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67825. * @param engine The engine which the post process will be applied. (default: current engine)
  67826. * @param reusable If the post process can be reused on the same frame. (default: false)
  67827. * @param textureType Type of textures used when performing the post process. (default: 0)
  67828. * @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)
  67829. */
  67830. 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);
  67831. }
  67832. }
  67833. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67834. /** @hidden */
  67835. export var depthOfFieldMergePixelShader: {
  67836. name: string;
  67837. shader: string;
  67838. };
  67839. }
  67840. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67841. import { Nullable } from "babylonjs/types";
  67842. import { Camera } from "babylonjs/Cameras/camera";
  67843. import { Effect } from "babylonjs/Materials/effect";
  67844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67845. import { Engine } from "babylonjs/Engines/engine";
  67846. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67847. /**
  67848. * Options to be set when merging outputs from the default pipeline.
  67849. */
  67850. export class DepthOfFieldMergePostProcessOptions {
  67851. /**
  67852. * The original image to merge on top of
  67853. */
  67854. originalFromInput: PostProcess;
  67855. /**
  67856. * Parameters to perform the merge of the depth of field effect
  67857. */
  67858. depthOfField?: {
  67859. circleOfConfusion: PostProcess;
  67860. blurSteps: Array<PostProcess>;
  67861. };
  67862. /**
  67863. * Parameters to perform the merge of bloom effect
  67864. */
  67865. bloom?: {
  67866. blurred: PostProcess;
  67867. weight: number;
  67868. };
  67869. }
  67870. /**
  67871. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67872. */
  67873. export class DepthOfFieldMergePostProcess extends PostProcess {
  67874. private blurSteps;
  67875. /**
  67876. * Creates a new instance of DepthOfFieldMergePostProcess
  67877. * @param name The name of the effect.
  67878. * @param originalFromInput Post process which's input will be used for the merge.
  67879. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67880. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67881. * @param options The required width/height ratio to downsize to before computing the render pass.
  67882. * @param camera The camera to apply the render pass to.
  67883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67884. * @param engine The engine which the post process will be applied. (default: current engine)
  67885. * @param reusable If the post process can be reused on the same frame. (default: false)
  67886. * @param textureType Type of textures used when performing the post process. (default: 0)
  67887. * @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)
  67888. */
  67889. 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);
  67890. /**
  67891. * Updates the effect with the current post process compile time values and recompiles the shader.
  67892. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67893. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67894. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67895. * @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
  67896. * @param onCompiled Called when the shader has been compiled.
  67897. * @param onError Called if there is an error when compiling a shader.
  67898. */
  67899. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67900. }
  67901. }
  67902. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67903. import { Nullable } from "babylonjs/types";
  67904. import { Camera } from "babylonjs/Cameras/camera";
  67905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67906. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67907. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67908. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67909. import { Scene } from "babylonjs/scene";
  67910. /**
  67911. * Specifies the level of max blur that should be applied when using the depth of field effect
  67912. */
  67913. export enum DepthOfFieldEffectBlurLevel {
  67914. /**
  67915. * Subtle blur
  67916. */
  67917. Low = 0,
  67918. /**
  67919. * Medium blur
  67920. */
  67921. Medium = 1,
  67922. /**
  67923. * Large blur
  67924. */
  67925. High = 2
  67926. }
  67927. /**
  67928. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67929. */
  67930. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67931. private _circleOfConfusion;
  67932. /**
  67933. * @hidden Internal, blurs from high to low
  67934. */
  67935. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67936. private _depthOfFieldBlurY;
  67937. private _dofMerge;
  67938. /**
  67939. * @hidden Internal post processes in depth of field effect
  67940. */
  67941. _effects: Array<PostProcess>;
  67942. /**
  67943. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67944. */
  67945. set focalLength(value: number);
  67946. get focalLength(): number;
  67947. /**
  67948. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67949. */
  67950. set fStop(value: number);
  67951. get fStop(): number;
  67952. /**
  67953. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67954. */
  67955. set focusDistance(value: number);
  67956. get focusDistance(): number;
  67957. /**
  67958. * 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.
  67959. */
  67960. set lensSize(value: number);
  67961. get lensSize(): number;
  67962. /**
  67963. * Creates a new instance DepthOfFieldEffect
  67964. * @param scene The scene the effect belongs to.
  67965. * @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.
  67966. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67967. * @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)
  67968. */
  67969. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67970. /**
  67971. * Get the current class name of the current effet
  67972. * @returns "DepthOfFieldEffect"
  67973. */
  67974. getClassName(): string;
  67975. /**
  67976. * 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.
  67977. */
  67978. set depthTexture(value: RenderTargetTexture);
  67979. /**
  67980. * Disposes each of the internal effects for a given camera.
  67981. * @param camera The camera to dispose the effect on.
  67982. */
  67983. disposeEffects(camera: Camera): void;
  67984. /**
  67985. * @hidden Internal
  67986. */
  67987. _updateEffects(): void;
  67988. /**
  67989. * Internal
  67990. * @returns if all the contained post processes are ready.
  67991. * @hidden
  67992. */
  67993. _isReady(): boolean;
  67994. }
  67995. }
  67996. declare module "babylonjs/Shaders/displayPass.fragment" {
  67997. /** @hidden */
  67998. export var displayPassPixelShader: {
  67999. name: string;
  68000. shader: string;
  68001. };
  68002. }
  68003. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68004. import { Nullable } from "babylonjs/types";
  68005. import { Camera } from "babylonjs/Cameras/camera";
  68006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68007. import { Engine } from "babylonjs/Engines/engine";
  68008. import "babylonjs/Shaders/displayPass.fragment";
  68009. /**
  68010. * DisplayPassPostProcess which produces an output the same as it's input
  68011. */
  68012. export class DisplayPassPostProcess extends PostProcess {
  68013. /**
  68014. * Creates the DisplayPassPostProcess
  68015. * @param name The name of the effect.
  68016. * @param options The required width/height ratio to downsize to before computing the render pass.
  68017. * @param camera The camera to apply the render pass to.
  68018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68019. * @param engine The engine which the post process will be applied. (default: current engine)
  68020. * @param reusable If the post process can be reused on the same frame. (default: false)
  68021. */
  68022. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68023. }
  68024. }
  68025. declare module "babylonjs/Shaders/filter.fragment" {
  68026. /** @hidden */
  68027. export var filterPixelShader: {
  68028. name: string;
  68029. shader: string;
  68030. };
  68031. }
  68032. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68033. import { Nullable } from "babylonjs/types";
  68034. import { Matrix } from "babylonjs/Maths/math.vector";
  68035. import { Camera } from "babylonjs/Cameras/camera";
  68036. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68037. import { Engine } from "babylonjs/Engines/engine";
  68038. import "babylonjs/Shaders/filter.fragment";
  68039. /**
  68040. * Applies a kernel filter to the image
  68041. */
  68042. export class FilterPostProcess extends PostProcess {
  68043. /** The matrix to be applied to the image */
  68044. kernelMatrix: Matrix;
  68045. /**
  68046. *
  68047. * @param name The name of the effect.
  68048. * @param kernelMatrix The matrix to be applied to the image
  68049. * @param options The required width/height ratio to downsize to before computing the render pass.
  68050. * @param camera The camera to apply the render pass to.
  68051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68052. * @param engine The engine which the post process will be applied. (default: current engine)
  68053. * @param reusable If the post process can be reused on the same frame. (default: false)
  68054. */
  68055. constructor(name: string,
  68056. /** The matrix to be applied to the image */
  68057. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68058. }
  68059. }
  68060. declare module "babylonjs/Shaders/fxaa.fragment" {
  68061. /** @hidden */
  68062. export var fxaaPixelShader: {
  68063. name: string;
  68064. shader: string;
  68065. };
  68066. }
  68067. declare module "babylonjs/Shaders/fxaa.vertex" {
  68068. /** @hidden */
  68069. export var fxaaVertexShader: {
  68070. name: string;
  68071. shader: string;
  68072. };
  68073. }
  68074. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68075. import { Nullable } from "babylonjs/types";
  68076. import { Camera } from "babylonjs/Cameras/camera";
  68077. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68078. import { Engine } from "babylonjs/Engines/engine";
  68079. import "babylonjs/Shaders/fxaa.fragment";
  68080. import "babylonjs/Shaders/fxaa.vertex";
  68081. /**
  68082. * Fxaa post process
  68083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68084. */
  68085. export class FxaaPostProcess extends PostProcess {
  68086. /** @hidden */
  68087. texelWidth: number;
  68088. /** @hidden */
  68089. texelHeight: number;
  68090. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68091. private _getDefines;
  68092. }
  68093. }
  68094. declare module "babylonjs/Shaders/grain.fragment" {
  68095. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68096. /** @hidden */
  68097. export var grainPixelShader: {
  68098. name: string;
  68099. shader: string;
  68100. };
  68101. }
  68102. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68103. import { Nullable } from "babylonjs/types";
  68104. import { Camera } from "babylonjs/Cameras/camera";
  68105. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68106. import { Engine } from "babylonjs/Engines/engine";
  68107. import "babylonjs/Shaders/grain.fragment";
  68108. /**
  68109. * The GrainPostProcess adds noise to the image at mid luminance levels
  68110. */
  68111. export class GrainPostProcess extends PostProcess {
  68112. /**
  68113. * The intensity of the grain added (default: 30)
  68114. */
  68115. intensity: number;
  68116. /**
  68117. * If the grain should be randomized on every frame
  68118. */
  68119. animated: boolean;
  68120. /**
  68121. * Creates a new instance of @see GrainPostProcess
  68122. * @param name The name of the effect.
  68123. * @param options The required width/height ratio to downsize to before computing the render pass.
  68124. * @param camera The camera to apply the render pass to.
  68125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68126. * @param engine The engine which the post process will be applied. (default: current engine)
  68127. * @param reusable If the post process can be reused on the same frame. (default: false)
  68128. * @param textureType Type of textures used when performing the post process. (default: 0)
  68129. * @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)
  68130. */
  68131. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68132. }
  68133. }
  68134. declare module "babylonjs/Shaders/highlights.fragment" {
  68135. /** @hidden */
  68136. export var highlightsPixelShader: {
  68137. name: string;
  68138. shader: string;
  68139. };
  68140. }
  68141. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68142. import { Nullable } from "babylonjs/types";
  68143. import { Camera } from "babylonjs/Cameras/camera";
  68144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68145. import { Engine } from "babylonjs/Engines/engine";
  68146. import "babylonjs/Shaders/highlights.fragment";
  68147. /**
  68148. * Extracts highlights from the image
  68149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68150. */
  68151. export class HighlightsPostProcess extends PostProcess {
  68152. /**
  68153. * Extracts highlights from the image
  68154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68155. * @param name The name of the effect.
  68156. * @param options The required width/height ratio to downsize to before computing the render pass.
  68157. * @param camera The camera to apply the render pass to.
  68158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68159. * @param engine The engine which the post process will be applied. (default: current engine)
  68160. * @param reusable If the post process can be reused on the same frame. (default: false)
  68161. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68162. */
  68163. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68164. }
  68165. }
  68166. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68167. /** @hidden */
  68168. export var mrtFragmentDeclaration: {
  68169. name: string;
  68170. shader: string;
  68171. };
  68172. }
  68173. declare module "babylonjs/Shaders/geometry.fragment" {
  68174. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68175. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68176. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68177. /** @hidden */
  68178. export var geometryPixelShader: {
  68179. name: string;
  68180. shader: string;
  68181. };
  68182. }
  68183. declare module "babylonjs/Shaders/geometry.vertex" {
  68184. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68185. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68186. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68187. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68189. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68190. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68191. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68192. /** @hidden */
  68193. export var geometryVertexShader: {
  68194. name: string;
  68195. shader: string;
  68196. };
  68197. }
  68198. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68199. import { Matrix } from "babylonjs/Maths/math.vector";
  68200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68201. import { Mesh } from "babylonjs/Meshes/mesh";
  68202. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68203. import { Effect } from "babylonjs/Materials/effect";
  68204. import { Scene } from "babylonjs/scene";
  68205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68206. import "babylonjs/Shaders/geometry.fragment";
  68207. import "babylonjs/Shaders/geometry.vertex";
  68208. /** @hidden */
  68209. interface ISavedTransformationMatrix {
  68210. world: Matrix;
  68211. viewProjection: Matrix;
  68212. }
  68213. /**
  68214. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68215. */
  68216. export class GeometryBufferRenderer {
  68217. /**
  68218. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68219. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68220. */
  68221. static readonly POSITION_TEXTURE_TYPE: number;
  68222. /**
  68223. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68224. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68225. */
  68226. static readonly VELOCITY_TEXTURE_TYPE: number;
  68227. /**
  68228. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68229. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68230. */
  68231. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68232. /**
  68233. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68234. * in order to compute objects velocities when enableVelocity is set to "true"
  68235. * @hidden
  68236. */
  68237. _previousTransformationMatrices: {
  68238. [index: number]: ISavedTransformationMatrix;
  68239. };
  68240. /**
  68241. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68242. * in order to compute objects velocities when enableVelocity is set to "true"
  68243. * @hidden
  68244. */
  68245. _previousBonesTransformationMatrices: {
  68246. [index: number]: Float32Array;
  68247. };
  68248. /**
  68249. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68250. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68251. */
  68252. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68253. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68254. renderTransparentMeshes: boolean;
  68255. private _scene;
  68256. private _multiRenderTarget;
  68257. private _ratio;
  68258. private _enablePosition;
  68259. private _enableVelocity;
  68260. private _enableReflectivity;
  68261. private _positionIndex;
  68262. private _velocityIndex;
  68263. private _reflectivityIndex;
  68264. protected _effect: Effect;
  68265. protected _cachedDefines: string;
  68266. /**
  68267. * Set the render list (meshes to be rendered) used in the G buffer.
  68268. */
  68269. set renderList(meshes: Mesh[]);
  68270. /**
  68271. * Gets wether or not G buffer are supported by the running hardware.
  68272. * This requires draw buffer supports
  68273. */
  68274. get isSupported(): boolean;
  68275. /**
  68276. * Returns the index of the given texture type in the G-Buffer textures array
  68277. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68278. * @returns the index of the given texture type in the G-Buffer textures array
  68279. */
  68280. getTextureIndex(textureType: number): number;
  68281. /**
  68282. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68283. */
  68284. get enablePosition(): boolean;
  68285. /**
  68286. * Sets whether or not objects positions are enabled for the G buffer.
  68287. */
  68288. set enablePosition(enable: boolean);
  68289. /**
  68290. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68291. */
  68292. get enableVelocity(): boolean;
  68293. /**
  68294. * Sets wether or not objects velocities are enabled for the G buffer.
  68295. */
  68296. set enableVelocity(enable: boolean);
  68297. /**
  68298. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68299. */
  68300. get enableReflectivity(): boolean;
  68301. /**
  68302. * Sets wether or not objects roughness are enabled for the G buffer.
  68303. */
  68304. set enableReflectivity(enable: boolean);
  68305. /**
  68306. * Gets the scene associated with the buffer.
  68307. */
  68308. get scene(): Scene;
  68309. /**
  68310. * Gets the ratio used by the buffer during its creation.
  68311. * How big is the buffer related to the main canvas.
  68312. */
  68313. get ratio(): number;
  68314. /** @hidden */
  68315. static _SceneComponentInitialization: (scene: Scene) => void;
  68316. /**
  68317. * Creates a new G Buffer for the scene
  68318. * @param scene The scene the buffer belongs to
  68319. * @param ratio How big is the buffer related to the main canvas.
  68320. */
  68321. constructor(scene: Scene, ratio?: number);
  68322. /**
  68323. * Checks wether everything is ready to render a submesh to the G buffer.
  68324. * @param subMesh the submesh to check readiness for
  68325. * @param useInstances is the mesh drawn using instance or not
  68326. * @returns true if ready otherwise false
  68327. */
  68328. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68329. /**
  68330. * Gets the current underlying G Buffer.
  68331. * @returns the buffer
  68332. */
  68333. getGBuffer(): MultiRenderTarget;
  68334. /**
  68335. * Gets the number of samples used to render the buffer (anti aliasing).
  68336. */
  68337. get samples(): number;
  68338. /**
  68339. * Sets the number of samples used to render the buffer (anti aliasing).
  68340. */
  68341. set samples(value: number);
  68342. /**
  68343. * Disposes the renderer and frees up associated resources.
  68344. */
  68345. dispose(): void;
  68346. protected _createRenderTargets(): void;
  68347. private _copyBonesTransformationMatrices;
  68348. }
  68349. }
  68350. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68351. import { Nullable } from "babylonjs/types";
  68352. import { Scene } from "babylonjs/scene";
  68353. import { ISceneComponent } from "babylonjs/sceneComponent";
  68354. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68355. module "babylonjs/scene" {
  68356. interface Scene {
  68357. /** @hidden (Backing field) */
  68358. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68359. /**
  68360. * Gets or Sets the current geometry buffer associated to the scene.
  68361. */
  68362. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68363. /**
  68364. * Enables a GeometryBufferRender and associates it with the scene
  68365. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68366. * @returns the GeometryBufferRenderer
  68367. */
  68368. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68369. /**
  68370. * Disables the GeometryBufferRender associated with the scene
  68371. */
  68372. disableGeometryBufferRenderer(): void;
  68373. }
  68374. }
  68375. /**
  68376. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68377. * in several rendering techniques.
  68378. */
  68379. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68380. /**
  68381. * The component name helpful to identify the component in the list of scene components.
  68382. */
  68383. readonly name: string;
  68384. /**
  68385. * The scene the component belongs to.
  68386. */
  68387. scene: Scene;
  68388. /**
  68389. * Creates a new instance of the component for the given scene
  68390. * @param scene Defines the scene to register the component in
  68391. */
  68392. constructor(scene: Scene);
  68393. /**
  68394. * Registers the component in a given scene
  68395. */
  68396. register(): void;
  68397. /**
  68398. * Rebuilds the elements related to this component in case of
  68399. * context lost for instance.
  68400. */
  68401. rebuild(): void;
  68402. /**
  68403. * Disposes the component and the associated ressources
  68404. */
  68405. dispose(): void;
  68406. private _gatherRenderTargets;
  68407. }
  68408. }
  68409. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68410. /** @hidden */
  68411. export var motionBlurPixelShader: {
  68412. name: string;
  68413. shader: string;
  68414. };
  68415. }
  68416. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68417. import { Nullable } from "babylonjs/types";
  68418. import { Camera } from "babylonjs/Cameras/camera";
  68419. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68420. import { Scene } from "babylonjs/scene";
  68421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68422. import "babylonjs/Animations/animatable";
  68423. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68424. import "babylonjs/Shaders/motionBlur.fragment";
  68425. import { Engine } from "babylonjs/Engines/engine";
  68426. /**
  68427. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68428. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68429. * As an example, all you have to do is to create the post-process:
  68430. * var mb = new BABYLON.MotionBlurPostProcess(
  68431. * 'mb', // The name of the effect.
  68432. * scene, // The scene containing the objects to blur according to their velocity.
  68433. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68434. * camera // The camera to apply the render pass to.
  68435. * );
  68436. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68437. */
  68438. export class MotionBlurPostProcess extends PostProcess {
  68439. /**
  68440. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68441. */
  68442. motionStrength: number;
  68443. /**
  68444. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68445. */
  68446. get motionBlurSamples(): number;
  68447. /**
  68448. * Sets the number of iterations to be used for motion blur quality
  68449. */
  68450. set motionBlurSamples(samples: number);
  68451. private _motionBlurSamples;
  68452. private _geometryBufferRenderer;
  68453. /**
  68454. * Creates a new instance MotionBlurPostProcess
  68455. * @param name The name of the effect.
  68456. * @param scene The scene containing the objects to blur according to their velocity.
  68457. * @param options The required width/height ratio to downsize to before computing the render pass.
  68458. * @param camera The camera to apply the render pass to.
  68459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68460. * @param engine The engine which the post process will be applied. (default: current engine)
  68461. * @param reusable If the post process can be reused on the same frame. (default: false)
  68462. * @param textureType Type of textures used when performing the post process. (default: 0)
  68463. * @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)
  68464. */
  68465. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68466. /**
  68467. * Excludes the given skinned mesh from computing bones velocities.
  68468. * 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.
  68469. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68470. */
  68471. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68472. /**
  68473. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68474. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68475. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68476. */
  68477. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68478. /**
  68479. * Disposes the post process.
  68480. * @param camera The camera to dispose the post process on.
  68481. */
  68482. dispose(camera?: Camera): void;
  68483. }
  68484. }
  68485. declare module "babylonjs/Shaders/refraction.fragment" {
  68486. /** @hidden */
  68487. export var refractionPixelShader: {
  68488. name: string;
  68489. shader: string;
  68490. };
  68491. }
  68492. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68493. import { Color3 } from "babylonjs/Maths/math.color";
  68494. import { Camera } from "babylonjs/Cameras/camera";
  68495. import { Texture } from "babylonjs/Materials/Textures/texture";
  68496. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68497. import { Engine } from "babylonjs/Engines/engine";
  68498. import "babylonjs/Shaders/refraction.fragment";
  68499. /**
  68500. * Post process which applies a refractin texture
  68501. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68502. */
  68503. export class RefractionPostProcess extends PostProcess {
  68504. /** the base color of the refraction (used to taint the rendering) */
  68505. color: Color3;
  68506. /** simulated refraction depth */
  68507. depth: number;
  68508. /** the coefficient of the base color (0 to remove base color tainting) */
  68509. colorLevel: number;
  68510. private _refTexture;
  68511. private _ownRefractionTexture;
  68512. /**
  68513. * Gets or sets the refraction texture
  68514. * Please note that you are responsible for disposing the texture if you set it manually
  68515. */
  68516. get refractionTexture(): Texture;
  68517. set refractionTexture(value: Texture);
  68518. /**
  68519. * Initializes the RefractionPostProcess
  68520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68521. * @param name The name of the effect.
  68522. * @param refractionTextureUrl Url of the refraction texture to use
  68523. * @param color the base color of the refraction (used to taint the rendering)
  68524. * @param depth simulated refraction depth
  68525. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68526. * @param camera The camera to apply the render pass to.
  68527. * @param options The required width/height ratio to downsize to before computing the render pass.
  68528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68529. * @param engine The engine which the post process will be applied. (default: current engine)
  68530. * @param reusable If the post process can be reused on the same frame. (default: false)
  68531. */
  68532. constructor(name: string, refractionTextureUrl: string,
  68533. /** the base color of the refraction (used to taint the rendering) */
  68534. color: Color3,
  68535. /** simulated refraction depth */
  68536. depth: number,
  68537. /** the coefficient of the base color (0 to remove base color tainting) */
  68538. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68539. /**
  68540. * Disposes of the post process
  68541. * @param camera Camera to dispose post process on
  68542. */
  68543. dispose(camera: Camera): void;
  68544. }
  68545. }
  68546. declare module "babylonjs/Shaders/sharpen.fragment" {
  68547. /** @hidden */
  68548. export var sharpenPixelShader: {
  68549. name: string;
  68550. shader: string;
  68551. };
  68552. }
  68553. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68554. import { Nullable } from "babylonjs/types";
  68555. import { Camera } from "babylonjs/Cameras/camera";
  68556. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68557. import "babylonjs/Shaders/sharpen.fragment";
  68558. import { Engine } from "babylonjs/Engines/engine";
  68559. /**
  68560. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68561. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68562. */
  68563. export class SharpenPostProcess extends PostProcess {
  68564. /**
  68565. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68566. */
  68567. colorAmount: number;
  68568. /**
  68569. * How much sharpness should be applied (default: 0.3)
  68570. */
  68571. edgeAmount: number;
  68572. /**
  68573. * Creates a new instance ConvolutionPostProcess
  68574. * @param name The name of the effect.
  68575. * @param options The required width/height ratio to downsize to before computing the render pass.
  68576. * @param camera The camera to apply the render pass to.
  68577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68578. * @param engine The engine which the post process will be applied. (default: current engine)
  68579. * @param reusable If the post process can be reused on the same frame. (default: false)
  68580. * @param textureType Type of textures used when performing the post process. (default: 0)
  68581. * @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)
  68582. */
  68583. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68584. }
  68585. }
  68586. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68587. import { Nullable } from "babylonjs/types";
  68588. import { Camera } from "babylonjs/Cameras/camera";
  68589. import { Engine } from "babylonjs/Engines/engine";
  68590. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68591. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68592. /**
  68593. * PostProcessRenderPipeline
  68594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68595. */
  68596. export class PostProcessRenderPipeline {
  68597. private engine;
  68598. private _renderEffects;
  68599. private _renderEffectsForIsolatedPass;
  68600. /**
  68601. * List of inspectable custom properties (used by the Inspector)
  68602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68603. */
  68604. inspectableCustomProperties: IInspectable[];
  68605. /**
  68606. * @hidden
  68607. */
  68608. protected _cameras: Camera[];
  68609. /** @hidden */
  68610. _name: string;
  68611. /**
  68612. * Gets pipeline name
  68613. */
  68614. get name(): string;
  68615. /** Gets the list of attached cameras */
  68616. get cameras(): Camera[];
  68617. /**
  68618. * Initializes a PostProcessRenderPipeline
  68619. * @param engine engine to add the pipeline to
  68620. * @param name name of the pipeline
  68621. */
  68622. constructor(engine: Engine, name: string);
  68623. /**
  68624. * Gets the class name
  68625. * @returns "PostProcessRenderPipeline"
  68626. */
  68627. getClassName(): string;
  68628. /**
  68629. * If all the render effects in the pipeline are supported
  68630. */
  68631. get isSupported(): boolean;
  68632. /**
  68633. * Adds an effect to the pipeline
  68634. * @param renderEffect the effect to add
  68635. */
  68636. addEffect(renderEffect: PostProcessRenderEffect): void;
  68637. /** @hidden */
  68638. _rebuild(): void;
  68639. /** @hidden */
  68640. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68641. /** @hidden */
  68642. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68643. /** @hidden */
  68644. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68645. /** @hidden */
  68646. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68647. /** @hidden */
  68648. _attachCameras(cameras: Camera, unique: boolean): void;
  68649. /** @hidden */
  68650. _attachCameras(cameras: Camera[], unique: boolean): void;
  68651. /** @hidden */
  68652. _detachCameras(cameras: Camera): void;
  68653. /** @hidden */
  68654. _detachCameras(cameras: Nullable<Camera[]>): void;
  68655. /** @hidden */
  68656. _update(): void;
  68657. /** @hidden */
  68658. _reset(): void;
  68659. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68660. /**
  68661. * Disposes of the pipeline
  68662. */
  68663. dispose(): void;
  68664. }
  68665. }
  68666. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68667. import { Camera } from "babylonjs/Cameras/camera";
  68668. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68669. /**
  68670. * PostProcessRenderPipelineManager class
  68671. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68672. */
  68673. export class PostProcessRenderPipelineManager {
  68674. private _renderPipelines;
  68675. /**
  68676. * Initializes a PostProcessRenderPipelineManager
  68677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68678. */
  68679. constructor();
  68680. /**
  68681. * Gets the list of supported render pipelines
  68682. */
  68683. get supportedPipelines(): PostProcessRenderPipeline[];
  68684. /**
  68685. * Adds a pipeline to the manager
  68686. * @param renderPipeline The pipeline to add
  68687. */
  68688. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68689. /**
  68690. * Attaches a camera to the pipeline
  68691. * @param renderPipelineName The name of the pipeline to attach to
  68692. * @param cameras the camera to attach
  68693. * @param unique if the camera can be attached multiple times to the pipeline
  68694. */
  68695. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68696. /**
  68697. * Detaches a camera from the pipeline
  68698. * @param renderPipelineName The name of the pipeline to detach from
  68699. * @param cameras the camera to detach
  68700. */
  68701. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68702. /**
  68703. * Enables an effect by name on a pipeline
  68704. * @param renderPipelineName the name of the pipeline to enable the effect in
  68705. * @param renderEffectName the name of the effect to enable
  68706. * @param cameras the cameras that the effect should be enabled on
  68707. */
  68708. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68709. /**
  68710. * Disables an effect by name on a pipeline
  68711. * @param renderPipelineName the name of the pipeline to disable the effect in
  68712. * @param renderEffectName the name of the effect to disable
  68713. * @param cameras the cameras that the effect should be disabled on
  68714. */
  68715. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68716. /**
  68717. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68718. */
  68719. update(): void;
  68720. /** @hidden */
  68721. _rebuild(): void;
  68722. /**
  68723. * Disposes of the manager and pipelines
  68724. */
  68725. dispose(): void;
  68726. }
  68727. }
  68728. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68729. import { ISceneComponent } from "babylonjs/sceneComponent";
  68730. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68731. import { Scene } from "babylonjs/scene";
  68732. module "babylonjs/scene" {
  68733. interface Scene {
  68734. /** @hidden (Backing field) */
  68735. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68736. /**
  68737. * Gets the postprocess render pipeline manager
  68738. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68739. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68740. */
  68741. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68742. }
  68743. }
  68744. /**
  68745. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68746. */
  68747. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68748. /**
  68749. * The component name helpfull to identify the component in the list of scene components.
  68750. */
  68751. readonly name: string;
  68752. /**
  68753. * The scene the component belongs to.
  68754. */
  68755. scene: Scene;
  68756. /**
  68757. * Creates a new instance of the component for the given scene
  68758. * @param scene Defines the scene to register the component in
  68759. */
  68760. constructor(scene: Scene);
  68761. /**
  68762. * Registers the component in a given scene
  68763. */
  68764. register(): void;
  68765. /**
  68766. * Rebuilds the elements related to this component in case of
  68767. * context lost for instance.
  68768. */
  68769. rebuild(): void;
  68770. /**
  68771. * Disposes the component and the associated ressources
  68772. */
  68773. dispose(): void;
  68774. private _gatherRenderTargets;
  68775. }
  68776. }
  68777. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68778. import { Nullable } from "babylonjs/types";
  68779. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68780. import { Camera } from "babylonjs/Cameras/camera";
  68781. import { IDisposable } from "babylonjs/scene";
  68782. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68783. import { Scene } from "babylonjs/scene";
  68784. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68785. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68786. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68787. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68788. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68789. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68790. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68791. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68792. import { Animation } from "babylonjs/Animations/animation";
  68793. /**
  68794. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68795. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68796. */
  68797. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68798. private _scene;
  68799. private _camerasToBeAttached;
  68800. /**
  68801. * ID of the sharpen post process,
  68802. */
  68803. private readonly SharpenPostProcessId;
  68804. /**
  68805. * @ignore
  68806. * ID of the image processing post process;
  68807. */
  68808. readonly ImageProcessingPostProcessId: string;
  68809. /**
  68810. * @ignore
  68811. * ID of the Fast Approximate Anti-Aliasing post process;
  68812. */
  68813. readonly FxaaPostProcessId: string;
  68814. /**
  68815. * ID of the chromatic aberration post process,
  68816. */
  68817. private readonly ChromaticAberrationPostProcessId;
  68818. /**
  68819. * ID of the grain post process
  68820. */
  68821. private readonly GrainPostProcessId;
  68822. /**
  68823. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68824. */
  68825. sharpen: SharpenPostProcess;
  68826. private _sharpenEffect;
  68827. private bloom;
  68828. /**
  68829. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68830. */
  68831. depthOfField: DepthOfFieldEffect;
  68832. /**
  68833. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68834. */
  68835. fxaa: FxaaPostProcess;
  68836. /**
  68837. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68838. */
  68839. imageProcessing: ImageProcessingPostProcess;
  68840. /**
  68841. * Chromatic aberration post process which will shift rgb colors in the image
  68842. */
  68843. chromaticAberration: ChromaticAberrationPostProcess;
  68844. private _chromaticAberrationEffect;
  68845. /**
  68846. * Grain post process which add noise to the image
  68847. */
  68848. grain: GrainPostProcess;
  68849. private _grainEffect;
  68850. /**
  68851. * Glow post process which adds a glow to emissive areas of the image
  68852. */
  68853. private _glowLayer;
  68854. /**
  68855. * Animations which can be used to tweak settings over a period of time
  68856. */
  68857. animations: Animation[];
  68858. private _imageProcessingConfigurationObserver;
  68859. private _sharpenEnabled;
  68860. private _bloomEnabled;
  68861. private _depthOfFieldEnabled;
  68862. private _depthOfFieldBlurLevel;
  68863. private _fxaaEnabled;
  68864. private _imageProcessingEnabled;
  68865. private _defaultPipelineTextureType;
  68866. private _bloomScale;
  68867. private _chromaticAberrationEnabled;
  68868. private _grainEnabled;
  68869. private _buildAllowed;
  68870. /**
  68871. * Gets active scene
  68872. */
  68873. get scene(): Scene;
  68874. /**
  68875. * Enable or disable the sharpen process from the pipeline
  68876. */
  68877. set sharpenEnabled(enabled: boolean);
  68878. get sharpenEnabled(): boolean;
  68879. private _resizeObserver;
  68880. private _hardwareScaleLevel;
  68881. private _bloomKernel;
  68882. /**
  68883. * Specifies the size of the bloom blur kernel, relative to the final output size
  68884. */
  68885. get bloomKernel(): number;
  68886. set bloomKernel(value: number);
  68887. /**
  68888. * Specifies the weight of the bloom in the final rendering
  68889. */
  68890. private _bloomWeight;
  68891. /**
  68892. * Specifies the luma threshold for the area that will be blurred by the bloom
  68893. */
  68894. private _bloomThreshold;
  68895. private _hdr;
  68896. /**
  68897. * The strength of the bloom.
  68898. */
  68899. set bloomWeight(value: number);
  68900. get bloomWeight(): number;
  68901. /**
  68902. * The strength of the bloom.
  68903. */
  68904. set bloomThreshold(value: number);
  68905. get bloomThreshold(): number;
  68906. /**
  68907. * The scale of the bloom, lower value will provide better performance.
  68908. */
  68909. set bloomScale(value: number);
  68910. get bloomScale(): number;
  68911. /**
  68912. * Enable or disable the bloom from the pipeline
  68913. */
  68914. set bloomEnabled(enabled: boolean);
  68915. get bloomEnabled(): boolean;
  68916. private _rebuildBloom;
  68917. /**
  68918. * If the depth of field is enabled.
  68919. */
  68920. get depthOfFieldEnabled(): boolean;
  68921. set depthOfFieldEnabled(enabled: boolean);
  68922. /**
  68923. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68924. */
  68925. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68926. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68927. /**
  68928. * If the anti aliasing is enabled.
  68929. */
  68930. set fxaaEnabled(enabled: boolean);
  68931. get fxaaEnabled(): boolean;
  68932. private _samples;
  68933. /**
  68934. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68935. */
  68936. set samples(sampleCount: number);
  68937. get samples(): number;
  68938. /**
  68939. * If image processing is enabled.
  68940. */
  68941. set imageProcessingEnabled(enabled: boolean);
  68942. get imageProcessingEnabled(): boolean;
  68943. /**
  68944. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68945. */
  68946. set glowLayerEnabled(enabled: boolean);
  68947. get glowLayerEnabled(): boolean;
  68948. /**
  68949. * Gets the glow layer (or null if not defined)
  68950. */
  68951. get glowLayer(): Nullable<GlowLayer>;
  68952. /**
  68953. * Enable or disable the chromaticAberration process from the pipeline
  68954. */
  68955. set chromaticAberrationEnabled(enabled: boolean);
  68956. get chromaticAberrationEnabled(): boolean;
  68957. /**
  68958. * Enable or disable the grain process from the pipeline
  68959. */
  68960. set grainEnabled(enabled: boolean);
  68961. get grainEnabled(): boolean;
  68962. /**
  68963. * @constructor
  68964. * @param name - The rendering pipeline name (default: "")
  68965. * @param hdr - If high dynamic range textures should be used (default: true)
  68966. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68967. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68968. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68969. */
  68970. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68971. /**
  68972. * Get the class name
  68973. * @returns "DefaultRenderingPipeline"
  68974. */
  68975. getClassName(): string;
  68976. /**
  68977. * Force the compilation of the entire pipeline.
  68978. */
  68979. prepare(): void;
  68980. private _hasCleared;
  68981. private _prevPostProcess;
  68982. private _prevPrevPostProcess;
  68983. private _setAutoClearAndTextureSharing;
  68984. private _depthOfFieldSceneObserver;
  68985. private _buildPipeline;
  68986. private _disposePostProcesses;
  68987. /**
  68988. * Adds a camera to the pipeline
  68989. * @param camera the camera to be added
  68990. */
  68991. addCamera(camera: Camera): void;
  68992. /**
  68993. * Removes a camera from the pipeline
  68994. * @param camera the camera to remove
  68995. */
  68996. removeCamera(camera: Camera): void;
  68997. /**
  68998. * Dispose of the pipeline and stop all post processes
  68999. */
  69000. dispose(): void;
  69001. /**
  69002. * Serialize the rendering pipeline (Used when exporting)
  69003. * @returns the serialized object
  69004. */
  69005. serialize(): any;
  69006. /**
  69007. * Parse the serialized pipeline
  69008. * @param source Source pipeline.
  69009. * @param scene The scene to load the pipeline to.
  69010. * @param rootUrl The URL of the serialized pipeline.
  69011. * @returns An instantiated pipeline from the serialized object.
  69012. */
  69013. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69014. }
  69015. }
  69016. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69017. /** @hidden */
  69018. export var lensHighlightsPixelShader: {
  69019. name: string;
  69020. shader: string;
  69021. };
  69022. }
  69023. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69024. /** @hidden */
  69025. export var depthOfFieldPixelShader: {
  69026. name: string;
  69027. shader: string;
  69028. };
  69029. }
  69030. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69031. import { Camera } from "babylonjs/Cameras/camera";
  69032. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69033. import { Scene } from "babylonjs/scene";
  69034. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69035. import "babylonjs/Shaders/chromaticAberration.fragment";
  69036. import "babylonjs/Shaders/lensHighlights.fragment";
  69037. import "babylonjs/Shaders/depthOfField.fragment";
  69038. /**
  69039. * BABYLON.JS Chromatic Aberration GLSL Shader
  69040. * Author: Olivier Guyot
  69041. * Separates very slightly R, G and B colors on the edges of the screen
  69042. * Inspired by Francois Tarlier & Martins Upitis
  69043. */
  69044. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69045. /**
  69046. * @ignore
  69047. * The chromatic aberration PostProcess id in the pipeline
  69048. */
  69049. LensChromaticAberrationEffect: string;
  69050. /**
  69051. * @ignore
  69052. * The highlights enhancing PostProcess id in the pipeline
  69053. */
  69054. HighlightsEnhancingEffect: string;
  69055. /**
  69056. * @ignore
  69057. * The depth-of-field PostProcess id in the pipeline
  69058. */
  69059. LensDepthOfFieldEffect: string;
  69060. private _scene;
  69061. private _depthTexture;
  69062. private _grainTexture;
  69063. private _chromaticAberrationPostProcess;
  69064. private _highlightsPostProcess;
  69065. private _depthOfFieldPostProcess;
  69066. private _edgeBlur;
  69067. private _grainAmount;
  69068. private _chromaticAberration;
  69069. private _distortion;
  69070. private _highlightsGain;
  69071. private _highlightsThreshold;
  69072. private _dofDistance;
  69073. private _dofAperture;
  69074. private _dofDarken;
  69075. private _dofPentagon;
  69076. private _blurNoise;
  69077. /**
  69078. * @constructor
  69079. *
  69080. * Effect parameters are as follow:
  69081. * {
  69082. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69083. * edge_blur: number; // from 0 to x (1 for realism)
  69084. * distortion: number; // from 0 to x (1 for realism)
  69085. * grain_amount: number; // from 0 to 1
  69086. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69087. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69088. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69089. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69090. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69091. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69092. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69093. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69094. * }
  69095. * Note: if an effect parameter is unset, effect is disabled
  69096. *
  69097. * @param name The rendering pipeline name
  69098. * @param parameters - An object containing all parameters (see above)
  69099. * @param scene The scene linked to this pipeline
  69100. * @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)
  69101. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69102. */
  69103. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69104. /**
  69105. * Get the class name
  69106. * @returns "LensRenderingPipeline"
  69107. */
  69108. getClassName(): string;
  69109. /**
  69110. * Gets associated scene
  69111. */
  69112. get scene(): Scene;
  69113. /**
  69114. * Gets or sets the edge blur
  69115. */
  69116. get edgeBlur(): number;
  69117. set edgeBlur(value: number);
  69118. /**
  69119. * Gets or sets the grain amount
  69120. */
  69121. get grainAmount(): number;
  69122. set grainAmount(value: number);
  69123. /**
  69124. * Gets or sets the chromatic aberration amount
  69125. */
  69126. get chromaticAberration(): number;
  69127. set chromaticAberration(value: number);
  69128. /**
  69129. * Gets or sets the depth of field aperture
  69130. */
  69131. get dofAperture(): number;
  69132. set dofAperture(value: number);
  69133. /**
  69134. * Gets or sets the edge distortion
  69135. */
  69136. get edgeDistortion(): number;
  69137. set edgeDistortion(value: number);
  69138. /**
  69139. * Gets or sets the depth of field distortion
  69140. */
  69141. get dofDistortion(): number;
  69142. set dofDistortion(value: number);
  69143. /**
  69144. * Gets or sets the darken out of focus amount
  69145. */
  69146. get darkenOutOfFocus(): number;
  69147. set darkenOutOfFocus(value: number);
  69148. /**
  69149. * Gets or sets a boolean indicating if blur noise is enabled
  69150. */
  69151. get blurNoise(): boolean;
  69152. set blurNoise(value: boolean);
  69153. /**
  69154. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69155. */
  69156. get pentagonBokeh(): boolean;
  69157. set pentagonBokeh(value: boolean);
  69158. /**
  69159. * Gets or sets the highlight grain amount
  69160. */
  69161. get highlightsGain(): number;
  69162. set highlightsGain(value: number);
  69163. /**
  69164. * Gets or sets the highlight threshold
  69165. */
  69166. get highlightsThreshold(): number;
  69167. set highlightsThreshold(value: number);
  69168. /**
  69169. * Sets the amount of blur at the edges
  69170. * @param amount blur amount
  69171. */
  69172. setEdgeBlur(amount: number): void;
  69173. /**
  69174. * Sets edge blur to 0
  69175. */
  69176. disableEdgeBlur(): void;
  69177. /**
  69178. * Sets the amout of grain
  69179. * @param amount Amount of grain
  69180. */
  69181. setGrainAmount(amount: number): void;
  69182. /**
  69183. * Set grain amount to 0
  69184. */
  69185. disableGrain(): void;
  69186. /**
  69187. * Sets the chromatic aberration amount
  69188. * @param amount amount of chromatic aberration
  69189. */
  69190. setChromaticAberration(amount: number): void;
  69191. /**
  69192. * Sets chromatic aberration amount to 0
  69193. */
  69194. disableChromaticAberration(): void;
  69195. /**
  69196. * Sets the EdgeDistortion amount
  69197. * @param amount amount of EdgeDistortion
  69198. */
  69199. setEdgeDistortion(amount: number): void;
  69200. /**
  69201. * Sets edge distortion to 0
  69202. */
  69203. disableEdgeDistortion(): void;
  69204. /**
  69205. * Sets the FocusDistance amount
  69206. * @param amount amount of FocusDistance
  69207. */
  69208. setFocusDistance(amount: number): void;
  69209. /**
  69210. * Disables depth of field
  69211. */
  69212. disableDepthOfField(): void;
  69213. /**
  69214. * Sets the Aperture amount
  69215. * @param amount amount of Aperture
  69216. */
  69217. setAperture(amount: number): void;
  69218. /**
  69219. * Sets the DarkenOutOfFocus amount
  69220. * @param amount amount of DarkenOutOfFocus
  69221. */
  69222. setDarkenOutOfFocus(amount: number): void;
  69223. private _pentagonBokehIsEnabled;
  69224. /**
  69225. * Creates a pentagon bokeh effect
  69226. */
  69227. enablePentagonBokeh(): void;
  69228. /**
  69229. * Disables the pentagon bokeh effect
  69230. */
  69231. disablePentagonBokeh(): void;
  69232. /**
  69233. * Enables noise blur
  69234. */
  69235. enableNoiseBlur(): void;
  69236. /**
  69237. * Disables noise blur
  69238. */
  69239. disableNoiseBlur(): void;
  69240. /**
  69241. * Sets the HighlightsGain amount
  69242. * @param amount amount of HighlightsGain
  69243. */
  69244. setHighlightsGain(amount: number): void;
  69245. /**
  69246. * Sets the HighlightsThreshold amount
  69247. * @param amount amount of HighlightsThreshold
  69248. */
  69249. setHighlightsThreshold(amount: number): void;
  69250. /**
  69251. * Disables highlights
  69252. */
  69253. disableHighlights(): void;
  69254. /**
  69255. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69256. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69257. */
  69258. dispose(disableDepthRender?: boolean): void;
  69259. private _createChromaticAberrationPostProcess;
  69260. private _createHighlightsPostProcess;
  69261. private _createDepthOfFieldPostProcess;
  69262. private _createGrainTexture;
  69263. }
  69264. }
  69265. declare module "babylonjs/Shaders/ssao2.fragment" {
  69266. /** @hidden */
  69267. export var ssao2PixelShader: {
  69268. name: string;
  69269. shader: string;
  69270. };
  69271. }
  69272. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69273. /** @hidden */
  69274. export var ssaoCombinePixelShader: {
  69275. name: string;
  69276. shader: string;
  69277. };
  69278. }
  69279. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69280. import { Camera } from "babylonjs/Cameras/camera";
  69281. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69282. import { Scene } from "babylonjs/scene";
  69283. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69284. import "babylonjs/Shaders/ssao2.fragment";
  69285. import "babylonjs/Shaders/ssaoCombine.fragment";
  69286. /**
  69287. * Render pipeline to produce ssao effect
  69288. */
  69289. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69290. /**
  69291. * @ignore
  69292. * The PassPostProcess id in the pipeline that contains the original scene color
  69293. */
  69294. SSAOOriginalSceneColorEffect: string;
  69295. /**
  69296. * @ignore
  69297. * The SSAO PostProcess id in the pipeline
  69298. */
  69299. SSAORenderEffect: string;
  69300. /**
  69301. * @ignore
  69302. * The horizontal blur PostProcess id in the pipeline
  69303. */
  69304. SSAOBlurHRenderEffect: string;
  69305. /**
  69306. * @ignore
  69307. * The vertical blur PostProcess id in the pipeline
  69308. */
  69309. SSAOBlurVRenderEffect: string;
  69310. /**
  69311. * @ignore
  69312. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69313. */
  69314. SSAOCombineRenderEffect: string;
  69315. /**
  69316. * The output strength of the SSAO post-process. Default value is 1.0.
  69317. */
  69318. totalStrength: number;
  69319. /**
  69320. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69321. */
  69322. maxZ: number;
  69323. /**
  69324. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69325. */
  69326. minZAspect: number;
  69327. private _samples;
  69328. /**
  69329. * Number of samples used for the SSAO calculations. Default value is 8
  69330. */
  69331. set samples(n: number);
  69332. get samples(): number;
  69333. private _textureSamples;
  69334. /**
  69335. * Number of samples to use for antialiasing
  69336. */
  69337. set textureSamples(n: number);
  69338. get textureSamples(): number;
  69339. /**
  69340. * Ratio object used for SSAO ratio and blur ratio
  69341. */
  69342. private _ratio;
  69343. /**
  69344. * Dynamically generated sphere sampler.
  69345. */
  69346. private _sampleSphere;
  69347. /**
  69348. * Blur filter offsets
  69349. */
  69350. private _samplerOffsets;
  69351. private _expensiveBlur;
  69352. /**
  69353. * If bilateral blur should be used
  69354. */
  69355. set expensiveBlur(b: boolean);
  69356. get expensiveBlur(): boolean;
  69357. /**
  69358. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69359. */
  69360. radius: number;
  69361. /**
  69362. * The base color of the SSAO post-process
  69363. * The final result is "base + ssao" between [0, 1]
  69364. */
  69365. base: number;
  69366. /**
  69367. * Support test.
  69368. */
  69369. static get IsSupported(): boolean;
  69370. private _scene;
  69371. private _depthTexture;
  69372. private _normalTexture;
  69373. private _randomTexture;
  69374. private _originalColorPostProcess;
  69375. private _ssaoPostProcess;
  69376. private _blurHPostProcess;
  69377. private _blurVPostProcess;
  69378. private _ssaoCombinePostProcess;
  69379. /**
  69380. * Gets active scene
  69381. */
  69382. get scene(): Scene;
  69383. /**
  69384. * @constructor
  69385. * @param name The rendering pipeline name
  69386. * @param scene The scene linked to this pipeline
  69387. * @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 }
  69388. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69389. */
  69390. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69391. /**
  69392. * Get the class name
  69393. * @returns "SSAO2RenderingPipeline"
  69394. */
  69395. getClassName(): string;
  69396. /**
  69397. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69398. */
  69399. dispose(disableGeometryBufferRenderer?: boolean): void;
  69400. private _createBlurPostProcess;
  69401. /** @hidden */
  69402. _rebuild(): void;
  69403. private _bits;
  69404. private _radicalInverse_VdC;
  69405. private _hammersley;
  69406. private _hemisphereSample_uniform;
  69407. private _generateHemisphere;
  69408. private _createSSAOPostProcess;
  69409. private _createSSAOCombinePostProcess;
  69410. private _createRandomTexture;
  69411. /**
  69412. * Serialize the rendering pipeline (Used when exporting)
  69413. * @returns the serialized object
  69414. */
  69415. serialize(): any;
  69416. /**
  69417. * Parse the serialized pipeline
  69418. * @param source Source pipeline.
  69419. * @param scene The scene to load the pipeline to.
  69420. * @param rootUrl The URL of the serialized pipeline.
  69421. * @returns An instantiated pipeline from the serialized object.
  69422. */
  69423. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69424. }
  69425. }
  69426. declare module "babylonjs/Shaders/ssao.fragment" {
  69427. /** @hidden */
  69428. export var ssaoPixelShader: {
  69429. name: string;
  69430. shader: string;
  69431. };
  69432. }
  69433. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69434. import { Camera } from "babylonjs/Cameras/camera";
  69435. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69436. import { Scene } from "babylonjs/scene";
  69437. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69438. import "babylonjs/Shaders/ssao.fragment";
  69439. import "babylonjs/Shaders/ssaoCombine.fragment";
  69440. /**
  69441. * Render pipeline to produce ssao effect
  69442. */
  69443. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69444. /**
  69445. * @ignore
  69446. * The PassPostProcess id in the pipeline that contains the original scene color
  69447. */
  69448. SSAOOriginalSceneColorEffect: string;
  69449. /**
  69450. * @ignore
  69451. * The SSAO PostProcess id in the pipeline
  69452. */
  69453. SSAORenderEffect: string;
  69454. /**
  69455. * @ignore
  69456. * The horizontal blur PostProcess id in the pipeline
  69457. */
  69458. SSAOBlurHRenderEffect: string;
  69459. /**
  69460. * @ignore
  69461. * The vertical blur PostProcess id in the pipeline
  69462. */
  69463. SSAOBlurVRenderEffect: string;
  69464. /**
  69465. * @ignore
  69466. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69467. */
  69468. SSAOCombineRenderEffect: string;
  69469. /**
  69470. * The output strength of the SSAO post-process. Default value is 1.0.
  69471. */
  69472. totalStrength: number;
  69473. /**
  69474. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69475. */
  69476. radius: number;
  69477. /**
  69478. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69479. * Must not be equal to fallOff and superior to fallOff.
  69480. * Default value is 0.0075
  69481. */
  69482. area: number;
  69483. /**
  69484. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69485. * Must not be equal to area and inferior to area.
  69486. * Default value is 0.000001
  69487. */
  69488. fallOff: number;
  69489. /**
  69490. * The base color of the SSAO post-process
  69491. * The final result is "base + ssao" between [0, 1]
  69492. */
  69493. base: number;
  69494. private _scene;
  69495. private _depthTexture;
  69496. private _randomTexture;
  69497. private _originalColorPostProcess;
  69498. private _ssaoPostProcess;
  69499. private _blurHPostProcess;
  69500. private _blurVPostProcess;
  69501. private _ssaoCombinePostProcess;
  69502. private _firstUpdate;
  69503. /**
  69504. * Gets active scene
  69505. */
  69506. get scene(): Scene;
  69507. /**
  69508. * @constructor
  69509. * @param name - The rendering pipeline name
  69510. * @param scene - The scene linked to this pipeline
  69511. * @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 }
  69512. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69513. */
  69514. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69515. /**
  69516. * Get the class name
  69517. * @returns "SSAORenderingPipeline"
  69518. */
  69519. getClassName(): string;
  69520. /**
  69521. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69522. */
  69523. dispose(disableDepthRender?: boolean): void;
  69524. private _createBlurPostProcess;
  69525. /** @hidden */
  69526. _rebuild(): void;
  69527. private _createSSAOPostProcess;
  69528. private _createSSAOCombinePostProcess;
  69529. private _createRandomTexture;
  69530. }
  69531. }
  69532. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69533. /** @hidden */
  69534. export var screenSpaceReflectionPixelShader: {
  69535. name: string;
  69536. shader: string;
  69537. };
  69538. }
  69539. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69540. import { Nullable } from "babylonjs/types";
  69541. import { Camera } from "babylonjs/Cameras/camera";
  69542. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69543. import { Scene } from "babylonjs/scene";
  69544. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69545. import { Engine } from "babylonjs/Engines/engine";
  69546. /**
  69547. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69548. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69549. */
  69550. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69551. /**
  69552. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69553. */
  69554. threshold: number;
  69555. /**
  69556. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69557. */
  69558. strength: number;
  69559. /**
  69560. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69561. */
  69562. reflectionSpecularFalloffExponent: number;
  69563. /**
  69564. * 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]
  69565. */
  69566. step: number;
  69567. /**
  69568. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69569. */
  69570. roughnessFactor: number;
  69571. private _geometryBufferRenderer;
  69572. private _enableSmoothReflections;
  69573. private _reflectionSamples;
  69574. private _smoothSteps;
  69575. /**
  69576. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69577. * @param name The name of the effect.
  69578. * @param scene The scene containing the objects to calculate reflections.
  69579. * @param options The required width/height ratio to downsize to before computing the render pass.
  69580. * @param camera The camera to apply the render pass to.
  69581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69582. * @param engine The engine which the post process will be applied. (default: current engine)
  69583. * @param reusable If the post process can be reused on the same frame. (default: false)
  69584. * @param textureType Type of textures used when performing the post process. (default: 0)
  69585. * @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)
  69586. */
  69587. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69588. /**
  69589. * Gets wether or not smoothing reflections is enabled.
  69590. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69591. */
  69592. get enableSmoothReflections(): boolean;
  69593. /**
  69594. * Sets wether or not smoothing reflections is enabled.
  69595. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69596. */
  69597. set enableSmoothReflections(enabled: boolean);
  69598. /**
  69599. * Gets the number of samples taken while computing reflections. More samples count is high,
  69600. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69601. */
  69602. get reflectionSamples(): number;
  69603. /**
  69604. * Sets the number of samples taken while computing reflections. More samples count is high,
  69605. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69606. */
  69607. set reflectionSamples(samples: number);
  69608. /**
  69609. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69610. * more the post-process will require GPU power and can generate a drop in FPS.
  69611. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69612. */
  69613. get smoothSteps(): number;
  69614. set smoothSteps(steps: number);
  69615. private _updateEffectDefines;
  69616. }
  69617. }
  69618. declare module "babylonjs/Shaders/standard.fragment" {
  69619. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69620. /** @hidden */
  69621. export var standardPixelShader: {
  69622. name: string;
  69623. shader: string;
  69624. };
  69625. }
  69626. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69627. import { Nullable } from "babylonjs/types";
  69628. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69629. import { Camera } from "babylonjs/Cameras/camera";
  69630. import { Texture } from "babylonjs/Materials/Textures/texture";
  69631. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69632. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69633. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69634. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69635. import { IDisposable } from "babylonjs/scene";
  69636. import { SpotLight } from "babylonjs/Lights/spotLight";
  69637. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69638. import { Scene } from "babylonjs/scene";
  69639. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69640. import { Animation } from "babylonjs/Animations/animation";
  69641. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69642. import "babylonjs/Shaders/standard.fragment";
  69643. /**
  69644. * Standard rendering pipeline
  69645. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69646. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69647. */
  69648. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69649. /**
  69650. * Public members
  69651. */
  69652. /**
  69653. * Post-process which contains the original scene color before the pipeline applies all the effects
  69654. */
  69655. originalPostProcess: Nullable<PostProcess>;
  69656. /**
  69657. * Post-process used to down scale an image x4
  69658. */
  69659. downSampleX4PostProcess: Nullable<PostProcess>;
  69660. /**
  69661. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69662. */
  69663. brightPassPostProcess: Nullable<PostProcess>;
  69664. /**
  69665. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69666. */
  69667. blurHPostProcesses: PostProcess[];
  69668. /**
  69669. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69670. */
  69671. blurVPostProcesses: PostProcess[];
  69672. /**
  69673. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69674. */
  69675. textureAdderPostProcess: Nullable<PostProcess>;
  69676. /**
  69677. * Post-process used to create volumetric lighting effect
  69678. */
  69679. volumetricLightPostProcess: Nullable<PostProcess>;
  69680. /**
  69681. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69682. */
  69683. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69684. /**
  69685. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69686. */
  69687. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69688. /**
  69689. * Post-process used to merge the volumetric light effect and the real scene color
  69690. */
  69691. volumetricLightMergePostProces: Nullable<PostProcess>;
  69692. /**
  69693. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69694. */
  69695. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69696. /**
  69697. * Base post-process used to calculate the average luminance of the final image for HDR
  69698. */
  69699. luminancePostProcess: Nullable<PostProcess>;
  69700. /**
  69701. * Post-processes used to create down sample post-processes in order to get
  69702. * the average luminance of the final image for HDR
  69703. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69704. */
  69705. luminanceDownSamplePostProcesses: PostProcess[];
  69706. /**
  69707. * Post-process used to create a HDR effect (light adaptation)
  69708. */
  69709. hdrPostProcess: Nullable<PostProcess>;
  69710. /**
  69711. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69712. */
  69713. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69714. /**
  69715. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69716. */
  69717. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69718. /**
  69719. * Post-process used to merge the final HDR post-process and the real scene color
  69720. */
  69721. hdrFinalPostProcess: Nullable<PostProcess>;
  69722. /**
  69723. * Post-process used to create a lens flare effect
  69724. */
  69725. lensFlarePostProcess: Nullable<PostProcess>;
  69726. /**
  69727. * Post-process that merges the result of the lens flare post-process and the real scene color
  69728. */
  69729. lensFlareComposePostProcess: Nullable<PostProcess>;
  69730. /**
  69731. * Post-process used to create a motion blur effect
  69732. */
  69733. motionBlurPostProcess: Nullable<PostProcess>;
  69734. /**
  69735. * Post-process used to create a depth of field effect
  69736. */
  69737. depthOfFieldPostProcess: Nullable<PostProcess>;
  69738. /**
  69739. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69740. */
  69741. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69742. /**
  69743. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69744. */
  69745. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69746. /**
  69747. * Represents the brightness threshold in order to configure the illuminated surfaces
  69748. */
  69749. brightThreshold: number;
  69750. /**
  69751. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69752. */
  69753. blurWidth: number;
  69754. /**
  69755. * Sets if the blur for highlighted surfaces must be only horizontal
  69756. */
  69757. horizontalBlur: boolean;
  69758. /**
  69759. * Gets the overall exposure used by the pipeline
  69760. */
  69761. get exposure(): number;
  69762. /**
  69763. * Sets the overall exposure used by the pipeline
  69764. */
  69765. set exposure(value: number);
  69766. /**
  69767. * Texture used typically to simulate "dirty" on camera lens
  69768. */
  69769. lensTexture: Nullable<Texture>;
  69770. /**
  69771. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69772. */
  69773. volumetricLightCoefficient: number;
  69774. /**
  69775. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69776. */
  69777. volumetricLightPower: number;
  69778. /**
  69779. * Used the set the blur intensity to smooth the volumetric lights
  69780. */
  69781. volumetricLightBlurScale: number;
  69782. /**
  69783. * Light (spot or directional) used to generate the volumetric lights rays
  69784. * The source light must have a shadow generate so the pipeline can get its
  69785. * depth map
  69786. */
  69787. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69788. /**
  69789. * For eye adaptation, represents the minimum luminance the eye can see
  69790. */
  69791. hdrMinimumLuminance: number;
  69792. /**
  69793. * For eye adaptation, represents the decrease luminance speed
  69794. */
  69795. hdrDecreaseRate: number;
  69796. /**
  69797. * For eye adaptation, represents the increase luminance speed
  69798. */
  69799. hdrIncreaseRate: number;
  69800. /**
  69801. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69802. */
  69803. get hdrAutoExposure(): boolean;
  69804. /**
  69805. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69806. */
  69807. set hdrAutoExposure(value: boolean);
  69808. /**
  69809. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69810. */
  69811. lensColorTexture: Nullable<Texture>;
  69812. /**
  69813. * The overall strengh for the lens flare effect
  69814. */
  69815. lensFlareStrength: number;
  69816. /**
  69817. * Dispersion coefficient for lens flare ghosts
  69818. */
  69819. lensFlareGhostDispersal: number;
  69820. /**
  69821. * Main lens flare halo width
  69822. */
  69823. lensFlareHaloWidth: number;
  69824. /**
  69825. * Based on the lens distortion effect, defines how much the lens flare result
  69826. * is distorted
  69827. */
  69828. lensFlareDistortionStrength: number;
  69829. /**
  69830. * Configures the blur intensity used for for lens flare (halo)
  69831. */
  69832. lensFlareBlurWidth: number;
  69833. /**
  69834. * Lens star texture must be used to simulate rays on the flares and is available
  69835. * in the documentation
  69836. */
  69837. lensStarTexture: Nullable<Texture>;
  69838. /**
  69839. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69840. * flare effect by taking account of the dirt texture
  69841. */
  69842. lensFlareDirtTexture: Nullable<Texture>;
  69843. /**
  69844. * Represents the focal length for the depth of field effect
  69845. */
  69846. depthOfFieldDistance: number;
  69847. /**
  69848. * Represents the blur intensity for the blurred part of the depth of field effect
  69849. */
  69850. depthOfFieldBlurWidth: number;
  69851. /**
  69852. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69853. */
  69854. get motionStrength(): number;
  69855. /**
  69856. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69857. */
  69858. set motionStrength(strength: number);
  69859. /**
  69860. * Gets wether or not the motion blur post-process is object based or screen based.
  69861. */
  69862. get objectBasedMotionBlur(): boolean;
  69863. /**
  69864. * Sets wether or not the motion blur post-process should be object based or screen based
  69865. */
  69866. set objectBasedMotionBlur(value: boolean);
  69867. /**
  69868. * List of animations for the pipeline (IAnimatable implementation)
  69869. */
  69870. animations: Animation[];
  69871. /**
  69872. * Private members
  69873. */
  69874. private _scene;
  69875. private _currentDepthOfFieldSource;
  69876. private _basePostProcess;
  69877. private _fixedExposure;
  69878. private _currentExposure;
  69879. private _hdrAutoExposure;
  69880. private _hdrCurrentLuminance;
  69881. private _motionStrength;
  69882. private _isObjectBasedMotionBlur;
  69883. private _floatTextureType;
  69884. private _camerasToBeAttached;
  69885. private _ratio;
  69886. private _bloomEnabled;
  69887. private _depthOfFieldEnabled;
  69888. private _vlsEnabled;
  69889. private _lensFlareEnabled;
  69890. private _hdrEnabled;
  69891. private _motionBlurEnabled;
  69892. private _fxaaEnabled;
  69893. private _screenSpaceReflectionsEnabled;
  69894. private _motionBlurSamples;
  69895. private _volumetricLightStepsCount;
  69896. private _samples;
  69897. /**
  69898. * @ignore
  69899. * Specifies if the bloom pipeline is enabled
  69900. */
  69901. get BloomEnabled(): boolean;
  69902. set BloomEnabled(enabled: boolean);
  69903. /**
  69904. * @ignore
  69905. * Specifies if the depth of field pipeline is enabed
  69906. */
  69907. get DepthOfFieldEnabled(): boolean;
  69908. set DepthOfFieldEnabled(enabled: boolean);
  69909. /**
  69910. * @ignore
  69911. * Specifies if the lens flare pipeline is enabed
  69912. */
  69913. get LensFlareEnabled(): boolean;
  69914. set LensFlareEnabled(enabled: boolean);
  69915. /**
  69916. * @ignore
  69917. * Specifies if the HDR pipeline is enabled
  69918. */
  69919. get HDREnabled(): boolean;
  69920. set HDREnabled(enabled: boolean);
  69921. /**
  69922. * @ignore
  69923. * Specifies if the volumetric lights scattering effect is enabled
  69924. */
  69925. get VLSEnabled(): boolean;
  69926. set VLSEnabled(enabled: boolean);
  69927. /**
  69928. * @ignore
  69929. * Specifies if the motion blur effect is enabled
  69930. */
  69931. get MotionBlurEnabled(): boolean;
  69932. set MotionBlurEnabled(enabled: boolean);
  69933. /**
  69934. * Specifies if anti-aliasing is enabled
  69935. */
  69936. get fxaaEnabled(): boolean;
  69937. set fxaaEnabled(enabled: boolean);
  69938. /**
  69939. * Specifies if screen space reflections are enabled.
  69940. */
  69941. get screenSpaceReflectionsEnabled(): boolean;
  69942. set screenSpaceReflectionsEnabled(enabled: boolean);
  69943. /**
  69944. * Specifies the number of steps used to calculate the volumetric lights
  69945. * Typically in interval [50, 200]
  69946. */
  69947. get volumetricLightStepsCount(): number;
  69948. set volumetricLightStepsCount(count: number);
  69949. /**
  69950. * Specifies the number of samples used for the motion blur effect
  69951. * Typically in interval [16, 64]
  69952. */
  69953. get motionBlurSamples(): number;
  69954. set motionBlurSamples(samples: number);
  69955. /**
  69956. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69957. */
  69958. get samples(): number;
  69959. set samples(sampleCount: number);
  69960. /**
  69961. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69962. * @constructor
  69963. * @param name The rendering pipeline name
  69964. * @param scene The scene linked to this pipeline
  69965. * @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)
  69966. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69967. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69968. */
  69969. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69970. private _buildPipeline;
  69971. private _createDownSampleX4PostProcess;
  69972. private _createBrightPassPostProcess;
  69973. private _createBlurPostProcesses;
  69974. private _createTextureAdderPostProcess;
  69975. private _createVolumetricLightPostProcess;
  69976. private _createLuminancePostProcesses;
  69977. private _createHdrPostProcess;
  69978. private _createLensFlarePostProcess;
  69979. private _createDepthOfFieldPostProcess;
  69980. private _createMotionBlurPostProcess;
  69981. private _getDepthTexture;
  69982. private _disposePostProcesses;
  69983. /**
  69984. * Dispose of the pipeline and stop all post processes
  69985. */
  69986. dispose(): void;
  69987. /**
  69988. * Serialize the rendering pipeline (Used when exporting)
  69989. * @returns the serialized object
  69990. */
  69991. serialize(): any;
  69992. /**
  69993. * Parse the serialized pipeline
  69994. * @param source Source pipeline.
  69995. * @param scene The scene to load the pipeline to.
  69996. * @param rootUrl The URL of the serialized pipeline.
  69997. * @returns An instantiated pipeline from the serialized object.
  69998. */
  69999. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70000. /**
  70001. * Luminance steps
  70002. */
  70003. static LuminanceSteps: number;
  70004. }
  70005. }
  70006. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70007. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70008. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70009. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70010. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70011. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70012. }
  70013. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70014. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70015. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70016. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70017. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70018. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70019. }
  70020. declare module "babylonjs/Shaders/tonemap.fragment" {
  70021. /** @hidden */
  70022. export var tonemapPixelShader: {
  70023. name: string;
  70024. shader: string;
  70025. };
  70026. }
  70027. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70028. import { Camera } from "babylonjs/Cameras/camera";
  70029. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70030. import "babylonjs/Shaders/tonemap.fragment";
  70031. import { Engine } from "babylonjs/Engines/engine";
  70032. /** Defines operator used for tonemapping */
  70033. export enum TonemappingOperator {
  70034. /** Hable */
  70035. Hable = 0,
  70036. /** Reinhard */
  70037. Reinhard = 1,
  70038. /** HejiDawson */
  70039. HejiDawson = 2,
  70040. /** Photographic */
  70041. Photographic = 3
  70042. }
  70043. /**
  70044. * Defines a post process to apply tone mapping
  70045. */
  70046. export class TonemapPostProcess extends PostProcess {
  70047. private _operator;
  70048. /** Defines the required exposure adjustement */
  70049. exposureAdjustment: number;
  70050. /**
  70051. * Creates a new TonemapPostProcess
  70052. * @param name defines the name of the postprocess
  70053. * @param _operator defines the operator to use
  70054. * @param exposureAdjustment defines the required exposure adjustement
  70055. * @param camera defines the camera to use (can be null)
  70056. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70057. * @param engine defines the hosting engine (can be ignore if camera is set)
  70058. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70059. */
  70060. constructor(name: string, _operator: TonemappingOperator,
  70061. /** Defines the required exposure adjustement */
  70062. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70063. }
  70064. }
  70065. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70066. /** @hidden */
  70067. export var volumetricLightScatteringPixelShader: {
  70068. name: string;
  70069. shader: string;
  70070. };
  70071. }
  70072. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70073. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70075. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70076. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70077. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70078. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70079. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70080. /** @hidden */
  70081. export var volumetricLightScatteringPassVertexShader: {
  70082. name: string;
  70083. shader: string;
  70084. };
  70085. }
  70086. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70087. /** @hidden */
  70088. export var volumetricLightScatteringPassPixelShader: {
  70089. name: string;
  70090. shader: string;
  70091. };
  70092. }
  70093. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70094. import { Vector3 } from "babylonjs/Maths/math.vector";
  70095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70096. import { Mesh } from "babylonjs/Meshes/mesh";
  70097. import { Camera } from "babylonjs/Cameras/camera";
  70098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70099. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70100. import { Scene } from "babylonjs/scene";
  70101. import "babylonjs/Meshes/Builders/planeBuilder";
  70102. import "babylonjs/Shaders/depth.vertex";
  70103. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70104. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70105. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70106. import { Engine } from "babylonjs/Engines/engine";
  70107. /**
  70108. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70109. */
  70110. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70111. private _volumetricLightScatteringPass;
  70112. private _volumetricLightScatteringRTT;
  70113. private _viewPort;
  70114. private _screenCoordinates;
  70115. private _cachedDefines;
  70116. /**
  70117. * If not undefined, the mesh position is computed from the attached node position
  70118. */
  70119. attachedNode: {
  70120. position: Vector3;
  70121. };
  70122. /**
  70123. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70124. */
  70125. customMeshPosition: Vector3;
  70126. /**
  70127. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70128. */
  70129. useCustomMeshPosition: boolean;
  70130. /**
  70131. * If the post-process should inverse the light scattering direction
  70132. */
  70133. invert: boolean;
  70134. /**
  70135. * The internal mesh used by the post-process
  70136. */
  70137. mesh: Mesh;
  70138. /**
  70139. * @hidden
  70140. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70141. */
  70142. get useDiffuseColor(): boolean;
  70143. set useDiffuseColor(useDiffuseColor: boolean);
  70144. /**
  70145. * Array containing the excluded meshes not rendered in the internal pass
  70146. */
  70147. excludedMeshes: AbstractMesh[];
  70148. /**
  70149. * Controls the overall intensity of the post-process
  70150. */
  70151. exposure: number;
  70152. /**
  70153. * Dissipates each sample's contribution in range [0, 1]
  70154. */
  70155. decay: number;
  70156. /**
  70157. * Controls the overall intensity of each sample
  70158. */
  70159. weight: number;
  70160. /**
  70161. * Controls the density of each sample
  70162. */
  70163. density: number;
  70164. /**
  70165. * @constructor
  70166. * @param name The post-process name
  70167. * @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)
  70168. * @param camera The camera that the post-process will be attached to
  70169. * @param mesh The mesh used to create the light scattering
  70170. * @param samples The post-process quality, default 100
  70171. * @param samplingModeThe post-process filtering mode
  70172. * @param engine The babylon engine
  70173. * @param reusable If the post-process is reusable
  70174. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70175. */
  70176. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70177. /**
  70178. * Returns the string "VolumetricLightScatteringPostProcess"
  70179. * @returns "VolumetricLightScatteringPostProcess"
  70180. */
  70181. getClassName(): string;
  70182. private _isReady;
  70183. /**
  70184. * Sets the new light position for light scattering effect
  70185. * @param position The new custom light position
  70186. */
  70187. setCustomMeshPosition(position: Vector3): void;
  70188. /**
  70189. * Returns the light position for light scattering effect
  70190. * @return Vector3 The custom light position
  70191. */
  70192. getCustomMeshPosition(): Vector3;
  70193. /**
  70194. * Disposes the internal assets and detaches the post-process from the camera
  70195. */
  70196. dispose(camera: Camera): void;
  70197. /**
  70198. * Returns the render target texture used by the post-process
  70199. * @return the render target texture used by the post-process
  70200. */
  70201. getPass(): RenderTargetTexture;
  70202. private _meshExcluded;
  70203. private _createPass;
  70204. private _updateMeshScreenCoordinates;
  70205. /**
  70206. * Creates a default mesh for the Volumeric Light Scattering post-process
  70207. * @param name The mesh name
  70208. * @param scene The scene where to create the mesh
  70209. * @return the default mesh
  70210. */
  70211. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70212. }
  70213. }
  70214. declare module "babylonjs/PostProcesses/index" {
  70215. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70216. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70217. export * from "babylonjs/PostProcesses/bloomEffect";
  70218. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70219. export * from "babylonjs/PostProcesses/blurPostProcess";
  70220. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70221. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70222. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70223. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70224. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70225. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70226. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70227. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70228. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70229. export * from "babylonjs/PostProcesses/filterPostProcess";
  70230. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70231. export * from "babylonjs/PostProcesses/grainPostProcess";
  70232. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70233. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70234. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70235. export * from "babylonjs/PostProcesses/passPostProcess";
  70236. export * from "babylonjs/PostProcesses/postProcess";
  70237. export * from "babylonjs/PostProcesses/postProcessManager";
  70238. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70239. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70240. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70241. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70242. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70243. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70244. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70245. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70246. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70247. }
  70248. declare module "babylonjs/Probes/index" {
  70249. export * from "babylonjs/Probes/reflectionProbe";
  70250. }
  70251. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70252. import { Scene } from "babylonjs/scene";
  70253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70254. import { SmartArray } from "babylonjs/Misc/smartArray";
  70255. import { ISceneComponent } from "babylonjs/sceneComponent";
  70256. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70257. import "babylonjs/Meshes/Builders/boxBuilder";
  70258. import "babylonjs/Shaders/color.fragment";
  70259. import "babylonjs/Shaders/color.vertex";
  70260. import { Color3 } from "babylonjs/Maths/math.color";
  70261. module "babylonjs/scene" {
  70262. interface Scene {
  70263. /** @hidden (Backing field) */
  70264. _boundingBoxRenderer: BoundingBoxRenderer;
  70265. /** @hidden (Backing field) */
  70266. _forceShowBoundingBoxes: boolean;
  70267. /**
  70268. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70269. */
  70270. forceShowBoundingBoxes: boolean;
  70271. /**
  70272. * Gets the bounding box renderer associated with the scene
  70273. * @returns a BoundingBoxRenderer
  70274. */
  70275. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70276. }
  70277. }
  70278. module "babylonjs/Meshes/abstractMesh" {
  70279. interface AbstractMesh {
  70280. /** @hidden (Backing field) */
  70281. _showBoundingBox: boolean;
  70282. /**
  70283. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70284. */
  70285. showBoundingBox: boolean;
  70286. }
  70287. }
  70288. /**
  70289. * Component responsible of rendering the bounding box of the meshes in a scene.
  70290. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70291. */
  70292. export class BoundingBoxRenderer implements ISceneComponent {
  70293. /**
  70294. * The component name helpfull to identify the component in the list of scene components.
  70295. */
  70296. readonly name: string;
  70297. /**
  70298. * The scene the component belongs to.
  70299. */
  70300. scene: Scene;
  70301. /**
  70302. * Color of the bounding box lines placed in front of an object
  70303. */
  70304. frontColor: Color3;
  70305. /**
  70306. * Color of the bounding box lines placed behind an object
  70307. */
  70308. backColor: Color3;
  70309. /**
  70310. * Defines if the renderer should show the back lines or not
  70311. */
  70312. showBackLines: boolean;
  70313. /**
  70314. * @hidden
  70315. */
  70316. renderList: SmartArray<BoundingBox>;
  70317. private _colorShader;
  70318. private _vertexBuffers;
  70319. private _indexBuffer;
  70320. private _fillIndexBuffer;
  70321. private _fillIndexData;
  70322. /**
  70323. * Instantiates a new bounding box renderer in a scene.
  70324. * @param scene the scene the renderer renders in
  70325. */
  70326. constructor(scene: Scene);
  70327. /**
  70328. * Registers the component in a given scene
  70329. */
  70330. register(): void;
  70331. private _evaluateSubMesh;
  70332. private _activeMesh;
  70333. private _prepareRessources;
  70334. private _createIndexBuffer;
  70335. /**
  70336. * Rebuilds the elements related to this component in case of
  70337. * context lost for instance.
  70338. */
  70339. rebuild(): void;
  70340. /**
  70341. * @hidden
  70342. */
  70343. reset(): void;
  70344. /**
  70345. * Render the bounding boxes of a specific rendering group
  70346. * @param renderingGroupId defines the rendering group to render
  70347. */
  70348. render(renderingGroupId: number): void;
  70349. /**
  70350. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70351. * @param mesh Define the mesh to render the occlusion bounding box for
  70352. */
  70353. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70354. /**
  70355. * Dispose and release the resources attached to this renderer.
  70356. */
  70357. dispose(): void;
  70358. }
  70359. }
  70360. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70361. import { Nullable } from "babylonjs/types";
  70362. import { Scene } from "babylonjs/scene";
  70363. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70364. import { Camera } from "babylonjs/Cameras/camera";
  70365. import { ISceneComponent } from "babylonjs/sceneComponent";
  70366. module "babylonjs/scene" {
  70367. interface Scene {
  70368. /** @hidden (Backing field) */
  70369. _depthRenderer: {
  70370. [id: string]: DepthRenderer;
  70371. };
  70372. /**
  70373. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70374. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70375. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70376. * @returns the created depth renderer
  70377. */
  70378. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70379. /**
  70380. * Disables a depth renderer for a given camera
  70381. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70382. */
  70383. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70384. }
  70385. }
  70386. /**
  70387. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70388. * in several rendering techniques.
  70389. */
  70390. export class DepthRendererSceneComponent implements ISceneComponent {
  70391. /**
  70392. * The component name helpfull to identify the component in the list of scene components.
  70393. */
  70394. readonly name: string;
  70395. /**
  70396. * The scene the component belongs to.
  70397. */
  70398. scene: Scene;
  70399. /**
  70400. * Creates a new instance of the component for the given scene
  70401. * @param scene Defines the scene to register the component in
  70402. */
  70403. constructor(scene: Scene);
  70404. /**
  70405. * Registers the component in a given scene
  70406. */
  70407. register(): void;
  70408. /**
  70409. * Rebuilds the elements related to this component in case of
  70410. * context lost for instance.
  70411. */
  70412. rebuild(): void;
  70413. /**
  70414. * Disposes the component and the associated ressources
  70415. */
  70416. dispose(): void;
  70417. private _gatherRenderTargets;
  70418. private _gatherActiveCameraRenderTargets;
  70419. }
  70420. }
  70421. declare module "babylonjs/Shaders/outline.fragment" {
  70422. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70423. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70424. /** @hidden */
  70425. export var outlinePixelShader: {
  70426. name: string;
  70427. shader: string;
  70428. };
  70429. }
  70430. declare module "babylonjs/Shaders/outline.vertex" {
  70431. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70434. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70435. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70437. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70438. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70439. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70440. /** @hidden */
  70441. export var outlineVertexShader: {
  70442. name: string;
  70443. shader: string;
  70444. };
  70445. }
  70446. declare module "babylonjs/Rendering/outlineRenderer" {
  70447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70448. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70449. import { Scene } from "babylonjs/scene";
  70450. import { ISceneComponent } from "babylonjs/sceneComponent";
  70451. import "babylonjs/Shaders/outline.fragment";
  70452. import "babylonjs/Shaders/outline.vertex";
  70453. module "babylonjs/scene" {
  70454. interface Scene {
  70455. /** @hidden */
  70456. _outlineRenderer: OutlineRenderer;
  70457. /**
  70458. * Gets the outline renderer associated with the scene
  70459. * @returns a OutlineRenderer
  70460. */
  70461. getOutlineRenderer(): OutlineRenderer;
  70462. }
  70463. }
  70464. module "babylonjs/Meshes/abstractMesh" {
  70465. interface AbstractMesh {
  70466. /** @hidden (Backing field) */
  70467. _renderOutline: boolean;
  70468. /**
  70469. * Gets or sets a boolean indicating if the outline must be rendered as well
  70470. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70471. */
  70472. renderOutline: boolean;
  70473. /** @hidden (Backing field) */
  70474. _renderOverlay: boolean;
  70475. /**
  70476. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70477. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70478. */
  70479. renderOverlay: boolean;
  70480. }
  70481. }
  70482. /**
  70483. * This class is responsible to draw bothe outline/overlay of meshes.
  70484. * It should not be used directly but through the available method on mesh.
  70485. */
  70486. export class OutlineRenderer implements ISceneComponent {
  70487. /**
  70488. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70489. */
  70490. private static _StencilReference;
  70491. /**
  70492. * The name of the component. Each component must have a unique name.
  70493. */
  70494. name: string;
  70495. /**
  70496. * The scene the component belongs to.
  70497. */
  70498. scene: Scene;
  70499. /**
  70500. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70501. */
  70502. zOffset: number;
  70503. private _engine;
  70504. private _effect;
  70505. private _cachedDefines;
  70506. private _savedDepthWrite;
  70507. /**
  70508. * Instantiates a new outline renderer. (There could be only one per scene).
  70509. * @param scene Defines the scene it belongs to
  70510. */
  70511. constructor(scene: Scene);
  70512. /**
  70513. * Register the component to one instance of a scene.
  70514. */
  70515. register(): void;
  70516. /**
  70517. * Rebuilds the elements related to this component in case of
  70518. * context lost for instance.
  70519. */
  70520. rebuild(): void;
  70521. /**
  70522. * Disposes the component and the associated ressources.
  70523. */
  70524. dispose(): void;
  70525. /**
  70526. * Renders the outline in the canvas.
  70527. * @param subMesh Defines the sumesh to render
  70528. * @param batch Defines the batch of meshes in case of instances
  70529. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70530. */
  70531. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70532. /**
  70533. * Returns whether or not the outline renderer is ready for a given submesh.
  70534. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70535. * @param subMesh Defines the submesh to check readyness for
  70536. * @param useInstances Defines wheter wee are trying to render instances or not
  70537. * @returns true if ready otherwise false
  70538. */
  70539. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70540. private _beforeRenderingMesh;
  70541. private _afterRenderingMesh;
  70542. }
  70543. }
  70544. declare module "babylonjs/Rendering/index" {
  70545. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70546. export * from "babylonjs/Rendering/depthRenderer";
  70547. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70548. export * from "babylonjs/Rendering/edgesRenderer";
  70549. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70550. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70551. export * from "babylonjs/Rendering/outlineRenderer";
  70552. export * from "babylonjs/Rendering/renderingGroup";
  70553. export * from "babylonjs/Rendering/renderingManager";
  70554. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70555. }
  70556. declare module "babylonjs/Sprites/ISprites" {
  70557. /**
  70558. * Defines the basic options interface of a Sprite Frame Source Size.
  70559. */
  70560. export interface ISpriteJSONSpriteSourceSize {
  70561. /**
  70562. * number of the original width of the Frame
  70563. */
  70564. w: number;
  70565. /**
  70566. * number of the original height of the Frame
  70567. */
  70568. h: number;
  70569. }
  70570. /**
  70571. * Defines the basic options interface of a Sprite Frame Data.
  70572. */
  70573. export interface ISpriteJSONSpriteFrameData {
  70574. /**
  70575. * number of the x offset of the Frame
  70576. */
  70577. x: number;
  70578. /**
  70579. * number of the y offset of the Frame
  70580. */
  70581. y: number;
  70582. /**
  70583. * number of the width of the Frame
  70584. */
  70585. w: number;
  70586. /**
  70587. * number of the height of the Frame
  70588. */
  70589. h: number;
  70590. }
  70591. /**
  70592. * Defines the basic options interface of a JSON Sprite.
  70593. */
  70594. export interface ISpriteJSONSprite {
  70595. /**
  70596. * string name of the Frame
  70597. */
  70598. filename: string;
  70599. /**
  70600. * ISpriteJSONSpriteFrame basic object of the frame data
  70601. */
  70602. frame: ISpriteJSONSpriteFrameData;
  70603. /**
  70604. * boolean to flag is the frame was rotated.
  70605. */
  70606. rotated: boolean;
  70607. /**
  70608. * boolean to flag is the frame was trimmed.
  70609. */
  70610. trimmed: boolean;
  70611. /**
  70612. * ISpriteJSONSpriteFrame basic object of the source data
  70613. */
  70614. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70615. /**
  70616. * ISpriteJSONSpriteFrame basic object of the source data
  70617. */
  70618. sourceSize: ISpriteJSONSpriteSourceSize;
  70619. }
  70620. /**
  70621. * Defines the basic options interface of a JSON atlas.
  70622. */
  70623. export interface ISpriteJSONAtlas {
  70624. /**
  70625. * Array of objects that contain the frame data.
  70626. */
  70627. frames: Array<ISpriteJSONSprite>;
  70628. /**
  70629. * object basic object containing the sprite meta data.
  70630. */
  70631. meta?: object;
  70632. }
  70633. }
  70634. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70635. /** @hidden */
  70636. export var spriteMapPixelShader: {
  70637. name: string;
  70638. shader: string;
  70639. };
  70640. }
  70641. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70642. /** @hidden */
  70643. export var spriteMapVertexShader: {
  70644. name: string;
  70645. shader: string;
  70646. };
  70647. }
  70648. declare module "babylonjs/Sprites/spriteMap" {
  70649. import { IDisposable, Scene } from "babylonjs/scene";
  70650. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70651. import { Texture } from "babylonjs/Materials/Textures/texture";
  70652. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70653. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70654. import "babylonjs/Meshes/Builders/planeBuilder";
  70655. import "babylonjs/Shaders/spriteMap.fragment";
  70656. import "babylonjs/Shaders/spriteMap.vertex";
  70657. /**
  70658. * Defines the basic options interface of a SpriteMap
  70659. */
  70660. export interface ISpriteMapOptions {
  70661. /**
  70662. * Vector2 of the number of cells in the grid.
  70663. */
  70664. stageSize?: Vector2;
  70665. /**
  70666. * Vector2 of the size of the output plane in World Units.
  70667. */
  70668. outputSize?: Vector2;
  70669. /**
  70670. * Vector3 of the position of the output plane in World Units.
  70671. */
  70672. outputPosition?: Vector3;
  70673. /**
  70674. * Vector3 of the rotation of the output plane.
  70675. */
  70676. outputRotation?: Vector3;
  70677. /**
  70678. * number of layers that the system will reserve in resources.
  70679. */
  70680. layerCount?: number;
  70681. /**
  70682. * number of max animation frames a single cell will reserve in resources.
  70683. */
  70684. maxAnimationFrames?: number;
  70685. /**
  70686. * number cell index of the base tile when the system compiles.
  70687. */
  70688. baseTile?: number;
  70689. /**
  70690. * boolean flip the sprite after its been repositioned by the framing data.
  70691. */
  70692. flipU?: boolean;
  70693. /**
  70694. * Vector3 scalar of the global RGB values of the SpriteMap.
  70695. */
  70696. colorMultiply?: Vector3;
  70697. }
  70698. /**
  70699. * Defines the IDisposable interface in order to be cleanable from resources.
  70700. */
  70701. export interface ISpriteMap extends IDisposable {
  70702. /**
  70703. * String name of the SpriteMap.
  70704. */
  70705. name: string;
  70706. /**
  70707. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70708. */
  70709. atlasJSON: ISpriteJSONAtlas;
  70710. /**
  70711. * Texture of the SpriteMap.
  70712. */
  70713. spriteSheet: Texture;
  70714. /**
  70715. * The parameters to initialize the SpriteMap with.
  70716. */
  70717. options: ISpriteMapOptions;
  70718. }
  70719. /**
  70720. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70721. */
  70722. export class SpriteMap implements ISpriteMap {
  70723. /** The Name of the spriteMap */
  70724. name: string;
  70725. /** The JSON file with the frame and meta data */
  70726. atlasJSON: ISpriteJSONAtlas;
  70727. /** The systems Sprite Sheet Texture */
  70728. spriteSheet: Texture;
  70729. /** Arguments passed with the Constructor */
  70730. options: ISpriteMapOptions;
  70731. /** Public Sprite Storage array, parsed from atlasJSON */
  70732. sprites: Array<ISpriteJSONSprite>;
  70733. /** Returns the Number of Sprites in the System */
  70734. get spriteCount(): number;
  70735. /** Returns the Position of Output Plane*/
  70736. get position(): Vector3;
  70737. /** Returns the Position of Output Plane*/
  70738. set position(v: Vector3);
  70739. /** Returns the Rotation of Output Plane*/
  70740. get rotation(): Vector3;
  70741. /** Returns the Rotation of Output Plane*/
  70742. set rotation(v: Vector3);
  70743. /** Sets the AnimationMap*/
  70744. get animationMap(): RawTexture;
  70745. /** Sets the AnimationMap*/
  70746. set animationMap(v: RawTexture);
  70747. /** Scene that the SpriteMap was created in */
  70748. private _scene;
  70749. /** Texture Buffer of Float32 that holds tile frame data*/
  70750. private _frameMap;
  70751. /** Texture Buffers of Float32 that holds tileMap data*/
  70752. private _tileMaps;
  70753. /** Texture Buffer of Float32 that holds Animation Data*/
  70754. private _animationMap;
  70755. /** Custom ShaderMaterial Central to the System*/
  70756. private _material;
  70757. /** Custom ShaderMaterial Central to the System*/
  70758. private _output;
  70759. /** Systems Time Ticker*/
  70760. private _time;
  70761. /**
  70762. * Creates a new SpriteMap
  70763. * @param name defines the SpriteMaps Name
  70764. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70765. * @param spriteSheet is the Texture that the Sprites are on.
  70766. * @param options a basic deployment configuration
  70767. * @param scene The Scene that the map is deployed on
  70768. */
  70769. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70770. /**
  70771. * Returns tileID location
  70772. * @returns Vector2 the cell position ID
  70773. */
  70774. getTileID(): Vector2;
  70775. /**
  70776. * Gets the UV location of the mouse over the SpriteMap.
  70777. * @returns Vector2 the UV position of the mouse interaction
  70778. */
  70779. getMousePosition(): Vector2;
  70780. /**
  70781. * Creates the "frame" texture Buffer
  70782. * -------------------------------------
  70783. * Structure of frames
  70784. * "filename": "Falling-Water-2.png",
  70785. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70786. * "rotated": true,
  70787. * "trimmed": true,
  70788. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70789. * "sourceSize": {"w":32,"h":32}
  70790. * @returns RawTexture of the frameMap
  70791. */
  70792. private _createFrameBuffer;
  70793. /**
  70794. * Creates the tileMap texture Buffer
  70795. * @param buffer normally and array of numbers, or a false to generate from scratch
  70796. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70797. * @returns RawTexture of the tileMap
  70798. */
  70799. private _createTileBuffer;
  70800. /**
  70801. * Modifies the data of the tileMaps
  70802. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70803. * @param pos is the iVector2 Coordinates of the Tile
  70804. * @param tile The SpriteIndex of the new Tile
  70805. */
  70806. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70807. /**
  70808. * Creates the animationMap texture Buffer
  70809. * @param buffer normally and array of numbers, or a false to generate from scratch
  70810. * @returns RawTexture of the animationMap
  70811. */
  70812. private _createTileAnimationBuffer;
  70813. /**
  70814. * Modifies the data of the animationMap
  70815. * @param cellID is the Index of the Sprite
  70816. * @param _frame is the target Animation frame
  70817. * @param toCell is the Target Index of the next frame of the animation
  70818. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70819. * @param speed is a global scalar of the time variable on the map.
  70820. */
  70821. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70822. /**
  70823. * Exports the .tilemaps file
  70824. */
  70825. saveTileMaps(): void;
  70826. /**
  70827. * Imports the .tilemaps file
  70828. * @param url of the .tilemaps file
  70829. */
  70830. loadTileMaps(url: string): void;
  70831. /**
  70832. * Release associated resources
  70833. */
  70834. dispose(): void;
  70835. }
  70836. }
  70837. declare module "babylonjs/Sprites/spritePackedManager" {
  70838. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70839. import { Scene } from "babylonjs/scene";
  70840. /**
  70841. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70842. * @see http://doc.babylonjs.com/babylon101/sprites
  70843. */
  70844. export class SpritePackedManager extends SpriteManager {
  70845. /** defines the packed manager's name */
  70846. name: string;
  70847. /**
  70848. * Creates a new sprite manager from a packed sprite sheet
  70849. * @param name defines the manager's name
  70850. * @param imgUrl defines the sprite sheet url
  70851. * @param capacity defines the maximum allowed number of sprites
  70852. * @param scene defines the hosting scene
  70853. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70854. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70855. * @param samplingMode defines the smapling mode to use with spritesheet
  70856. * @param fromPacked set to true; do not alter
  70857. */
  70858. constructor(
  70859. /** defines the packed manager's name */
  70860. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70861. }
  70862. }
  70863. declare module "babylonjs/Sprites/index" {
  70864. export * from "babylonjs/Sprites/sprite";
  70865. export * from "babylonjs/Sprites/ISprites";
  70866. export * from "babylonjs/Sprites/spriteManager";
  70867. export * from "babylonjs/Sprites/spriteMap";
  70868. export * from "babylonjs/Sprites/spritePackedManager";
  70869. export * from "babylonjs/Sprites/spriteSceneComponent";
  70870. }
  70871. declare module "babylonjs/States/index" {
  70872. export * from "babylonjs/States/alphaCullingState";
  70873. export * from "babylonjs/States/depthCullingState";
  70874. export * from "babylonjs/States/stencilState";
  70875. }
  70876. declare module "babylonjs/Misc/assetsManager" {
  70877. import { Scene } from "babylonjs/scene";
  70878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70879. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70880. import { Skeleton } from "babylonjs/Bones/skeleton";
  70881. import { Observable } from "babylonjs/Misc/observable";
  70882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70883. import { Texture } from "babylonjs/Materials/Textures/texture";
  70884. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70885. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70886. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70887. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70888. /**
  70889. * Defines the list of states available for a task inside a AssetsManager
  70890. */
  70891. export enum AssetTaskState {
  70892. /**
  70893. * Initialization
  70894. */
  70895. INIT = 0,
  70896. /**
  70897. * Running
  70898. */
  70899. RUNNING = 1,
  70900. /**
  70901. * Done
  70902. */
  70903. DONE = 2,
  70904. /**
  70905. * Error
  70906. */
  70907. ERROR = 3
  70908. }
  70909. /**
  70910. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70911. */
  70912. export abstract class AbstractAssetTask {
  70913. /**
  70914. * Task name
  70915. */ name: string;
  70916. /**
  70917. * Callback called when the task is successful
  70918. */
  70919. onSuccess: (task: any) => void;
  70920. /**
  70921. * Callback called when the task is not successful
  70922. */
  70923. onError: (task: any, message?: string, exception?: any) => void;
  70924. /**
  70925. * Creates a new AssetsManager
  70926. * @param name defines the name of the task
  70927. */
  70928. constructor(
  70929. /**
  70930. * Task name
  70931. */ name: string);
  70932. private _isCompleted;
  70933. private _taskState;
  70934. private _errorObject;
  70935. /**
  70936. * Get if the task is completed
  70937. */
  70938. get isCompleted(): boolean;
  70939. /**
  70940. * Gets the current state of the task
  70941. */
  70942. get taskState(): AssetTaskState;
  70943. /**
  70944. * Gets the current error object (if task is in error)
  70945. */
  70946. get errorObject(): {
  70947. message?: string;
  70948. exception?: any;
  70949. };
  70950. /**
  70951. * Internal only
  70952. * @hidden
  70953. */
  70954. _setErrorObject(message?: string, exception?: any): void;
  70955. /**
  70956. * Execute the current task
  70957. * @param scene defines the scene where you want your assets to be loaded
  70958. * @param onSuccess is a callback called when the task is successfully executed
  70959. * @param onError is a callback called if an error occurs
  70960. */
  70961. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70962. /**
  70963. * Execute the current task
  70964. * @param scene defines the scene where you want your assets to be loaded
  70965. * @param onSuccess is a callback called when the task is successfully executed
  70966. * @param onError is a callback called if an error occurs
  70967. */
  70968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70969. /**
  70970. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70971. * This can be used with failed tasks that have the reason for failure fixed.
  70972. */
  70973. reset(): void;
  70974. private onErrorCallback;
  70975. private onDoneCallback;
  70976. }
  70977. /**
  70978. * Define the interface used by progress events raised during assets loading
  70979. */
  70980. export interface IAssetsProgressEvent {
  70981. /**
  70982. * Defines the number of remaining tasks to process
  70983. */
  70984. remainingCount: number;
  70985. /**
  70986. * Defines the total number of tasks
  70987. */
  70988. totalCount: number;
  70989. /**
  70990. * Defines the task that was just processed
  70991. */
  70992. task: AbstractAssetTask;
  70993. }
  70994. /**
  70995. * Class used to share progress information about assets loading
  70996. */
  70997. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70998. /**
  70999. * Defines the number of remaining tasks to process
  71000. */
  71001. remainingCount: number;
  71002. /**
  71003. * Defines the total number of tasks
  71004. */
  71005. totalCount: number;
  71006. /**
  71007. * Defines the task that was just processed
  71008. */
  71009. task: AbstractAssetTask;
  71010. /**
  71011. * Creates a AssetsProgressEvent
  71012. * @param remainingCount defines the number of remaining tasks to process
  71013. * @param totalCount defines the total number of tasks
  71014. * @param task defines the task that was just processed
  71015. */
  71016. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71017. }
  71018. /**
  71019. * Define a task used by AssetsManager to load meshes
  71020. */
  71021. export class MeshAssetTask extends AbstractAssetTask {
  71022. /**
  71023. * Defines the name of the task
  71024. */
  71025. name: string;
  71026. /**
  71027. * Defines the list of mesh's names you want to load
  71028. */
  71029. meshesNames: any;
  71030. /**
  71031. * Defines the root url to use as a base to load your meshes and associated resources
  71032. */
  71033. rootUrl: string;
  71034. /**
  71035. * Defines the filename of the scene to load from
  71036. */
  71037. sceneFilename: string;
  71038. /**
  71039. * Gets the list of loaded meshes
  71040. */
  71041. loadedMeshes: Array<AbstractMesh>;
  71042. /**
  71043. * Gets the list of loaded particle systems
  71044. */
  71045. loadedParticleSystems: Array<IParticleSystem>;
  71046. /**
  71047. * Gets the list of loaded skeletons
  71048. */
  71049. loadedSkeletons: Array<Skeleton>;
  71050. /**
  71051. * Gets the list of loaded animation groups
  71052. */
  71053. loadedAnimationGroups: Array<AnimationGroup>;
  71054. /**
  71055. * Callback called when the task is successful
  71056. */
  71057. onSuccess: (task: MeshAssetTask) => void;
  71058. /**
  71059. * Callback called when the task is successful
  71060. */
  71061. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71062. /**
  71063. * Creates a new MeshAssetTask
  71064. * @param name defines the name of the task
  71065. * @param meshesNames defines the list of mesh's names you want to load
  71066. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71067. * @param sceneFilename defines the filename of the scene to load from
  71068. */
  71069. constructor(
  71070. /**
  71071. * Defines the name of the task
  71072. */
  71073. name: string,
  71074. /**
  71075. * Defines the list of mesh's names you want to load
  71076. */
  71077. meshesNames: any,
  71078. /**
  71079. * Defines the root url to use as a base to load your meshes and associated resources
  71080. */
  71081. rootUrl: string,
  71082. /**
  71083. * Defines the filename of the scene to load from
  71084. */
  71085. sceneFilename: string);
  71086. /**
  71087. * Execute the current task
  71088. * @param scene defines the scene where you want your assets to be loaded
  71089. * @param onSuccess is a callback called when the task is successfully executed
  71090. * @param onError is a callback called if an error occurs
  71091. */
  71092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71093. }
  71094. /**
  71095. * Define a task used by AssetsManager to load text content
  71096. */
  71097. export class TextFileAssetTask extends AbstractAssetTask {
  71098. /**
  71099. * Defines the name of the task
  71100. */
  71101. name: string;
  71102. /**
  71103. * Defines the location of the file to load
  71104. */
  71105. url: string;
  71106. /**
  71107. * Gets the loaded text string
  71108. */
  71109. text: string;
  71110. /**
  71111. * Callback called when the task is successful
  71112. */
  71113. onSuccess: (task: TextFileAssetTask) => void;
  71114. /**
  71115. * Callback called when the task is successful
  71116. */
  71117. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71118. /**
  71119. * Creates a new TextFileAssetTask object
  71120. * @param name defines the name of the task
  71121. * @param url defines the location of the file to load
  71122. */
  71123. constructor(
  71124. /**
  71125. * Defines the name of the task
  71126. */
  71127. name: string,
  71128. /**
  71129. * Defines the location of the file to load
  71130. */
  71131. url: string);
  71132. /**
  71133. * Execute the current task
  71134. * @param scene defines the scene where you want your assets to be loaded
  71135. * @param onSuccess is a callback called when the task is successfully executed
  71136. * @param onError is a callback called if an error occurs
  71137. */
  71138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71139. }
  71140. /**
  71141. * Define a task used by AssetsManager to load binary data
  71142. */
  71143. export class BinaryFileAssetTask extends AbstractAssetTask {
  71144. /**
  71145. * Defines the name of the task
  71146. */
  71147. name: string;
  71148. /**
  71149. * Defines the location of the file to load
  71150. */
  71151. url: string;
  71152. /**
  71153. * Gets the lodaded data (as an array buffer)
  71154. */
  71155. data: ArrayBuffer;
  71156. /**
  71157. * Callback called when the task is successful
  71158. */
  71159. onSuccess: (task: BinaryFileAssetTask) => void;
  71160. /**
  71161. * Callback called when the task is successful
  71162. */
  71163. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71164. /**
  71165. * Creates a new BinaryFileAssetTask object
  71166. * @param name defines the name of the new task
  71167. * @param url defines the location of the file to load
  71168. */
  71169. constructor(
  71170. /**
  71171. * Defines the name of the task
  71172. */
  71173. name: string,
  71174. /**
  71175. * Defines the location of the file to load
  71176. */
  71177. url: string);
  71178. /**
  71179. * Execute the current task
  71180. * @param scene defines the scene where you want your assets to be loaded
  71181. * @param onSuccess is a callback called when the task is successfully executed
  71182. * @param onError is a callback called if an error occurs
  71183. */
  71184. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71185. }
  71186. /**
  71187. * Define a task used by AssetsManager to load images
  71188. */
  71189. export class ImageAssetTask extends AbstractAssetTask {
  71190. /**
  71191. * Defines the name of the task
  71192. */
  71193. name: string;
  71194. /**
  71195. * Defines the location of the image to load
  71196. */
  71197. url: string;
  71198. /**
  71199. * Gets the loaded images
  71200. */
  71201. image: HTMLImageElement;
  71202. /**
  71203. * Callback called when the task is successful
  71204. */
  71205. onSuccess: (task: ImageAssetTask) => void;
  71206. /**
  71207. * Callback called when the task is successful
  71208. */
  71209. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71210. /**
  71211. * Creates a new ImageAssetTask
  71212. * @param name defines the name of the task
  71213. * @param url defines the location of the image to load
  71214. */
  71215. constructor(
  71216. /**
  71217. * Defines the name of the task
  71218. */
  71219. name: string,
  71220. /**
  71221. * Defines the location of the image to load
  71222. */
  71223. url: string);
  71224. /**
  71225. * Execute the current task
  71226. * @param scene defines the scene where you want your assets to be loaded
  71227. * @param onSuccess is a callback called when the task is successfully executed
  71228. * @param onError is a callback called if an error occurs
  71229. */
  71230. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71231. }
  71232. /**
  71233. * Defines the interface used by texture loading tasks
  71234. */
  71235. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71236. /**
  71237. * Gets the loaded texture
  71238. */
  71239. texture: TEX;
  71240. }
  71241. /**
  71242. * Define a task used by AssetsManager to load 2D textures
  71243. */
  71244. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71245. /**
  71246. * Defines the name of the task
  71247. */
  71248. name: string;
  71249. /**
  71250. * Defines the location of the file to load
  71251. */
  71252. url: string;
  71253. /**
  71254. * Defines if mipmap should not be generated (default is false)
  71255. */
  71256. noMipmap?: boolean | undefined;
  71257. /**
  71258. * Defines if texture must be inverted on Y axis (default is false)
  71259. */
  71260. invertY?: boolean | undefined;
  71261. /**
  71262. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71263. */
  71264. samplingMode: number;
  71265. /**
  71266. * Gets the loaded texture
  71267. */
  71268. texture: Texture;
  71269. /**
  71270. * Callback called when the task is successful
  71271. */
  71272. onSuccess: (task: TextureAssetTask) => void;
  71273. /**
  71274. * Callback called when the task is successful
  71275. */
  71276. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71277. /**
  71278. * Creates a new TextureAssetTask object
  71279. * @param name defines the name of the task
  71280. * @param url defines the location of the file to load
  71281. * @param noMipmap defines if mipmap should not be generated (default is false)
  71282. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71283. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71284. */
  71285. constructor(
  71286. /**
  71287. * Defines the name of the task
  71288. */
  71289. name: string,
  71290. /**
  71291. * Defines the location of the file to load
  71292. */
  71293. url: string,
  71294. /**
  71295. * Defines if mipmap should not be generated (default is false)
  71296. */
  71297. noMipmap?: boolean | undefined,
  71298. /**
  71299. * Defines if texture must be inverted on Y axis (default is false)
  71300. */
  71301. invertY?: boolean | undefined,
  71302. /**
  71303. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71304. */
  71305. samplingMode?: number);
  71306. /**
  71307. * Execute the current task
  71308. * @param scene defines the scene where you want your assets to be loaded
  71309. * @param onSuccess is a callback called when the task is successfully executed
  71310. * @param onError is a callback called if an error occurs
  71311. */
  71312. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71313. }
  71314. /**
  71315. * Define a task used by AssetsManager to load cube textures
  71316. */
  71317. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71318. /**
  71319. * Defines the name of the task
  71320. */
  71321. name: string;
  71322. /**
  71323. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71324. */
  71325. url: string;
  71326. /**
  71327. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71328. */
  71329. extensions?: string[] | undefined;
  71330. /**
  71331. * Defines if mipmaps should not be generated (default is false)
  71332. */
  71333. noMipmap?: boolean | undefined;
  71334. /**
  71335. * Defines the explicit list of files (undefined by default)
  71336. */
  71337. files?: string[] | undefined;
  71338. /**
  71339. * Gets the loaded texture
  71340. */
  71341. texture: CubeTexture;
  71342. /**
  71343. * Callback called when the task is successful
  71344. */
  71345. onSuccess: (task: CubeTextureAssetTask) => void;
  71346. /**
  71347. * Callback called when the task is successful
  71348. */
  71349. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71350. /**
  71351. * Creates a new CubeTextureAssetTask
  71352. * @param name defines the name of the task
  71353. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71354. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71355. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71356. * @param files defines the explicit list of files (undefined by default)
  71357. */
  71358. constructor(
  71359. /**
  71360. * Defines the name of the task
  71361. */
  71362. name: string,
  71363. /**
  71364. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71365. */
  71366. url: string,
  71367. /**
  71368. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71369. */
  71370. extensions?: string[] | undefined,
  71371. /**
  71372. * Defines if mipmaps should not be generated (default is false)
  71373. */
  71374. noMipmap?: boolean | undefined,
  71375. /**
  71376. * Defines the explicit list of files (undefined by default)
  71377. */
  71378. files?: string[] | undefined);
  71379. /**
  71380. * Execute the current task
  71381. * @param scene defines the scene where you want your assets to be loaded
  71382. * @param onSuccess is a callback called when the task is successfully executed
  71383. * @param onError is a callback called if an error occurs
  71384. */
  71385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71386. }
  71387. /**
  71388. * Define a task used by AssetsManager to load HDR cube textures
  71389. */
  71390. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71391. /**
  71392. * Defines the name of the task
  71393. */
  71394. name: string;
  71395. /**
  71396. * Defines the location of the file to load
  71397. */
  71398. url: string;
  71399. /**
  71400. * Defines the desired size (the more it increases the longer the generation will be)
  71401. */
  71402. size: number;
  71403. /**
  71404. * Defines if mipmaps should not be generated (default is false)
  71405. */
  71406. noMipmap: boolean;
  71407. /**
  71408. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71409. */
  71410. generateHarmonics: boolean;
  71411. /**
  71412. * 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)
  71413. */
  71414. gammaSpace: boolean;
  71415. /**
  71416. * Internal Use Only
  71417. */
  71418. reserved: boolean;
  71419. /**
  71420. * Gets the loaded texture
  71421. */
  71422. texture: HDRCubeTexture;
  71423. /**
  71424. * Callback called when the task is successful
  71425. */
  71426. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71427. /**
  71428. * Callback called when the task is successful
  71429. */
  71430. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71431. /**
  71432. * Creates a new HDRCubeTextureAssetTask object
  71433. * @param name defines the name of the task
  71434. * @param url defines the location of the file to load
  71435. * @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.
  71436. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71437. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71438. * @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)
  71439. * @param reserved Internal use only
  71440. */
  71441. constructor(
  71442. /**
  71443. * Defines the name of the task
  71444. */
  71445. name: string,
  71446. /**
  71447. * Defines the location of the file to load
  71448. */
  71449. url: string,
  71450. /**
  71451. * Defines the desired size (the more it increases the longer the generation will be)
  71452. */
  71453. size: number,
  71454. /**
  71455. * Defines if mipmaps should not be generated (default is false)
  71456. */
  71457. noMipmap?: boolean,
  71458. /**
  71459. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71460. */
  71461. generateHarmonics?: boolean,
  71462. /**
  71463. * 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)
  71464. */
  71465. gammaSpace?: boolean,
  71466. /**
  71467. * Internal Use Only
  71468. */
  71469. reserved?: boolean);
  71470. /**
  71471. * Execute the current task
  71472. * @param scene defines the scene where you want your assets to be loaded
  71473. * @param onSuccess is a callback called when the task is successfully executed
  71474. * @param onError is a callback called if an error occurs
  71475. */
  71476. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71477. }
  71478. /**
  71479. * Define a task used by AssetsManager to load Equirectangular cube textures
  71480. */
  71481. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71482. /**
  71483. * Defines the name of the task
  71484. */
  71485. name: string;
  71486. /**
  71487. * Defines the location of the file to load
  71488. */
  71489. url: string;
  71490. /**
  71491. * Defines the desired size (the more it increases the longer the generation will be)
  71492. */
  71493. size: number;
  71494. /**
  71495. * Defines if mipmaps should not be generated (default is false)
  71496. */
  71497. noMipmap: boolean;
  71498. /**
  71499. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71500. * but the standard material would require them in Gamma space) (default is true)
  71501. */
  71502. gammaSpace: boolean;
  71503. /**
  71504. * Gets the loaded texture
  71505. */
  71506. texture: EquiRectangularCubeTexture;
  71507. /**
  71508. * Callback called when the task is successful
  71509. */
  71510. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71511. /**
  71512. * Callback called when the task is successful
  71513. */
  71514. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71515. /**
  71516. * Creates a new EquiRectangularCubeTextureAssetTask object
  71517. * @param name defines the name of the task
  71518. * @param url defines the location of the file to load
  71519. * @param size defines the desired size (the more it increases the longer the generation will be)
  71520. * If the size is omitted this implies you are using a preprocessed cubemap.
  71521. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71522. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71523. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71524. * (default is true)
  71525. */
  71526. constructor(
  71527. /**
  71528. * Defines the name of the task
  71529. */
  71530. name: string,
  71531. /**
  71532. * Defines the location of the file to load
  71533. */
  71534. url: string,
  71535. /**
  71536. * Defines the desired size (the more it increases the longer the generation will be)
  71537. */
  71538. size: number,
  71539. /**
  71540. * Defines if mipmaps should not be generated (default is false)
  71541. */
  71542. noMipmap?: boolean,
  71543. /**
  71544. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71545. * but the standard material would require them in Gamma space) (default is true)
  71546. */
  71547. gammaSpace?: boolean);
  71548. /**
  71549. * Execute the current task
  71550. * @param scene defines the scene where you want your assets to be loaded
  71551. * @param onSuccess is a callback called when the task is successfully executed
  71552. * @param onError is a callback called if an error occurs
  71553. */
  71554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71555. }
  71556. /**
  71557. * This class can be used to easily import assets into a scene
  71558. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71559. */
  71560. export class AssetsManager {
  71561. private _scene;
  71562. private _isLoading;
  71563. protected _tasks: AbstractAssetTask[];
  71564. protected _waitingTasksCount: number;
  71565. protected _totalTasksCount: number;
  71566. /**
  71567. * Callback called when all tasks are processed
  71568. */
  71569. onFinish: (tasks: AbstractAssetTask[]) => void;
  71570. /**
  71571. * Callback called when a task is successful
  71572. */
  71573. onTaskSuccess: (task: AbstractAssetTask) => void;
  71574. /**
  71575. * Callback called when a task had an error
  71576. */
  71577. onTaskError: (task: AbstractAssetTask) => void;
  71578. /**
  71579. * Callback called when a task is done (whatever the result is)
  71580. */
  71581. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71582. /**
  71583. * Observable called when all tasks are processed
  71584. */
  71585. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71586. /**
  71587. * Observable called when a task had an error
  71588. */
  71589. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71590. /**
  71591. * Observable called when all tasks were executed
  71592. */
  71593. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71594. /**
  71595. * Observable called when a task is done (whatever the result is)
  71596. */
  71597. onProgressObservable: Observable<IAssetsProgressEvent>;
  71598. /**
  71599. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71600. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71601. */
  71602. useDefaultLoadingScreen: boolean;
  71603. /**
  71604. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71605. * when all assets have been downloaded.
  71606. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71607. */
  71608. autoHideLoadingUI: boolean;
  71609. /**
  71610. * Creates a new AssetsManager
  71611. * @param scene defines the scene to work on
  71612. */
  71613. constructor(scene: Scene);
  71614. /**
  71615. * Add a MeshAssetTask to the list of active tasks
  71616. * @param taskName defines the name of the new task
  71617. * @param meshesNames defines the name of meshes to load
  71618. * @param rootUrl defines the root url to use to locate files
  71619. * @param sceneFilename defines the filename of the scene file
  71620. * @returns a new MeshAssetTask object
  71621. */
  71622. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71623. /**
  71624. * Add a TextFileAssetTask to the list of active tasks
  71625. * @param taskName defines the name of the new task
  71626. * @param url defines the url of the file to load
  71627. * @returns a new TextFileAssetTask object
  71628. */
  71629. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71630. /**
  71631. * Add a BinaryFileAssetTask to the list of active tasks
  71632. * @param taskName defines the name of the new task
  71633. * @param url defines the url of the file to load
  71634. * @returns a new BinaryFileAssetTask object
  71635. */
  71636. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71637. /**
  71638. * Add a ImageAssetTask to the list of active tasks
  71639. * @param taskName defines the name of the new task
  71640. * @param url defines the url of the file to load
  71641. * @returns a new ImageAssetTask object
  71642. */
  71643. addImageTask(taskName: string, url: string): ImageAssetTask;
  71644. /**
  71645. * Add a TextureAssetTask to the list of active tasks
  71646. * @param taskName defines the name of the new task
  71647. * @param url defines the url of the file to load
  71648. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71649. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71650. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71651. * @returns a new TextureAssetTask object
  71652. */
  71653. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71654. /**
  71655. * Add a CubeTextureAssetTask to the list of active tasks
  71656. * @param taskName defines the name of the new task
  71657. * @param url defines the url of the file to load
  71658. * @param extensions defines the extension to use to load the cube map (can be null)
  71659. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71660. * @param files defines the list of files to load (can be null)
  71661. * @returns a new CubeTextureAssetTask object
  71662. */
  71663. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71664. /**
  71665. *
  71666. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71667. * @param taskName defines the name of the new task
  71668. * @param url defines the url of the file to load
  71669. * @param size defines the size you want for the cubemap (can be null)
  71670. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71671. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71672. * @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)
  71673. * @param reserved Internal use only
  71674. * @returns a new HDRCubeTextureAssetTask object
  71675. */
  71676. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71677. /**
  71678. *
  71679. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71680. * @param taskName defines the name of the new task
  71681. * @param url defines the url of the file to load
  71682. * @param size defines the size you want for the cubemap (can be null)
  71683. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71684. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71685. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71686. * @returns a new EquiRectangularCubeTextureAssetTask object
  71687. */
  71688. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71689. /**
  71690. * Remove a task from the assets manager.
  71691. * @param task the task to remove
  71692. */
  71693. removeTask(task: AbstractAssetTask): void;
  71694. private _decreaseWaitingTasksCount;
  71695. private _runTask;
  71696. /**
  71697. * Reset the AssetsManager and remove all tasks
  71698. * @return the current instance of the AssetsManager
  71699. */
  71700. reset(): AssetsManager;
  71701. /**
  71702. * Start the loading process
  71703. * @return the current instance of the AssetsManager
  71704. */
  71705. load(): AssetsManager;
  71706. /**
  71707. * Start the loading process as an async operation
  71708. * @return a promise returning the list of failed tasks
  71709. */
  71710. loadAsync(): Promise<void>;
  71711. }
  71712. }
  71713. declare module "babylonjs/Misc/deferred" {
  71714. /**
  71715. * Wrapper class for promise with external resolve and reject.
  71716. */
  71717. export class Deferred<T> {
  71718. /**
  71719. * The promise associated with this deferred object.
  71720. */
  71721. readonly promise: Promise<T>;
  71722. private _resolve;
  71723. private _reject;
  71724. /**
  71725. * The resolve method of the promise associated with this deferred object.
  71726. */
  71727. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71728. /**
  71729. * The reject method of the promise associated with this deferred object.
  71730. */
  71731. get reject(): (reason?: any) => void;
  71732. /**
  71733. * Constructor for this deferred object.
  71734. */
  71735. constructor();
  71736. }
  71737. }
  71738. declare module "babylonjs/Misc/meshExploder" {
  71739. import { Mesh } from "babylonjs/Meshes/mesh";
  71740. /**
  71741. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71742. */
  71743. export class MeshExploder {
  71744. private _centerMesh;
  71745. private _meshes;
  71746. private _meshesOrigins;
  71747. private _toCenterVectors;
  71748. private _scaledDirection;
  71749. private _newPosition;
  71750. private _centerPosition;
  71751. /**
  71752. * Explodes meshes from a center mesh.
  71753. * @param meshes The meshes to explode.
  71754. * @param centerMesh The mesh to be center of explosion.
  71755. */
  71756. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71757. private _setCenterMesh;
  71758. /**
  71759. * Get class name
  71760. * @returns "MeshExploder"
  71761. */
  71762. getClassName(): string;
  71763. /**
  71764. * "Exploded meshes"
  71765. * @returns Array of meshes with the centerMesh at index 0.
  71766. */
  71767. getMeshes(): Array<Mesh>;
  71768. /**
  71769. * Explodes meshes giving a specific direction
  71770. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71771. */
  71772. explode(direction?: number): void;
  71773. }
  71774. }
  71775. declare module "babylonjs/Misc/filesInput" {
  71776. import { Engine } from "babylonjs/Engines/engine";
  71777. import { Scene } from "babylonjs/scene";
  71778. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71779. /**
  71780. * Class used to help managing file picking and drag'n'drop
  71781. */
  71782. export class FilesInput {
  71783. /**
  71784. * List of files ready to be loaded
  71785. */
  71786. static get FilesToLoad(): {
  71787. [key: string]: File;
  71788. };
  71789. /**
  71790. * Callback called when a file is processed
  71791. */
  71792. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71793. private _engine;
  71794. private _currentScene;
  71795. private _sceneLoadedCallback;
  71796. private _progressCallback;
  71797. private _additionalRenderLoopLogicCallback;
  71798. private _textureLoadingCallback;
  71799. private _startingProcessingFilesCallback;
  71800. private _onReloadCallback;
  71801. private _errorCallback;
  71802. private _elementToMonitor;
  71803. private _sceneFileToLoad;
  71804. private _filesToLoad;
  71805. /**
  71806. * Creates a new FilesInput
  71807. * @param engine defines the rendering engine
  71808. * @param scene defines the hosting scene
  71809. * @param sceneLoadedCallback callback called when scene is loaded
  71810. * @param progressCallback callback called to track progress
  71811. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71812. * @param textureLoadingCallback callback called when a texture is loading
  71813. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71814. * @param onReloadCallback callback called when a reload is requested
  71815. * @param errorCallback callback call if an error occurs
  71816. */
  71817. 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);
  71818. private _dragEnterHandler;
  71819. private _dragOverHandler;
  71820. private _dropHandler;
  71821. /**
  71822. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71823. * @param elementToMonitor defines the DOM element to track
  71824. */
  71825. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71826. /**
  71827. * Release all associated resources
  71828. */
  71829. dispose(): void;
  71830. private renderFunction;
  71831. private drag;
  71832. private drop;
  71833. private _traverseFolder;
  71834. private _processFiles;
  71835. /**
  71836. * Load files from a drop event
  71837. * @param event defines the drop event to use as source
  71838. */
  71839. loadFiles(event: any): void;
  71840. private _processReload;
  71841. /**
  71842. * Reload the current scene from the loaded files
  71843. */
  71844. reload(): void;
  71845. }
  71846. }
  71847. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71848. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71849. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71850. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71851. }
  71852. declare module "babylonjs/Misc/sceneOptimizer" {
  71853. import { Scene, IDisposable } from "babylonjs/scene";
  71854. import { Observable } from "babylonjs/Misc/observable";
  71855. /**
  71856. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71857. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71858. */
  71859. export class SceneOptimization {
  71860. /**
  71861. * Defines the priority of this optimization (0 by default which means first in the list)
  71862. */
  71863. priority: number;
  71864. /**
  71865. * Gets a string describing the action executed by the current optimization
  71866. * @returns description string
  71867. */
  71868. getDescription(): string;
  71869. /**
  71870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71871. * @param scene defines the current scene where to apply this optimization
  71872. * @param optimizer defines the current optimizer
  71873. * @returns true if everything that can be done was applied
  71874. */
  71875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71876. /**
  71877. * Creates the SceneOptimization object
  71878. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71879. * @param desc defines the description associated with the optimization
  71880. */
  71881. constructor(
  71882. /**
  71883. * Defines the priority of this optimization (0 by default which means first in the list)
  71884. */
  71885. priority?: number);
  71886. }
  71887. /**
  71888. * Defines an optimization used to reduce the size of render target textures
  71889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71890. */
  71891. export class TextureOptimization extends SceneOptimization {
  71892. /**
  71893. * Defines the priority of this optimization (0 by default which means first in the list)
  71894. */
  71895. priority: number;
  71896. /**
  71897. * 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
  71898. */
  71899. maximumSize: number;
  71900. /**
  71901. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71902. */
  71903. step: number;
  71904. /**
  71905. * Gets a string describing the action executed by the current optimization
  71906. * @returns description string
  71907. */
  71908. getDescription(): string;
  71909. /**
  71910. * Creates the TextureOptimization object
  71911. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71912. * @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
  71913. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71914. */
  71915. constructor(
  71916. /**
  71917. * Defines the priority of this optimization (0 by default which means first in the list)
  71918. */
  71919. priority?: number,
  71920. /**
  71921. * 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
  71922. */
  71923. maximumSize?: number,
  71924. /**
  71925. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71926. */
  71927. step?: number);
  71928. /**
  71929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71930. * @param scene defines the current scene where to apply this optimization
  71931. * @param optimizer defines the current optimizer
  71932. * @returns true if everything that can be done was applied
  71933. */
  71934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71935. }
  71936. /**
  71937. * Defines an optimization used to increase or decrease the rendering resolution
  71938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71939. */
  71940. export class HardwareScalingOptimization extends SceneOptimization {
  71941. /**
  71942. * Defines the priority of this optimization (0 by default which means first in the list)
  71943. */
  71944. priority: number;
  71945. /**
  71946. * Defines the maximum scale to use (2 by default)
  71947. */
  71948. maximumScale: number;
  71949. /**
  71950. * Defines the step to use between two passes (0.5 by default)
  71951. */
  71952. step: number;
  71953. private _currentScale;
  71954. private _directionOffset;
  71955. /**
  71956. * Gets a string describing the action executed by the current optimization
  71957. * @return description string
  71958. */
  71959. getDescription(): string;
  71960. /**
  71961. * Creates the HardwareScalingOptimization object
  71962. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71963. * @param maximumScale defines the maximum scale to use (2 by default)
  71964. * @param step defines the step to use between two passes (0.5 by default)
  71965. */
  71966. constructor(
  71967. /**
  71968. * Defines the priority of this optimization (0 by default which means first in the list)
  71969. */
  71970. priority?: number,
  71971. /**
  71972. * Defines the maximum scale to use (2 by default)
  71973. */
  71974. maximumScale?: number,
  71975. /**
  71976. * Defines the step to use between two passes (0.5 by default)
  71977. */
  71978. step?: number);
  71979. /**
  71980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71981. * @param scene defines the current scene where to apply this optimization
  71982. * @param optimizer defines the current optimizer
  71983. * @returns true if everything that can be done was applied
  71984. */
  71985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71986. }
  71987. /**
  71988. * Defines an optimization used to remove shadows
  71989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71990. */
  71991. export class ShadowsOptimization extends SceneOptimization {
  71992. /**
  71993. * Gets a string describing the action executed by the current optimization
  71994. * @return description string
  71995. */
  71996. getDescription(): string;
  71997. /**
  71998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71999. * @param scene defines the current scene where to apply this optimization
  72000. * @param optimizer defines the current optimizer
  72001. * @returns true if everything that can be done was applied
  72002. */
  72003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72004. }
  72005. /**
  72006. * Defines an optimization used to turn post-processes off
  72007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72008. */
  72009. export class PostProcessesOptimization extends SceneOptimization {
  72010. /**
  72011. * Gets a string describing the action executed by the current optimization
  72012. * @return description string
  72013. */
  72014. getDescription(): string;
  72015. /**
  72016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72017. * @param scene defines the current scene where to apply this optimization
  72018. * @param optimizer defines the current optimizer
  72019. * @returns true if everything that can be done was applied
  72020. */
  72021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72022. }
  72023. /**
  72024. * Defines an optimization used to turn lens flares off
  72025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72026. */
  72027. export class LensFlaresOptimization extends SceneOptimization {
  72028. /**
  72029. * Gets a string describing the action executed by the current optimization
  72030. * @return description string
  72031. */
  72032. getDescription(): string;
  72033. /**
  72034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72035. * @param scene defines the current scene where to apply this optimization
  72036. * @param optimizer defines the current optimizer
  72037. * @returns true if everything that can be done was applied
  72038. */
  72039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72040. }
  72041. /**
  72042. * Defines an optimization based on user defined callback.
  72043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72044. */
  72045. export class CustomOptimization extends SceneOptimization {
  72046. /**
  72047. * Callback called to apply the custom optimization.
  72048. */
  72049. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72050. /**
  72051. * Callback called to get custom description
  72052. */
  72053. onGetDescription: () => string;
  72054. /**
  72055. * Gets a string describing the action executed by the current optimization
  72056. * @returns description string
  72057. */
  72058. getDescription(): string;
  72059. /**
  72060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72061. * @param scene defines the current scene where to apply this optimization
  72062. * @param optimizer defines the current optimizer
  72063. * @returns true if everything that can be done was applied
  72064. */
  72065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72066. }
  72067. /**
  72068. * Defines an optimization used to turn particles off
  72069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72070. */
  72071. export class ParticlesOptimization extends SceneOptimization {
  72072. /**
  72073. * Gets a string describing the action executed by the current optimization
  72074. * @return description string
  72075. */
  72076. getDescription(): string;
  72077. /**
  72078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72079. * @param scene defines the current scene where to apply this optimization
  72080. * @param optimizer defines the current optimizer
  72081. * @returns true if everything that can be done was applied
  72082. */
  72083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72084. }
  72085. /**
  72086. * Defines an optimization used to turn render targets off
  72087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72088. */
  72089. export class RenderTargetsOptimization extends SceneOptimization {
  72090. /**
  72091. * Gets a string describing the action executed by the current optimization
  72092. * @return description string
  72093. */
  72094. getDescription(): string;
  72095. /**
  72096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72097. * @param scene defines the current scene where to apply this optimization
  72098. * @param optimizer defines the current optimizer
  72099. * @returns true if everything that can be done was applied
  72100. */
  72101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72102. }
  72103. /**
  72104. * Defines an optimization used to merge meshes with compatible materials
  72105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72106. */
  72107. export class MergeMeshesOptimization extends SceneOptimization {
  72108. private static _UpdateSelectionTree;
  72109. /**
  72110. * Gets or sets a boolean which defines if optimization octree has to be updated
  72111. */
  72112. static get UpdateSelectionTree(): boolean;
  72113. /**
  72114. * Gets or sets a boolean which defines if optimization octree has to be updated
  72115. */
  72116. static set UpdateSelectionTree(value: boolean);
  72117. /**
  72118. * Gets a string describing the action executed by the current optimization
  72119. * @return description string
  72120. */
  72121. getDescription(): string;
  72122. private _canBeMerged;
  72123. /**
  72124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72125. * @param scene defines the current scene where to apply this optimization
  72126. * @param optimizer defines the current optimizer
  72127. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72128. * @returns true if everything that can be done was applied
  72129. */
  72130. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72131. }
  72132. /**
  72133. * Defines a list of options used by SceneOptimizer
  72134. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72135. */
  72136. export class SceneOptimizerOptions {
  72137. /**
  72138. * Defines the target frame rate to reach (60 by default)
  72139. */
  72140. targetFrameRate: number;
  72141. /**
  72142. * Defines the interval between two checkes (2000ms by default)
  72143. */
  72144. trackerDuration: number;
  72145. /**
  72146. * Gets the list of optimizations to apply
  72147. */
  72148. optimizations: SceneOptimization[];
  72149. /**
  72150. * Creates a new list of options used by SceneOptimizer
  72151. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72152. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72153. */
  72154. constructor(
  72155. /**
  72156. * Defines the target frame rate to reach (60 by default)
  72157. */
  72158. targetFrameRate?: number,
  72159. /**
  72160. * Defines the interval between two checkes (2000ms by default)
  72161. */
  72162. trackerDuration?: number);
  72163. /**
  72164. * Add a new optimization
  72165. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72166. * @returns the current SceneOptimizerOptions
  72167. */
  72168. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72169. /**
  72170. * Add a new custom optimization
  72171. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72172. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72173. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72174. * @returns the current SceneOptimizerOptions
  72175. */
  72176. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72177. /**
  72178. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72179. * @param targetFrameRate defines the target frame rate (60 by default)
  72180. * @returns a SceneOptimizerOptions object
  72181. */
  72182. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72183. /**
  72184. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72185. * @param targetFrameRate defines the target frame rate (60 by default)
  72186. * @returns a SceneOptimizerOptions object
  72187. */
  72188. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72189. /**
  72190. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72191. * @param targetFrameRate defines the target frame rate (60 by default)
  72192. * @returns a SceneOptimizerOptions object
  72193. */
  72194. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72195. }
  72196. /**
  72197. * Class used to run optimizations in order to reach a target frame rate
  72198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72199. */
  72200. export class SceneOptimizer implements IDisposable {
  72201. private _isRunning;
  72202. private _options;
  72203. private _scene;
  72204. private _currentPriorityLevel;
  72205. private _targetFrameRate;
  72206. private _trackerDuration;
  72207. private _currentFrameRate;
  72208. private _sceneDisposeObserver;
  72209. private _improvementMode;
  72210. /**
  72211. * Defines an observable called when the optimizer reaches the target frame rate
  72212. */
  72213. onSuccessObservable: Observable<SceneOptimizer>;
  72214. /**
  72215. * Defines an observable called when the optimizer enables an optimization
  72216. */
  72217. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72218. /**
  72219. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72220. */
  72221. onFailureObservable: Observable<SceneOptimizer>;
  72222. /**
  72223. * Gets a boolean indicating if the optimizer is in improvement mode
  72224. */
  72225. get isInImprovementMode(): boolean;
  72226. /**
  72227. * Gets the current priority level (0 at start)
  72228. */
  72229. get currentPriorityLevel(): number;
  72230. /**
  72231. * Gets the current frame rate checked by the SceneOptimizer
  72232. */
  72233. get currentFrameRate(): number;
  72234. /**
  72235. * Gets or sets the current target frame rate (60 by default)
  72236. */
  72237. get targetFrameRate(): number;
  72238. /**
  72239. * Gets or sets the current target frame rate (60 by default)
  72240. */
  72241. set targetFrameRate(value: number);
  72242. /**
  72243. * Gets or sets the current interval between two checks (every 2000ms by default)
  72244. */
  72245. get trackerDuration(): number;
  72246. /**
  72247. * Gets or sets the current interval between two checks (every 2000ms by default)
  72248. */
  72249. set trackerDuration(value: number);
  72250. /**
  72251. * Gets the list of active optimizations
  72252. */
  72253. get optimizations(): SceneOptimization[];
  72254. /**
  72255. * Creates a new SceneOptimizer
  72256. * @param scene defines the scene to work on
  72257. * @param options defines the options to use with the SceneOptimizer
  72258. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72259. * @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)
  72260. */
  72261. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72262. /**
  72263. * Stops the current optimizer
  72264. */
  72265. stop(): void;
  72266. /**
  72267. * Reset the optimizer to initial step (current priority level = 0)
  72268. */
  72269. reset(): void;
  72270. /**
  72271. * Start the optimizer. By default it will try to reach a specific framerate
  72272. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72273. */
  72274. start(): void;
  72275. private _checkCurrentState;
  72276. /**
  72277. * Release all resources
  72278. */
  72279. dispose(): void;
  72280. /**
  72281. * Helper function to create a SceneOptimizer with one single line of code
  72282. * @param scene defines the scene to work on
  72283. * @param options defines the options to use with the SceneOptimizer
  72284. * @param onSuccess defines a callback to call on success
  72285. * @param onFailure defines a callback to call on failure
  72286. * @returns the new SceneOptimizer object
  72287. */
  72288. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72289. }
  72290. }
  72291. declare module "babylonjs/Misc/sceneSerializer" {
  72292. import { Scene } from "babylonjs/scene";
  72293. /**
  72294. * Class used to serialize a scene into a string
  72295. */
  72296. export class SceneSerializer {
  72297. /**
  72298. * Clear cache used by a previous serialization
  72299. */
  72300. static ClearCache(): void;
  72301. /**
  72302. * Serialize a scene into a JSON compatible object
  72303. * @param scene defines the scene to serialize
  72304. * @returns a JSON compatible object
  72305. */
  72306. static Serialize(scene: Scene): any;
  72307. /**
  72308. * Serialize a mesh into a JSON compatible object
  72309. * @param toSerialize defines the mesh to serialize
  72310. * @param withParents defines if parents must be serialized as well
  72311. * @param withChildren defines if children must be serialized as well
  72312. * @returns a JSON compatible object
  72313. */
  72314. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72315. }
  72316. }
  72317. declare module "babylonjs/Misc/textureTools" {
  72318. import { Texture } from "babylonjs/Materials/Textures/texture";
  72319. /**
  72320. * Class used to host texture specific utilities
  72321. */
  72322. export class TextureTools {
  72323. /**
  72324. * Uses the GPU to create a copy texture rescaled at a given size
  72325. * @param texture Texture to copy from
  72326. * @param width defines the desired width
  72327. * @param height defines the desired height
  72328. * @param useBilinearMode defines if bilinear mode has to be used
  72329. * @return the generated texture
  72330. */
  72331. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72332. }
  72333. }
  72334. declare module "babylonjs/Misc/videoRecorder" {
  72335. import { Nullable } from "babylonjs/types";
  72336. import { Engine } from "babylonjs/Engines/engine";
  72337. /**
  72338. * This represents the different options available for the video capture.
  72339. */
  72340. export interface VideoRecorderOptions {
  72341. /** Defines the mime type of the video. */
  72342. mimeType: string;
  72343. /** Defines the FPS the video should be recorded at. */
  72344. fps: number;
  72345. /** Defines the chunk size for the recording data. */
  72346. recordChunckSize: number;
  72347. /** The audio tracks to attach to the recording. */
  72348. audioTracks?: MediaStreamTrack[];
  72349. }
  72350. /**
  72351. * This can help with recording videos from BabylonJS.
  72352. * This is based on the available WebRTC functionalities of the browser.
  72353. *
  72354. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72355. */
  72356. export class VideoRecorder {
  72357. private static readonly _defaultOptions;
  72358. /**
  72359. * Returns whether or not the VideoRecorder is available in your browser.
  72360. * @param engine Defines the Babylon Engine.
  72361. * @returns true if supported otherwise false.
  72362. */
  72363. static IsSupported(engine: Engine): boolean;
  72364. private readonly _options;
  72365. private _canvas;
  72366. private _mediaRecorder;
  72367. private _recordedChunks;
  72368. private _fileName;
  72369. private _resolve;
  72370. private _reject;
  72371. /**
  72372. * True when a recording is already in progress.
  72373. */
  72374. get isRecording(): boolean;
  72375. /**
  72376. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72377. * @param engine Defines the BabylonJS Engine you wish to record.
  72378. * @param options Defines options that can be used to customize the capture.
  72379. */
  72380. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72381. /**
  72382. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72383. */
  72384. stopRecording(): void;
  72385. /**
  72386. * Starts recording the canvas for a max duration specified in parameters.
  72387. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72388. * If null no automatic download will start and you can rely on the promise to get the data back.
  72389. * @param maxDuration Defines the maximum recording time in seconds.
  72390. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72391. * @return A promise callback at the end of the recording with the video data in Blob.
  72392. */
  72393. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72394. /**
  72395. * Releases internal resources used during the recording.
  72396. */
  72397. dispose(): void;
  72398. private _handleDataAvailable;
  72399. private _handleError;
  72400. private _handleStop;
  72401. }
  72402. }
  72403. declare module "babylonjs/Misc/screenshotTools" {
  72404. import { Camera } from "babylonjs/Cameras/camera";
  72405. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72406. import { Engine } from "babylonjs/Engines/engine";
  72407. /**
  72408. * Class containing a set of static utilities functions for screenshots
  72409. */
  72410. export class ScreenshotTools {
  72411. /**
  72412. * Captures a screenshot of the current rendering
  72413. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72414. * @param engine defines the rendering engine
  72415. * @param camera defines the source camera
  72416. * @param size This parameter can be set to a single number or to an object with the
  72417. * following (optional) properties: precision, width, height. If a single number is passed,
  72418. * it will be used for both width and height. If an object is passed, the screenshot size
  72419. * will be derived from the parameters. The precision property is a multiplier allowing
  72420. * rendering at a higher or lower resolution
  72421. * @param successCallback defines the callback receives a single parameter which contains the
  72422. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72423. * src parameter of an <img> to display it
  72424. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72425. * Check your browser for supported MIME types
  72426. */
  72427. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72428. /**
  72429. * Captures a screenshot of the current rendering
  72430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72431. * @param engine defines the rendering engine
  72432. * @param camera defines the source camera
  72433. * @param size This parameter can be set to a single number or to an object with the
  72434. * following (optional) properties: precision, width, height. If a single number is passed,
  72435. * it will be used for both width and height. If an object is passed, the screenshot size
  72436. * will be derived from the parameters. The precision property is a multiplier allowing
  72437. * rendering at a higher or lower resolution
  72438. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72439. * Check your browser for supported MIME types
  72440. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72441. * to the src parameter of an <img> to display it
  72442. */
  72443. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72444. /**
  72445. * Generates an image screenshot from the specified camera.
  72446. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72447. * @param engine The engine to use for rendering
  72448. * @param camera The camera to use for rendering
  72449. * @param size This parameter can be set to a single number or to an object with the
  72450. * following (optional) properties: precision, width, height. If a single number is passed,
  72451. * it will be used for both width and height. If an object is passed, the screenshot size
  72452. * will be derived from the parameters. The precision property is a multiplier allowing
  72453. * rendering at a higher or lower resolution
  72454. * @param successCallback The callback receives a single parameter which contains the
  72455. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72456. * src parameter of an <img> to display it
  72457. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72458. * Check your browser for supported MIME types
  72459. * @param samples Texture samples (default: 1)
  72460. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72461. * @param fileName A name for for the downloaded file.
  72462. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72463. */
  72464. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72465. /**
  72466. * Generates an image screenshot from the specified camera.
  72467. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72468. * @param engine The engine to use for rendering
  72469. * @param camera The camera to use for rendering
  72470. * @param size This parameter can be set to a single number or to an object with the
  72471. * following (optional) properties: precision, width, height. If a single number is passed,
  72472. * it will be used for both width and height. If an object is passed, the screenshot size
  72473. * will be derived from the parameters. The precision property is a multiplier allowing
  72474. * rendering at a higher or lower resolution
  72475. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72476. * Check your browser for supported MIME types
  72477. * @param samples Texture samples (default: 1)
  72478. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72479. * @param fileName A name for for the downloaded file.
  72480. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72481. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72482. * to the src parameter of an <img> to display it
  72483. */
  72484. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72485. /**
  72486. * Gets height and width for screenshot size
  72487. * @private
  72488. */
  72489. private static _getScreenshotSize;
  72490. }
  72491. }
  72492. declare module "babylonjs/Misc/dataReader" {
  72493. /**
  72494. * Interface for a data buffer
  72495. */
  72496. export interface IDataBuffer {
  72497. /**
  72498. * Reads bytes from the data buffer.
  72499. * @param byteOffset The byte offset to read
  72500. * @param byteLength The byte length to read
  72501. * @returns A promise that resolves when the bytes are read
  72502. */
  72503. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72504. /**
  72505. * The byte length of the buffer.
  72506. */
  72507. readonly byteLength: number;
  72508. }
  72509. /**
  72510. * Utility class for reading from a data buffer
  72511. */
  72512. export class DataReader {
  72513. /**
  72514. * The data buffer associated with this data reader.
  72515. */
  72516. readonly buffer: IDataBuffer;
  72517. /**
  72518. * The current byte offset from the beginning of the data buffer.
  72519. */
  72520. byteOffset: number;
  72521. private _dataView;
  72522. private _dataByteOffset;
  72523. /**
  72524. * Constructor
  72525. * @param buffer The buffer to read
  72526. */
  72527. constructor(buffer: IDataBuffer);
  72528. /**
  72529. * Loads the given byte length.
  72530. * @param byteLength The byte length to load
  72531. * @returns A promise that resolves when the load is complete
  72532. */
  72533. loadAsync(byteLength: number): Promise<void>;
  72534. /**
  72535. * Read a unsigned 32-bit integer from the currently loaded data range.
  72536. * @returns The 32-bit integer read
  72537. */
  72538. readUint32(): number;
  72539. /**
  72540. * Read a byte array from the currently loaded data range.
  72541. * @param byteLength The byte length to read
  72542. * @returns The byte array read
  72543. */
  72544. readUint8Array(byteLength: number): Uint8Array;
  72545. /**
  72546. * Read a string from the currently loaded data range.
  72547. * @param byteLength The byte length to read
  72548. * @returns The string read
  72549. */
  72550. readString(byteLength: number): string;
  72551. /**
  72552. * Skips the given byte length the currently loaded data range.
  72553. * @param byteLength The byte length to skip
  72554. */
  72555. skipBytes(byteLength: number): void;
  72556. }
  72557. }
  72558. declare module "babylonjs/Misc/dataStorage" {
  72559. /**
  72560. * Class for storing data to local storage if available or in-memory storage otherwise
  72561. */
  72562. export class DataStorage {
  72563. private static _Storage;
  72564. private static _GetStorage;
  72565. /**
  72566. * Reads a string from the data storage
  72567. * @param key The key to read
  72568. * @param defaultValue The value if the key doesn't exist
  72569. * @returns The string value
  72570. */
  72571. static ReadString(key: string, defaultValue: string): string;
  72572. /**
  72573. * Writes a string to the data storage
  72574. * @param key The key to write
  72575. * @param value The value to write
  72576. */
  72577. static WriteString(key: string, value: string): void;
  72578. /**
  72579. * Reads a boolean from the data storage
  72580. * @param key The key to read
  72581. * @param defaultValue The value if the key doesn't exist
  72582. * @returns The boolean value
  72583. */
  72584. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72585. /**
  72586. * Writes a boolean to the data storage
  72587. * @param key The key to write
  72588. * @param value The value to write
  72589. */
  72590. static WriteBoolean(key: string, value: boolean): void;
  72591. /**
  72592. * Reads a number from the data storage
  72593. * @param key The key to read
  72594. * @param defaultValue The value if the key doesn't exist
  72595. * @returns The number value
  72596. */
  72597. static ReadNumber(key: string, defaultValue: number): number;
  72598. /**
  72599. * Writes a number to the data storage
  72600. * @param key The key to write
  72601. * @param value The value to write
  72602. */
  72603. static WriteNumber(key: string, value: number): void;
  72604. }
  72605. }
  72606. declare module "babylonjs/Misc/index" {
  72607. export * from "babylonjs/Misc/andOrNotEvaluator";
  72608. export * from "babylonjs/Misc/assetsManager";
  72609. export * from "babylonjs/Misc/basis";
  72610. export * from "babylonjs/Misc/dds";
  72611. export * from "babylonjs/Misc/decorators";
  72612. export * from "babylonjs/Misc/deferred";
  72613. export * from "babylonjs/Misc/environmentTextureTools";
  72614. export * from "babylonjs/Misc/meshExploder";
  72615. export * from "babylonjs/Misc/filesInput";
  72616. export * from "babylonjs/Misc/HighDynamicRange/index";
  72617. export * from "babylonjs/Misc/khronosTextureContainer";
  72618. export * from "babylonjs/Misc/observable";
  72619. export * from "babylonjs/Misc/performanceMonitor";
  72620. export * from "babylonjs/Misc/promise";
  72621. export * from "babylonjs/Misc/sceneOptimizer";
  72622. export * from "babylonjs/Misc/sceneSerializer";
  72623. export * from "babylonjs/Misc/smartArray";
  72624. export * from "babylonjs/Misc/stringDictionary";
  72625. export * from "babylonjs/Misc/tags";
  72626. export * from "babylonjs/Misc/textureTools";
  72627. export * from "babylonjs/Misc/tga";
  72628. export * from "babylonjs/Misc/tools";
  72629. export * from "babylonjs/Misc/videoRecorder";
  72630. export * from "babylonjs/Misc/virtualJoystick";
  72631. export * from "babylonjs/Misc/workerPool";
  72632. export * from "babylonjs/Misc/logger";
  72633. export * from "babylonjs/Misc/typeStore";
  72634. export * from "babylonjs/Misc/filesInputStore";
  72635. export * from "babylonjs/Misc/deepCopier";
  72636. export * from "babylonjs/Misc/pivotTools";
  72637. export * from "babylonjs/Misc/precisionDate";
  72638. export * from "babylonjs/Misc/screenshotTools";
  72639. export * from "babylonjs/Misc/typeStore";
  72640. export * from "babylonjs/Misc/webRequest";
  72641. export * from "babylonjs/Misc/iInspectable";
  72642. export * from "babylonjs/Misc/brdfTextureTools";
  72643. export * from "babylonjs/Misc/rgbdTextureTools";
  72644. export * from "babylonjs/Misc/gradients";
  72645. export * from "babylonjs/Misc/perfCounter";
  72646. export * from "babylonjs/Misc/fileRequest";
  72647. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72648. export * from "babylonjs/Misc/retryStrategy";
  72649. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72650. export * from "babylonjs/Misc/canvasGenerator";
  72651. export * from "babylonjs/Misc/fileTools";
  72652. export * from "babylonjs/Misc/stringTools";
  72653. export * from "babylonjs/Misc/dataReader";
  72654. export * from "babylonjs/Misc/minMaxReducer";
  72655. export * from "babylonjs/Misc/depthReducer";
  72656. export * from "babylonjs/Misc/dataStorage";
  72657. }
  72658. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72659. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72660. import { Observable } from "babylonjs/Misc/observable";
  72661. import { Matrix } from "babylonjs/Maths/math.vector";
  72662. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72663. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72664. /**
  72665. * Options used for hit testing
  72666. */
  72667. export interface IWebXRHitTestOptions {
  72668. /**
  72669. * Only test when user interacted with the scene. Default - hit test every frame
  72670. */
  72671. testOnPointerDownOnly?: boolean;
  72672. /**
  72673. * The node to use to transform the local results to world coordinates
  72674. */
  72675. worldParentNode?: TransformNode;
  72676. }
  72677. /**
  72678. * Interface defining the babylon result of raycasting/hit-test
  72679. */
  72680. export interface IWebXRHitResult {
  72681. /**
  72682. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72683. */
  72684. transformationMatrix: Matrix;
  72685. /**
  72686. * The native hit test result
  72687. */
  72688. xrHitResult: XRHitResult;
  72689. }
  72690. /**
  72691. * The currently-working hit-test module.
  72692. * Hit test (or Ray-casting) is used to interact with the real world.
  72693. * For further information read here - https://github.com/immersive-web/hit-test
  72694. */
  72695. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72696. /**
  72697. * options to use when constructing this feature
  72698. */
  72699. readonly options: IWebXRHitTestOptions;
  72700. private _direction;
  72701. private _mat;
  72702. private _onSelectEnabled;
  72703. private _origin;
  72704. /**
  72705. * The module's name
  72706. */
  72707. static readonly Name: string;
  72708. /**
  72709. * The (Babylon) version of this module.
  72710. * This is an integer representing the implementation version.
  72711. * This number does not correspond to the WebXR specs version
  72712. */
  72713. static readonly Version: number;
  72714. /**
  72715. * Populated with the last native XR Hit Results
  72716. */
  72717. lastNativeXRHitResults: XRHitResult[];
  72718. /**
  72719. * Triggered when new babylon (transformed) hit test results are available
  72720. */
  72721. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72722. /**
  72723. * Creates a new instance of the (legacy version) hit test feature
  72724. * @param _xrSessionManager an instance of WebXRSessionManager
  72725. * @param options options to use when constructing this feature
  72726. */
  72727. constructor(_xrSessionManager: WebXRSessionManager,
  72728. /**
  72729. * options to use when constructing this feature
  72730. */
  72731. options?: IWebXRHitTestOptions);
  72732. /**
  72733. * execute a hit test with an XR Ray
  72734. *
  72735. * @param xrSession a native xrSession that will execute this hit test
  72736. * @param xrRay the ray (position and direction) to use for ray-casting
  72737. * @param referenceSpace native XR reference space to use for the hit-test
  72738. * @param filter filter function that will filter the results
  72739. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72740. */
  72741. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72742. /**
  72743. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72744. * @param event the (select) event to use to select with
  72745. * @param referenceSpace the reference space to use for this hit test
  72746. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72747. */
  72748. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72749. /**
  72750. * attach this feature
  72751. * Will usually be called by the features manager
  72752. *
  72753. * @returns true if successful.
  72754. */
  72755. attach(): boolean;
  72756. /**
  72757. * detach this feature.
  72758. * Will usually be called by the features manager
  72759. *
  72760. * @returns true if successful.
  72761. */
  72762. detach(): boolean;
  72763. /**
  72764. * Dispose this feature and all of the resources attached
  72765. */
  72766. dispose(): void;
  72767. protected _onXRFrame(frame: XRFrame): void;
  72768. private _onHitTestResults;
  72769. private _onSelect;
  72770. }
  72771. }
  72772. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72773. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72774. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72775. import { Observable } from "babylonjs/Misc/observable";
  72776. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72777. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72778. /**
  72779. * Options used in the plane detector module
  72780. */
  72781. export interface IWebXRPlaneDetectorOptions {
  72782. /**
  72783. * The node to use to transform the local results to world coordinates
  72784. */
  72785. worldParentNode?: TransformNode;
  72786. }
  72787. /**
  72788. * A babylon interface for a WebXR plane.
  72789. * A Plane is actually a polygon, built from N points in space
  72790. *
  72791. * Supported in chrome 79, not supported in canary 81 ATM
  72792. */
  72793. export interface IWebXRPlane {
  72794. /**
  72795. * a babylon-assigned ID for this polygon
  72796. */
  72797. id: number;
  72798. /**
  72799. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72800. */
  72801. polygonDefinition: Array<Vector3>;
  72802. /**
  72803. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72804. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72805. */
  72806. transformationMatrix: Matrix;
  72807. /**
  72808. * the native xr-plane object
  72809. */
  72810. xrPlane: XRPlane;
  72811. }
  72812. /**
  72813. * The plane detector is used to detect planes in the real world when in AR
  72814. * For more information see https://github.com/immersive-web/real-world-geometry/
  72815. */
  72816. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72817. private _options;
  72818. private _detectedPlanes;
  72819. private _enabled;
  72820. private _lastFrameDetected;
  72821. /**
  72822. * The module's name
  72823. */
  72824. static readonly Name: string;
  72825. /**
  72826. * The (Babylon) version of this module.
  72827. * This is an integer representing the implementation version.
  72828. * This number does not correspond to the WebXR specs version
  72829. */
  72830. static readonly Version: number;
  72831. /**
  72832. * Observers registered here will be executed when a new plane was added to the session
  72833. */
  72834. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72835. /**
  72836. * Observers registered here will be executed when a plane is no longer detected in the session
  72837. */
  72838. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72839. /**
  72840. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72841. * This can execute N times every frame
  72842. */
  72843. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72844. /**
  72845. * construct a new Plane Detector
  72846. * @param _xrSessionManager an instance of xr Session manager
  72847. * @param _options configuration to use when constructing this feature
  72848. */
  72849. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72850. /**
  72851. * Dispose this feature and all of the resources attached
  72852. */
  72853. dispose(): void;
  72854. protected _onXRFrame(frame: XRFrame): void;
  72855. private _init;
  72856. private _updatePlaneWithXRPlane;
  72857. /**
  72858. * avoiding using Array.find for global support.
  72859. * @param xrPlane the plane to find in the array
  72860. */
  72861. private findIndexInPlaneArray;
  72862. }
  72863. }
  72864. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72865. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72866. import { Observable } from "babylonjs/Misc/observable";
  72867. import { Matrix } from "babylonjs/Maths/math.vector";
  72868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72869. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72870. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72871. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72872. /**
  72873. * Configuration options of the anchor system
  72874. */
  72875. export interface IWebXRAnchorSystemOptions {
  72876. /**
  72877. * Should a new anchor be added every time a select event is triggered
  72878. */
  72879. addAnchorOnSelect?: boolean;
  72880. /**
  72881. * should the anchor system use plane detection.
  72882. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72883. */
  72884. usePlaneDetection?: boolean;
  72885. /**
  72886. * a node that will be used to convert local to world coordinates
  72887. */
  72888. worldParentNode?: TransformNode;
  72889. }
  72890. /**
  72891. * A babylon container for an XR Anchor
  72892. */
  72893. export interface IWebXRAnchor {
  72894. /**
  72895. * A babylon-assigned ID for this anchor
  72896. */
  72897. id: number;
  72898. /**
  72899. * Transformation matrix to apply to an object attached to this anchor
  72900. */
  72901. transformationMatrix: Matrix;
  72902. /**
  72903. * The native anchor object
  72904. */
  72905. xrAnchor: XRAnchor;
  72906. }
  72907. /**
  72908. * An implementation of the anchor system of WebXR.
  72909. * Note that the current documented implementation is not available in any browser. Future implementations
  72910. * will use the frame to create an anchor and not the session or a detected plane
  72911. * For further information see https://github.com/immersive-web/anchors/
  72912. */
  72913. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72914. private _options;
  72915. private _enabled;
  72916. private _hitTestModule;
  72917. private _lastFrameDetected;
  72918. private _onSelect;
  72919. private _planeDetector;
  72920. private _trackedAnchors;
  72921. /**
  72922. * The module's name
  72923. */
  72924. static readonly Name: string;
  72925. /**
  72926. * The (Babylon) version of this module.
  72927. * This is an integer representing the implementation version.
  72928. * This number does not correspond to the WebXR specs version
  72929. */
  72930. static readonly Version: number;
  72931. /**
  72932. * Observers registered here will be executed when a new anchor was added to the session
  72933. */
  72934. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72935. /**
  72936. * Observers registered here will be executed when an anchor was removed from the session
  72937. */
  72938. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72939. /**
  72940. * Observers registered here will be executed when an existing anchor updates
  72941. * This can execute N times every frame
  72942. */
  72943. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72944. /**
  72945. * constructs a new anchor system
  72946. * @param _xrSessionManager an instance of WebXRSessionManager
  72947. * @param _options configuration object for this feature
  72948. */
  72949. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72950. /**
  72951. * Add anchor at a specific XR point.
  72952. *
  72953. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72954. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72955. * @returns a promise the fulfills when the anchor was created
  72956. */
  72957. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72958. /**
  72959. * attach this feature
  72960. * Will usually be called by the features manager
  72961. *
  72962. * @returns true if successful.
  72963. */
  72964. attach(): boolean;
  72965. /**
  72966. * detach this feature.
  72967. * Will usually be called by the features manager
  72968. *
  72969. * @returns true if successful.
  72970. */
  72971. detach(): boolean;
  72972. /**
  72973. * Dispose this feature and all of the resources attached
  72974. */
  72975. dispose(): void;
  72976. /**
  72977. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72978. * @param hitTestModule the hit-test module to use.
  72979. */
  72980. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72981. /**
  72982. * set the plane detector to use in order to create anchors from frames
  72983. * @param planeDetector the plane-detector module to use
  72984. * @param enable enable plane-anchors. default is true
  72985. */
  72986. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72987. protected _onXRFrame(frame: XRFrame): void;
  72988. /**
  72989. * avoiding using Array.find for global support.
  72990. * @param xrAnchor the plane to find in the array
  72991. */
  72992. private _findIndexInAnchorArray;
  72993. private _updateAnchorWithXRFrame;
  72994. }
  72995. }
  72996. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72997. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72999. import { Observable } from "babylonjs/Misc/observable";
  73000. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73001. /**
  73002. * Options interface for the background remover plugin
  73003. */
  73004. export interface IWebXRBackgroundRemoverOptions {
  73005. /**
  73006. * Further background meshes to disable when entering AR
  73007. */
  73008. backgroundMeshes?: AbstractMesh[];
  73009. /**
  73010. * flags to configure the removal of the environment helper.
  73011. * If not set, the entire background will be removed. If set, flags should be set as well.
  73012. */
  73013. environmentHelperRemovalFlags?: {
  73014. /**
  73015. * Should the skybox be removed (default false)
  73016. */
  73017. skyBox?: boolean;
  73018. /**
  73019. * Should the ground be removed (default false)
  73020. */
  73021. ground?: boolean;
  73022. };
  73023. /**
  73024. * don't disable the environment helper
  73025. */
  73026. ignoreEnvironmentHelper?: boolean;
  73027. }
  73028. /**
  73029. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73030. */
  73031. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73032. /**
  73033. * read-only options to be used in this module
  73034. */
  73035. readonly options: IWebXRBackgroundRemoverOptions;
  73036. /**
  73037. * The module's name
  73038. */
  73039. static readonly Name: string;
  73040. /**
  73041. * The (Babylon) version of this module.
  73042. * This is an integer representing the implementation version.
  73043. * This number does not correspond to the WebXR specs version
  73044. */
  73045. static readonly Version: number;
  73046. /**
  73047. * registered observers will be triggered when the background state changes
  73048. */
  73049. onBackgroundStateChangedObservable: Observable<boolean>;
  73050. /**
  73051. * constructs a new background remover module
  73052. * @param _xrSessionManager the session manager for this module
  73053. * @param options read-only options to be used in this module
  73054. */
  73055. constructor(_xrSessionManager: WebXRSessionManager,
  73056. /**
  73057. * read-only options to be used in this module
  73058. */
  73059. options?: IWebXRBackgroundRemoverOptions);
  73060. /**
  73061. * attach this feature
  73062. * Will usually be called by the features manager
  73063. *
  73064. * @returns true if successful.
  73065. */
  73066. attach(): boolean;
  73067. /**
  73068. * detach this feature.
  73069. * Will usually be called by the features manager
  73070. *
  73071. * @returns true if successful.
  73072. */
  73073. detach(): boolean;
  73074. /**
  73075. * Dispose this feature and all of the resources attached
  73076. */
  73077. dispose(): void;
  73078. protected _onXRFrame(_xrFrame: XRFrame): void;
  73079. private _setBackgroundState;
  73080. }
  73081. }
  73082. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73083. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73084. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73085. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73086. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73087. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73088. import { Nullable } from "babylonjs/types";
  73089. /**
  73090. * Options for the controller physics feature
  73091. */
  73092. export class IWebXRControllerPhysicsOptions {
  73093. /**
  73094. * Should the headset get its own impostor
  73095. */
  73096. enableHeadsetImpostor?: boolean;
  73097. /**
  73098. * Optional parameters for the headset impostor
  73099. */
  73100. headsetImpostorParams?: {
  73101. /**
  73102. * The type of impostor to create. Default is sphere
  73103. */
  73104. impostorType: number;
  73105. /**
  73106. * the size of the impostor. Defaults to 10cm
  73107. */
  73108. impostorSize?: number | {
  73109. width: number;
  73110. height: number;
  73111. depth: number;
  73112. };
  73113. /**
  73114. * Friction definitions
  73115. */
  73116. friction?: number;
  73117. /**
  73118. * Restitution
  73119. */
  73120. restitution?: number;
  73121. };
  73122. /**
  73123. * The physics properties of the future impostors
  73124. */
  73125. physicsProperties?: {
  73126. /**
  73127. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73128. * Note that this requires a physics engine that supports mesh impostors!
  73129. */
  73130. useControllerMesh?: boolean;
  73131. /**
  73132. * The type of impostor to create. Default is sphere
  73133. */
  73134. impostorType?: number;
  73135. /**
  73136. * the size of the impostor. Defaults to 10cm
  73137. */
  73138. impostorSize?: number | {
  73139. width: number;
  73140. height: number;
  73141. depth: number;
  73142. };
  73143. /**
  73144. * Friction definitions
  73145. */
  73146. friction?: number;
  73147. /**
  73148. * Restitution
  73149. */
  73150. restitution?: number;
  73151. };
  73152. /**
  73153. * the xr input to use with this pointer selection
  73154. */
  73155. xrInput: WebXRInput;
  73156. }
  73157. /**
  73158. * Add physics impostor to your webxr controllers,
  73159. * including naive calculation of their linear and angular velocity
  73160. */
  73161. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73162. private readonly _options;
  73163. private _attachController;
  73164. private _controllers;
  73165. private _debugMode;
  73166. private _delta;
  73167. private _headsetImpostor?;
  73168. private _headsetMesh?;
  73169. private _lastTimestamp;
  73170. private _tmpQuaternion;
  73171. private _tmpVector;
  73172. /**
  73173. * The module's name
  73174. */
  73175. static readonly Name: string;
  73176. /**
  73177. * The (Babylon) version of this module.
  73178. * This is an integer representing the implementation version.
  73179. * This number does not correspond to the webxr specs version
  73180. */
  73181. static readonly Version: number;
  73182. /**
  73183. * Construct a new Controller Physics Feature
  73184. * @param _xrSessionManager the corresponding xr session manager
  73185. * @param _options options to create this feature with
  73186. */
  73187. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73188. /**
  73189. * @hidden
  73190. * enable debugging - will show console outputs and the impostor mesh
  73191. */
  73192. _enablePhysicsDebug(): void;
  73193. /**
  73194. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73195. * @param xrController the controller to add
  73196. */
  73197. addController(xrController: WebXRInputSource): void;
  73198. /**
  73199. * attach this feature
  73200. * Will usually be called by the features manager
  73201. *
  73202. * @returns true if successful.
  73203. */
  73204. attach(): boolean;
  73205. /**
  73206. * detach this feature.
  73207. * Will usually be called by the features manager
  73208. *
  73209. * @returns true if successful.
  73210. */
  73211. detach(): boolean;
  73212. /**
  73213. * Get the headset impostor, if enabled
  73214. * @returns the impostor
  73215. */
  73216. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73217. /**
  73218. * Get the physics impostor of a specific controller.
  73219. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73220. * @param controller the controller or the controller id of which to get the impostor
  73221. * @returns the impostor or null
  73222. */
  73223. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73224. /**
  73225. * Update the physics properties provided in the constructor
  73226. * @param newProperties the new properties object
  73227. */
  73228. setPhysicsProperties(newProperties: {
  73229. impostorType?: number;
  73230. impostorSize?: number | {
  73231. width: number;
  73232. height: number;
  73233. depth: number;
  73234. };
  73235. friction?: number;
  73236. restitution?: number;
  73237. }): void;
  73238. protected _onXRFrame(_xrFrame: any): void;
  73239. private _detachController;
  73240. }
  73241. }
  73242. declare module "babylonjs/XR/features/index" {
  73243. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73244. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73245. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73246. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73247. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73248. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73249. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73250. }
  73251. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73252. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73254. import { Scene } from "babylonjs/scene";
  73255. /**
  73256. * The motion controller class for all microsoft mixed reality controllers
  73257. */
  73258. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73259. protected readonly _mapping: {
  73260. defaultButton: {
  73261. "valueNodeName": string;
  73262. "unpressedNodeName": string;
  73263. "pressedNodeName": string;
  73264. };
  73265. defaultAxis: {
  73266. "valueNodeName": string;
  73267. "minNodeName": string;
  73268. "maxNodeName": string;
  73269. };
  73270. buttons: {
  73271. "xr-standard-trigger": {
  73272. "rootNodeName": string;
  73273. "componentProperty": string;
  73274. "states": string[];
  73275. };
  73276. "xr-standard-squeeze": {
  73277. "rootNodeName": string;
  73278. "componentProperty": string;
  73279. "states": string[];
  73280. };
  73281. "xr-standard-touchpad": {
  73282. "rootNodeName": string;
  73283. "labelAnchorNodeName": string;
  73284. "touchPointNodeName": string;
  73285. };
  73286. "xr-standard-thumbstick": {
  73287. "rootNodeName": string;
  73288. "componentProperty": string;
  73289. "states": string[];
  73290. };
  73291. };
  73292. axes: {
  73293. "xr-standard-touchpad": {
  73294. "x-axis": {
  73295. "rootNodeName": string;
  73296. };
  73297. "y-axis": {
  73298. "rootNodeName": string;
  73299. };
  73300. };
  73301. "xr-standard-thumbstick": {
  73302. "x-axis": {
  73303. "rootNodeName": string;
  73304. };
  73305. "y-axis": {
  73306. "rootNodeName": string;
  73307. };
  73308. };
  73309. };
  73310. };
  73311. /**
  73312. * The base url used to load the left and right controller models
  73313. */
  73314. static MODEL_BASE_URL: string;
  73315. /**
  73316. * The name of the left controller model file
  73317. */
  73318. static MODEL_LEFT_FILENAME: string;
  73319. /**
  73320. * The name of the right controller model file
  73321. */
  73322. static MODEL_RIGHT_FILENAME: string;
  73323. profileId: string;
  73324. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73325. protected _getFilenameAndPath(): {
  73326. filename: string;
  73327. path: string;
  73328. };
  73329. protected _getModelLoadingConstraints(): boolean;
  73330. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73331. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73332. protected _updateModel(): void;
  73333. }
  73334. }
  73335. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73336. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73338. import { Scene } from "babylonjs/scene";
  73339. /**
  73340. * The motion controller class for oculus touch (quest, rift).
  73341. * This class supports legacy mapping as well the standard xr mapping
  73342. */
  73343. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73344. private _forceLegacyControllers;
  73345. private _modelRootNode;
  73346. /**
  73347. * The base url used to load the left and right controller models
  73348. */
  73349. static MODEL_BASE_URL: string;
  73350. /**
  73351. * The name of the left controller model file
  73352. */
  73353. static MODEL_LEFT_FILENAME: string;
  73354. /**
  73355. * The name of the right controller model file
  73356. */
  73357. static MODEL_RIGHT_FILENAME: string;
  73358. /**
  73359. * Base Url for the Quest controller model.
  73360. */
  73361. static QUEST_MODEL_BASE_URL: string;
  73362. profileId: string;
  73363. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73364. protected _getFilenameAndPath(): {
  73365. filename: string;
  73366. path: string;
  73367. };
  73368. protected _getModelLoadingConstraints(): boolean;
  73369. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73370. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73371. protected _updateModel(): void;
  73372. /**
  73373. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73374. * between the touch and touch 2.
  73375. */
  73376. private _isQuest;
  73377. }
  73378. }
  73379. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73380. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73381. import { Scene } from "babylonjs/scene";
  73382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73383. /**
  73384. * The motion controller class for the standard HTC-Vive controllers
  73385. */
  73386. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73387. private _modelRootNode;
  73388. /**
  73389. * The base url used to load the left and right controller models
  73390. */
  73391. static MODEL_BASE_URL: string;
  73392. /**
  73393. * File name for the controller model.
  73394. */
  73395. static MODEL_FILENAME: string;
  73396. profileId: string;
  73397. /**
  73398. * Create a new Vive motion controller object
  73399. * @param scene the scene to use to create this controller
  73400. * @param gamepadObject the corresponding gamepad object
  73401. * @param handness the handness of the controller
  73402. */
  73403. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73404. protected _getFilenameAndPath(): {
  73405. filename: string;
  73406. path: string;
  73407. };
  73408. protected _getModelLoadingConstraints(): boolean;
  73409. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73410. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73411. protected _updateModel(): void;
  73412. }
  73413. }
  73414. declare module "babylonjs/XR/motionController/index" {
  73415. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73416. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73417. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73418. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73419. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73420. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73421. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73422. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73423. }
  73424. declare module "babylonjs/XR/index" {
  73425. export * from "babylonjs/XR/webXRCamera";
  73426. export * from "babylonjs/XR/webXREnterExitUI";
  73427. export * from "babylonjs/XR/webXRExperienceHelper";
  73428. export * from "babylonjs/XR/webXRInput";
  73429. export * from "babylonjs/XR/webXRInputSource";
  73430. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73431. export * from "babylonjs/XR/webXRTypes";
  73432. export * from "babylonjs/XR/webXRSessionManager";
  73433. export * from "babylonjs/XR/webXRDefaultExperience";
  73434. export * from "babylonjs/XR/webXRFeaturesManager";
  73435. export * from "babylonjs/XR/features/index";
  73436. export * from "babylonjs/XR/motionController/index";
  73437. }
  73438. declare module "babylonjs/index" {
  73439. export * from "babylonjs/abstractScene";
  73440. export * from "babylonjs/Actions/index";
  73441. export * from "babylonjs/Animations/index";
  73442. export * from "babylonjs/assetContainer";
  73443. export * from "babylonjs/Audio/index";
  73444. export * from "babylonjs/Behaviors/index";
  73445. export * from "babylonjs/Bones/index";
  73446. export * from "babylonjs/Cameras/index";
  73447. export * from "babylonjs/Collisions/index";
  73448. export * from "babylonjs/Culling/index";
  73449. export * from "babylonjs/Debug/index";
  73450. export * from "babylonjs/Engines/index";
  73451. export * from "babylonjs/Events/index";
  73452. export * from "babylonjs/Gamepads/index";
  73453. export * from "babylonjs/Gizmos/index";
  73454. export * from "babylonjs/Helpers/index";
  73455. export * from "babylonjs/Instrumentation/index";
  73456. export * from "babylonjs/Layers/index";
  73457. export * from "babylonjs/LensFlares/index";
  73458. export * from "babylonjs/Lights/index";
  73459. export * from "babylonjs/Loading/index";
  73460. export * from "babylonjs/Materials/index";
  73461. export * from "babylonjs/Maths/index";
  73462. export * from "babylonjs/Meshes/index";
  73463. export * from "babylonjs/Morph/index";
  73464. export * from "babylonjs/Navigation/index";
  73465. export * from "babylonjs/node";
  73466. export * from "babylonjs/Offline/index";
  73467. export * from "babylonjs/Particles/index";
  73468. export * from "babylonjs/Physics/index";
  73469. export * from "babylonjs/PostProcesses/index";
  73470. export * from "babylonjs/Probes/index";
  73471. export * from "babylonjs/Rendering/index";
  73472. export * from "babylonjs/scene";
  73473. export * from "babylonjs/sceneComponent";
  73474. export * from "babylonjs/Sprites/index";
  73475. export * from "babylonjs/States/index";
  73476. export * from "babylonjs/Misc/index";
  73477. export * from "babylonjs/XR/index";
  73478. export * from "babylonjs/types";
  73479. }
  73480. declare module "babylonjs/Animations/pathCursor" {
  73481. import { Vector3 } from "babylonjs/Maths/math.vector";
  73482. import { Path2 } from "babylonjs/Maths/math.path";
  73483. /**
  73484. * A cursor which tracks a point on a path
  73485. */
  73486. export class PathCursor {
  73487. private path;
  73488. /**
  73489. * Stores path cursor callbacks for when an onchange event is triggered
  73490. */
  73491. private _onchange;
  73492. /**
  73493. * The value of the path cursor
  73494. */
  73495. value: number;
  73496. /**
  73497. * The animation array of the path cursor
  73498. */
  73499. animations: Animation[];
  73500. /**
  73501. * Initializes the path cursor
  73502. * @param path The path to track
  73503. */
  73504. constructor(path: Path2);
  73505. /**
  73506. * Gets the cursor point on the path
  73507. * @returns A point on the path cursor at the cursor location
  73508. */
  73509. getPoint(): Vector3;
  73510. /**
  73511. * Moves the cursor ahead by the step amount
  73512. * @param step The amount to move the cursor forward
  73513. * @returns This path cursor
  73514. */
  73515. moveAhead(step?: number): PathCursor;
  73516. /**
  73517. * Moves the cursor behind by the step amount
  73518. * @param step The amount to move the cursor back
  73519. * @returns This path cursor
  73520. */
  73521. moveBack(step?: number): PathCursor;
  73522. /**
  73523. * Moves the cursor by the step amount
  73524. * If the step amount is greater than one, an exception is thrown
  73525. * @param step The amount to move the cursor
  73526. * @returns This path cursor
  73527. */
  73528. move(step: number): PathCursor;
  73529. /**
  73530. * Ensures that the value is limited between zero and one
  73531. * @returns This path cursor
  73532. */
  73533. private ensureLimits;
  73534. /**
  73535. * Runs onchange callbacks on change (used by the animation engine)
  73536. * @returns This path cursor
  73537. */
  73538. private raiseOnChange;
  73539. /**
  73540. * Executes a function on change
  73541. * @param f A path cursor onchange callback
  73542. * @returns This path cursor
  73543. */
  73544. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73545. }
  73546. }
  73547. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73548. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73549. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73550. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73551. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73552. }
  73553. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73554. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73555. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73556. }
  73557. declare module "babylonjs/Engines/Processors/index" {
  73558. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73559. export * from "babylonjs/Engines/Processors/Expressions/index";
  73560. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73561. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73562. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73563. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73564. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73565. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73566. }
  73567. declare module "babylonjs/Legacy/legacy" {
  73568. import * as Babylon from "babylonjs/index";
  73569. export * from "babylonjs/index";
  73570. }
  73571. declare module "babylonjs/Shaders/blur.fragment" {
  73572. /** @hidden */
  73573. export var blurPixelShader: {
  73574. name: string;
  73575. shader: string;
  73576. };
  73577. }
  73578. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73579. /** @hidden */
  73580. export var pointCloudVertexDeclaration: {
  73581. name: string;
  73582. shader: string;
  73583. };
  73584. }
  73585. declare module "babylonjs" {
  73586. export * from "babylonjs/Legacy/legacy";
  73587. }
  73588. declare module BABYLON {
  73589. /** Alias type for value that can be null */
  73590. export type Nullable<T> = T | null;
  73591. /**
  73592. * Alias type for number that are floats
  73593. * @ignorenaming
  73594. */
  73595. export type float = number;
  73596. /**
  73597. * Alias type for number that are doubles.
  73598. * @ignorenaming
  73599. */
  73600. export type double = number;
  73601. /**
  73602. * Alias type for number that are integer
  73603. * @ignorenaming
  73604. */
  73605. export type int = number;
  73606. /** Alias type for number array or Float32Array */
  73607. export type FloatArray = number[] | Float32Array;
  73608. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73609. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73610. /**
  73611. * Alias for types that can be used by a Buffer or VertexBuffer.
  73612. */
  73613. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73614. /**
  73615. * Alias type for primitive types
  73616. * @ignorenaming
  73617. */
  73618. type Primitive = undefined | null | boolean | string | number | Function;
  73619. /**
  73620. * Type modifier to make all the properties of an object Readonly
  73621. */
  73622. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73623. /**
  73624. * Type modifier to make all the properties of an object Readonly recursively
  73625. */
  73626. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73627. /**
  73628. * Type modifier to make object properties readonly.
  73629. */
  73630. export type DeepImmutableObject<T> = {
  73631. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73632. };
  73633. /** @hidden */
  73634. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73635. }
  73636. }
  73637. declare module BABYLON {
  73638. /**
  73639. * A class serves as a medium between the observable and its observers
  73640. */
  73641. export class EventState {
  73642. /**
  73643. * Create a new EventState
  73644. * @param mask defines the mask associated with this state
  73645. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73646. * @param target defines the original target of the state
  73647. * @param currentTarget defines the current target of the state
  73648. */
  73649. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73650. /**
  73651. * Initialize the current event state
  73652. * @param mask defines the mask associated with this state
  73653. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73654. * @param target defines the original target of the state
  73655. * @param currentTarget defines the current target of the state
  73656. * @returns the current event state
  73657. */
  73658. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73659. /**
  73660. * An Observer can set this property to true to prevent subsequent observers of being notified
  73661. */
  73662. skipNextObservers: boolean;
  73663. /**
  73664. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73665. */
  73666. mask: number;
  73667. /**
  73668. * The object that originally notified the event
  73669. */
  73670. target?: any;
  73671. /**
  73672. * The current object in the bubbling phase
  73673. */
  73674. currentTarget?: any;
  73675. /**
  73676. * This will be populated with the return value of the last function that was executed.
  73677. * If it is the first function in the callback chain it will be the event data.
  73678. */
  73679. lastReturnValue?: any;
  73680. }
  73681. /**
  73682. * Represent an Observer registered to a given Observable object.
  73683. */
  73684. export class Observer<T> {
  73685. /**
  73686. * Defines the callback to call when the observer is notified
  73687. */
  73688. callback: (eventData: T, eventState: EventState) => void;
  73689. /**
  73690. * Defines the mask of the observer (used to filter notifications)
  73691. */
  73692. mask: number;
  73693. /**
  73694. * Defines the current scope used to restore the JS context
  73695. */
  73696. scope: any;
  73697. /** @hidden */
  73698. _willBeUnregistered: boolean;
  73699. /**
  73700. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73701. */
  73702. unregisterOnNextCall: boolean;
  73703. /**
  73704. * Creates a new observer
  73705. * @param callback defines the callback to call when the observer is notified
  73706. * @param mask defines the mask of the observer (used to filter notifications)
  73707. * @param scope defines the current scope used to restore the JS context
  73708. */
  73709. constructor(
  73710. /**
  73711. * Defines the callback to call when the observer is notified
  73712. */
  73713. callback: (eventData: T, eventState: EventState) => void,
  73714. /**
  73715. * Defines the mask of the observer (used to filter notifications)
  73716. */
  73717. mask: number,
  73718. /**
  73719. * Defines the current scope used to restore the JS context
  73720. */
  73721. scope?: any);
  73722. }
  73723. /**
  73724. * Represent a list of observers registered to multiple Observables object.
  73725. */
  73726. export class MultiObserver<T> {
  73727. private _observers;
  73728. private _observables;
  73729. /**
  73730. * Release associated resources
  73731. */
  73732. dispose(): void;
  73733. /**
  73734. * Raise a callback when one of the observable will notify
  73735. * @param observables defines a list of observables to watch
  73736. * @param callback defines the callback to call on notification
  73737. * @param mask defines the mask used to filter notifications
  73738. * @param scope defines the current scope used to restore the JS context
  73739. * @returns the new MultiObserver
  73740. */
  73741. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73742. }
  73743. /**
  73744. * The Observable class is a simple implementation of the Observable pattern.
  73745. *
  73746. * 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.
  73747. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73748. * 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).
  73749. * 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.
  73750. */
  73751. export class Observable<T> {
  73752. private _observers;
  73753. private _eventState;
  73754. private _onObserverAdded;
  73755. /**
  73756. * Gets the list of observers
  73757. */
  73758. get observers(): Array<Observer<T>>;
  73759. /**
  73760. * Creates a new observable
  73761. * @param onObserverAdded defines a callback to call when a new observer is added
  73762. */
  73763. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73764. /**
  73765. * Create a new Observer with the specified callback
  73766. * @param callback the callback that will be executed for that Observer
  73767. * @param mask the mask used to filter observers
  73768. * @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.
  73769. * @param scope optional scope for the callback to be called from
  73770. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73771. * @returns the new observer created for the callback
  73772. */
  73773. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73774. /**
  73775. * Create a new Observer with the specified callback and unregisters after the next notification
  73776. * @param callback the callback that will be executed for that Observer
  73777. * @returns the new observer created for the callback
  73778. */
  73779. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73780. /**
  73781. * Remove an Observer from the Observable object
  73782. * @param observer the instance of the Observer to remove
  73783. * @returns false if it doesn't belong to this Observable
  73784. */
  73785. remove(observer: Nullable<Observer<T>>): boolean;
  73786. /**
  73787. * Remove a callback from the Observable object
  73788. * @param callback the callback to remove
  73789. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73790. * @returns false if it doesn't belong to this Observable
  73791. */
  73792. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73793. private _deferUnregister;
  73794. private _remove;
  73795. /**
  73796. * Moves the observable to the top of the observer list making it get called first when notified
  73797. * @param observer the observer to move
  73798. */
  73799. makeObserverTopPriority(observer: Observer<T>): void;
  73800. /**
  73801. * Moves the observable to the bottom of the observer list making it get called last when notified
  73802. * @param observer the observer to move
  73803. */
  73804. makeObserverBottomPriority(observer: Observer<T>): void;
  73805. /**
  73806. * Notify all Observers by calling their respective callback with the given data
  73807. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73808. * @param eventData defines the data to send to all observers
  73809. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73810. * @param target defines the original target of the state
  73811. * @param currentTarget defines the current target of the state
  73812. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73813. */
  73814. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73815. /**
  73816. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73817. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73818. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73819. * and it is crucial that all callbacks will be executed.
  73820. * The order of the callbacks is kept, callbacks are not executed parallel.
  73821. *
  73822. * @param eventData The data to be sent to each callback
  73823. * @param mask is used to filter observers defaults to -1
  73824. * @param target defines the callback target (see EventState)
  73825. * @param currentTarget defines he current object in the bubbling phase
  73826. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73827. */
  73828. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73829. /**
  73830. * Notify a specific observer
  73831. * @param observer defines the observer to notify
  73832. * @param eventData defines the data to be sent to each callback
  73833. * @param mask is used to filter observers defaults to -1
  73834. */
  73835. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73836. /**
  73837. * Gets a boolean indicating if the observable has at least one observer
  73838. * @returns true is the Observable has at least one Observer registered
  73839. */
  73840. hasObservers(): boolean;
  73841. /**
  73842. * Clear the list of observers
  73843. */
  73844. clear(): void;
  73845. /**
  73846. * Clone the current observable
  73847. * @returns a new observable
  73848. */
  73849. clone(): Observable<T>;
  73850. /**
  73851. * Does this observable handles observer registered with a given mask
  73852. * @param mask defines the mask to be tested
  73853. * @return whether or not one observer registered with the given mask is handeled
  73854. **/
  73855. hasSpecificMask(mask?: number): boolean;
  73856. }
  73857. }
  73858. declare module BABYLON {
  73859. /**
  73860. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73861. * Babylon.js
  73862. */
  73863. export class DomManagement {
  73864. /**
  73865. * Checks if the window object exists
  73866. * @returns true if the window object exists
  73867. */
  73868. static IsWindowObjectExist(): boolean;
  73869. /**
  73870. * Checks if the navigator object exists
  73871. * @returns true if the navigator object exists
  73872. */
  73873. static IsNavigatorAvailable(): boolean;
  73874. /**
  73875. * Extracts text content from a DOM element hierarchy
  73876. * @param element defines the root element
  73877. * @returns a string
  73878. */
  73879. static GetDOMTextContent(element: HTMLElement): string;
  73880. }
  73881. }
  73882. declare module BABYLON {
  73883. /**
  73884. * Logger used througouht the application to allow configuration of
  73885. * the log level required for the messages.
  73886. */
  73887. export class Logger {
  73888. /**
  73889. * No log
  73890. */
  73891. static readonly NoneLogLevel: number;
  73892. /**
  73893. * Only message logs
  73894. */
  73895. static readonly MessageLogLevel: number;
  73896. /**
  73897. * Only warning logs
  73898. */
  73899. static readonly WarningLogLevel: number;
  73900. /**
  73901. * Only error logs
  73902. */
  73903. static readonly ErrorLogLevel: number;
  73904. /**
  73905. * All logs
  73906. */
  73907. static readonly AllLogLevel: number;
  73908. private static _LogCache;
  73909. /**
  73910. * Gets a value indicating the number of loading errors
  73911. * @ignorenaming
  73912. */
  73913. static errorsCount: number;
  73914. /**
  73915. * Callback called when a new log is added
  73916. */
  73917. static OnNewCacheEntry: (entry: string) => void;
  73918. private static _AddLogEntry;
  73919. private static _FormatMessage;
  73920. private static _LogDisabled;
  73921. private static _LogEnabled;
  73922. private static _WarnDisabled;
  73923. private static _WarnEnabled;
  73924. private static _ErrorDisabled;
  73925. private static _ErrorEnabled;
  73926. /**
  73927. * Log a message to the console
  73928. */
  73929. static Log: (message: string) => void;
  73930. /**
  73931. * Write a warning message to the console
  73932. */
  73933. static Warn: (message: string) => void;
  73934. /**
  73935. * Write an error message to the console
  73936. */
  73937. static Error: (message: string) => void;
  73938. /**
  73939. * Gets current log cache (list of logs)
  73940. */
  73941. static get LogCache(): string;
  73942. /**
  73943. * Clears the log cache
  73944. */
  73945. static ClearLogCache(): void;
  73946. /**
  73947. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73948. */
  73949. static set LogLevels(level: number);
  73950. }
  73951. }
  73952. declare module BABYLON {
  73953. /** @hidden */
  73954. export class _TypeStore {
  73955. /** @hidden */
  73956. static RegisteredTypes: {
  73957. [key: string]: Object;
  73958. };
  73959. /** @hidden */
  73960. static GetClass(fqdn: string): any;
  73961. }
  73962. }
  73963. declare module BABYLON {
  73964. /**
  73965. * Helper to manipulate strings
  73966. */
  73967. export class StringTools {
  73968. /**
  73969. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73970. * @param str Source string
  73971. * @param suffix Suffix to search for in the source string
  73972. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73973. */
  73974. static EndsWith(str: string, suffix: string): boolean;
  73975. /**
  73976. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73977. * @param str Source string
  73978. * @param suffix Suffix to search for in the source string
  73979. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73980. */
  73981. static StartsWith(str: string, suffix: string): boolean;
  73982. /**
  73983. * Decodes a buffer into a string
  73984. * @param buffer The buffer to decode
  73985. * @returns The decoded string
  73986. */
  73987. static Decode(buffer: Uint8Array | Uint16Array): string;
  73988. /**
  73989. * Encode a buffer to a base64 string
  73990. * @param buffer defines the buffer to encode
  73991. * @returns the encoded string
  73992. */
  73993. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73994. /**
  73995. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  73996. * @param num the number to convert and pad
  73997. * @param length the expected length of the string
  73998. * @returns the padded string
  73999. */
  74000. static PadNumber(num: number, length: number): string;
  74001. }
  74002. }
  74003. declare module BABYLON {
  74004. /**
  74005. * Class containing a set of static utilities functions for deep copy.
  74006. */
  74007. export class DeepCopier {
  74008. /**
  74009. * Tries to copy an object by duplicating every property
  74010. * @param source defines the source object
  74011. * @param destination defines the target object
  74012. * @param doNotCopyList defines a list of properties to avoid
  74013. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74014. */
  74015. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74016. }
  74017. }
  74018. declare module BABYLON {
  74019. /**
  74020. * Class containing a set of static utilities functions for precision date
  74021. */
  74022. export class PrecisionDate {
  74023. /**
  74024. * Gets either window.performance.now() if supported or Date.now() else
  74025. */
  74026. static get Now(): number;
  74027. }
  74028. }
  74029. declare module BABYLON {
  74030. /** @hidden */
  74031. export class _DevTools {
  74032. static WarnImport(name: string): string;
  74033. }
  74034. }
  74035. declare module BABYLON {
  74036. /**
  74037. * Interface used to define the mechanism to get data from the network
  74038. */
  74039. export interface IWebRequest {
  74040. /**
  74041. * Returns client's response url
  74042. */
  74043. responseURL: string;
  74044. /**
  74045. * Returns client's status
  74046. */
  74047. status: number;
  74048. /**
  74049. * Returns client's status as a text
  74050. */
  74051. statusText: string;
  74052. }
  74053. }
  74054. declare module BABYLON {
  74055. /**
  74056. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74057. */
  74058. export class WebRequest implements IWebRequest {
  74059. private _xhr;
  74060. /**
  74061. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74062. * i.e. when loading files, where the server/service expects an Authorization header
  74063. */
  74064. static CustomRequestHeaders: {
  74065. [key: string]: string;
  74066. };
  74067. /**
  74068. * Add callback functions in this array to update all the requests before they get sent to the network
  74069. */
  74070. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74071. private _injectCustomRequestHeaders;
  74072. /**
  74073. * Gets or sets a function to be called when loading progress changes
  74074. */
  74075. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74076. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74077. /**
  74078. * Returns client's state
  74079. */
  74080. get readyState(): number;
  74081. /**
  74082. * Returns client's status
  74083. */
  74084. get status(): number;
  74085. /**
  74086. * Returns client's status as a text
  74087. */
  74088. get statusText(): string;
  74089. /**
  74090. * Returns client's response
  74091. */
  74092. get response(): any;
  74093. /**
  74094. * Returns client's response url
  74095. */
  74096. get responseURL(): string;
  74097. /**
  74098. * Returns client's response as text
  74099. */
  74100. get responseText(): string;
  74101. /**
  74102. * Gets or sets the expected response type
  74103. */
  74104. get responseType(): XMLHttpRequestResponseType;
  74105. set responseType(value: XMLHttpRequestResponseType);
  74106. /** @hidden */
  74107. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74108. /** @hidden */
  74109. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74110. /**
  74111. * Cancels any network activity
  74112. */
  74113. abort(): void;
  74114. /**
  74115. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74116. * @param body defines an optional request body
  74117. */
  74118. send(body?: Document | BodyInit | null): void;
  74119. /**
  74120. * Sets the request method, request URL
  74121. * @param method defines the method to use (GET, POST, etc..)
  74122. * @param url defines the url to connect with
  74123. */
  74124. open(method: string, url: string): void;
  74125. /**
  74126. * Sets the value of a request header.
  74127. * @param name The name of the header whose value is to be set
  74128. * @param value The value to set as the body of the header
  74129. */
  74130. setRequestHeader(name: string, value: string): void;
  74131. /**
  74132. * Get the string containing the text of a particular header's value.
  74133. * @param name The name of the header
  74134. * @returns The string containing the text of the given header name
  74135. */
  74136. getResponseHeader(name: string): Nullable<string>;
  74137. }
  74138. }
  74139. declare module BABYLON {
  74140. /**
  74141. * File request interface
  74142. */
  74143. export interface IFileRequest {
  74144. /**
  74145. * Raised when the request is complete (success or error).
  74146. */
  74147. onCompleteObservable: Observable<IFileRequest>;
  74148. /**
  74149. * Aborts the request for a file.
  74150. */
  74151. abort: () => void;
  74152. }
  74153. }
  74154. declare module BABYLON {
  74155. /**
  74156. * Define options used to create a render target texture
  74157. */
  74158. export class RenderTargetCreationOptions {
  74159. /**
  74160. * Specifies is mipmaps must be generated
  74161. */
  74162. generateMipMaps?: boolean;
  74163. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74164. generateDepthBuffer?: boolean;
  74165. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74166. generateStencilBuffer?: boolean;
  74167. /** Defines texture type (int by default) */
  74168. type?: number;
  74169. /** Defines sampling mode (trilinear by default) */
  74170. samplingMode?: number;
  74171. /** Defines format (RGBA by default) */
  74172. format?: number;
  74173. }
  74174. }
  74175. declare module BABYLON {
  74176. /** Defines the cross module used constants to avoid circular dependncies */
  74177. export class Constants {
  74178. /** Defines that alpha blending is disabled */
  74179. static readonly ALPHA_DISABLE: number;
  74180. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74181. static readonly ALPHA_ADD: number;
  74182. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74183. static readonly ALPHA_COMBINE: number;
  74184. /** Defines that alpha blending is DEST - SRC * DEST */
  74185. static readonly ALPHA_SUBTRACT: number;
  74186. /** Defines that alpha blending is SRC * DEST */
  74187. static readonly ALPHA_MULTIPLY: number;
  74188. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74189. static readonly ALPHA_MAXIMIZED: number;
  74190. /** Defines that alpha blending is SRC + DEST */
  74191. static readonly ALPHA_ONEONE: number;
  74192. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74193. static readonly ALPHA_PREMULTIPLIED: number;
  74194. /**
  74195. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74196. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74197. */
  74198. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74199. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74200. static readonly ALPHA_INTERPOLATE: number;
  74201. /**
  74202. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74203. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74204. */
  74205. static readonly ALPHA_SCREENMODE: number;
  74206. /**
  74207. * Defines that alpha blending is SRC + DST
  74208. * Alpha will be set to SRC ALPHA + DST ALPHA
  74209. */
  74210. static readonly ALPHA_ONEONE_ONEONE: number;
  74211. /**
  74212. * Defines that alpha blending is SRC * DST ALPHA + DST
  74213. * Alpha will be set to 0
  74214. */
  74215. static readonly ALPHA_ALPHATOCOLOR: number;
  74216. /**
  74217. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74218. */
  74219. static readonly ALPHA_REVERSEONEMINUS: number;
  74220. /**
  74221. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74222. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74223. */
  74224. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74225. /**
  74226. * Defines that alpha blending is SRC + DST
  74227. * Alpha will be set to SRC ALPHA
  74228. */
  74229. static readonly ALPHA_ONEONE_ONEZERO: number;
  74230. /**
  74231. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74232. * Alpha will be set to DST ALPHA
  74233. */
  74234. static readonly ALPHA_EXCLUSION: number;
  74235. /** Defines that alpha blending equation a SUM */
  74236. static readonly ALPHA_EQUATION_ADD: number;
  74237. /** Defines that alpha blending equation a SUBSTRACTION */
  74238. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74239. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74240. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74241. /** Defines that alpha blending equation a MAX operation */
  74242. static readonly ALPHA_EQUATION_MAX: number;
  74243. /** Defines that alpha blending equation a MIN operation */
  74244. static readonly ALPHA_EQUATION_MIN: number;
  74245. /**
  74246. * Defines that alpha blending equation a DARKEN operation:
  74247. * It takes the min of the src and sums the alpha channels.
  74248. */
  74249. static readonly ALPHA_EQUATION_DARKEN: number;
  74250. /** Defines that the ressource is not delayed*/
  74251. static readonly DELAYLOADSTATE_NONE: number;
  74252. /** Defines that the ressource was successfully delay loaded */
  74253. static readonly DELAYLOADSTATE_LOADED: number;
  74254. /** Defines that the ressource is currently delay loading */
  74255. static readonly DELAYLOADSTATE_LOADING: number;
  74256. /** Defines that the ressource is delayed and has not started loading */
  74257. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74258. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74259. static readonly NEVER: number;
  74260. /** 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 */
  74261. static readonly ALWAYS: number;
  74262. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74263. static readonly LESS: number;
  74264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74265. static readonly EQUAL: number;
  74266. /** 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 */
  74267. static readonly LEQUAL: number;
  74268. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74269. static readonly GREATER: number;
  74270. /** 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 */
  74271. static readonly GEQUAL: number;
  74272. /** 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 */
  74273. static readonly NOTEQUAL: number;
  74274. /** Passed to stencilOperation to specify that stencil value must be kept */
  74275. static readonly KEEP: number;
  74276. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74277. static readonly REPLACE: number;
  74278. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74279. static readonly INCR: number;
  74280. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74281. static readonly DECR: number;
  74282. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74283. static readonly INVERT: number;
  74284. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74285. static readonly INCR_WRAP: number;
  74286. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74287. static readonly DECR_WRAP: number;
  74288. /** Texture is not repeating outside of 0..1 UVs */
  74289. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74290. /** Texture is repeating outside of 0..1 UVs */
  74291. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74292. /** Texture is repeating and mirrored */
  74293. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74294. /** ALPHA */
  74295. static readonly TEXTUREFORMAT_ALPHA: number;
  74296. /** LUMINANCE */
  74297. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74298. /** LUMINANCE_ALPHA */
  74299. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74300. /** RGB */
  74301. static readonly TEXTUREFORMAT_RGB: number;
  74302. /** RGBA */
  74303. static readonly TEXTUREFORMAT_RGBA: number;
  74304. /** RED */
  74305. static readonly TEXTUREFORMAT_RED: number;
  74306. /** RED (2nd reference) */
  74307. static readonly TEXTUREFORMAT_R: number;
  74308. /** RG */
  74309. static readonly TEXTUREFORMAT_RG: number;
  74310. /** RED_INTEGER */
  74311. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74312. /** RED_INTEGER (2nd reference) */
  74313. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74314. /** RG_INTEGER */
  74315. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74316. /** RGB_INTEGER */
  74317. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74318. /** RGBA_INTEGER */
  74319. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74320. /** UNSIGNED_BYTE */
  74321. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74322. /** UNSIGNED_BYTE (2nd reference) */
  74323. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74324. /** FLOAT */
  74325. static readonly TEXTURETYPE_FLOAT: number;
  74326. /** HALF_FLOAT */
  74327. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74328. /** BYTE */
  74329. static readonly TEXTURETYPE_BYTE: number;
  74330. /** SHORT */
  74331. static readonly TEXTURETYPE_SHORT: number;
  74332. /** UNSIGNED_SHORT */
  74333. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74334. /** INT */
  74335. static readonly TEXTURETYPE_INT: number;
  74336. /** UNSIGNED_INT */
  74337. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74338. /** UNSIGNED_SHORT_4_4_4_4 */
  74339. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74340. /** UNSIGNED_SHORT_5_5_5_1 */
  74341. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74342. /** UNSIGNED_SHORT_5_6_5 */
  74343. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74344. /** UNSIGNED_INT_2_10_10_10_REV */
  74345. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74346. /** UNSIGNED_INT_24_8 */
  74347. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74348. /** UNSIGNED_INT_10F_11F_11F_REV */
  74349. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74350. /** UNSIGNED_INT_5_9_9_9_REV */
  74351. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74352. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74353. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74354. /** nearest is mag = nearest and min = nearest and no mip */
  74355. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74356. /** mag = nearest and min = nearest and mip = none */
  74357. static readonly TEXTURE_NEAREST_NEAREST: number;
  74358. /** Bilinear is mag = linear and min = linear and no mip */
  74359. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74360. /** mag = linear and min = linear and mip = none */
  74361. static readonly TEXTURE_LINEAR_LINEAR: number;
  74362. /** Trilinear is mag = linear and min = linear and mip = linear */
  74363. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74364. /** Trilinear is mag = linear and min = linear and mip = linear */
  74365. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74366. /** mag = nearest and min = nearest and mip = nearest */
  74367. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74368. /** mag = nearest and min = linear and mip = nearest */
  74369. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74370. /** mag = nearest and min = linear and mip = linear */
  74371. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74372. /** mag = nearest and min = linear and mip = none */
  74373. static readonly TEXTURE_NEAREST_LINEAR: number;
  74374. /** nearest is mag = nearest and min = nearest and mip = linear */
  74375. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74376. /** mag = linear and min = nearest and mip = nearest */
  74377. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74378. /** mag = linear and min = nearest and mip = linear */
  74379. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74381. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74382. /** mag = linear and min = nearest and mip = none */
  74383. static readonly TEXTURE_LINEAR_NEAREST: number;
  74384. /** Explicit coordinates mode */
  74385. static readonly TEXTURE_EXPLICIT_MODE: number;
  74386. /** Spherical coordinates mode */
  74387. static readonly TEXTURE_SPHERICAL_MODE: number;
  74388. /** Planar coordinates mode */
  74389. static readonly TEXTURE_PLANAR_MODE: number;
  74390. /** Cubic coordinates mode */
  74391. static readonly TEXTURE_CUBIC_MODE: number;
  74392. /** Projection coordinates mode */
  74393. static readonly TEXTURE_PROJECTION_MODE: number;
  74394. /** Skybox coordinates mode */
  74395. static readonly TEXTURE_SKYBOX_MODE: number;
  74396. /** Inverse Cubic coordinates mode */
  74397. static readonly TEXTURE_INVCUBIC_MODE: number;
  74398. /** Equirectangular coordinates mode */
  74399. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74400. /** Equirectangular Fixed coordinates mode */
  74401. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74402. /** Equirectangular Fixed Mirrored coordinates mode */
  74403. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74404. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74405. static readonly SCALEMODE_FLOOR: number;
  74406. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74407. static readonly SCALEMODE_NEAREST: number;
  74408. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74409. static readonly SCALEMODE_CEILING: number;
  74410. /**
  74411. * The dirty texture flag value
  74412. */
  74413. static readonly MATERIAL_TextureDirtyFlag: number;
  74414. /**
  74415. * The dirty light flag value
  74416. */
  74417. static readonly MATERIAL_LightDirtyFlag: number;
  74418. /**
  74419. * The dirty fresnel flag value
  74420. */
  74421. static readonly MATERIAL_FresnelDirtyFlag: number;
  74422. /**
  74423. * The dirty attribute flag value
  74424. */
  74425. static readonly MATERIAL_AttributesDirtyFlag: number;
  74426. /**
  74427. * The dirty misc flag value
  74428. */
  74429. static readonly MATERIAL_MiscDirtyFlag: number;
  74430. /**
  74431. * The all dirty flag value
  74432. */
  74433. static readonly MATERIAL_AllDirtyFlag: number;
  74434. /**
  74435. * Returns the triangle fill mode
  74436. */
  74437. static readonly MATERIAL_TriangleFillMode: number;
  74438. /**
  74439. * Returns the wireframe mode
  74440. */
  74441. static readonly MATERIAL_WireFrameFillMode: number;
  74442. /**
  74443. * Returns the point fill mode
  74444. */
  74445. static readonly MATERIAL_PointFillMode: number;
  74446. /**
  74447. * Returns the point list draw mode
  74448. */
  74449. static readonly MATERIAL_PointListDrawMode: number;
  74450. /**
  74451. * Returns the line list draw mode
  74452. */
  74453. static readonly MATERIAL_LineListDrawMode: number;
  74454. /**
  74455. * Returns the line loop draw mode
  74456. */
  74457. static readonly MATERIAL_LineLoopDrawMode: number;
  74458. /**
  74459. * Returns the line strip draw mode
  74460. */
  74461. static readonly MATERIAL_LineStripDrawMode: number;
  74462. /**
  74463. * Returns the triangle strip draw mode
  74464. */
  74465. static readonly MATERIAL_TriangleStripDrawMode: number;
  74466. /**
  74467. * Returns the triangle fan draw mode
  74468. */
  74469. static readonly MATERIAL_TriangleFanDrawMode: number;
  74470. /**
  74471. * Stores the clock-wise side orientation
  74472. */
  74473. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74474. /**
  74475. * Stores the counter clock-wise side orientation
  74476. */
  74477. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74478. /**
  74479. * Nothing
  74480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74481. */
  74482. static readonly ACTION_NothingTrigger: number;
  74483. /**
  74484. * On pick
  74485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74486. */
  74487. static readonly ACTION_OnPickTrigger: number;
  74488. /**
  74489. * On left pick
  74490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74491. */
  74492. static readonly ACTION_OnLeftPickTrigger: number;
  74493. /**
  74494. * On right pick
  74495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74496. */
  74497. static readonly ACTION_OnRightPickTrigger: number;
  74498. /**
  74499. * On center pick
  74500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74501. */
  74502. static readonly ACTION_OnCenterPickTrigger: number;
  74503. /**
  74504. * On pick down
  74505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74506. */
  74507. static readonly ACTION_OnPickDownTrigger: number;
  74508. /**
  74509. * On double pick
  74510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74511. */
  74512. static readonly ACTION_OnDoublePickTrigger: number;
  74513. /**
  74514. * On pick up
  74515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74516. */
  74517. static readonly ACTION_OnPickUpTrigger: number;
  74518. /**
  74519. * On pick out.
  74520. * This trigger will only be raised if you also declared a OnPickDown
  74521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74522. */
  74523. static readonly ACTION_OnPickOutTrigger: number;
  74524. /**
  74525. * On long press
  74526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74527. */
  74528. static readonly ACTION_OnLongPressTrigger: number;
  74529. /**
  74530. * On pointer over
  74531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74532. */
  74533. static readonly ACTION_OnPointerOverTrigger: number;
  74534. /**
  74535. * On pointer out
  74536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74537. */
  74538. static readonly ACTION_OnPointerOutTrigger: number;
  74539. /**
  74540. * On every frame
  74541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74542. */
  74543. static readonly ACTION_OnEveryFrameTrigger: number;
  74544. /**
  74545. * On intersection enter
  74546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74547. */
  74548. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74549. /**
  74550. * On intersection exit
  74551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74552. */
  74553. static readonly ACTION_OnIntersectionExitTrigger: number;
  74554. /**
  74555. * On key down
  74556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74557. */
  74558. static readonly ACTION_OnKeyDownTrigger: number;
  74559. /**
  74560. * On key up
  74561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74562. */
  74563. static readonly ACTION_OnKeyUpTrigger: number;
  74564. /**
  74565. * Billboard mode will only apply to Y axis
  74566. */
  74567. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74568. /**
  74569. * Billboard mode will apply to all axes
  74570. */
  74571. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74572. /**
  74573. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74574. */
  74575. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74576. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74577. * Test order :
  74578. * Is the bounding sphere outside the frustum ?
  74579. * If not, are the bounding box vertices outside the frustum ?
  74580. * It not, then the cullable object is in the frustum.
  74581. */
  74582. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74583. /** Culling strategy : Bounding Sphere Only.
  74584. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74585. * It's also less accurate than the standard because some not visible objects can still be selected.
  74586. * Test : is the bounding sphere outside the frustum ?
  74587. * If not, then the cullable object is in the frustum.
  74588. */
  74589. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74590. /** Culling strategy : Optimistic Inclusion.
  74591. * This in an inclusion test first, then the standard exclusion test.
  74592. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74593. * 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.
  74594. * Anyway, it's as accurate as the standard strategy.
  74595. * Test :
  74596. * Is the cullable object bounding sphere center in the frustum ?
  74597. * If not, apply the default culling strategy.
  74598. */
  74599. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74600. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74601. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74602. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74603. * 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.
  74604. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74605. * Test :
  74606. * Is the cullable object bounding sphere center in the frustum ?
  74607. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74608. */
  74609. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74610. /**
  74611. * No logging while loading
  74612. */
  74613. static readonly SCENELOADER_NO_LOGGING: number;
  74614. /**
  74615. * Minimal logging while loading
  74616. */
  74617. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74618. /**
  74619. * Summary logging while loading
  74620. */
  74621. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74622. /**
  74623. * Detailled logging while loading
  74624. */
  74625. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74626. }
  74627. }
  74628. declare module BABYLON {
  74629. /**
  74630. * This represents the required contract to create a new type of texture loader.
  74631. */
  74632. export interface IInternalTextureLoader {
  74633. /**
  74634. * Defines wether the loader supports cascade loading the different faces.
  74635. */
  74636. supportCascades: boolean;
  74637. /**
  74638. * This returns if the loader support the current file information.
  74639. * @param extension defines the file extension of the file being loaded
  74640. * @returns true if the loader can load the specified file
  74641. */
  74642. canLoad(extension: string): boolean;
  74643. /**
  74644. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74645. * @param data contains the texture data
  74646. * @param texture defines the BabylonJS internal texture
  74647. * @param createPolynomials will be true if polynomials have been requested
  74648. * @param onLoad defines the callback to trigger once the texture is ready
  74649. * @param onError defines the callback to trigger in case of error
  74650. */
  74651. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74652. /**
  74653. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74654. * @param data contains the texture data
  74655. * @param texture defines the BabylonJS internal texture
  74656. * @param callback defines the method to call once ready to upload
  74657. */
  74658. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74659. }
  74660. }
  74661. declare module BABYLON {
  74662. /**
  74663. * Class used to store and describe the pipeline context associated with an effect
  74664. */
  74665. export interface IPipelineContext {
  74666. /**
  74667. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74668. */
  74669. isAsync: boolean;
  74670. /**
  74671. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74672. */
  74673. isReady: boolean;
  74674. /** @hidden */
  74675. _getVertexShaderCode(): string | null;
  74676. /** @hidden */
  74677. _getFragmentShaderCode(): string | null;
  74678. /** @hidden */
  74679. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74680. }
  74681. }
  74682. declare module BABYLON {
  74683. /**
  74684. * Class used to store gfx data (like WebGLBuffer)
  74685. */
  74686. export class DataBuffer {
  74687. /**
  74688. * Gets or sets the number of objects referencing this buffer
  74689. */
  74690. references: number;
  74691. /** Gets or sets the size of the underlying buffer */
  74692. capacity: number;
  74693. /**
  74694. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74695. */
  74696. is32Bits: boolean;
  74697. /**
  74698. * Gets the underlying buffer
  74699. */
  74700. get underlyingResource(): any;
  74701. }
  74702. }
  74703. declare module BABYLON {
  74704. /** @hidden */
  74705. export interface IShaderProcessor {
  74706. attributeProcessor?: (attribute: string) => string;
  74707. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74708. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74709. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74710. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74711. lineProcessor?: (line: string, isFragment: boolean) => string;
  74712. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74713. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74714. }
  74715. }
  74716. declare module BABYLON {
  74717. /** @hidden */
  74718. export interface ProcessingOptions {
  74719. defines: string[];
  74720. indexParameters: any;
  74721. isFragment: boolean;
  74722. shouldUseHighPrecisionShader: boolean;
  74723. supportsUniformBuffers: boolean;
  74724. shadersRepository: string;
  74725. includesShadersStore: {
  74726. [key: string]: string;
  74727. };
  74728. processor?: IShaderProcessor;
  74729. version: string;
  74730. platformName: string;
  74731. lookForClosingBracketForUniformBuffer?: boolean;
  74732. }
  74733. }
  74734. declare module BABYLON {
  74735. /** @hidden */
  74736. export class ShaderCodeNode {
  74737. line: string;
  74738. children: ShaderCodeNode[];
  74739. additionalDefineKey?: string;
  74740. additionalDefineValue?: string;
  74741. isValid(preprocessors: {
  74742. [key: string]: string;
  74743. }): boolean;
  74744. process(preprocessors: {
  74745. [key: string]: string;
  74746. }, options: ProcessingOptions): string;
  74747. }
  74748. }
  74749. declare module BABYLON {
  74750. /** @hidden */
  74751. export class ShaderCodeCursor {
  74752. private _lines;
  74753. lineIndex: number;
  74754. get currentLine(): string;
  74755. get canRead(): boolean;
  74756. set lines(value: string[]);
  74757. }
  74758. }
  74759. declare module BABYLON {
  74760. /** @hidden */
  74761. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74762. process(preprocessors: {
  74763. [key: string]: string;
  74764. }, options: ProcessingOptions): string;
  74765. }
  74766. }
  74767. declare module BABYLON {
  74768. /** @hidden */
  74769. export class ShaderDefineExpression {
  74770. isTrue(preprocessors: {
  74771. [key: string]: string;
  74772. }): boolean;
  74773. }
  74774. }
  74775. declare module BABYLON {
  74776. /** @hidden */
  74777. export class ShaderCodeTestNode extends ShaderCodeNode {
  74778. testExpression: ShaderDefineExpression;
  74779. isValid(preprocessors: {
  74780. [key: string]: string;
  74781. }): boolean;
  74782. }
  74783. }
  74784. declare module BABYLON {
  74785. /** @hidden */
  74786. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74787. define: string;
  74788. not: boolean;
  74789. constructor(define: string, not?: boolean);
  74790. isTrue(preprocessors: {
  74791. [key: string]: string;
  74792. }): boolean;
  74793. }
  74794. }
  74795. declare module BABYLON {
  74796. /** @hidden */
  74797. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74798. leftOperand: ShaderDefineExpression;
  74799. rightOperand: ShaderDefineExpression;
  74800. isTrue(preprocessors: {
  74801. [key: string]: string;
  74802. }): boolean;
  74803. }
  74804. }
  74805. declare module BABYLON {
  74806. /** @hidden */
  74807. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74808. leftOperand: ShaderDefineExpression;
  74809. rightOperand: ShaderDefineExpression;
  74810. isTrue(preprocessors: {
  74811. [key: string]: string;
  74812. }): boolean;
  74813. }
  74814. }
  74815. declare module BABYLON {
  74816. /** @hidden */
  74817. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74818. define: string;
  74819. operand: string;
  74820. testValue: string;
  74821. constructor(define: string, operand: string, testValue: string);
  74822. isTrue(preprocessors: {
  74823. [key: string]: string;
  74824. }): boolean;
  74825. }
  74826. }
  74827. declare module BABYLON {
  74828. /**
  74829. * Class used to enable access to offline support
  74830. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74831. */
  74832. export interface IOfflineProvider {
  74833. /**
  74834. * Gets a boolean indicating if scene must be saved in the database
  74835. */
  74836. enableSceneOffline: boolean;
  74837. /**
  74838. * Gets a boolean indicating if textures must be saved in the database
  74839. */
  74840. enableTexturesOffline: boolean;
  74841. /**
  74842. * Open the offline support and make it available
  74843. * @param successCallback defines the callback to call on success
  74844. * @param errorCallback defines the callback to call on error
  74845. */
  74846. open(successCallback: () => void, errorCallback: () => void): void;
  74847. /**
  74848. * Loads an image from the offline support
  74849. * @param url defines the url to load from
  74850. * @param image defines the target DOM image
  74851. */
  74852. loadImage(url: string, image: HTMLImageElement): void;
  74853. /**
  74854. * Loads a file from offline support
  74855. * @param url defines the URL to load from
  74856. * @param sceneLoaded defines a callback to call on success
  74857. * @param progressCallBack defines a callback to call when progress changed
  74858. * @param errorCallback defines a callback to call on error
  74859. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74860. */
  74861. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74862. }
  74863. }
  74864. declare module BABYLON {
  74865. /**
  74866. * Class used to help managing file picking and drag'n'drop
  74867. * File Storage
  74868. */
  74869. export class FilesInputStore {
  74870. /**
  74871. * List of files ready to be loaded
  74872. */
  74873. static FilesToLoad: {
  74874. [key: string]: File;
  74875. };
  74876. }
  74877. }
  74878. declare module BABYLON {
  74879. /**
  74880. * Class used to define a retry strategy when error happens while loading assets
  74881. */
  74882. export class RetryStrategy {
  74883. /**
  74884. * Function used to defines an exponential back off strategy
  74885. * @param maxRetries defines the maximum number of retries (3 by default)
  74886. * @param baseInterval defines the interval between retries
  74887. * @returns the strategy function to use
  74888. */
  74889. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74890. }
  74891. }
  74892. declare module BABYLON {
  74893. /**
  74894. * @ignore
  74895. * Application error to support additional information when loading a file
  74896. */
  74897. export abstract class BaseError extends Error {
  74898. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74899. }
  74900. }
  74901. declare module BABYLON {
  74902. /** @ignore */
  74903. export class LoadFileError extends BaseError {
  74904. request?: WebRequest;
  74905. file?: File;
  74906. /**
  74907. * Creates a new LoadFileError
  74908. * @param message defines the message of the error
  74909. * @param request defines the optional web request
  74910. * @param file defines the optional file
  74911. */
  74912. constructor(message: string, object?: WebRequest | File);
  74913. }
  74914. /** @ignore */
  74915. export class RequestFileError extends BaseError {
  74916. request: WebRequest;
  74917. /**
  74918. * Creates a new LoadFileError
  74919. * @param message defines the message of the error
  74920. * @param request defines the optional web request
  74921. */
  74922. constructor(message: string, request: WebRequest);
  74923. }
  74924. /** @ignore */
  74925. export class ReadFileError extends BaseError {
  74926. file: File;
  74927. /**
  74928. * Creates a new ReadFileError
  74929. * @param message defines the message of the error
  74930. * @param file defines the optional file
  74931. */
  74932. constructor(message: string, file: File);
  74933. }
  74934. /**
  74935. * @hidden
  74936. */
  74937. export class FileTools {
  74938. /**
  74939. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74940. */
  74941. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74942. /**
  74943. * Gets or sets the base URL to use to load assets
  74944. */
  74945. static BaseUrl: string;
  74946. /**
  74947. * Default behaviour for cors in the application.
  74948. * It can be a string if the expected behavior is identical in the entire app.
  74949. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74950. */
  74951. static CorsBehavior: string | ((url: string | string[]) => string);
  74952. /**
  74953. * Gets or sets a function used to pre-process url before using them to load assets
  74954. */
  74955. static PreprocessUrl: (url: string) => string;
  74956. /**
  74957. * Removes unwanted characters from an url
  74958. * @param url defines the url to clean
  74959. * @returns the cleaned url
  74960. */
  74961. private static _CleanUrl;
  74962. /**
  74963. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74964. * @param url define the url we are trying
  74965. * @param element define the dom element where to configure the cors policy
  74966. */
  74967. static SetCorsBehavior(url: string | string[], element: {
  74968. crossOrigin: string | null;
  74969. }): void;
  74970. /**
  74971. * Loads an image as an HTMLImageElement.
  74972. * @param input url string, ArrayBuffer, or Blob to load
  74973. * @param onLoad callback called when the image successfully loads
  74974. * @param onError callback called when the image fails to load
  74975. * @param offlineProvider offline provider for caching
  74976. * @param mimeType optional mime type
  74977. * @returns the HTMLImageElement of the loaded image
  74978. */
  74979. 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>;
  74980. /**
  74981. * Reads a file from a File object
  74982. * @param file defines the file to load
  74983. * @param onSuccess defines the callback to call when data is loaded
  74984. * @param onProgress defines the callback to call during loading process
  74985. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74986. * @param onError defines the callback to call when an error occurs
  74987. * @returns a file request object
  74988. */
  74989. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74990. /**
  74991. * Loads a file from a url
  74992. * @param url url to load
  74993. * @param onSuccess callback called when the file successfully loads
  74994. * @param onProgress callback called while file is loading (if the server supports this mode)
  74995. * @param offlineProvider defines the offline provider for caching
  74996. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74997. * @param onError callback called when the file fails to load
  74998. * @returns a file request object
  74999. */
  75000. 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;
  75001. /**
  75002. * Loads a file
  75003. * @param url url to load
  75004. * @param onSuccess callback called when the file successfully loads
  75005. * @param onProgress callback called while file is loading (if the server supports this mode)
  75006. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75007. * @param onError callback called when the file fails to load
  75008. * @param onOpened callback called when the web request is opened
  75009. * @returns a file request object
  75010. */
  75011. 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;
  75012. /**
  75013. * Checks if the loaded document was accessed via `file:`-Protocol.
  75014. * @returns boolean
  75015. */
  75016. static IsFileURL(): boolean;
  75017. }
  75018. }
  75019. declare module BABYLON {
  75020. /** @hidden */
  75021. export class ShaderProcessor {
  75022. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75023. private static _ProcessPrecision;
  75024. private static _ExtractOperation;
  75025. private static _BuildSubExpression;
  75026. private static _BuildExpression;
  75027. private static _MoveCursorWithinIf;
  75028. private static _MoveCursor;
  75029. private static _EvaluatePreProcessors;
  75030. private static _PreparePreProcessors;
  75031. private static _ProcessShaderConversion;
  75032. private static _ProcessIncludes;
  75033. /**
  75034. * Loads a file from a url
  75035. * @param url url to load
  75036. * @param onSuccess callback called when the file successfully loads
  75037. * @param onProgress callback called while file is loading (if the server supports this mode)
  75038. * @param offlineProvider defines the offline provider for caching
  75039. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75040. * @param onError callback called when the file fails to load
  75041. * @returns a file request object
  75042. * @hidden
  75043. */
  75044. 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;
  75045. }
  75046. }
  75047. declare module BABYLON {
  75048. /**
  75049. * @hidden
  75050. */
  75051. export interface IColor4Like {
  75052. r: float;
  75053. g: float;
  75054. b: float;
  75055. a: float;
  75056. }
  75057. /**
  75058. * @hidden
  75059. */
  75060. export interface IColor3Like {
  75061. r: float;
  75062. g: float;
  75063. b: float;
  75064. }
  75065. /**
  75066. * @hidden
  75067. */
  75068. export interface IVector4Like {
  75069. x: float;
  75070. y: float;
  75071. z: float;
  75072. w: float;
  75073. }
  75074. /**
  75075. * @hidden
  75076. */
  75077. export interface IVector3Like {
  75078. x: float;
  75079. y: float;
  75080. z: float;
  75081. }
  75082. /**
  75083. * @hidden
  75084. */
  75085. export interface IVector2Like {
  75086. x: float;
  75087. y: float;
  75088. }
  75089. /**
  75090. * @hidden
  75091. */
  75092. export interface IMatrixLike {
  75093. toArray(): DeepImmutable<Float32Array>;
  75094. updateFlag: int;
  75095. }
  75096. /**
  75097. * @hidden
  75098. */
  75099. export interface IViewportLike {
  75100. x: float;
  75101. y: float;
  75102. width: float;
  75103. height: float;
  75104. }
  75105. /**
  75106. * @hidden
  75107. */
  75108. export interface IPlaneLike {
  75109. normal: IVector3Like;
  75110. d: float;
  75111. normalize(): void;
  75112. }
  75113. }
  75114. declare module BABYLON {
  75115. /**
  75116. * Interface used to define common properties for effect fallbacks
  75117. */
  75118. export interface IEffectFallbacks {
  75119. /**
  75120. * Removes the defines that should be removed when falling back.
  75121. * @param currentDefines defines the current define statements for the shader.
  75122. * @param effect defines the current effect we try to compile
  75123. * @returns The resulting defines with defines of the current rank removed.
  75124. */
  75125. reduce(currentDefines: string, effect: Effect): string;
  75126. /**
  75127. * Removes the fallback from the bound mesh.
  75128. */
  75129. unBindMesh(): void;
  75130. /**
  75131. * Checks to see if more fallbacks are still availible.
  75132. */
  75133. hasMoreFallbacks: boolean;
  75134. }
  75135. }
  75136. declare module BABYLON {
  75137. /**
  75138. * Class used to evalaute queries containing `and` and `or` operators
  75139. */
  75140. export class AndOrNotEvaluator {
  75141. /**
  75142. * Evaluate a query
  75143. * @param query defines the query to evaluate
  75144. * @param evaluateCallback defines the callback used to filter result
  75145. * @returns true if the query matches
  75146. */
  75147. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75148. private static _HandleParenthesisContent;
  75149. private static _SimplifyNegation;
  75150. }
  75151. }
  75152. declare module BABYLON {
  75153. /**
  75154. * Class used to store custom tags
  75155. */
  75156. export class Tags {
  75157. /**
  75158. * Adds support for tags on the given object
  75159. * @param obj defines the object to use
  75160. */
  75161. static EnableFor(obj: any): void;
  75162. /**
  75163. * Removes tags support
  75164. * @param obj defines the object to use
  75165. */
  75166. static DisableFor(obj: any): void;
  75167. /**
  75168. * Gets a boolean indicating if the given object has tags
  75169. * @param obj defines the object to use
  75170. * @returns a boolean
  75171. */
  75172. static HasTags(obj: any): boolean;
  75173. /**
  75174. * Gets the tags available on a given object
  75175. * @param obj defines the object to use
  75176. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75177. * @returns the tags
  75178. */
  75179. static GetTags(obj: any, asString?: boolean): any;
  75180. /**
  75181. * Adds tags to an object
  75182. * @param obj defines the object to use
  75183. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75184. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75185. */
  75186. static AddTagsTo(obj: any, tagsString: string): void;
  75187. /**
  75188. * @hidden
  75189. */
  75190. static _AddTagTo(obj: any, tag: string): void;
  75191. /**
  75192. * Removes specific tags from a specific object
  75193. * @param obj defines the object to use
  75194. * @param tagsString defines the tags to remove
  75195. */
  75196. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75197. /**
  75198. * @hidden
  75199. */
  75200. static _RemoveTagFrom(obj: any, tag: string): void;
  75201. /**
  75202. * Defines if tags hosted on an object match a given query
  75203. * @param obj defines the object to use
  75204. * @param tagsQuery defines the tag query
  75205. * @returns a boolean
  75206. */
  75207. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75208. }
  75209. }
  75210. declare module BABYLON {
  75211. /**
  75212. * Scalar computation library
  75213. */
  75214. export class Scalar {
  75215. /**
  75216. * Two pi constants convenient for computation.
  75217. */
  75218. static TwoPi: number;
  75219. /**
  75220. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75221. * @param a number
  75222. * @param b number
  75223. * @param epsilon (default = 1.401298E-45)
  75224. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75225. */
  75226. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75227. /**
  75228. * Returns a string : the upper case translation of the number i to hexadecimal.
  75229. * @param i number
  75230. * @returns the upper case translation of the number i to hexadecimal.
  75231. */
  75232. static ToHex(i: number): string;
  75233. /**
  75234. * Returns -1 if value is negative and +1 is value is positive.
  75235. * @param value the value
  75236. * @returns the value itself if it's equal to zero.
  75237. */
  75238. static Sign(value: number): number;
  75239. /**
  75240. * Returns the value itself if it's between min and max.
  75241. * Returns min if the value is lower than min.
  75242. * Returns max if the value is greater than max.
  75243. * @param value the value to clmap
  75244. * @param min the min value to clamp to (default: 0)
  75245. * @param max the max value to clamp to (default: 1)
  75246. * @returns the clamped value
  75247. */
  75248. static Clamp(value: number, min?: number, max?: number): number;
  75249. /**
  75250. * the log2 of value.
  75251. * @param value the value to compute log2 of
  75252. * @returns the log2 of value.
  75253. */
  75254. static Log2(value: number): number;
  75255. /**
  75256. * Loops the value, so that it is never larger than length and never smaller than 0.
  75257. *
  75258. * This is similar to the modulo operator but it works with floating point numbers.
  75259. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75260. * With t = 5 and length = 2.5, the result would be 0.0.
  75261. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75262. * @param value the value
  75263. * @param length the length
  75264. * @returns the looped value
  75265. */
  75266. static Repeat(value: number, length: number): number;
  75267. /**
  75268. * Normalize the value between 0.0 and 1.0 using min and max values
  75269. * @param value value to normalize
  75270. * @param min max to normalize between
  75271. * @param max min to normalize between
  75272. * @returns the normalized value
  75273. */
  75274. static Normalize(value: number, min: number, max: number): number;
  75275. /**
  75276. * Denormalize the value from 0.0 and 1.0 using min and max values
  75277. * @param normalized value to denormalize
  75278. * @param min max to denormalize between
  75279. * @param max min to denormalize between
  75280. * @returns the denormalized value
  75281. */
  75282. static Denormalize(normalized: number, min: number, max: number): number;
  75283. /**
  75284. * Calculates the shortest difference between two given angles given in degrees.
  75285. * @param current current angle in degrees
  75286. * @param target target angle in degrees
  75287. * @returns the delta
  75288. */
  75289. static DeltaAngle(current: number, target: number): number;
  75290. /**
  75291. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75292. * @param tx value
  75293. * @param length length
  75294. * @returns The returned value will move back and forth between 0 and length
  75295. */
  75296. static PingPong(tx: number, length: number): number;
  75297. /**
  75298. * Interpolates between min and max with smoothing at the limits.
  75299. *
  75300. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75301. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75302. * @param from from
  75303. * @param to to
  75304. * @param tx value
  75305. * @returns the smooth stepped value
  75306. */
  75307. static SmoothStep(from: number, to: number, tx: number): number;
  75308. /**
  75309. * Moves a value current towards target.
  75310. *
  75311. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75312. * Negative values of maxDelta pushes the value away from target.
  75313. * @param current current value
  75314. * @param target target value
  75315. * @param maxDelta max distance to move
  75316. * @returns resulting value
  75317. */
  75318. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75319. /**
  75320. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75321. *
  75322. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75323. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75324. * @param current current value
  75325. * @param target target value
  75326. * @param maxDelta max distance to move
  75327. * @returns resulting angle
  75328. */
  75329. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75330. /**
  75331. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75332. * @param start start value
  75333. * @param end target value
  75334. * @param amount amount to lerp between
  75335. * @returns the lerped value
  75336. */
  75337. static Lerp(start: number, end: number, amount: number): number;
  75338. /**
  75339. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75340. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75341. * @param start start value
  75342. * @param end target value
  75343. * @param amount amount to lerp between
  75344. * @returns the lerped value
  75345. */
  75346. static LerpAngle(start: number, end: number, amount: number): number;
  75347. /**
  75348. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75349. * @param a start value
  75350. * @param b target value
  75351. * @param value value between a and b
  75352. * @returns the inverseLerp value
  75353. */
  75354. static InverseLerp(a: number, b: number, value: number): number;
  75355. /**
  75356. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75357. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75358. * @param value1 spline value
  75359. * @param tangent1 spline value
  75360. * @param value2 spline value
  75361. * @param tangent2 spline value
  75362. * @param amount input value
  75363. * @returns hermite result
  75364. */
  75365. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75366. /**
  75367. * Returns a random float number between and min and max values
  75368. * @param min min value of random
  75369. * @param max max value of random
  75370. * @returns random value
  75371. */
  75372. static RandomRange(min: number, max: number): number;
  75373. /**
  75374. * This function returns percentage of a number in a given range.
  75375. *
  75376. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75377. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75378. * @param number to convert to percentage
  75379. * @param min min range
  75380. * @param max max range
  75381. * @returns the percentage
  75382. */
  75383. static RangeToPercent(number: number, min: number, max: number): number;
  75384. /**
  75385. * This function returns number that corresponds to the percentage in a given range.
  75386. *
  75387. * PercentToRange(0.34,0,100) will return 34.
  75388. * @param percent to convert to number
  75389. * @param min min range
  75390. * @param max max range
  75391. * @returns the number
  75392. */
  75393. static PercentToRange(percent: number, min: number, max: number): number;
  75394. /**
  75395. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75396. * @param angle The angle to normalize in radian.
  75397. * @return The converted angle.
  75398. */
  75399. static NormalizeRadians(angle: number): number;
  75400. }
  75401. }
  75402. declare module BABYLON {
  75403. /**
  75404. * Constant used to convert a value to gamma space
  75405. * @ignorenaming
  75406. */
  75407. export const ToGammaSpace: number;
  75408. /**
  75409. * Constant used to convert a value to linear space
  75410. * @ignorenaming
  75411. */
  75412. export const ToLinearSpace = 2.2;
  75413. /**
  75414. * Constant used to define the minimal number value in Babylon.js
  75415. * @ignorenaming
  75416. */
  75417. let Epsilon: number;
  75418. }
  75419. declare module BABYLON {
  75420. /**
  75421. * Class used to represent a viewport on screen
  75422. */
  75423. export class Viewport {
  75424. /** viewport left coordinate */
  75425. x: number;
  75426. /** viewport top coordinate */
  75427. y: number;
  75428. /**viewport width */
  75429. width: number;
  75430. /** viewport height */
  75431. height: number;
  75432. /**
  75433. * Creates a Viewport object located at (x, y) and sized (width, height)
  75434. * @param x defines viewport left coordinate
  75435. * @param y defines viewport top coordinate
  75436. * @param width defines the viewport width
  75437. * @param height defines the viewport height
  75438. */
  75439. constructor(
  75440. /** viewport left coordinate */
  75441. x: number,
  75442. /** viewport top coordinate */
  75443. y: number,
  75444. /**viewport width */
  75445. width: number,
  75446. /** viewport height */
  75447. height: number);
  75448. /**
  75449. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75450. * @param renderWidth defines the rendering width
  75451. * @param renderHeight defines the rendering height
  75452. * @returns a new Viewport
  75453. */
  75454. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75455. /**
  75456. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75457. * @param renderWidth defines the rendering width
  75458. * @param renderHeight defines the rendering height
  75459. * @param ref defines the target viewport
  75460. * @returns the current viewport
  75461. */
  75462. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75463. /**
  75464. * Returns a new Viewport copied from the current one
  75465. * @returns a new Viewport
  75466. */
  75467. clone(): Viewport;
  75468. }
  75469. }
  75470. declare module BABYLON {
  75471. /**
  75472. * Class containing a set of static utilities functions for arrays.
  75473. */
  75474. export class ArrayTools {
  75475. /**
  75476. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75477. * @param size the number of element to construct and put in the array
  75478. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75479. * @returns a new array filled with new objects
  75480. */
  75481. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75482. }
  75483. }
  75484. declare module BABYLON {
  75485. /**
  75486. * Class representing a vector containing 2 coordinates
  75487. */
  75488. export class Vector2 {
  75489. /** defines the first coordinate */
  75490. x: number;
  75491. /** defines the second coordinate */
  75492. y: number;
  75493. /**
  75494. * Creates a new Vector2 from the given x and y coordinates
  75495. * @param x defines the first coordinate
  75496. * @param y defines the second coordinate
  75497. */
  75498. constructor(
  75499. /** defines the first coordinate */
  75500. x?: number,
  75501. /** defines the second coordinate */
  75502. y?: number);
  75503. /**
  75504. * Gets a string with the Vector2 coordinates
  75505. * @returns a string with the Vector2 coordinates
  75506. */
  75507. toString(): string;
  75508. /**
  75509. * Gets class name
  75510. * @returns the string "Vector2"
  75511. */
  75512. getClassName(): string;
  75513. /**
  75514. * Gets current vector hash code
  75515. * @returns the Vector2 hash code as a number
  75516. */
  75517. getHashCode(): number;
  75518. /**
  75519. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75520. * @param array defines the source array
  75521. * @param index defines the offset in source array
  75522. * @returns the current Vector2
  75523. */
  75524. toArray(array: FloatArray, index?: number): Vector2;
  75525. /**
  75526. * Copy the current vector to an array
  75527. * @returns a new array with 2 elements: the Vector2 coordinates.
  75528. */
  75529. asArray(): number[];
  75530. /**
  75531. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75532. * @param source defines the source Vector2
  75533. * @returns the current updated Vector2
  75534. */
  75535. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75536. /**
  75537. * Sets the Vector2 coordinates with the given floats
  75538. * @param x defines the first coordinate
  75539. * @param y defines the second coordinate
  75540. * @returns the current updated Vector2
  75541. */
  75542. copyFromFloats(x: number, y: number): Vector2;
  75543. /**
  75544. * Sets the Vector2 coordinates with the given floats
  75545. * @param x defines the first coordinate
  75546. * @param y defines the second coordinate
  75547. * @returns the current updated Vector2
  75548. */
  75549. set(x: number, y: number): Vector2;
  75550. /**
  75551. * Add another vector with the current one
  75552. * @param otherVector defines the other vector
  75553. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75554. */
  75555. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75556. /**
  75557. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75558. * @param otherVector defines the other vector
  75559. * @param result defines the target vector
  75560. * @returns the unmodified current Vector2
  75561. */
  75562. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75563. /**
  75564. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75565. * @param otherVector defines the other vector
  75566. * @returns the current updated Vector2
  75567. */
  75568. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75569. /**
  75570. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75571. * @param otherVector defines the other vector
  75572. * @returns a new Vector2
  75573. */
  75574. addVector3(otherVector: Vector3): Vector2;
  75575. /**
  75576. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75577. * @param otherVector defines the other vector
  75578. * @returns a new Vector2
  75579. */
  75580. subtract(otherVector: Vector2): Vector2;
  75581. /**
  75582. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75583. * @param otherVector defines the other vector
  75584. * @param result defines the target vector
  75585. * @returns the unmodified current Vector2
  75586. */
  75587. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75588. /**
  75589. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75590. * @param otherVector defines the other vector
  75591. * @returns the current updated Vector2
  75592. */
  75593. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75594. /**
  75595. * Multiplies in place the current Vector2 coordinates by the given ones
  75596. * @param otherVector defines the other vector
  75597. * @returns the current updated Vector2
  75598. */
  75599. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75600. /**
  75601. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75602. * @param otherVector defines the other vector
  75603. * @returns a new Vector2
  75604. */
  75605. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75606. /**
  75607. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75608. * @param otherVector defines the other vector
  75609. * @param result defines the target vector
  75610. * @returns the unmodified current Vector2
  75611. */
  75612. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75613. /**
  75614. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75615. * @param x defines the first coordinate
  75616. * @param y defines the second coordinate
  75617. * @returns a new Vector2
  75618. */
  75619. multiplyByFloats(x: number, y: number): Vector2;
  75620. /**
  75621. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75622. * @param otherVector defines the other vector
  75623. * @returns a new Vector2
  75624. */
  75625. divide(otherVector: Vector2): Vector2;
  75626. /**
  75627. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75628. * @param otherVector defines the other vector
  75629. * @param result defines the target vector
  75630. * @returns the unmodified current Vector2
  75631. */
  75632. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75633. /**
  75634. * Divides the current Vector2 coordinates by the given ones
  75635. * @param otherVector defines the other vector
  75636. * @returns the current updated Vector2
  75637. */
  75638. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75639. /**
  75640. * Gets a new Vector2 with current Vector2 negated coordinates
  75641. * @returns a new Vector2
  75642. */
  75643. negate(): Vector2;
  75644. /**
  75645. * Negate this vector in place
  75646. * @returns this
  75647. */
  75648. negateInPlace(): Vector2;
  75649. /**
  75650. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75651. * @param result defines the Vector3 object where to store the result
  75652. * @returns the current Vector2
  75653. */
  75654. negateToRef(result: Vector2): Vector2;
  75655. /**
  75656. * Multiply the Vector2 coordinates by scale
  75657. * @param scale defines the scaling factor
  75658. * @returns the current updated Vector2
  75659. */
  75660. scaleInPlace(scale: number): Vector2;
  75661. /**
  75662. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75663. * @param scale defines the scaling factor
  75664. * @returns a new Vector2
  75665. */
  75666. scale(scale: number): Vector2;
  75667. /**
  75668. * Scale the current Vector2 values by a factor to a given Vector2
  75669. * @param scale defines the scale factor
  75670. * @param result defines the Vector2 object where to store the result
  75671. * @returns the unmodified current Vector2
  75672. */
  75673. scaleToRef(scale: number, result: Vector2): Vector2;
  75674. /**
  75675. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75676. * @param scale defines the scale factor
  75677. * @param result defines the Vector2 object where to store the result
  75678. * @returns the unmodified current Vector2
  75679. */
  75680. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75681. /**
  75682. * Gets a boolean if two vectors are equals
  75683. * @param otherVector defines the other vector
  75684. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75685. */
  75686. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75687. /**
  75688. * Gets a boolean if two vectors are equals (using an epsilon value)
  75689. * @param otherVector defines the other vector
  75690. * @param epsilon defines the minimal distance to consider equality
  75691. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75692. */
  75693. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75694. /**
  75695. * Gets a new Vector2 from current Vector2 floored values
  75696. * @returns a new Vector2
  75697. */
  75698. floor(): Vector2;
  75699. /**
  75700. * Gets a new Vector2 from current Vector2 floored values
  75701. * @returns a new Vector2
  75702. */
  75703. fract(): Vector2;
  75704. /**
  75705. * Gets the length of the vector
  75706. * @returns the vector length (float)
  75707. */
  75708. length(): number;
  75709. /**
  75710. * Gets the vector squared length
  75711. * @returns the vector squared length (float)
  75712. */
  75713. lengthSquared(): number;
  75714. /**
  75715. * Normalize the vector
  75716. * @returns the current updated Vector2
  75717. */
  75718. normalize(): Vector2;
  75719. /**
  75720. * Gets a new Vector2 copied from the Vector2
  75721. * @returns a new Vector2
  75722. */
  75723. clone(): Vector2;
  75724. /**
  75725. * Gets a new Vector2(0, 0)
  75726. * @returns a new Vector2
  75727. */
  75728. static Zero(): Vector2;
  75729. /**
  75730. * Gets a new Vector2(1, 1)
  75731. * @returns a new Vector2
  75732. */
  75733. static One(): Vector2;
  75734. /**
  75735. * Gets a new Vector2 set from the given index element of the given array
  75736. * @param array defines the data source
  75737. * @param offset defines the offset in the data source
  75738. * @returns a new Vector2
  75739. */
  75740. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75741. /**
  75742. * Sets "result" from the given index element of the given array
  75743. * @param array defines the data source
  75744. * @param offset defines the offset in the data source
  75745. * @param result defines the target vector
  75746. */
  75747. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75748. /**
  75749. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75750. * @param value1 defines 1st point of control
  75751. * @param value2 defines 2nd point of control
  75752. * @param value3 defines 3rd point of control
  75753. * @param value4 defines 4th point of control
  75754. * @param amount defines the interpolation factor
  75755. * @returns a new Vector2
  75756. */
  75757. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75758. /**
  75759. * 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".
  75760. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75761. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75762. * @param value defines the value to clamp
  75763. * @param min defines the lower limit
  75764. * @param max defines the upper limit
  75765. * @returns a new Vector2
  75766. */
  75767. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75768. /**
  75769. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75770. * @param value1 defines the 1st control point
  75771. * @param tangent1 defines the outgoing tangent
  75772. * @param value2 defines the 2nd control point
  75773. * @param tangent2 defines the incoming tangent
  75774. * @param amount defines the interpolation factor
  75775. * @returns a new Vector2
  75776. */
  75777. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75778. /**
  75779. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75780. * @param start defines the start vector
  75781. * @param end defines the end vector
  75782. * @param amount defines the interpolation factor
  75783. * @returns a new Vector2
  75784. */
  75785. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75786. /**
  75787. * Gets the dot product of the vector "left" and the vector "right"
  75788. * @param left defines first vector
  75789. * @param right defines second vector
  75790. * @returns the dot product (float)
  75791. */
  75792. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75793. /**
  75794. * Returns a new Vector2 equal to the normalized given vector
  75795. * @param vector defines the vector to normalize
  75796. * @returns a new Vector2
  75797. */
  75798. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75799. /**
  75800. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75801. * @param left defines 1st vector
  75802. * @param right defines 2nd vector
  75803. * @returns a new Vector2
  75804. */
  75805. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75806. /**
  75807. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75808. * @param left defines 1st vector
  75809. * @param right defines 2nd vector
  75810. * @returns a new Vector2
  75811. */
  75812. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75813. /**
  75814. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75815. * @param vector defines the vector to transform
  75816. * @param transformation defines the matrix to apply
  75817. * @returns a new Vector2
  75818. */
  75819. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75820. /**
  75821. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75822. * @param vector defines the vector to transform
  75823. * @param transformation defines the matrix to apply
  75824. * @param result defines the target vector
  75825. */
  75826. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75827. /**
  75828. * Determines if a given vector is included in a triangle
  75829. * @param p defines the vector to test
  75830. * @param p0 defines 1st triangle point
  75831. * @param p1 defines 2nd triangle point
  75832. * @param p2 defines 3rd triangle point
  75833. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75834. */
  75835. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75836. /**
  75837. * Gets the distance between the vectors "value1" and "value2"
  75838. * @param value1 defines first vector
  75839. * @param value2 defines second vector
  75840. * @returns the distance between vectors
  75841. */
  75842. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75843. /**
  75844. * Returns the squared distance between the vectors "value1" and "value2"
  75845. * @param value1 defines first vector
  75846. * @param value2 defines second vector
  75847. * @returns the squared distance between vectors
  75848. */
  75849. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75850. /**
  75851. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75852. * @param value1 defines first vector
  75853. * @param value2 defines second vector
  75854. * @returns a new Vector2
  75855. */
  75856. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75857. /**
  75858. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75859. * @param p defines the middle point
  75860. * @param segA defines one point of the segment
  75861. * @param segB defines the other point of the segment
  75862. * @returns the shortest distance
  75863. */
  75864. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75865. }
  75866. /**
  75867. * Class used to store (x,y,z) vector representation
  75868. * A Vector3 is the main object used in 3D geometry
  75869. * It can represent etiher the coordinates of a point the space, either a direction
  75870. * Reminder: js uses a left handed forward facing system
  75871. */
  75872. export class Vector3 {
  75873. /**
  75874. * Defines the first coordinates (on X axis)
  75875. */
  75876. x: number;
  75877. /**
  75878. * Defines the second coordinates (on Y axis)
  75879. */
  75880. y: number;
  75881. /**
  75882. * Defines the third coordinates (on Z axis)
  75883. */
  75884. z: number;
  75885. private static _UpReadOnly;
  75886. private static _ZeroReadOnly;
  75887. /**
  75888. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75889. * @param x defines the first coordinates (on X axis)
  75890. * @param y defines the second coordinates (on Y axis)
  75891. * @param z defines the third coordinates (on Z axis)
  75892. */
  75893. constructor(
  75894. /**
  75895. * Defines the first coordinates (on X axis)
  75896. */
  75897. x?: number,
  75898. /**
  75899. * Defines the second coordinates (on Y axis)
  75900. */
  75901. y?: number,
  75902. /**
  75903. * Defines the third coordinates (on Z axis)
  75904. */
  75905. z?: number);
  75906. /**
  75907. * Creates a string representation of the Vector3
  75908. * @returns a string with the Vector3 coordinates.
  75909. */
  75910. toString(): string;
  75911. /**
  75912. * Gets the class name
  75913. * @returns the string "Vector3"
  75914. */
  75915. getClassName(): string;
  75916. /**
  75917. * Creates the Vector3 hash code
  75918. * @returns a number which tends to be unique between Vector3 instances
  75919. */
  75920. getHashCode(): number;
  75921. /**
  75922. * Creates an array containing three elements : the coordinates of the Vector3
  75923. * @returns a new array of numbers
  75924. */
  75925. asArray(): number[];
  75926. /**
  75927. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75928. * @param array defines the destination array
  75929. * @param index defines the offset in the destination array
  75930. * @returns the current Vector3
  75931. */
  75932. toArray(array: FloatArray, index?: number): Vector3;
  75933. /**
  75934. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75935. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75936. */
  75937. toQuaternion(): Quaternion;
  75938. /**
  75939. * Adds the given vector to the current Vector3
  75940. * @param otherVector defines the second operand
  75941. * @returns the current updated Vector3
  75942. */
  75943. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75944. /**
  75945. * Adds the given coordinates to the current Vector3
  75946. * @param x defines the x coordinate of the operand
  75947. * @param y defines the y coordinate of the operand
  75948. * @param z defines the z coordinate of the operand
  75949. * @returns the current updated Vector3
  75950. */
  75951. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75952. /**
  75953. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75954. * @param otherVector defines the second operand
  75955. * @returns the resulting Vector3
  75956. */
  75957. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75958. /**
  75959. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75960. * @param otherVector defines the second operand
  75961. * @param result defines the Vector3 object where to store the result
  75962. * @returns the current Vector3
  75963. */
  75964. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75965. /**
  75966. * Subtract the given vector from the current Vector3
  75967. * @param otherVector defines the second operand
  75968. * @returns the current updated Vector3
  75969. */
  75970. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75971. /**
  75972. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75973. * @param otherVector defines the second operand
  75974. * @returns the resulting Vector3
  75975. */
  75976. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75977. /**
  75978. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75979. * @param otherVector defines the second operand
  75980. * @param result defines the Vector3 object where to store the result
  75981. * @returns the current Vector3
  75982. */
  75983. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75984. /**
  75985. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75986. * @param x defines the x coordinate of the operand
  75987. * @param y defines the y coordinate of the operand
  75988. * @param z defines the z coordinate of the operand
  75989. * @returns the resulting Vector3
  75990. */
  75991. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75992. /**
  75993. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75994. * @param x defines the x coordinate of the operand
  75995. * @param y defines the y coordinate of the operand
  75996. * @param z defines the z coordinate of the operand
  75997. * @param result defines the Vector3 object where to store the result
  75998. * @returns the current Vector3
  75999. */
  76000. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76001. /**
  76002. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76003. * @returns a new Vector3
  76004. */
  76005. negate(): Vector3;
  76006. /**
  76007. * Negate this vector in place
  76008. * @returns this
  76009. */
  76010. negateInPlace(): Vector3;
  76011. /**
  76012. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76013. * @param result defines the Vector3 object where to store the result
  76014. * @returns the current Vector3
  76015. */
  76016. negateToRef(result: Vector3): Vector3;
  76017. /**
  76018. * Multiplies the Vector3 coordinates by the float "scale"
  76019. * @param scale defines the multiplier factor
  76020. * @returns the current updated Vector3
  76021. */
  76022. scaleInPlace(scale: number): Vector3;
  76023. /**
  76024. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76025. * @param scale defines the multiplier factor
  76026. * @returns a new Vector3
  76027. */
  76028. scale(scale: number): Vector3;
  76029. /**
  76030. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76031. * @param scale defines the multiplier factor
  76032. * @param result defines the Vector3 object where to store the result
  76033. * @returns the current Vector3
  76034. */
  76035. scaleToRef(scale: number, result: Vector3): Vector3;
  76036. /**
  76037. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76038. * @param scale defines the scale factor
  76039. * @param result defines the Vector3 object where to store the result
  76040. * @returns the unmodified current Vector3
  76041. */
  76042. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76043. /**
  76044. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76045. * @param otherVector defines the second operand
  76046. * @returns true if both vectors are equals
  76047. */
  76048. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76049. /**
  76050. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76051. * @param otherVector defines the second operand
  76052. * @param epsilon defines the minimal distance to define values as equals
  76053. * @returns true if both vectors are distant less than epsilon
  76054. */
  76055. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76056. /**
  76057. * Returns true if the current Vector3 coordinates equals the given floats
  76058. * @param x defines the x coordinate of the operand
  76059. * @param y defines the y coordinate of the operand
  76060. * @param z defines the z coordinate of the operand
  76061. * @returns true if both vectors are equals
  76062. */
  76063. equalsToFloats(x: number, y: number, z: number): boolean;
  76064. /**
  76065. * Multiplies the current Vector3 coordinates by the given ones
  76066. * @param otherVector defines the second operand
  76067. * @returns the current updated Vector3
  76068. */
  76069. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76070. /**
  76071. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76072. * @param otherVector defines the second operand
  76073. * @returns the new Vector3
  76074. */
  76075. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76076. /**
  76077. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76078. * @param otherVector defines the second operand
  76079. * @param result defines the Vector3 object where to store the result
  76080. * @returns the current Vector3
  76081. */
  76082. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76083. /**
  76084. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76085. * @param x defines the x coordinate of the operand
  76086. * @param y defines the y coordinate of the operand
  76087. * @param z defines the z coordinate of the operand
  76088. * @returns the new Vector3
  76089. */
  76090. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76091. /**
  76092. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76093. * @param otherVector defines the second operand
  76094. * @returns the new Vector3
  76095. */
  76096. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76097. /**
  76098. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76099. * @param otherVector defines the second operand
  76100. * @param result defines the Vector3 object where to store the result
  76101. * @returns the current Vector3
  76102. */
  76103. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76104. /**
  76105. * Divides the current Vector3 coordinates by the given ones.
  76106. * @param otherVector defines the second operand
  76107. * @returns the current updated Vector3
  76108. */
  76109. divideInPlace(otherVector: Vector3): Vector3;
  76110. /**
  76111. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76112. * @param other defines the second operand
  76113. * @returns the current updated Vector3
  76114. */
  76115. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76116. /**
  76117. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76118. * @param other defines the second operand
  76119. * @returns the current updated Vector3
  76120. */
  76121. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76122. /**
  76123. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76124. * @param x defines the x coordinate of the operand
  76125. * @param y defines the y coordinate of the operand
  76126. * @param z defines the z coordinate of the operand
  76127. * @returns the current updated Vector3
  76128. */
  76129. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76130. /**
  76131. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76132. * @param x defines the x coordinate of the operand
  76133. * @param y defines the y coordinate of the operand
  76134. * @param z defines the z coordinate of the operand
  76135. * @returns the current updated Vector3
  76136. */
  76137. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76138. /**
  76139. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76140. * Check if is non uniform within a certain amount of decimal places to account for this
  76141. * @param epsilon the amount the values can differ
  76142. * @returns if the the vector is non uniform to a certain number of decimal places
  76143. */
  76144. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76145. /**
  76146. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76147. */
  76148. get isNonUniform(): boolean;
  76149. /**
  76150. * Gets a new Vector3 from current Vector3 floored values
  76151. * @returns a new Vector3
  76152. */
  76153. floor(): Vector3;
  76154. /**
  76155. * Gets a new Vector3 from current Vector3 floored values
  76156. * @returns a new Vector3
  76157. */
  76158. fract(): Vector3;
  76159. /**
  76160. * Gets the length of the Vector3
  76161. * @returns the length of the Vector3
  76162. */
  76163. length(): number;
  76164. /**
  76165. * Gets the squared length of the Vector3
  76166. * @returns squared length of the Vector3
  76167. */
  76168. lengthSquared(): number;
  76169. /**
  76170. * Normalize the current Vector3.
  76171. * Please note that this is an in place operation.
  76172. * @returns the current updated Vector3
  76173. */
  76174. normalize(): Vector3;
  76175. /**
  76176. * Reorders the x y z properties of the vector in place
  76177. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76178. * @returns the current updated vector
  76179. */
  76180. reorderInPlace(order: string): this;
  76181. /**
  76182. * Rotates the vector around 0,0,0 by a quaternion
  76183. * @param quaternion the rotation quaternion
  76184. * @param result vector to store the result
  76185. * @returns the resulting vector
  76186. */
  76187. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76188. /**
  76189. * Rotates a vector around a given point
  76190. * @param quaternion the rotation quaternion
  76191. * @param point the point to rotate around
  76192. * @param result vector to store the result
  76193. * @returns the resulting vector
  76194. */
  76195. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76196. /**
  76197. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76198. * The cross product is then orthogonal to both current and "other"
  76199. * @param other defines the right operand
  76200. * @returns the cross product
  76201. */
  76202. cross(other: Vector3): Vector3;
  76203. /**
  76204. * Normalize the current Vector3 with the given input length.
  76205. * Please note that this is an in place operation.
  76206. * @param len the length of the vector
  76207. * @returns the current updated Vector3
  76208. */
  76209. normalizeFromLength(len: number): Vector3;
  76210. /**
  76211. * Normalize the current Vector3 to a new vector
  76212. * @returns the new Vector3
  76213. */
  76214. normalizeToNew(): Vector3;
  76215. /**
  76216. * Normalize the current Vector3 to the reference
  76217. * @param reference define the Vector3 to update
  76218. * @returns the updated Vector3
  76219. */
  76220. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76221. /**
  76222. * Creates a new Vector3 copied from the current Vector3
  76223. * @returns the new Vector3
  76224. */
  76225. clone(): Vector3;
  76226. /**
  76227. * Copies the given vector coordinates to the current Vector3 ones
  76228. * @param source defines the source Vector3
  76229. * @returns the current updated Vector3
  76230. */
  76231. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76232. /**
  76233. * Copies the given floats to the current Vector3 coordinates
  76234. * @param x defines the x coordinate of the operand
  76235. * @param y defines the y coordinate of the operand
  76236. * @param z defines the z coordinate of the operand
  76237. * @returns the current updated Vector3
  76238. */
  76239. copyFromFloats(x: number, y: number, z: number): Vector3;
  76240. /**
  76241. * Copies the given floats to the current Vector3 coordinates
  76242. * @param x defines the x coordinate of the operand
  76243. * @param y defines the y coordinate of the operand
  76244. * @param z defines the z coordinate of the operand
  76245. * @returns the current updated Vector3
  76246. */
  76247. set(x: number, y: number, z: number): Vector3;
  76248. /**
  76249. * Copies the given float to the current Vector3 coordinates
  76250. * @param v defines the x, y and z coordinates of the operand
  76251. * @returns the current updated Vector3
  76252. */
  76253. setAll(v: number): Vector3;
  76254. /**
  76255. * Get the clip factor between two vectors
  76256. * @param vector0 defines the first operand
  76257. * @param vector1 defines the second operand
  76258. * @param axis defines the axis to use
  76259. * @param size defines the size along the axis
  76260. * @returns the clip factor
  76261. */
  76262. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76263. /**
  76264. * Get angle between two vectors
  76265. * @param vector0 angle between vector0 and vector1
  76266. * @param vector1 angle between vector0 and vector1
  76267. * @param normal direction of the normal
  76268. * @return the angle between vector0 and vector1
  76269. */
  76270. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76271. /**
  76272. * Returns a new Vector3 set from the index "offset" of the given array
  76273. * @param array defines the source array
  76274. * @param offset defines the offset in the source array
  76275. * @returns the new Vector3
  76276. */
  76277. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76278. /**
  76279. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76280. * @param array defines the source array
  76281. * @param offset defines the offset in the source array
  76282. * @returns the new Vector3
  76283. * @deprecated Please use FromArray instead.
  76284. */
  76285. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76286. /**
  76287. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76288. * @param array defines the source array
  76289. * @param offset defines the offset in the source array
  76290. * @param result defines the Vector3 where to store the result
  76291. */
  76292. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76293. /**
  76294. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76295. * @param array defines the source array
  76296. * @param offset defines the offset in the source array
  76297. * @param result defines the Vector3 where to store the result
  76298. * @deprecated Please use FromArrayToRef instead.
  76299. */
  76300. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76301. /**
  76302. * Sets the given vector "result" with the given floats.
  76303. * @param x defines the x coordinate of the source
  76304. * @param y defines the y coordinate of the source
  76305. * @param z defines the z coordinate of the source
  76306. * @param result defines the Vector3 where to store the result
  76307. */
  76308. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76309. /**
  76310. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76311. * @returns a new empty Vector3
  76312. */
  76313. static Zero(): Vector3;
  76314. /**
  76315. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76316. * @returns a new unit Vector3
  76317. */
  76318. static One(): Vector3;
  76319. /**
  76320. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76321. * @returns a new up Vector3
  76322. */
  76323. static Up(): Vector3;
  76324. /**
  76325. * Gets a up Vector3 that must not be updated
  76326. */
  76327. static get UpReadOnly(): DeepImmutable<Vector3>;
  76328. /**
  76329. * Gets a zero Vector3 that must not be updated
  76330. */
  76331. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76332. /**
  76333. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76334. * @returns a new down Vector3
  76335. */
  76336. static Down(): Vector3;
  76337. /**
  76338. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76339. * @returns a new forward Vector3
  76340. */
  76341. static Forward(): Vector3;
  76342. /**
  76343. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76344. * @returns a new forward Vector3
  76345. */
  76346. static Backward(): Vector3;
  76347. /**
  76348. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76349. * @returns a new right Vector3
  76350. */
  76351. static Right(): Vector3;
  76352. /**
  76353. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76354. * @returns a new left Vector3
  76355. */
  76356. static Left(): Vector3;
  76357. /**
  76358. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76359. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76360. * @param vector defines the Vector3 to transform
  76361. * @param transformation defines the transformation matrix
  76362. * @returns the transformed Vector3
  76363. */
  76364. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76365. /**
  76366. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76367. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76368. * @param vector defines the Vector3 to transform
  76369. * @param transformation defines the transformation matrix
  76370. * @param result defines the Vector3 where to store the result
  76371. */
  76372. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76373. /**
  76374. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76375. * This method computes tranformed coordinates only, not transformed direction vectors
  76376. * @param x define the x coordinate of the source vector
  76377. * @param y define the y coordinate of the source vector
  76378. * @param z define the z coordinate of the source vector
  76379. * @param transformation defines the transformation matrix
  76380. * @param result defines the Vector3 where to store the result
  76381. */
  76382. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76383. /**
  76384. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76385. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76386. * @param vector defines the Vector3 to transform
  76387. * @param transformation defines the transformation matrix
  76388. * @returns the new Vector3
  76389. */
  76390. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76391. /**
  76392. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76393. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76394. * @param vector defines the Vector3 to transform
  76395. * @param transformation defines the transformation matrix
  76396. * @param result defines the Vector3 where to store the result
  76397. */
  76398. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76399. /**
  76400. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76401. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76402. * @param x define the x coordinate of the source vector
  76403. * @param y define the y coordinate of the source vector
  76404. * @param z define the z coordinate of the source vector
  76405. * @param transformation defines the transformation matrix
  76406. * @param result defines the Vector3 where to store the result
  76407. */
  76408. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76409. /**
  76410. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76411. * @param value1 defines the first control point
  76412. * @param value2 defines the second control point
  76413. * @param value3 defines the third control point
  76414. * @param value4 defines the fourth control point
  76415. * @param amount defines the amount on the spline to use
  76416. * @returns the new Vector3
  76417. */
  76418. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76419. /**
  76420. * 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"
  76421. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76422. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76423. * @param value defines the current value
  76424. * @param min defines the lower range value
  76425. * @param max defines the upper range value
  76426. * @returns the new Vector3
  76427. */
  76428. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76429. /**
  76430. * 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"
  76431. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76432. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76433. * @param value defines the current value
  76434. * @param min defines the lower range value
  76435. * @param max defines the upper range value
  76436. * @param result defines the Vector3 where to store the result
  76437. */
  76438. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76439. /**
  76440. * Checks if a given vector is inside a specific range
  76441. * @param v defines the vector to test
  76442. * @param min defines the minimum range
  76443. * @param max defines the maximum range
  76444. */
  76445. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76446. /**
  76447. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76448. * @param value1 defines the first control point
  76449. * @param tangent1 defines the first tangent vector
  76450. * @param value2 defines the second control point
  76451. * @param tangent2 defines the second tangent vector
  76452. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76453. * @returns the new Vector3
  76454. */
  76455. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76456. /**
  76457. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76458. * @param start defines the start value
  76459. * @param end defines the end value
  76460. * @param amount max defines amount between both (between 0 and 1)
  76461. * @returns the new Vector3
  76462. */
  76463. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76464. /**
  76465. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76466. * @param start defines the start value
  76467. * @param end defines the end value
  76468. * @param amount max defines amount between both (between 0 and 1)
  76469. * @param result defines the Vector3 where to store the result
  76470. */
  76471. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76472. /**
  76473. * Returns the dot product (float) between the vectors "left" and "right"
  76474. * @param left defines the left operand
  76475. * @param right defines the right operand
  76476. * @returns the dot product
  76477. */
  76478. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76479. /**
  76480. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76481. * The cross product is then orthogonal to both "left" and "right"
  76482. * @param left defines the left operand
  76483. * @param right defines the right operand
  76484. * @returns the cross product
  76485. */
  76486. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76487. /**
  76488. * Sets the given vector "result" with the cross product of "left" and "right"
  76489. * The cross product is then orthogonal to both "left" and "right"
  76490. * @param left defines the left operand
  76491. * @param right defines the right operand
  76492. * @param result defines the Vector3 where to store the result
  76493. */
  76494. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76495. /**
  76496. * Returns a new Vector3 as the normalization of the given vector
  76497. * @param vector defines the Vector3 to normalize
  76498. * @returns the new Vector3
  76499. */
  76500. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76501. /**
  76502. * Sets the given vector "result" with the normalization of the given first vector
  76503. * @param vector defines the Vector3 to normalize
  76504. * @param result defines the Vector3 where to store the result
  76505. */
  76506. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76507. /**
  76508. * Project a Vector3 onto screen space
  76509. * @param vector defines the Vector3 to project
  76510. * @param world defines the world matrix to use
  76511. * @param transform defines the transform (view x projection) matrix to use
  76512. * @param viewport defines the screen viewport to use
  76513. * @returns the new Vector3
  76514. */
  76515. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76516. /** @hidden */
  76517. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76518. /**
  76519. * Unproject from screen space to object space
  76520. * @param source defines the screen space Vector3 to use
  76521. * @param viewportWidth defines the current width of the viewport
  76522. * @param viewportHeight defines the current height of the viewport
  76523. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76524. * @param transform defines the transform (view x projection) matrix to use
  76525. * @returns the new Vector3
  76526. */
  76527. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76528. /**
  76529. * Unproject from screen space to object space
  76530. * @param source defines the screen space Vector3 to use
  76531. * @param viewportWidth defines the current width of the viewport
  76532. * @param viewportHeight defines the current height of the viewport
  76533. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76534. * @param view defines the view matrix to use
  76535. * @param projection defines the projection matrix to use
  76536. * @returns the new Vector3
  76537. */
  76538. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76539. /**
  76540. * Unproject from screen space to object space
  76541. * @param source defines the screen space Vector3 to use
  76542. * @param viewportWidth defines the current width of the viewport
  76543. * @param viewportHeight defines the current height of the viewport
  76544. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76545. * @param view defines the view matrix to use
  76546. * @param projection defines the projection matrix to use
  76547. * @param result defines the Vector3 where to store the result
  76548. */
  76549. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76550. /**
  76551. * Unproject from screen space to object space
  76552. * @param sourceX defines the screen space x coordinate to use
  76553. * @param sourceY defines the screen space y coordinate to use
  76554. * @param sourceZ defines the screen space z coordinate to use
  76555. * @param viewportWidth defines the current width of the viewport
  76556. * @param viewportHeight defines the current height of the viewport
  76557. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76558. * @param view defines the view matrix to use
  76559. * @param projection defines the projection matrix to use
  76560. * @param result defines the Vector3 where to store the result
  76561. */
  76562. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76563. /**
  76564. * Gets the minimal coordinate values between two Vector3
  76565. * @param left defines the first operand
  76566. * @param right defines the second operand
  76567. * @returns the new Vector3
  76568. */
  76569. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76570. /**
  76571. * Gets the maximal coordinate values between two Vector3
  76572. * @param left defines the first operand
  76573. * @param right defines the second operand
  76574. * @returns the new Vector3
  76575. */
  76576. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76577. /**
  76578. * Returns the distance between the vectors "value1" and "value2"
  76579. * @param value1 defines the first operand
  76580. * @param value2 defines the second operand
  76581. * @returns the distance
  76582. */
  76583. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76584. /**
  76585. * Returns the squared distance between the vectors "value1" and "value2"
  76586. * @param value1 defines the first operand
  76587. * @param value2 defines the second operand
  76588. * @returns the squared distance
  76589. */
  76590. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76591. /**
  76592. * Returns a new Vector3 located at the center between "value1" and "value2"
  76593. * @param value1 defines the first operand
  76594. * @param value2 defines the second operand
  76595. * @returns the new Vector3
  76596. */
  76597. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76598. /**
  76599. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76600. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76601. * to something in order to rotate it from its local system to the given target system
  76602. * Note: axis1, axis2 and axis3 are normalized during this operation
  76603. * @param axis1 defines the first axis
  76604. * @param axis2 defines the second axis
  76605. * @param axis3 defines the third axis
  76606. * @returns a new Vector3
  76607. */
  76608. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76609. /**
  76610. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76611. * @param axis1 defines the first axis
  76612. * @param axis2 defines the second axis
  76613. * @param axis3 defines the third axis
  76614. * @param ref defines the Vector3 where to store the result
  76615. */
  76616. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76617. }
  76618. /**
  76619. * Vector4 class created for EulerAngle class conversion to Quaternion
  76620. */
  76621. export class Vector4 {
  76622. /** x value of the vector */
  76623. x: number;
  76624. /** y value of the vector */
  76625. y: number;
  76626. /** z value of the vector */
  76627. z: number;
  76628. /** w value of the vector */
  76629. w: number;
  76630. /**
  76631. * Creates a Vector4 object from the given floats.
  76632. * @param x x value of the vector
  76633. * @param y y value of the vector
  76634. * @param z z value of the vector
  76635. * @param w w value of the vector
  76636. */
  76637. constructor(
  76638. /** x value of the vector */
  76639. x: number,
  76640. /** y value of the vector */
  76641. y: number,
  76642. /** z value of the vector */
  76643. z: number,
  76644. /** w value of the vector */
  76645. w: number);
  76646. /**
  76647. * Returns the string with the Vector4 coordinates.
  76648. * @returns a string containing all the vector values
  76649. */
  76650. toString(): string;
  76651. /**
  76652. * Returns the string "Vector4".
  76653. * @returns "Vector4"
  76654. */
  76655. getClassName(): string;
  76656. /**
  76657. * Returns the Vector4 hash code.
  76658. * @returns a unique hash code
  76659. */
  76660. getHashCode(): number;
  76661. /**
  76662. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76663. * @returns the resulting array
  76664. */
  76665. asArray(): number[];
  76666. /**
  76667. * Populates the given array from the given index with the Vector4 coordinates.
  76668. * @param array array to populate
  76669. * @param index index of the array to start at (default: 0)
  76670. * @returns the Vector4.
  76671. */
  76672. toArray(array: FloatArray, index?: number): Vector4;
  76673. /**
  76674. * Adds the given vector to the current Vector4.
  76675. * @param otherVector the vector to add
  76676. * @returns the updated Vector4.
  76677. */
  76678. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76679. /**
  76680. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76681. * @param otherVector the vector to add
  76682. * @returns the resulting vector
  76683. */
  76684. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76685. /**
  76686. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76687. * @param otherVector the vector to add
  76688. * @param result the vector to store the result
  76689. * @returns the current Vector4.
  76690. */
  76691. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76692. /**
  76693. * Subtract in place the given vector from the current Vector4.
  76694. * @param otherVector the vector to subtract
  76695. * @returns the updated Vector4.
  76696. */
  76697. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76698. /**
  76699. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76700. * @param otherVector the vector to add
  76701. * @returns the new vector with the result
  76702. */
  76703. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76704. /**
  76705. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76706. * @param otherVector the vector to subtract
  76707. * @param result the vector to store the result
  76708. * @returns the current Vector4.
  76709. */
  76710. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76711. /**
  76712. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76713. */
  76714. /**
  76715. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76716. * @param x value to subtract
  76717. * @param y value to subtract
  76718. * @param z value to subtract
  76719. * @param w value to subtract
  76720. * @returns new vector containing the result
  76721. */
  76722. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76723. /**
  76724. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76725. * @param x value to subtract
  76726. * @param y value to subtract
  76727. * @param z value to subtract
  76728. * @param w value to subtract
  76729. * @param result the vector to store the result in
  76730. * @returns the current Vector4.
  76731. */
  76732. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76733. /**
  76734. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76735. * @returns a new vector with the negated values
  76736. */
  76737. negate(): Vector4;
  76738. /**
  76739. * Negate this vector in place
  76740. * @returns this
  76741. */
  76742. negateInPlace(): Vector4;
  76743. /**
  76744. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76745. * @param result defines the Vector3 object where to store the result
  76746. * @returns the current Vector4
  76747. */
  76748. negateToRef(result: Vector4): Vector4;
  76749. /**
  76750. * Multiplies the current Vector4 coordinates by scale (float).
  76751. * @param scale the number to scale with
  76752. * @returns the updated Vector4.
  76753. */
  76754. scaleInPlace(scale: number): Vector4;
  76755. /**
  76756. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76757. * @param scale the number to scale with
  76758. * @returns a new vector with the result
  76759. */
  76760. scale(scale: number): Vector4;
  76761. /**
  76762. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76763. * @param scale the number to scale with
  76764. * @param result a vector to store the result in
  76765. * @returns the current Vector4.
  76766. */
  76767. scaleToRef(scale: number, result: Vector4): Vector4;
  76768. /**
  76769. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76770. * @param scale defines the scale factor
  76771. * @param result defines the Vector4 object where to store the result
  76772. * @returns the unmodified current Vector4
  76773. */
  76774. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76775. /**
  76776. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76777. * @param otherVector the vector to compare against
  76778. * @returns true if they are equal
  76779. */
  76780. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76781. /**
  76782. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76783. * @param otherVector vector to compare against
  76784. * @param epsilon (Default: very small number)
  76785. * @returns true if they are equal
  76786. */
  76787. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76788. /**
  76789. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76790. * @param x x value to compare against
  76791. * @param y y value to compare against
  76792. * @param z z value to compare against
  76793. * @param w w value to compare against
  76794. * @returns true if equal
  76795. */
  76796. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76797. /**
  76798. * Multiplies in place the current Vector4 by the given one.
  76799. * @param otherVector vector to multiple with
  76800. * @returns the updated Vector4.
  76801. */
  76802. multiplyInPlace(otherVector: Vector4): Vector4;
  76803. /**
  76804. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76805. * @param otherVector vector to multiple with
  76806. * @returns resulting new vector
  76807. */
  76808. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76809. /**
  76810. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76811. * @param otherVector vector to multiple with
  76812. * @param result vector to store the result
  76813. * @returns the current Vector4.
  76814. */
  76815. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76816. /**
  76817. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76818. * @param x x value multiply with
  76819. * @param y y value multiply with
  76820. * @param z z value multiply with
  76821. * @param w w value multiply with
  76822. * @returns resulting new vector
  76823. */
  76824. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76825. /**
  76826. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76827. * @param otherVector vector to devide with
  76828. * @returns resulting new vector
  76829. */
  76830. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76831. /**
  76832. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76833. * @param otherVector vector to devide with
  76834. * @param result vector to store the result
  76835. * @returns the current Vector4.
  76836. */
  76837. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76838. /**
  76839. * Divides the current Vector3 coordinates by the given ones.
  76840. * @param otherVector vector to devide with
  76841. * @returns the updated Vector3.
  76842. */
  76843. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76844. /**
  76845. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76846. * @param other defines the second operand
  76847. * @returns the current updated Vector4
  76848. */
  76849. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76850. /**
  76851. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76852. * @param other defines the second operand
  76853. * @returns the current updated Vector4
  76854. */
  76855. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76856. /**
  76857. * Gets a new Vector4 from current Vector4 floored values
  76858. * @returns a new Vector4
  76859. */
  76860. floor(): Vector4;
  76861. /**
  76862. * Gets a new Vector4 from current Vector3 floored values
  76863. * @returns a new Vector4
  76864. */
  76865. fract(): Vector4;
  76866. /**
  76867. * Returns the Vector4 length (float).
  76868. * @returns the length
  76869. */
  76870. length(): number;
  76871. /**
  76872. * Returns the Vector4 squared length (float).
  76873. * @returns the length squared
  76874. */
  76875. lengthSquared(): number;
  76876. /**
  76877. * Normalizes in place the Vector4.
  76878. * @returns the updated Vector4.
  76879. */
  76880. normalize(): Vector4;
  76881. /**
  76882. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76883. * @returns this converted to a new vector3
  76884. */
  76885. toVector3(): Vector3;
  76886. /**
  76887. * Returns a new Vector4 copied from the current one.
  76888. * @returns the new cloned vector
  76889. */
  76890. clone(): Vector4;
  76891. /**
  76892. * Updates the current Vector4 with the given one coordinates.
  76893. * @param source the source vector to copy from
  76894. * @returns the updated Vector4.
  76895. */
  76896. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76897. /**
  76898. * Updates the current Vector4 coordinates with the given floats.
  76899. * @param x float to copy from
  76900. * @param y float to copy from
  76901. * @param z float to copy from
  76902. * @param w float to copy from
  76903. * @returns the updated Vector4.
  76904. */
  76905. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76906. /**
  76907. * Updates the current Vector4 coordinates with the given floats.
  76908. * @param x float to set from
  76909. * @param y float to set from
  76910. * @param z float to set from
  76911. * @param w float to set from
  76912. * @returns the updated Vector4.
  76913. */
  76914. set(x: number, y: number, z: number, w: number): Vector4;
  76915. /**
  76916. * Copies the given float to the current Vector3 coordinates
  76917. * @param v defines the x, y, z and w coordinates of the operand
  76918. * @returns the current updated Vector3
  76919. */
  76920. setAll(v: number): Vector4;
  76921. /**
  76922. * Returns a new Vector4 set from the starting index of the given array.
  76923. * @param array the array to pull values from
  76924. * @param offset the offset into the array to start at
  76925. * @returns the new vector
  76926. */
  76927. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76928. /**
  76929. * Updates the given vector "result" from the starting index of the given array.
  76930. * @param array the array to pull values from
  76931. * @param offset the offset into the array to start at
  76932. * @param result the vector to store the result in
  76933. */
  76934. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76935. /**
  76936. * Updates the given vector "result" from the starting index of the given Float32Array.
  76937. * @param array the array to pull values from
  76938. * @param offset the offset into the array to start at
  76939. * @param result the vector to store the result in
  76940. */
  76941. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76942. /**
  76943. * Updates the given vector "result" coordinates from the given floats.
  76944. * @param x float to set from
  76945. * @param y float to set from
  76946. * @param z float to set from
  76947. * @param w float to set from
  76948. * @param result the vector to the floats in
  76949. */
  76950. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76951. /**
  76952. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76953. * @returns the new vector
  76954. */
  76955. static Zero(): Vector4;
  76956. /**
  76957. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76958. * @returns the new vector
  76959. */
  76960. static One(): Vector4;
  76961. /**
  76962. * Returns a new normalized Vector4 from the given one.
  76963. * @param vector the vector to normalize
  76964. * @returns the vector
  76965. */
  76966. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76967. /**
  76968. * Updates the given vector "result" from the normalization of the given one.
  76969. * @param vector the vector to normalize
  76970. * @param result the vector to store the result in
  76971. */
  76972. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76973. /**
  76974. * Returns a vector with the minimum values from the left and right vectors
  76975. * @param left left vector to minimize
  76976. * @param right right vector to minimize
  76977. * @returns a new vector with the minimum of the left and right vector values
  76978. */
  76979. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76980. /**
  76981. * Returns a vector with the maximum values from the left and right vectors
  76982. * @param left left vector to maximize
  76983. * @param right right vector to maximize
  76984. * @returns a new vector with the maximum of the left and right vector values
  76985. */
  76986. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76987. /**
  76988. * Returns the distance (float) between the vectors "value1" and "value2".
  76989. * @param value1 value to calulate the distance between
  76990. * @param value2 value to calulate the distance between
  76991. * @return the distance between the two vectors
  76992. */
  76993. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76994. /**
  76995. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76996. * @param value1 value to calulate the distance between
  76997. * @param value2 value to calulate the distance between
  76998. * @return the distance between the two vectors squared
  76999. */
  77000. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77001. /**
  77002. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77003. * @param value1 value to calulate the center between
  77004. * @param value2 value to calulate the center between
  77005. * @return the center between the two vectors
  77006. */
  77007. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77008. /**
  77009. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77010. * This methods computes transformed normalized direction vectors only.
  77011. * @param vector the vector to transform
  77012. * @param transformation the transformation matrix to apply
  77013. * @returns the new vector
  77014. */
  77015. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77016. /**
  77017. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77018. * This methods computes transformed normalized direction vectors only.
  77019. * @param vector the vector to transform
  77020. * @param transformation the transformation matrix to apply
  77021. * @param result the vector to store the result in
  77022. */
  77023. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77024. /**
  77025. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77026. * This methods computes transformed normalized direction vectors only.
  77027. * @param x value to transform
  77028. * @param y value to transform
  77029. * @param z value to transform
  77030. * @param w value to transform
  77031. * @param transformation the transformation matrix to apply
  77032. * @param result the vector to store the results in
  77033. */
  77034. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77035. /**
  77036. * Creates a new Vector4 from a Vector3
  77037. * @param source defines the source data
  77038. * @param w defines the 4th component (default is 0)
  77039. * @returns a new Vector4
  77040. */
  77041. static FromVector3(source: Vector3, w?: number): Vector4;
  77042. }
  77043. /**
  77044. * Class used to store quaternion data
  77045. * @see https://en.wikipedia.org/wiki/Quaternion
  77046. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77047. */
  77048. export class Quaternion {
  77049. /** defines the first component (0 by default) */
  77050. x: number;
  77051. /** defines the second component (0 by default) */
  77052. y: number;
  77053. /** defines the third component (0 by default) */
  77054. z: number;
  77055. /** defines the fourth component (1.0 by default) */
  77056. w: number;
  77057. /**
  77058. * Creates a new Quaternion from the given floats
  77059. * @param x defines the first component (0 by default)
  77060. * @param y defines the second component (0 by default)
  77061. * @param z defines the third component (0 by default)
  77062. * @param w defines the fourth component (1.0 by default)
  77063. */
  77064. constructor(
  77065. /** defines the first component (0 by default) */
  77066. x?: number,
  77067. /** defines the second component (0 by default) */
  77068. y?: number,
  77069. /** defines the third component (0 by default) */
  77070. z?: number,
  77071. /** defines the fourth component (1.0 by default) */
  77072. w?: number);
  77073. /**
  77074. * Gets a string representation for the current quaternion
  77075. * @returns a string with the Quaternion coordinates
  77076. */
  77077. toString(): string;
  77078. /**
  77079. * Gets the class name of the quaternion
  77080. * @returns the string "Quaternion"
  77081. */
  77082. getClassName(): string;
  77083. /**
  77084. * Gets a hash code for this quaternion
  77085. * @returns the quaternion hash code
  77086. */
  77087. getHashCode(): number;
  77088. /**
  77089. * Copy the quaternion to an array
  77090. * @returns a new array populated with 4 elements from the quaternion coordinates
  77091. */
  77092. asArray(): number[];
  77093. /**
  77094. * Check if two quaternions are equals
  77095. * @param otherQuaternion defines the second operand
  77096. * @return true if the current quaternion and the given one coordinates are strictly equals
  77097. */
  77098. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77099. /**
  77100. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77101. * @param otherQuaternion defines the other quaternion
  77102. * @param epsilon defines the minimal distance to consider equality
  77103. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77104. */
  77105. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77106. /**
  77107. * Clone the current quaternion
  77108. * @returns a new quaternion copied from the current one
  77109. */
  77110. clone(): Quaternion;
  77111. /**
  77112. * Copy a quaternion to the current one
  77113. * @param other defines the other quaternion
  77114. * @returns the updated current quaternion
  77115. */
  77116. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77117. /**
  77118. * Updates the current quaternion with the given float coordinates
  77119. * @param x defines the x coordinate
  77120. * @param y defines the y coordinate
  77121. * @param z defines the z coordinate
  77122. * @param w defines the w coordinate
  77123. * @returns the updated current quaternion
  77124. */
  77125. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77126. /**
  77127. * Updates the current quaternion from the given float coordinates
  77128. * @param x defines the x coordinate
  77129. * @param y defines the y coordinate
  77130. * @param z defines the z coordinate
  77131. * @param w defines the w coordinate
  77132. * @returns the updated current quaternion
  77133. */
  77134. set(x: number, y: number, z: number, w: number): Quaternion;
  77135. /**
  77136. * Adds two quaternions
  77137. * @param other defines the second operand
  77138. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77139. */
  77140. add(other: DeepImmutable<Quaternion>): Quaternion;
  77141. /**
  77142. * Add a quaternion to the current one
  77143. * @param other defines the quaternion to add
  77144. * @returns the current quaternion
  77145. */
  77146. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77147. /**
  77148. * Subtract two quaternions
  77149. * @param other defines the second operand
  77150. * @returns a new quaternion as the subtraction result of the given one from the current one
  77151. */
  77152. subtract(other: Quaternion): Quaternion;
  77153. /**
  77154. * Multiplies the current quaternion by a scale factor
  77155. * @param value defines the scale factor
  77156. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77157. */
  77158. scale(value: number): Quaternion;
  77159. /**
  77160. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77161. * @param scale defines the scale factor
  77162. * @param result defines the Quaternion object where to store the result
  77163. * @returns the unmodified current quaternion
  77164. */
  77165. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77166. /**
  77167. * Multiplies in place the current quaternion by a scale factor
  77168. * @param value defines the scale factor
  77169. * @returns the current modified quaternion
  77170. */
  77171. scaleInPlace(value: number): Quaternion;
  77172. /**
  77173. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77174. * @param scale defines the scale factor
  77175. * @param result defines the Quaternion object where to store the result
  77176. * @returns the unmodified current quaternion
  77177. */
  77178. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77179. /**
  77180. * Multiplies two quaternions
  77181. * @param q1 defines the second operand
  77182. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77183. */
  77184. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77185. /**
  77186. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77187. * @param q1 defines the second operand
  77188. * @param result defines the target quaternion
  77189. * @returns the current quaternion
  77190. */
  77191. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77192. /**
  77193. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77194. * @param q1 defines the second operand
  77195. * @returns the currentupdated quaternion
  77196. */
  77197. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77198. /**
  77199. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77200. * @param ref defines the target quaternion
  77201. * @returns the current quaternion
  77202. */
  77203. conjugateToRef(ref: Quaternion): Quaternion;
  77204. /**
  77205. * Conjugates in place (1-q) the current quaternion
  77206. * @returns the current updated quaternion
  77207. */
  77208. conjugateInPlace(): Quaternion;
  77209. /**
  77210. * Conjugates in place (1-q) the current quaternion
  77211. * @returns a new quaternion
  77212. */
  77213. conjugate(): Quaternion;
  77214. /**
  77215. * Gets length of current quaternion
  77216. * @returns the quaternion length (float)
  77217. */
  77218. length(): number;
  77219. /**
  77220. * Normalize in place the current quaternion
  77221. * @returns the current updated quaternion
  77222. */
  77223. normalize(): Quaternion;
  77224. /**
  77225. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77226. * @param order is a reserved parameter and is ignore for now
  77227. * @returns a new Vector3 containing the Euler angles
  77228. */
  77229. toEulerAngles(order?: string): Vector3;
  77230. /**
  77231. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77232. * @param result defines the vector which will be filled with the Euler angles
  77233. * @param order is a reserved parameter and is ignore for now
  77234. * @returns the current unchanged quaternion
  77235. */
  77236. toEulerAnglesToRef(result: Vector3): Quaternion;
  77237. /**
  77238. * Updates the given rotation matrix with the current quaternion values
  77239. * @param result defines the target matrix
  77240. * @returns the current unchanged quaternion
  77241. */
  77242. toRotationMatrix(result: Matrix): Quaternion;
  77243. /**
  77244. * Updates the current quaternion from the given rotation matrix values
  77245. * @param matrix defines the source matrix
  77246. * @returns the current updated quaternion
  77247. */
  77248. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77249. /**
  77250. * Creates a new quaternion from a rotation matrix
  77251. * @param matrix defines the source matrix
  77252. * @returns a new quaternion created from the given rotation matrix values
  77253. */
  77254. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77255. /**
  77256. * Updates the given quaternion with the given rotation matrix values
  77257. * @param matrix defines the source matrix
  77258. * @param result defines the target quaternion
  77259. */
  77260. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77261. /**
  77262. * Returns the dot product (float) between the quaternions "left" and "right"
  77263. * @param left defines the left operand
  77264. * @param right defines the right operand
  77265. * @returns the dot product
  77266. */
  77267. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77268. /**
  77269. * Checks if the two quaternions are close to each other
  77270. * @param quat0 defines the first quaternion to check
  77271. * @param quat1 defines the second quaternion to check
  77272. * @returns true if the two quaternions are close to each other
  77273. */
  77274. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77275. /**
  77276. * Creates an empty quaternion
  77277. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77278. */
  77279. static Zero(): Quaternion;
  77280. /**
  77281. * Inverse a given quaternion
  77282. * @param q defines the source quaternion
  77283. * @returns a new quaternion as the inverted current quaternion
  77284. */
  77285. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77286. /**
  77287. * Inverse a given quaternion
  77288. * @param q defines the source quaternion
  77289. * @param result the quaternion the result will be stored in
  77290. * @returns the result quaternion
  77291. */
  77292. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77293. /**
  77294. * Creates an identity quaternion
  77295. * @returns the identity quaternion
  77296. */
  77297. static Identity(): Quaternion;
  77298. /**
  77299. * Gets a boolean indicating if the given quaternion is identity
  77300. * @param quaternion defines the quaternion to check
  77301. * @returns true if the quaternion is identity
  77302. */
  77303. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77304. /**
  77305. * Creates a quaternion from a rotation around an axis
  77306. * @param axis defines the axis to use
  77307. * @param angle defines the angle to use
  77308. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77309. */
  77310. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77311. /**
  77312. * Creates a rotation around an axis and stores it into the given quaternion
  77313. * @param axis defines the axis to use
  77314. * @param angle defines the angle to use
  77315. * @param result defines the target quaternion
  77316. * @returns the target quaternion
  77317. */
  77318. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77319. /**
  77320. * Creates a new quaternion from data stored into an array
  77321. * @param array defines the data source
  77322. * @param offset defines the offset in the source array where the data starts
  77323. * @returns a new quaternion
  77324. */
  77325. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77326. /**
  77327. * Updates the given quaternion "result" from the starting index of the given array.
  77328. * @param array the array to pull values from
  77329. * @param offset the offset into the array to start at
  77330. * @param result the quaternion to store the result in
  77331. */
  77332. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  77333. /**
  77334. * Create a quaternion from Euler rotation angles
  77335. * @param x Pitch
  77336. * @param y Yaw
  77337. * @param z Roll
  77338. * @returns the new Quaternion
  77339. */
  77340. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77341. /**
  77342. * Updates a quaternion from Euler rotation angles
  77343. * @param x Pitch
  77344. * @param y Yaw
  77345. * @param z Roll
  77346. * @param result the quaternion to store the result
  77347. * @returns the updated quaternion
  77348. */
  77349. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77350. /**
  77351. * Create a quaternion from Euler rotation vector
  77352. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77353. * @returns the new Quaternion
  77354. */
  77355. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77356. /**
  77357. * Updates a quaternion from Euler rotation vector
  77358. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77359. * @param result the quaternion to store the result
  77360. * @returns the updated quaternion
  77361. */
  77362. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77363. /**
  77364. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77365. * @param yaw defines the rotation around Y axis
  77366. * @param pitch defines the rotation around X axis
  77367. * @param roll defines the rotation around Z axis
  77368. * @returns the new quaternion
  77369. */
  77370. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77371. /**
  77372. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77373. * @param yaw defines the rotation around Y axis
  77374. * @param pitch defines the rotation around X axis
  77375. * @param roll defines the rotation around Z axis
  77376. * @param result defines the target quaternion
  77377. */
  77378. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77379. /**
  77380. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77381. * @param alpha defines the rotation around first axis
  77382. * @param beta defines the rotation around second axis
  77383. * @param gamma defines the rotation around third axis
  77384. * @returns the new quaternion
  77385. */
  77386. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77387. /**
  77388. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77389. * @param alpha defines the rotation around first axis
  77390. * @param beta defines the rotation around second axis
  77391. * @param gamma defines the rotation around third axis
  77392. * @param result defines the target quaternion
  77393. */
  77394. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77395. /**
  77396. * 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)
  77397. * @param axis1 defines the first axis
  77398. * @param axis2 defines the second axis
  77399. * @param axis3 defines the third axis
  77400. * @returns the new quaternion
  77401. */
  77402. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77403. /**
  77404. * 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
  77405. * @param axis1 defines the first axis
  77406. * @param axis2 defines the second axis
  77407. * @param axis3 defines the third axis
  77408. * @param ref defines the target quaternion
  77409. */
  77410. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77411. /**
  77412. * Interpolates between two quaternions
  77413. * @param left defines first quaternion
  77414. * @param right defines second quaternion
  77415. * @param amount defines the gradient to use
  77416. * @returns the new interpolated quaternion
  77417. */
  77418. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77419. /**
  77420. * Interpolates between two quaternions and stores it into a target quaternion
  77421. * @param left defines first quaternion
  77422. * @param right defines second quaternion
  77423. * @param amount defines the gradient to use
  77424. * @param result defines the target quaternion
  77425. */
  77426. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77427. /**
  77428. * Interpolate between two quaternions using Hermite interpolation
  77429. * @param value1 defines first quaternion
  77430. * @param tangent1 defines the incoming tangent
  77431. * @param value2 defines second quaternion
  77432. * @param tangent2 defines the outgoing tangent
  77433. * @param amount defines the target quaternion
  77434. * @returns the new interpolated quaternion
  77435. */
  77436. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77437. }
  77438. /**
  77439. * Class used to store matrix data (4x4)
  77440. */
  77441. export class Matrix {
  77442. private static _updateFlagSeed;
  77443. private static _identityReadOnly;
  77444. private _isIdentity;
  77445. private _isIdentityDirty;
  77446. private _isIdentity3x2;
  77447. private _isIdentity3x2Dirty;
  77448. /**
  77449. * Gets the update flag of the matrix which is an unique number for the matrix.
  77450. * It will be incremented every time the matrix data change.
  77451. * You can use it to speed the comparison between two versions of the same matrix.
  77452. */
  77453. updateFlag: number;
  77454. private readonly _m;
  77455. /**
  77456. * Gets the internal data of the matrix
  77457. */
  77458. get m(): DeepImmutable<Float32Array>;
  77459. /** @hidden */
  77460. _markAsUpdated(): void;
  77461. /** @hidden */
  77462. private _updateIdentityStatus;
  77463. /**
  77464. * Creates an empty matrix (filled with zeros)
  77465. */
  77466. constructor();
  77467. /**
  77468. * Check if the current matrix is identity
  77469. * @returns true is the matrix is the identity matrix
  77470. */
  77471. isIdentity(): boolean;
  77472. /**
  77473. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77474. * @returns true is the matrix is the identity matrix
  77475. */
  77476. isIdentityAs3x2(): boolean;
  77477. /**
  77478. * Gets the determinant of the matrix
  77479. * @returns the matrix determinant
  77480. */
  77481. determinant(): number;
  77482. /**
  77483. * Returns the matrix as a Float32Array
  77484. * @returns the matrix underlying array
  77485. */
  77486. toArray(): DeepImmutable<Float32Array>;
  77487. /**
  77488. * Returns the matrix as a Float32Array
  77489. * @returns the matrix underlying array.
  77490. */
  77491. asArray(): DeepImmutable<Float32Array>;
  77492. /**
  77493. * Inverts the current matrix in place
  77494. * @returns the current inverted matrix
  77495. */
  77496. invert(): Matrix;
  77497. /**
  77498. * Sets all the matrix elements to zero
  77499. * @returns the current matrix
  77500. */
  77501. reset(): Matrix;
  77502. /**
  77503. * Adds the current matrix with a second one
  77504. * @param other defines the matrix to add
  77505. * @returns a new matrix as the addition of the current matrix and the given one
  77506. */
  77507. add(other: DeepImmutable<Matrix>): Matrix;
  77508. /**
  77509. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77510. * @param other defines the matrix to add
  77511. * @param result defines the target matrix
  77512. * @returns the current matrix
  77513. */
  77514. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77515. /**
  77516. * Adds in place the given matrix to the current matrix
  77517. * @param other defines the second operand
  77518. * @returns the current updated matrix
  77519. */
  77520. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77521. /**
  77522. * Sets the given matrix to the current inverted Matrix
  77523. * @param other defines the target matrix
  77524. * @returns the unmodified current matrix
  77525. */
  77526. invertToRef(other: Matrix): Matrix;
  77527. /**
  77528. * add a value at the specified position in the current Matrix
  77529. * @param index the index of the value within the matrix. between 0 and 15.
  77530. * @param value the value to be added
  77531. * @returns the current updated matrix
  77532. */
  77533. addAtIndex(index: number, value: number): Matrix;
  77534. /**
  77535. * mutiply the specified position in the current Matrix by a value
  77536. * @param index the index of the value within the matrix. between 0 and 15.
  77537. * @param value the value to be added
  77538. * @returns the current updated matrix
  77539. */
  77540. multiplyAtIndex(index: number, value: number): Matrix;
  77541. /**
  77542. * Inserts the translation vector (using 3 floats) in the current matrix
  77543. * @param x defines the 1st component of the translation
  77544. * @param y defines the 2nd component of the translation
  77545. * @param z defines the 3rd component of the translation
  77546. * @returns the current updated matrix
  77547. */
  77548. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77549. /**
  77550. * Adds the translation vector (using 3 floats) in the current matrix
  77551. * @param x defines the 1st component of the translation
  77552. * @param y defines the 2nd component of the translation
  77553. * @param z defines the 3rd component of the translation
  77554. * @returns the current updated matrix
  77555. */
  77556. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77557. /**
  77558. * Inserts the translation vector in the current matrix
  77559. * @param vector3 defines the translation to insert
  77560. * @returns the current updated matrix
  77561. */
  77562. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77563. /**
  77564. * Gets the translation value of the current matrix
  77565. * @returns a new Vector3 as the extracted translation from the matrix
  77566. */
  77567. getTranslation(): Vector3;
  77568. /**
  77569. * Fill a Vector3 with the extracted translation from the matrix
  77570. * @param result defines the Vector3 where to store the translation
  77571. * @returns the current matrix
  77572. */
  77573. getTranslationToRef(result: Vector3): Matrix;
  77574. /**
  77575. * Remove rotation and scaling part from the matrix
  77576. * @returns the updated matrix
  77577. */
  77578. removeRotationAndScaling(): Matrix;
  77579. /**
  77580. * Multiply two matrices
  77581. * @param other defines the second operand
  77582. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77583. */
  77584. multiply(other: DeepImmutable<Matrix>): Matrix;
  77585. /**
  77586. * Copy the current matrix from the given one
  77587. * @param other defines the source matrix
  77588. * @returns the current updated matrix
  77589. */
  77590. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77591. /**
  77592. * Populates the given array from the starting index with the current matrix values
  77593. * @param array defines the target array
  77594. * @param offset defines the offset in the target array where to start storing values
  77595. * @returns the current matrix
  77596. */
  77597. copyToArray(array: Float32Array, offset?: number): Matrix;
  77598. /**
  77599. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77600. * @param other defines the second operand
  77601. * @param result defines the matrix where to store the multiplication
  77602. * @returns the current matrix
  77603. */
  77604. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77605. /**
  77606. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77607. * @param other defines the second operand
  77608. * @param result defines the array where to store the multiplication
  77609. * @param offset defines the offset in the target array where to start storing values
  77610. * @returns the current matrix
  77611. */
  77612. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77613. /**
  77614. * Check equality between this matrix and a second one
  77615. * @param value defines the second matrix to compare
  77616. * @returns true is the current matrix and the given one values are strictly equal
  77617. */
  77618. equals(value: DeepImmutable<Matrix>): boolean;
  77619. /**
  77620. * Clone the current matrix
  77621. * @returns a new matrix from the current matrix
  77622. */
  77623. clone(): Matrix;
  77624. /**
  77625. * Returns the name of the current matrix class
  77626. * @returns the string "Matrix"
  77627. */
  77628. getClassName(): string;
  77629. /**
  77630. * Gets the hash code of the current matrix
  77631. * @returns the hash code
  77632. */
  77633. getHashCode(): number;
  77634. /**
  77635. * Decomposes the current Matrix into a translation, rotation and scaling components
  77636. * @param scale defines the scale vector3 given as a reference to update
  77637. * @param rotation defines the rotation quaternion given as a reference to update
  77638. * @param translation defines the translation vector3 given as a reference to update
  77639. * @returns true if operation was successful
  77640. */
  77641. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77642. /**
  77643. * Gets specific row of the matrix
  77644. * @param index defines the number of the row to get
  77645. * @returns the index-th row of the current matrix as a new Vector4
  77646. */
  77647. getRow(index: number): Nullable<Vector4>;
  77648. /**
  77649. * Sets the index-th row of the current matrix to the vector4 values
  77650. * @param index defines the number of the row to set
  77651. * @param row defines the target vector4
  77652. * @returns the updated current matrix
  77653. */
  77654. setRow(index: number, row: Vector4): Matrix;
  77655. /**
  77656. * Compute the transpose of the matrix
  77657. * @returns the new transposed matrix
  77658. */
  77659. transpose(): Matrix;
  77660. /**
  77661. * Compute the transpose of the matrix and store it in a given matrix
  77662. * @param result defines the target matrix
  77663. * @returns the current matrix
  77664. */
  77665. transposeToRef(result: Matrix): Matrix;
  77666. /**
  77667. * Sets the index-th row of the current matrix with the given 4 x float values
  77668. * @param index defines the row index
  77669. * @param x defines the x component to set
  77670. * @param y defines the y component to set
  77671. * @param z defines the z component to set
  77672. * @param w defines the w component to set
  77673. * @returns the updated current matrix
  77674. */
  77675. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77676. /**
  77677. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77678. * @param scale defines the scale factor
  77679. * @returns a new matrix
  77680. */
  77681. scale(scale: number): Matrix;
  77682. /**
  77683. * Scale the current matrix values by a factor to a given result matrix
  77684. * @param scale defines the scale factor
  77685. * @param result defines the matrix to store the result
  77686. * @returns the current matrix
  77687. */
  77688. scaleToRef(scale: number, result: Matrix): Matrix;
  77689. /**
  77690. * Scale the current matrix values by a factor and add the result to a given matrix
  77691. * @param scale defines the scale factor
  77692. * @param result defines the Matrix to store the result
  77693. * @returns the current matrix
  77694. */
  77695. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77696. /**
  77697. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77698. * @param ref matrix to store the result
  77699. */
  77700. toNormalMatrix(ref: Matrix): void;
  77701. /**
  77702. * Gets only rotation part of the current matrix
  77703. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77704. */
  77705. getRotationMatrix(): Matrix;
  77706. /**
  77707. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77708. * @param result defines the target matrix to store data to
  77709. * @returns the current matrix
  77710. */
  77711. getRotationMatrixToRef(result: Matrix): Matrix;
  77712. /**
  77713. * Toggles model matrix from being right handed to left handed in place and vice versa
  77714. */
  77715. toggleModelMatrixHandInPlace(): void;
  77716. /**
  77717. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77718. */
  77719. toggleProjectionMatrixHandInPlace(): void;
  77720. /**
  77721. * Creates a matrix from an array
  77722. * @param array defines the source array
  77723. * @param offset defines an offset in the source array
  77724. * @returns a new Matrix set from the starting index of the given array
  77725. */
  77726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77727. /**
  77728. * Copy the content of an array into a given matrix
  77729. * @param array defines the source array
  77730. * @param offset defines an offset in the source array
  77731. * @param result defines the target matrix
  77732. */
  77733. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77734. /**
  77735. * Stores an array into a matrix after having multiplied each component by a given factor
  77736. * @param array defines the source array
  77737. * @param offset defines the offset in the source array
  77738. * @param scale defines the scaling factor
  77739. * @param result defines the target matrix
  77740. */
  77741. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77742. /**
  77743. * Gets an identity matrix that must not be updated
  77744. */
  77745. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77746. /**
  77747. * Stores a list of values (16) inside a given matrix
  77748. * @param initialM11 defines 1st value of 1st row
  77749. * @param initialM12 defines 2nd value of 1st row
  77750. * @param initialM13 defines 3rd value of 1st row
  77751. * @param initialM14 defines 4th value of 1st row
  77752. * @param initialM21 defines 1st value of 2nd row
  77753. * @param initialM22 defines 2nd value of 2nd row
  77754. * @param initialM23 defines 3rd value of 2nd row
  77755. * @param initialM24 defines 4th value of 2nd row
  77756. * @param initialM31 defines 1st value of 3rd row
  77757. * @param initialM32 defines 2nd value of 3rd row
  77758. * @param initialM33 defines 3rd value of 3rd row
  77759. * @param initialM34 defines 4th value of 3rd row
  77760. * @param initialM41 defines 1st value of 4th row
  77761. * @param initialM42 defines 2nd value of 4th row
  77762. * @param initialM43 defines 3rd value of 4th row
  77763. * @param initialM44 defines 4th value of 4th row
  77764. * @param result defines the target matrix
  77765. */
  77766. 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;
  77767. /**
  77768. * Creates new matrix from a list of values (16)
  77769. * @param initialM11 defines 1st value of 1st row
  77770. * @param initialM12 defines 2nd value of 1st row
  77771. * @param initialM13 defines 3rd value of 1st row
  77772. * @param initialM14 defines 4th value of 1st row
  77773. * @param initialM21 defines 1st value of 2nd row
  77774. * @param initialM22 defines 2nd value of 2nd row
  77775. * @param initialM23 defines 3rd value of 2nd row
  77776. * @param initialM24 defines 4th value of 2nd row
  77777. * @param initialM31 defines 1st value of 3rd row
  77778. * @param initialM32 defines 2nd value of 3rd row
  77779. * @param initialM33 defines 3rd value of 3rd row
  77780. * @param initialM34 defines 4th value of 3rd row
  77781. * @param initialM41 defines 1st value of 4th row
  77782. * @param initialM42 defines 2nd value of 4th row
  77783. * @param initialM43 defines 3rd value of 4th row
  77784. * @param initialM44 defines 4th value of 4th row
  77785. * @returns the new matrix
  77786. */
  77787. 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;
  77788. /**
  77789. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77790. * @param scale defines the scale vector3
  77791. * @param rotation defines the rotation quaternion
  77792. * @param translation defines the translation vector3
  77793. * @returns a new matrix
  77794. */
  77795. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77796. /**
  77797. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77798. * @param scale defines the scale vector3
  77799. * @param rotation defines the rotation quaternion
  77800. * @param translation defines the translation vector3
  77801. * @param result defines the target matrix
  77802. */
  77803. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77804. /**
  77805. * Creates a new identity matrix
  77806. * @returns a new identity matrix
  77807. */
  77808. static Identity(): Matrix;
  77809. /**
  77810. * Creates a new identity matrix and stores the result in a given matrix
  77811. * @param result defines the target matrix
  77812. */
  77813. static IdentityToRef(result: Matrix): void;
  77814. /**
  77815. * Creates a new zero matrix
  77816. * @returns a new zero matrix
  77817. */
  77818. static Zero(): Matrix;
  77819. /**
  77820. * Creates a new rotation matrix for "angle" radians around the X axis
  77821. * @param angle defines the angle (in radians) to use
  77822. * @return the new matrix
  77823. */
  77824. static RotationX(angle: number): Matrix;
  77825. /**
  77826. * Creates a new matrix as the invert of a given matrix
  77827. * @param source defines the source matrix
  77828. * @returns the new matrix
  77829. */
  77830. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77831. /**
  77832. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77833. * @param angle defines the angle (in radians) to use
  77834. * @param result defines the target matrix
  77835. */
  77836. static RotationXToRef(angle: number, result: Matrix): void;
  77837. /**
  77838. * Creates a new rotation matrix for "angle" radians around the Y axis
  77839. * @param angle defines the angle (in radians) to use
  77840. * @return the new matrix
  77841. */
  77842. static RotationY(angle: number): Matrix;
  77843. /**
  77844. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77845. * @param angle defines the angle (in radians) to use
  77846. * @param result defines the target matrix
  77847. */
  77848. static RotationYToRef(angle: number, result: Matrix): void;
  77849. /**
  77850. * Creates a new rotation matrix for "angle" radians around the Z axis
  77851. * @param angle defines the angle (in radians) to use
  77852. * @return the new matrix
  77853. */
  77854. static RotationZ(angle: number): Matrix;
  77855. /**
  77856. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77857. * @param angle defines the angle (in radians) to use
  77858. * @param result defines the target matrix
  77859. */
  77860. static RotationZToRef(angle: number, result: Matrix): void;
  77861. /**
  77862. * Creates a new rotation matrix for "angle" radians around the given axis
  77863. * @param axis defines the axis to use
  77864. * @param angle defines the angle (in radians) to use
  77865. * @return the new matrix
  77866. */
  77867. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77868. /**
  77869. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77870. * @param axis defines the axis to use
  77871. * @param angle defines the angle (in radians) to use
  77872. * @param result defines the target matrix
  77873. */
  77874. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77875. /**
  77876. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77877. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77878. * @param from defines the vector to align
  77879. * @param to defines the vector to align to
  77880. * @param result defines the target matrix
  77881. */
  77882. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77883. /**
  77884. * Creates a rotation matrix
  77885. * @param yaw defines the yaw angle in radians (Y axis)
  77886. * @param pitch defines the pitch angle in radians (X axis)
  77887. * @param roll defines the roll angle in radians (X axis)
  77888. * @returns the new rotation matrix
  77889. */
  77890. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77891. /**
  77892. * Creates a rotation matrix and stores it in a given matrix
  77893. * @param yaw defines the yaw angle in radians (Y axis)
  77894. * @param pitch defines the pitch angle in radians (X axis)
  77895. * @param roll defines the roll angle in radians (X axis)
  77896. * @param result defines the target matrix
  77897. */
  77898. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77899. /**
  77900. * Creates a scaling matrix
  77901. * @param x defines the scale factor on X axis
  77902. * @param y defines the scale factor on Y axis
  77903. * @param z defines the scale factor on Z axis
  77904. * @returns the new matrix
  77905. */
  77906. static Scaling(x: number, y: number, z: number): Matrix;
  77907. /**
  77908. * Creates a scaling matrix and stores it in a given matrix
  77909. * @param x defines the scale factor on X axis
  77910. * @param y defines the scale factor on Y axis
  77911. * @param z defines the scale factor on Z axis
  77912. * @param result defines the target matrix
  77913. */
  77914. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77915. /**
  77916. * Creates a translation matrix
  77917. * @param x defines the translation on X axis
  77918. * @param y defines the translation on Y axis
  77919. * @param z defines the translationon Z axis
  77920. * @returns the new matrix
  77921. */
  77922. static Translation(x: number, y: number, z: number): Matrix;
  77923. /**
  77924. * Creates a translation matrix and stores it in a given matrix
  77925. * @param x defines the translation on X axis
  77926. * @param y defines the translation on Y axis
  77927. * @param z defines the translationon Z axis
  77928. * @param result defines the target matrix
  77929. */
  77930. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77931. /**
  77932. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77933. * @param startValue defines the start value
  77934. * @param endValue defines the end value
  77935. * @param gradient defines the gradient factor
  77936. * @returns the new matrix
  77937. */
  77938. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77939. /**
  77940. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77941. * @param startValue defines the start value
  77942. * @param endValue defines the end value
  77943. * @param gradient defines the gradient factor
  77944. * @param result defines the Matrix object where to store data
  77945. */
  77946. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77947. /**
  77948. * Builds a new matrix whose values are computed by:
  77949. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77950. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77951. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77952. * @param startValue defines the first matrix
  77953. * @param endValue defines the second matrix
  77954. * @param gradient defines the gradient between the two matrices
  77955. * @returns the new matrix
  77956. */
  77957. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77958. /**
  77959. * Update a matrix to values which are computed by:
  77960. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77961. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77962. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77963. * @param startValue defines the first matrix
  77964. * @param endValue defines the second matrix
  77965. * @param gradient defines the gradient between the two matrices
  77966. * @param result defines the target matrix
  77967. */
  77968. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77969. /**
  77970. * 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"
  77971. * This function works in left handed mode
  77972. * @param eye defines the final position of the entity
  77973. * @param target defines where the entity should look at
  77974. * @param up defines the up vector for the entity
  77975. * @returns the new matrix
  77976. */
  77977. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77978. /**
  77979. * 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".
  77980. * This function works in left handed mode
  77981. * @param eye defines the final position of the entity
  77982. * @param target defines where the entity should look at
  77983. * @param up defines the up vector for the entity
  77984. * @param result defines the target matrix
  77985. */
  77986. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77987. /**
  77988. * 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"
  77989. * This function works in right handed mode
  77990. * @param eye defines the final position of the entity
  77991. * @param target defines where the entity should look at
  77992. * @param up defines the up vector for the entity
  77993. * @returns the new matrix
  77994. */
  77995. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77996. /**
  77997. * 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".
  77998. * This function works in right handed mode
  77999. * @param eye defines the final position of the entity
  78000. * @param target defines where the entity should look at
  78001. * @param up defines the up vector for the entity
  78002. * @param result defines the target matrix
  78003. */
  78004. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78005. /**
  78006. * Create a left-handed orthographic projection matrix
  78007. * @param width defines the viewport width
  78008. * @param height defines the viewport height
  78009. * @param znear defines the near clip plane
  78010. * @param zfar defines the far clip plane
  78011. * @returns a new matrix as a left-handed orthographic projection matrix
  78012. */
  78013. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78014. /**
  78015. * Store a left-handed orthographic projection to a given matrix
  78016. * @param width defines the viewport width
  78017. * @param height defines the viewport height
  78018. * @param znear defines the near clip plane
  78019. * @param zfar defines the far clip plane
  78020. * @param result defines the target matrix
  78021. */
  78022. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78023. /**
  78024. * Create a left-handed orthographic projection matrix
  78025. * @param left defines the viewport left coordinate
  78026. * @param right defines the viewport right coordinate
  78027. * @param bottom defines the viewport bottom coordinate
  78028. * @param top defines the viewport top coordinate
  78029. * @param znear defines the near clip plane
  78030. * @param zfar defines the far clip plane
  78031. * @returns a new matrix as a left-handed orthographic projection matrix
  78032. */
  78033. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78034. /**
  78035. * Stores a left-handed orthographic projection into a given matrix
  78036. * @param left defines the viewport left coordinate
  78037. * @param right defines the viewport right coordinate
  78038. * @param bottom defines the viewport bottom coordinate
  78039. * @param top defines the viewport top coordinate
  78040. * @param znear defines the near clip plane
  78041. * @param zfar defines the far clip plane
  78042. * @param result defines the target matrix
  78043. */
  78044. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78045. /**
  78046. * Creates a right-handed orthographic projection matrix
  78047. * @param left defines the viewport left coordinate
  78048. * @param right defines the viewport right coordinate
  78049. * @param bottom defines the viewport bottom coordinate
  78050. * @param top defines the viewport top coordinate
  78051. * @param znear defines the near clip plane
  78052. * @param zfar defines the far clip plane
  78053. * @returns a new matrix as a right-handed orthographic projection matrix
  78054. */
  78055. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78056. /**
  78057. * Stores a right-handed orthographic projection into a given matrix
  78058. * @param left defines the viewport left coordinate
  78059. * @param right defines the viewport right coordinate
  78060. * @param bottom defines the viewport bottom coordinate
  78061. * @param top defines the viewport top coordinate
  78062. * @param znear defines the near clip plane
  78063. * @param zfar defines the far clip plane
  78064. * @param result defines the target matrix
  78065. */
  78066. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78067. /**
  78068. * Creates a left-handed perspective projection matrix
  78069. * @param width defines the viewport width
  78070. * @param height defines the viewport height
  78071. * @param znear defines the near clip plane
  78072. * @param zfar defines the far clip plane
  78073. * @returns a new matrix as a left-handed perspective projection matrix
  78074. */
  78075. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78076. /**
  78077. * Creates a left-handed perspective projection matrix
  78078. * @param fov defines the horizontal field of view
  78079. * @param aspect defines the aspect ratio
  78080. * @param znear defines the near clip plane
  78081. * @param zfar defines the far clip plane
  78082. * @returns a new matrix as a left-handed perspective projection matrix
  78083. */
  78084. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78085. /**
  78086. * Stores a left-handed perspective projection into a given matrix
  78087. * @param fov defines the horizontal field of view
  78088. * @param aspect defines the aspect ratio
  78089. * @param znear defines the near clip plane
  78090. * @param zfar defines the far clip plane
  78091. * @param result defines the target matrix
  78092. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78093. */
  78094. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78095. /**
  78096. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78097. * @param fov defines the horizontal field of view
  78098. * @param aspect defines the aspect ratio
  78099. * @param znear defines the near clip plane
  78100. * @param zfar not used as infinity is used as far clip
  78101. * @param result defines the target matrix
  78102. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78103. */
  78104. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78105. /**
  78106. * Creates a right-handed perspective projection matrix
  78107. * @param fov defines the horizontal field of view
  78108. * @param aspect defines the aspect ratio
  78109. * @param znear defines the near clip plane
  78110. * @param zfar defines the far clip plane
  78111. * @returns a new matrix as a right-handed perspective projection matrix
  78112. */
  78113. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78114. /**
  78115. * Stores a right-handed perspective projection into a given matrix
  78116. * @param fov defines the horizontal field of view
  78117. * @param aspect defines the aspect ratio
  78118. * @param znear defines the near clip plane
  78119. * @param zfar defines the far clip plane
  78120. * @param result defines the target matrix
  78121. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78122. */
  78123. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78124. /**
  78125. * Stores a right-handed perspective projection into a given matrix
  78126. * @param fov defines the horizontal field of view
  78127. * @param aspect defines the aspect ratio
  78128. * @param znear defines the near clip plane
  78129. * @param zfar not used as infinity is used as far clip
  78130. * @param result defines the target matrix
  78131. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78132. */
  78133. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78134. /**
  78135. * Stores a perspective projection for WebVR info a given matrix
  78136. * @param fov defines the field of view
  78137. * @param znear defines the near clip plane
  78138. * @param zfar defines the far clip plane
  78139. * @param result defines the target matrix
  78140. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78141. */
  78142. static PerspectiveFovWebVRToRef(fov: {
  78143. upDegrees: number;
  78144. downDegrees: number;
  78145. leftDegrees: number;
  78146. rightDegrees: number;
  78147. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78148. /**
  78149. * Computes a complete transformation matrix
  78150. * @param viewport defines the viewport to use
  78151. * @param world defines the world matrix
  78152. * @param view defines the view matrix
  78153. * @param projection defines the projection matrix
  78154. * @param zmin defines the near clip plane
  78155. * @param zmax defines the far clip plane
  78156. * @returns the transformation matrix
  78157. */
  78158. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78159. /**
  78160. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78161. * @param matrix defines the matrix to use
  78162. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78163. */
  78164. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78165. /**
  78166. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78167. * @param matrix defines the matrix to use
  78168. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78169. */
  78170. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78171. /**
  78172. * Compute the transpose of a given matrix
  78173. * @param matrix defines the matrix to transpose
  78174. * @returns the new matrix
  78175. */
  78176. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78177. /**
  78178. * Compute the transpose of a matrix and store it in a target matrix
  78179. * @param matrix defines the matrix to transpose
  78180. * @param result defines the target matrix
  78181. */
  78182. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78183. /**
  78184. * Computes a reflection matrix from a plane
  78185. * @param plane defines the reflection plane
  78186. * @returns a new matrix
  78187. */
  78188. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78189. /**
  78190. * Computes a reflection matrix from a plane
  78191. * @param plane defines the reflection plane
  78192. * @param result defines the target matrix
  78193. */
  78194. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78195. /**
  78196. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78197. * @param xaxis defines the value of the 1st axis
  78198. * @param yaxis defines the value of the 2nd axis
  78199. * @param zaxis defines the value of the 3rd axis
  78200. * @param result defines the target matrix
  78201. */
  78202. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78203. /**
  78204. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78205. * @param quat defines the quaternion to use
  78206. * @param result defines the target matrix
  78207. */
  78208. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78209. }
  78210. /**
  78211. * @hidden
  78212. */
  78213. export class TmpVectors {
  78214. static Vector2: Vector2[];
  78215. static Vector3: Vector3[];
  78216. static Vector4: Vector4[];
  78217. static Quaternion: Quaternion[];
  78218. static Matrix: Matrix[];
  78219. }
  78220. }
  78221. declare module BABYLON {
  78222. /**
  78223. * Defines potential orientation for back face culling
  78224. */
  78225. export enum Orientation {
  78226. /**
  78227. * Clockwise
  78228. */
  78229. CW = 0,
  78230. /** Counter clockwise */
  78231. CCW = 1
  78232. }
  78233. /** Class used to represent a Bezier curve */
  78234. export class BezierCurve {
  78235. /**
  78236. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78237. * @param t defines the time
  78238. * @param x1 defines the left coordinate on X axis
  78239. * @param y1 defines the left coordinate on Y axis
  78240. * @param x2 defines the right coordinate on X axis
  78241. * @param y2 defines the right coordinate on Y axis
  78242. * @returns the interpolated value
  78243. */
  78244. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78245. }
  78246. /**
  78247. * Defines angle representation
  78248. */
  78249. export class Angle {
  78250. private _radians;
  78251. /**
  78252. * Creates an Angle object of "radians" radians (float).
  78253. * @param radians the angle in radians
  78254. */
  78255. constructor(radians: number);
  78256. /**
  78257. * Get value in degrees
  78258. * @returns the Angle value in degrees (float)
  78259. */
  78260. degrees(): number;
  78261. /**
  78262. * Get value in radians
  78263. * @returns the Angle value in radians (float)
  78264. */
  78265. radians(): number;
  78266. /**
  78267. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78268. * @param a defines first vector
  78269. * @param b defines second vector
  78270. * @returns a new Angle
  78271. */
  78272. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78273. /**
  78274. * Gets a new Angle object from the given float in radians
  78275. * @param radians defines the angle value in radians
  78276. * @returns a new Angle
  78277. */
  78278. static FromRadians(radians: number): Angle;
  78279. /**
  78280. * Gets a new Angle object from the given float in degrees
  78281. * @param degrees defines the angle value in degrees
  78282. * @returns a new Angle
  78283. */
  78284. static FromDegrees(degrees: number): Angle;
  78285. }
  78286. /**
  78287. * This represents an arc in a 2d space.
  78288. */
  78289. export class Arc2 {
  78290. /** Defines the start point of the arc */
  78291. startPoint: Vector2;
  78292. /** Defines the mid point of the arc */
  78293. midPoint: Vector2;
  78294. /** Defines the end point of the arc */
  78295. endPoint: Vector2;
  78296. /**
  78297. * Defines the center point of the arc.
  78298. */
  78299. centerPoint: Vector2;
  78300. /**
  78301. * Defines the radius of the arc.
  78302. */
  78303. radius: number;
  78304. /**
  78305. * Defines the angle of the arc (from mid point to end point).
  78306. */
  78307. angle: Angle;
  78308. /**
  78309. * Defines the start angle of the arc (from start point to middle point).
  78310. */
  78311. startAngle: Angle;
  78312. /**
  78313. * Defines the orientation of the arc (clock wise/counter clock wise).
  78314. */
  78315. orientation: Orientation;
  78316. /**
  78317. * Creates an Arc object from the three given points : start, middle and end.
  78318. * @param startPoint Defines the start point of the arc
  78319. * @param midPoint Defines the midlle point of the arc
  78320. * @param endPoint Defines the end point of the arc
  78321. */
  78322. constructor(
  78323. /** Defines the start point of the arc */
  78324. startPoint: Vector2,
  78325. /** Defines the mid point of the arc */
  78326. midPoint: Vector2,
  78327. /** Defines the end point of the arc */
  78328. endPoint: Vector2);
  78329. }
  78330. /**
  78331. * Represents a 2D path made up of multiple 2D points
  78332. */
  78333. export class Path2 {
  78334. private _points;
  78335. private _length;
  78336. /**
  78337. * If the path start and end point are the same
  78338. */
  78339. closed: boolean;
  78340. /**
  78341. * Creates a Path2 object from the starting 2D coordinates x and y.
  78342. * @param x the starting points x value
  78343. * @param y the starting points y value
  78344. */
  78345. constructor(x: number, y: number);
  78346. /**
  78347. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78348. * @param x the added points x value
  78349. * @param y the added points y value
  78350. * @returns the updated Path2.
  78351. */
  78352. addLineTo(x: number, y: number): Path2;
  78353. /**
  78354. * 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.
  78355. * @param midX middle point x value
  78356. * @param midY middle point y value
  78357. * @param endX end point x value
  78358. * @param endY end point y value
  78359. * @param numberOfSegments (default: 36)
  78360. * @returns the updated Path2.
  78361. */
  78362. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78363. /**
  78364. * Closes the Path2.
  78365. * @returns the Path2.
  78366. */
  78367. close(): Path2;
  78368. /**
  78369. * Gets the sum of the distance between each sequential point in the path
  78370. * @returns the Path2 total length (float).
  78371. */
  78372. length(): number;
  78373. /**
  78374. * Gets the points which construct the path
  78375. * @returns the Path2 internal array of points.
  78376. */
  78377. getPoints(): Vector2[];
  78378. /**
  78379. * Retreives the point at the distance aways from the starting point
  78380. * @param normalizedLengthPosition the length along the path to retreive the point from
  78381. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78382. */
  78383. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78384. /**
  78385. * Creates a new path starting from an x and y position
  78386. * @param x starting x value
  78387. * @param y starting y value
  78388. * @returns a new Path2 starting at the coordinates (x, y).
  78389. */
  78390. static StartingAt(x: number, y: number): Path2;
  78391. }
  78392. /**
  78393. * Represents a 3D path made up of multiple 3D points
  78394. */
  78395. export class Path3D {
  78396. /**
  78397. * an array of Vector3, the curve axis of the Path3D
  78398. */
  78399. path: Vector3[];
  78400. private _curve;
  78401. private _distances;
  78402. private _tangents;
  78403. private _normals;
  78404. private _binormals;
  78405. private _raw;
  78406. private _alignTangentsWithPath;
  78407. private readonly _pointAtData;
  78408. /**
  78409. * new Path3D(path, normal, raw)
  78410. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78411. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78412. * @param path an array of Vector3, the curve axis of the Path3D
  78413. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78414. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78415. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78416. */
  78417. constructor(
  78418. /**
  78419. * an array of Vector3, the curve axis of the Path3D
  78420. */
  78421. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78422. /**
  78423. * Returns the Path3D array of successive Vector3 designing its curve.
  78424. * @returns the Path3D array of successive Vector3 designing its curve.
  78425. */
  78426. getCurve(): Vector3[];
  78427. /**
  78428. * Returns the Path3D array of successive Vector3 designing its curve.
  78429. * @returns the Path3D array of successive Vector3 designing its curve.
  78430. */
  78431. getPoints(): Vector3[];
  78432. /**
  78433. * @returns the computed length (float) of the path.
  78434. */
  78435. length(): number;
  78436. /**
  78437. * Returns an array populated with tangent vectors on each Path3D curve point.
  78438. * @returns an array populated with tangent vectors on each Path3D curve point.
  78439. */
  78440. getTangents(): Vector3[];
  78441. /**
  78442. * Returns an array populated with normal vectors on each Path3D curve point.
  78443. * @returns an array populated with normal vectors on each Path3D curve point.
  78444. */
  78445. getNormals(): Vector3[];
  78446. /**
  78447. * Returns an array populated with binormal vectors on each Path3D curve point.
  78448. * @returns an array populated with binormal vectors on each Path3D curve point.
  78449. */
  78450. getBinormals(): Vector3[];
  78451. /**
  78452. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78453. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78454. */
  78455. getDistances(): number[];
  78456. /**
  78457. * Returns an interpolated point along this path
  78458. * @param position the position of the point along this path, from 0.0 to 1.0
  78459. * @returns a new Vector3 as the point
  78460. */
  78461. getPointAt(position: number): Vector3;
  78462. /**
  78463. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78464. * @param position the position of the point along this path, from 0.0 to 1.0
  78465. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78466. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78467. */
  78468. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78469. /**
  78470. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78471. * @param position the position of the point along this path, from 0.0 to 1.0
  78472. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78473. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78474. */
  78475. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78476. /**
  78477. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78478. * @param position the position of the point along this path, from 0.0 to 1.0
  78479. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78480. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78481. */
  78482. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78483. /**
  78484. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78485. * @param position the position of the point along this path, from 0.0 to 1.0
  78486. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78487. */
  78488. getDistanceAt(position: number): number;
  78489. /**
  78490. * Returns the array index of the previous point of an interpolated point along this path
  78491. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78492. * @returns the array index
  78493. */
  78494. getPreviousPointIndexAt(position: number): number;
  78495. /**
  78496. * 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)
  78497. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78498. * @returns the sub position
  78499. */
  78500. getSubPositionAt(position: number): number;
  78501. /**
  78502. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78503. * @param target the vector of which to get the closest position to
  78504. * @returns the position of the closest virtual point on this path to the target vector
  78505. */
  78506. getClosestPositionTo(target: Vector3): number;
  78507. /**
  78508. * Returns a sub path (slice) of this path
  78509. * @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
  78510. * @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
  78511. * @returns a sub path (slice) of this path
  78512. */
  78513. slice(start?: number, end?: number): Path3D;
  78514. /**
  78515. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78516. * @param path path which all values are copied into the curves points
  78517. * @param firstNormal which should be projected onto the curve
  78518. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78519. * @returns the same object updated.
  78520. */
  78521. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78522. private _compute;
  78523. private _getFirstNonNullVector;
  78524. private _getLastNonNullVector;
  78525. private _normalVector;
  78526. /**
  78527. * Updates the point at data for an interpolated point along this curve
  78528. * @param position the position of the point along this curve, from 0.0 to 1.0
  78529. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78530. * @returns the (updated) point at data
  78531. */
  78532. private _updatePointAtData;
  78533. /**
  78534. * Updates the point at data from the specified parameters
  78535. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78536. * @param point the interpolated point
  78537. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78538. */
  78539. private _setPointAtData;
  78540. /**
  78541. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78542. */
  78543. private _updateInterpolationMatrix;
  78544. }
  78545. /**
  78546. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78547. * A Curve3 is designed from a series of successive Vector3.
  78548. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78549. */
  78550. export class Curve3 {
  78551. private _points;
  78552. private _length;
  78553. /**
  78554. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78555. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78556. * @param v1 (Vector3) the control point
  78557. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78558. * @param nbPoints (integer) the wanted number of points in the curve
  78559. * @returns the created Curve3
  78560. */
  78561. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78562. /**
  78563. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78564. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78565. * @param v1 (Vector3) the first control point
  78566. * @param v2 (Vector3) the second control point
  78567. * @param v3 (Vector3) the end point of the Cubic Bezier
  78568. * @param nbPoints (integer) the wanted number of points in the curve
  78569. * @returns the created Curve3
  78570. */
  78571. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78572. /**
  78573. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78574. * @param p1 (Vector3) the origin point of the Hermite Spline
  78575. * @param t1 (Vector3) the tangent vector at the origin point
  78576. * @param p2 (Vector3) the end point of the Hermite Spline
  78577. * @param t2 (Vector3) the tangent vector at the end point
  78578. * @param nbPoints (integer) the wanted number of points in the curve
  78579. * @returns the created Curve3
  78580. */
  78581. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78582. /**
  78583. * Returns a Curve3 object along a CatmullRom Spline curve :
  78584. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78585. * @param nbPoints (integer) the wanted number of points between each curve control points
  78586. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78587. * @returns the created Curve3
  78588. */
  78589. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78590. /**
  78591. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78592. * A Curve3 is designed from a series of successive Vector3.
  78593. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78594. * @param points points which make up the curve
  78595. */
  78596. constructor(points: Vector3[]);
  78597. /**
  78598. * @returns the Curve3 stored array of successive Vector3
  78599. */
  78600. getPoints(): Vector3[];
  78601. /**
  78602. * @returns the computed length (float) of the curve.
  78603. */
  78604. length(): number;
  78605. /**
  78606. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78607. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78608. * curveA and curveB keep unchanged.
  78609. * @param curve the curve to continue from this curve
  78610. * @returns the newly constructed curve
  78611. */
  78612. continue(curve: DeepImmutable<Curve3>): Curve3;
  78613. private _computeLength;
  78614. }
  78615. }
  78616. declare module BABYLON {
  78617. /**
  78618. * This represents the main contract an easing function should follow.
  78619. * Easing functions are used throughout the animation system.
  78620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78621. */
  78622. export interface IEasingFunction {
  78623. /**
  78624. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78625. * of the easing function.
  78626. * The link below provides some of the most common examples of easing functions.
  78627. * @see https://easings.net/
  78628. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78629. * @returns the corresponding value on the curve defined by the easing function
  78630. */
  78631. ease(gradient: number): number;
  78632. }
  78633. /**
  78634. * Base class used for every default easing function.
  78635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78636. */
  78637. export class EasingFunction implements IEasingFunction {
  78638. /**
  78639. * Interpolation follows the mathematical formula associated with the easing function.
  78640. */
  78641. static readonly EASINGMODE_EASEIN: number;
  78642. /**
  78643. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78644. */
  78645. static readonly EASINGMODE_EASEOUT: number;
  78646. /**
  78647. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78648. */
  78649. static readonly EASINGMODE_EASEINOUT: number;
  78650. private _easingMode;
  78651. /**
  78652. * Sets the easing mode of the current function.
  78653. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78654. */
  78655. setEasingMode(easingMode: number): void;
  78656. /**
  78657. * Gets the current easing mode.
  78658. * @returns the easing mode
  78659. */
  78660. getEasingMode(): number;
  78661. /**
  78662. * @hidden
  78663. */
  78664. easeInCore(gradient: number): number;
  78665. /**
  78666. * Given an input gradient between 0 and 1, this returns the corresponding value
  78667. * of the easing function.
  78668. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78669. * @returns the corresponding value on the curve defined by the easing function
  78670. */
  78671. ease(gradient: number): number;
  78672. }
  78673. /**
  78674. * Easing function with a circle shape (see link below).
  78675. * @see https://easings.net/#easeInCirc
  78676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78677. */
  78678. export class CircleEase extends EasingFunction implements IEasingFunction {
  78679. /** @hidden */
  78680. easeInCore(gradient: number): number;
  78681. }
  78682. /**
  78683. * Easing function with a ease back shape (see link below).
  78684. * @see https://easings.net/#easeInBack
  78685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78686. */
  78687. export class BackEase extends EasingFunction implements IEasingFunction {
  78688. /** Defines the amplitude of the function */
  78689. amplitude: number;
  78690. /**
  78691. * Instantiates a back ease easing
  78692. * @see https://easings.net/#easeInBack
  78693. * @param amplitude Defines the amplitude of the function
  78694. */
  78695. constructor(
  78696. /** Defines the amplitude of the function */
  78697. amplitude?: number);
  78698. /** @hidden */
  78699. easeInCore(gradient: number): number;
  78700. }
  78701. /**
  78702. * Easing function with a bouncing shape (see link below).
  78703. * @see https://easings.net/#easeInBounce
  78704. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78705. */
  78706. export class BounceEase extends EasingFunction implements IEasingFunction {
  78707. /** Defines the number of bounces */
  78708. bounces: number;
  78709. /** Defines the amplitude of the bounce */
  78710. bounciness: number;
  78711. /**
  78712. * Instantiates a bounce easing
  78713. * @see https://easings.net/#easeInBounce
  78714. * @param bounces Defines the number of bounces
  78715. * @param bounciness Defines the amplitude of the bounce
  78716. */
  78717. constructor(
  78718. /** Defines the number of bounces */
  78719. bounces?: number,
  78720. /** Defines the amplitude of the bounce */
  78721. bounciness?: number);
  78722. /** @hidden */
  78723. easeInCore(gradient: number): number;
  78724. }
  78725. /**
  78726. * Easing function with a power of 3 shape (see link below).
  78727. * @see https://easings.net/#easeInCubic
  78728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78729. */
  78730. export class CubicEase extends EasingFunction implements IEasingFunction {
  78731. /** @hidden */
  78732. easeInCore(gradient: number): number;
  78733. }
  78734. /**
  78735. * Easing function with an elastic shape (see link below).
  78736. * @see https://easings.net/#easeInElastic
  78737. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78738. */
  78739. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78740. /** Defines the number of oscillations*/
  78741. oscillations: number;
  78742. /** Defines the amplitude of the oscillations*/
  78743. springiness: number;
  78744. /**
  78745. * Instantiates an elastic easing function
  78746. * @see https://easings.net/#easeInElastic
  78747. * @param oscillations Defines the number of oscillations
  78748. * @param springiness Defines the amplitude of the oscillations
  78749. */
  78750. constructor(
  78751. /** Defines the number of oscillations*/
  78752. oscillations?: number,
  78753. /** Defines the amplitude of the oscillations*/
  78754. springiness?: number);
  78755. /** @hidden */
  78756. easeInCore(gradient: number): number;
  78757. }
  78758. /**
  78759. * Easing function with an exponential shape (see link below).
  78760. * @see https://easings.net/#easeInExpo
  78761. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78762. */
  78763. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78764. /** Defines the exponent of the function */
  78765. exponent: number;
  78766. /**
  78767. * Instantiates an exponential easing function
  78768. * @see https://easings.net/#easeInExpo
  78769. * @param exponent Defines the exponent of the function
  78770. */
  78771. constructor(
  78772. /** Defines the exponent of the function */
  78773. exponent?: number);
  78774. /** @hidden */
  78775. easeInCore(gradient: number): number;
  78776. }
  78777. /**
  78778. * Easing function with a power shape (see link below).
  78779. * @see https://easings.net/#easeInQuad
  78780. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78781. */
  78782. export class PowerEase extends EasingFunction implements IEasingFunction {
  78783. /** Defines the power of the function */
  78784. power: number;
  78785. /**
  78786. * Instantiates an power base easing function
  78787. * @see https://easings.net/#easeInQuad
  78788. * @param power Defines the power of the function
  78789. */
  78790. constructor(
  78791. /** Defines the power of the function */
  78792. power?: number);
  78793. /** @hidden */
  78794. easeInCore(gradient: number): number;
  78795. }
  78796. /**
  78797. * Easing function with a power of 2 shape (see link below).
  78798. * @see https://easings.net/#easeInQuad
  78799. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78800. */
  78801. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78802. /** @hidden */
  78803. easeInCore(gradient: number): number;
  78804. }
  78805. /**
  78806. * Easing function with a power of 4 shape (see link below).
  78807. * @see https://easings.net/#easeInQuart
  78808. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78809. */
  78810. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78811. /** @hidden */
  78812. easeInCore(gradient: number): number;
  78813. }
  78814. /**
  78815. * Easing function with a power of 5 shape (see link below).
  78816. * @see https://easings.net/#easeInQuint
  78817. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78818. */
  78819. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78820. /** @hidden */
  78821. easeInCore(gradient: number): number;
  78822. }
  78823. /**
  78824. * Easing function with a sin shape (see link below).
  78825. * @see https://easings.net/#easeInSine
  78826. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78827. */
  78828. export class SineEase extends EasingFunction implements IEasingFunction {
  78829. /** @hidden */
  78830. easeInCore(gradient: number): number;
  78831. }
  78832. /**
  78833. * Easing function with a bezier shape (see link below).
  78834. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78835. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78836. */
  78837. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78838. /** Defines the x component of the start tangent in the bezier curve */
  78839. x1: number;
  78840. /** Defines the y component of the start tangent in the bezier curve */
  78841. y1: number;
  78842. /** Defines the x component of the end tangent in the bezier curve */
  78843. x2: number;
  78844. /** Defines the y component of the end tangent in the bezier curve */
  78845. y2: number;
  78846. /**
  78847. * Instantiates a bezier function
  78848. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78849. * @param x1 Defines the x component of the start tangent in the bezier curve
  78850. * @param y1 Defines the y component of the start tangent in the bezier curve
  78851. * @param x2 Defines the x component of the end tangent in the bezier curve
  78852. * @param y2 Defines the y component of the end tangent in the bezier curve
  78853. */
  78854. constructor(
  78855. /** Defines the x component of the start tangent in the bezier curve */
  78856. x1?: number,
  78857. /** Defines the y component of the start tangent in the bezier curve */
  78858. y1?: number,
  78859. /** Defines the x component of the end tangent in the bezier curve */
  78860. x2?: number,
  78861. /** Defines the y component of the end tangent in the bezier curve */
  78862. y2?: number);
  78863. /** @hidden */
  78864. easeInCore(gradient: number): number;
  78865. }
  78866. }
  78867. declare module BABYLON {
  78868. /**
  78869. * Class used to hold a RBG color
  78870. */
  78871. export class Color3 {
  78872. /**
  78873. * Defines the red component (between 0 and 1, default is 0)
  78874. */
  78875. r: number;
  78876. /**
  78877. * Defines the green component (between 0 and 1, default is 0)
  78878. */
  78879. g: number;
  78880. /**
  78881. * Defines the blue component (between 0 and 1, default is 0)
  78882. */
  78883. b: number;
  78884. /**
  78885. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78886. * @param r defines the red component (between 0 and 1, default is 0)
  78887. * @param g defines the green component (between 0 and 1, default is 0)
  78888. * @param b defines the blue component (between 0 and 1, default is 0)
  78889. */
  78890. constructor(
  78891. /**
  78892. * Defines the red component (between 0 and 1, default is 0)
  78893. */
  78894. r?: number,
  78895. /**
  78896. * Defines the green component (between 0 and 1, default is 0)
  78897. */
  78898. g?: number,
  78899. /**
  78900. * Defines the blue component (between 0 and 1, default is 0)
  78901. */
  78902. b?: number);
  78903. /**
  78904. * Creates a string with the Color3 current values
  78905. * @returns the string representation of the Color3 object
  78906. */
  78907. toString(): string;
  78908. /**
  78909. * Returns the string "Color3"
  78910. * @returns "Color3"
  78911. */
  78912. getClassName(): string;
  78913. /**
  78914. * Compute the Color3 hash code
  78915. * @returns an unique number that can be used to hash Color3 objects
  78916. */
  78917. getHashCode(): number;
  78918. /**
  78919. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78920. * @param array defines the array where to store the r,g,b components
  78921. * @param index defines an optional index in the target array to define where to start storing values
  78922. * @returns the current Color3 object
  78923. */
  78924. toArray(array: FloatArray, index?: number): Color3;
  78925. /**
  78926. * Returns a new Color4 object from the current Color3 and the given alpha
  78927. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78928. * @returns a new Color4 object
  78929. */
  78930. toColor4(alpha?: number): Color4;
  78931. /**
  78932. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78933. * @returns the new array
  78934. */
  78935. asArray(): number[];
  78936. /**
  78937. * Returns the luminance value
  78938. * @returns a float value
  78939. */
  78940. toLuminance(): number;
  78941. /**
  78942. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78943. * @param otherColor defines the second operand
  78944. * @returns the new Color3 object
  78945. */
  78946. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78947. /**
  78948. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78949. * @param otherColor defines the second operand
  78950. * @param result defines the Color3 object where to store the result
  78951. * @returns the current Color3
  78952. */
  78953. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78954. /**
  78955. * Determines equality between Color3 objects
  78956. * @param otherColor defines the second operand
  78957. * @returns true if the rgb values are equal to the given ones
  78958. */
  78959. equals(otherColor: DeepImmutable<Color3>): boolean;
  78960. /**
  78961. * Determines equality between the current Color3 object and a set of r,b,g values
  78962. * @param r defines the red component to check
  78963. * @param g defines the green component to check
  78964. * @param b defines the blue component to check
  78965. * @returns true if the rgb values are equal to the given ones
  78966. */
  78967. equalsFloats(r: number, g: number, b: number): boolean;
  78968. /**
  78969. * Multiplies in place each rgb value by scale
  78970. * @param scale defines the scaling factor
  78971. * @returns the updated Color3
  78972. */
  78973. scale(scale: number): Color3;
  78974. /**
  78975. * Multiplies the rgb values by scale and stores the result into "result"
  78976. * @param scale defines the scaling factor
  78977. * @param result defines the Color3 object where to store the result
  78978. * @returns the unmodified current Color3
  78979. */
  78980. scaleToRef(scale: number, result: Color3): Color3;
  78981. /**
  78982. * Scale the current Color3 values by a factor and add the result to a given Color3
  78983. * @param scale defines the scale factor
  78984. * @param result defines color to store the result into
  78985. * @returns the unmodified current Color3
  78986. */
  78987. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78988. /**
  78989. * Clamps the rgb values by the min and max values and stores the result into "result"
  78990. * @param min defines minimum clamping value (default is 0)
  78991. * @param max defines maximum clamping value (default is 1)
  78992. * @param result defines color to store the result into
  78993. * @returns the original Color3
  78994. */
  78995. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78996. /**
  78997. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78998. * @param otherColor defines the second operand
  78999. * @returns the new Color3
  79000. */
  79001. add(otherColor: DeepImmutable<Color3>): Color3;
  79002. /**
  79003. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79004. * @param otherColor defines the second operand
  79005. * @param result defines Color3 object to store the result into
  79006. * @returns the unmodified current Color3
  79007. */
  79008. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79009. /**
  79010. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79011. * @param otherColor defines the second operand
  79012. * @returns the new Color3
  79013. */
  79014. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79015. /**
  79016. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79017. * @param otherColor defines the second operand
  79018. * @param result defines Color3 object to store the result into
  79019. * @returns the unmodified current Color3
  79020. */
  79021. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79022. /**
  79023. * Copy the current object
  79024. * @returns a new Color3 copied the current one
  79025. */
  79026. clone(): Color3;
  79027. /**
  79028. * Copies the rgb values from the source in the current Color3
  79029. * @param source defines the source Color3 object
  79030. * @returns the updated Color3 object
  79031. */
  79032. copyFrom(source: DeepImmutable<Color3>): Color3;
  79033. /**
  79034. * Updates the Color3 rgb values from the given floats
  79035. * @param r defines the red component to read from
  79036. * @param g defines the green component to read from
  79037. * @param b defines the blue component to read from
  79038. * @returns the current Color3 object
  79039. */
  79040. copyFromFloats(r: number, g: number, b: number): Color3;
  79041. /**
  79042. * Updates the Color3 rgb values from the given floats
  79043. * @param r defines the red component to read from
  79044. * @param g defines the green component to read from
  79045. * @param b defines the blue component to read from
  79046. * @returns the current Color3 object
  79047. */
  79048. set(r: number, g: number, b: number): Color3;
  79049. /**
  79050. * Compute the Color3 hexadecimal code as a string
  79051. * @returns a string containing the hexadecimal representation of the Color3 object
  79052. */
  79053. toHexString(): string;
  79054. /**
  79055. * Computes a new Color3 converted from the current one to linear space
  79056. * @returns a new Color3 object
  79057. */
  79058. toLinearSpace(): Color3;
  79059. /**
  79060. * Converts current color in rgb space to HSV values
  79061. * @returns a new color3 representing the HSV values
  79062. */
  79063. toHSV(): Color3;
  79064. /**
  79065. * Converts current color in rgb space to HSV values
  79066. * @param result defines the Color3 where to store the HSV values
  79067. */
  79068. toHSVToRef(result: Color3): void;
  79069. /**
  79070. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79071. * @param convertedColor defines the Color3 object where to store the linear space version
  79072. * @returns the unmodified Color3
  79073. */
  79074. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79075. /**
  79076. * Computes a new Color3 converted from the current one to gamma space
  79077. * @returns a new Color3 object
  79078. */
  79079. toGammaSpace(): Color3;
  79080. /**
  79081. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79082. * @param convertedColor defines the Color3 object where to store the gamma space version
  79083. * @returns the unmodified Color3
  79084. */
  79085. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79086. private static _BlackReadOnly;
  79087. /**
  79088. * Convert Hue, saturation and value to a Color3 (RGB)
  79089. * @param hue defines the hue
  79090. * @param saturation defines the saturation
  79091. * @param value defines the value
  79092. * @param result defines the Color3 where to store the RGB values
  79093. */
  79094. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79095. /**
  79096. * Creates a new Color3 from the string containing valid hexadecimal values
  79097. * @param hex defines a string containing valid hexadecimal values
  79098. * @returns a new Color3 object
  79099. */
  79100. static FromHexString(hex: string): Color3;
  79101. /**
  79102. * Creates a new Color3 from the starting index of the given array
  79103. * @param array defines the source array
  79104. * @param offset defines an offset in the source array
  79105. * @returns a new Color3 object
  79106. */
  79107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79108. /**
  79109. * Creates a new Color3 from integer values (< 256)
  79110. * @param r defines the red component to read from (value between 0 and 255)
  79111. * @param g defines the green component to read from (value between 0 and 255)
  79112. * @param b defines the blue component to read from (value between 0 and 255)
  79113. * @returns a new Color3 object
  79114. */
  79115. static FromInts(r: number, g: number, b: number): Color3;
  79116. /**
  79117. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79118. * @param start defines the start Color3 value
  79119. * @param end defines the end Color3 value
  79120. * @param amount defines the gradient value between start and end
  79121. * @returns a new Color3 object
  79122. */
  79123. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79124. /**
  79125. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79126. * @param left defines the start value
  79127. * @param right defines the end value
  79128. * @param amount defines the gradient factor
  79129. * @param result defines the Color3 object where to store the result
  79130. */
  79131. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79132. /**
  79133. * Returns a Color3 value containing a red color
  79134. * @returns a new Color3 object
  79135. */
  79136. static Red(): Color3;
  79137. /**
  79138. * Returns a Color3 value containing a green color
  79139. * @returns a new Color3 object
  79140. */
  79141. static Green(): Color3;
  79142. /**
  79143. * Returns a Color3 value containing a blue color
  79144. * @returns a new Color3 object
  79145. */
  79146. static Blue(): Color3;
  79147. /**
  79148. * Returns a Color3 value containing a black color
  79149. * @returns a new Color3 object
  79150. */
  79151. static Black(): Color3;
  79152. /**
  79153. * Gets a Color3 value containing a black color that must not be updated
  79154. */
  79155. static get BlackReadOnly(): DeepImmutable<Color3>;
  79156. /**
  79157. * Returns a Color3 value containing a white color
  79158. * @returns a new Color3 object
  79159. */
  79160. static White(): Color3;
  79161. /**
  79162. * Returns a Color3 value containing a purple color
  79163. * @returns a new Color3 object
  79164. */
  79165. static Purple(): Color3;
  79166. /**
  79167. * Returns a Color3 value containing a magenta color
  79168. * @returns a new Color3 object
  79169. */
  79170. static Magenta(): Color3;
  79171. /**
  79172. * Returns a Color3 value containing a yellow color
  79173. * @returns a new Color3 object
  79174. */
  79175. static Yellow(): Color3;
  79176. /**
  79177. * Returns a Color3 value containing a gray color
  79178. * @returns a new Color3 object
  79179. */
  79180. static Gray(): Color3;
  79181. /**
  79182. * Returns a Color3 value containing a teal color
  79183. * @returns a new Color3 object
  79184. */
  79185. static Teal(): Color3;
  79186. /**
  79187. * Returns a Color3 value containing a random color
  79188. * @returns a new Color3 object
  79189. */
  79190. static Random(): Color3;
  79191. }
  79192. /**
  79193. * Class used to hold a RBGA color
  79194. */
  79195. export class Color4 {
  79196. /**
  79197. * Defines the red component (between 0 and 1, default is 0)
  79198. */
  79199. r: number;
  79200. /**
  79201. * Defines the green component (between 0 and 1, default is 0)
  79202. */
  79203. g: number;
  79204. /**
  79205. * Defines the blue component (between 0 and 1, default is 0)
  79206. */
  79207. b: number;
  79208. /**
  79209. * Defines the alpha component (between 0 and 1, default is 1)
  79210. */
  79211. a: number;
  79212. /**
  79213. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79214. * @param r defines the red component (between 0 and 1, default is 0)
  79215. * @param g defines the green component (between 0 and 1, default is 0)
  79216. * @param b defines the blue component (between 0 and 1, default is 0)
  79217. * @param a defines the alpha component (between 0 and 1, default is 1)
  79218. */
  79219. constructor(
  79220. /**
  79221. * Defines the red component (between 0 and 1, default is 0)
  79222. */
  79223. r?: number,
  79224. /**
  79225. * Defines the green component (between 0 and 1, default is 0)
  79226. */
  79227. g?: number,
  79228. /**
  79229. * Defines the blue component (between 0 and 1, default is 0)
  79230. */
  79231. b?: number,
  79232. /**
  79233. * Defines the alpha component (between 0 and 1, default is 1)
  79234. */
  79235. a?: number);
  79236. /**
  79237. * Adds in place the given Color4 values to the current Color4 object
  79238. * @param right defines the second operand
  79239. * @returns the current updated Color4 object
  79240. */
  79241. addInPlace(right: DeepImmutable<Color4>): Color4;
  79242. /**
  79243. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79244. * @returns the new array
  79245. */
  79246. asArray(): number[];
  79247. /**
  79248. * Stores from the starting index in the given array the Color4 successive values
  79249. * @param array defines the array where to store the r,g,b components
  79250. * @param index defines an optional index in the target array to define where to start storing values
  79251. * @returns the current Color4 object
  79252. */
  79253. toArray(array: number[], index?: number): Color4;
  79254. /**
  79255. * Determines equality between Color4 objects
  79256. * @param otherColor defines the second operand
  79257. * @returns true if the rgba values are equal to the given ones
  79258. */
  79259. equals(otherColor: DeepImmutable<Color4>): boolean;
  79260. /**
  79261. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79262. * @param right defines the second operand
  79263. * @returns a new Color4 object
  79264. */
  79265. add(right: DeepImmutable<Color4>): Color4;
  79266. /**
  79267. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79268. * @param right defines the second operand
  79269. * @returns a new Color4 object
  79270. */
  79271. subtract(right: DeepImmutable<Color4>): Color4;
  79272. /**
  79273. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79274. * @param right defines the second operand
  79275. * @param result defines the Color4 object where to store the result
  79276. * @returns the current Color4 object
  79277. */
  79278. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79279. /**
  79280. * Creates a new Color4 with the current Color4 values multiplied by scale
  79281. * @param scale defines the scaling factor to apply
  79282. * @returns a new Color4 object
  79283. */
  79284. scale(scale: number): Color4;
  79285. /**
  79286. * Multiplies the current Color4 values by scale and stores the result in "result"
  79287. * @param scale defines the scaling factor to apply
  79288. * @param result defines the Color4 object where to store the result
  79289. * @returns the current unmodified Color4
  79290. */
  79291. scaleToRef(scale: number, result: Color4): Color4;
  79292. /**
  79293. * Scale the current Color4 values by a factor and add the result to a given Color4
  79294. * @param scale defines the scale factor
  79295. * @param result defines the Color4 object where to store the result
  79296. * @returns the unmodified current Color4
  79297. */
  79298. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79299. /**
  79300. * Clamps the rgb values by the min and max values and stores the result into "result"
  79301. * @param min defines minimum clamping value (default is 0)
  79302. * @param max defines maximum clamping value (default is 1)
  79303. * @param result defines color to store the result into.
  79304. * @returns the cuurent Color4
  79305. */
  79306. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79307. /**
  79308. * Multipy an Color4 value by another and return a new Color4 object
  79309. * @param color defines the Color4 value to multiply by
  79310. * @returns a new Color4 object
  79311. */
  79312. multiply(color: Color4): Color4;
  79313. /**
  79314. * Multipy a Color4 value by another and push the result in a reference value
  79315. * @param color defines the Color4 value to multiply by
  79316. * @param result defines the Color4 to fill the result in
  79317. * @returns the result Color4
  79318. */
  79319. multiplyToRef(color: Color4, result: Color4): Color4;
  79320. /**
  79321. * Creates a string with the Color4 current values
  79322. * @returns the string representation of the Color4 object
  79323. */
  79324. toString(): string;
  79325. /**
  79326. * Returns the string "Color4"
  79327. * @returns "Color4"
  79328. */
  79329. getClassName(): string;
  79330. /**
  79331. * Compute the Color4 hash code
  79332. * @returns an unique number that can be used to hash Color4 objects
  79333. */
  79334. getHashCode(): number;
  79335. /**
  79336. * Creates a new Color4 copied from the current one
  79337. * @returns a new Color4 object
  79338. */
  79339. clone(): Color4;
  79340. /**
  79341. * Copies the given Color4 values into the current one
  79342. * @param source defines the source Color4 object
  79343. * @returns the current updated Color4 object
  79344. */
  79345. copyFrom(source: Color4): Color4;
  79346. /**
  79347. * Copies the given float values into the current one
  79348. * @param r defines the red component to read from
  79349. * @param g defines the green component to read from
  79350. * @param b defines the blue component to read from
  79351. * @param a defines the alpha component to read from
  79352. * @returns the current updated Color4 object
  79353. */
  79354. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79355. /**
  79356. * Copies the given float values into the current one
  79357. * @param r defines the red component to read from
  79358. * @param g defines the green component to read from
  79359. * @param b defines the blue component to read from
  79360. * @param a defines the alpha component to read from
  79361. * @returns the current updated Color4 object
  79362. */
  79363. set(r: number, g: number, b: number, a: number): Color4;
  79364. /**
  79365. * Compute the Color4 hexadecimal code as a string
  79366. * @returns a string containing the hexadecimal representation of the Color4 object
  79367. */
  79368. toHexString(): string;
  79369. /**
  79370. * Computes a new Color4 converted from the current one to linear space
  79371. * @returns a new Color4 object
  79372. */
  79373. toLinearSpace(): Color4;
  79374. /**
  79375. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79376. * @param convertedColor defines the Color4 object where to store the linear space version
  79377. * @returns the unmodified Color4
  79378. */
  79379. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79380. /**
  79381. * Computes a new Color4 converted from the current one to gamma space
  79382. * @returns a new Color4 object
  79383. */
  79384. toGammaSpace(): Color4;
  79385. /**
  79386. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79387. * @param convertedColor defines the Color4 object where to store the gamma space version
  79388. * @returns the unmodified Color4
  79389. */
  79390. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79391. /**
  79392. * Creates a new Color4 from the string containing valid hexadecimal values
  79393. * @param hex defines a string containing valid hexadecimal values
  79394. * @returns a new Color4 object
  79395. */
  79396. static FromHexString(hex: string): Color4;
  79397. /**
  79398. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79399. * @param left defines the start value
  79400. * @param right defines the end value
  79401. * @param amount defines the gradient factor
  79402. * @returns a new Color4 object
  79403. */
  79404. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79405. /**
  79406. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79407. * @param left defines the start value
  79408. * @param right defines the end value
  79409. * @param amount defines the gradient factor
  79410. * @param result defines the Color4 object where to store data
  79411. */
  79412. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79413. /**
  79414. * Creates a new Color4 from a Color3 and an alpha value
  79415. * @param color3 defines the source Color3 to read from
  79416. * @param alpha defines the alpha component (1.0 by default)
  79417. * @returns a new Color4 object
  79418. */
  79419. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79420. /**
  79421. * Creates a new Color4 from the starting index element of the given array
  79422. * @param array defines the source array to read from
  79423. * @param offset defines the offset in the source array
  79424. * @returns a new Color4 object
  79425. */
  79426. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79427. /**
  79428. * Creates a new Color3 from integer values (< 256)
  79429. * @param r defines the red component to read from (value between 0 and 255)
  79430. * @param g defines the green component to read from (value between 0 and 255)
  79431. * @param b defines the blue component to read from (value between 0 and 255)
  79432. * @param a defines the alpha component to read from (value between 0 and 255)
  79433. * @returns a new Color3 object
  79434. */
  79435. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79436. /**
  79437. * Check the content of a given array and convert it to an array containing RGBA data
  79438. * If the original array was already containing count * 4 values then it is returned directly
  79439. * @param colors defines the array to check
  79440. * @param count defines the number of RGBA data to expect
  79441. * @returns an array containing count * 4 values (RGBA)
  79442. */
  79443. static CheckColors4(colors: number[], count: number): number[];
  79444. }
  79445. /**
  79446. * @hidden
  79447. */
  79448. export class TmpColors {
  79449. static Color3: Color3[];
  79450. static Color4: Color4[];
  79451. }
  79452. }
  79453. declare module BABYLON {
  79454. /**
  79455. * Defines an interface which represents an animation key frame
  79456. */
  79457. export interface IAnimationKey {
  79458. /**
  79459. * Frame of the key frame
  79460. */
  79461. frame: number;
  79462. /**
  79463. * Value at the specifies key frame
  79464. */
  79465. value: any;
  79466. /**
  79467. * The input tangent for the cubic hermite spline
  79468. */
  79469. inTangent?: any;
  79470. /**
  79471. * The output tangent for the cubic hermite spline
  79472. */
  79473. outTangent?: any;
  79474. /**
  79475. * The animation interpolation type
  79476. */
  79477. interpolation?: AnimationKeyInterpolation;
  79478. }
  79479. /**
  79480. * Enum for the animation key frame interpolation type
  79481. */
  79482. export enum AnimationKeyInterpolation {
  79483. /**
  79484. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79485. */
  79486. STEP = 1
  79487. }
  79488. }
  79489. declare module BABYLON {
  79490. /**
  79491. * Represents the range of an animation
  79492. */
  79493. export class AnimationRange {
  79494. /**The name of the animation range**/
  79495. name: string;
  79496. /**The starting frame of the animation */
  79497. from: number;
  79498. /**The ending frame of the animation*/
  79499. to: number;
  79500. /**
  79501. * Initializes the range of an animation
  79502. * @param name The name of the animation range
  79503. * @param from The starting frame of the animation
  79504. * @param to The ending frame of the animation
  79505. */
  79506. constructor(
  79507. /**The name of the animation range**/
  79508. name: string,
  79509. /**The starting frame of the animation */
  79510. from: number,
  79511. /**The ending frame of the animation*/
  79512. to: number);
  79513. /**
  79514. * Makes a copy of the animation range
  79515. * @returns A copy of the animation range
  79516. */
  79517. clone(): AnimationRange;
  79518. }
  79519. }
  79520. declare module BABYLON {
  79521. /**
  79522. * Composed of a frame, and an action function
  79523. */
  79524. export class AnimationEvent {
  79525. /** The frame for which the event is triggered **/
  79526. frame: number;
  79527. /** The event to perform when triggered **/
  79528. action: (currentFrame: number) => void;
  79529. /** Specifies if the event should be triggered only once**/
  79530. onlyOnce?: boolean | undefined;
  79531. /**
  79532. * Specifies if the animation event is done
  79533. */
  79534. isDone: boolean;
  79535. /**
  79536. * Initializes the animation event
  79537. * @param frame The frame for which the event is triggered
  79538. * @param action The event to perform when triggered
  79539. * @param onlyOnce Specifies if the event should be triggered only once
  79540. */
  79541. constructor(
  79542. /** The frame for which the event is triggered **/
  79543. frame: number,
  79544. /** The event to perform when triggered **/
  79545. action: (currentFrame: number) => void,
  79546. /** Specifies if the event should be triggered only once**/
  79547. onlyOnce?: boolean | undefined);
  79548. /** @hidden */
  79549. _clone(): AnimationEvent;
  79550. }
  79551. }
  79552. declare module BABYLON {
  79553. /**
  79554. * Interface used to define a behavior
  79555. */
  79556. export interface Behavior<T> {
  79557. /** gets or sets behavior's name */
  79558. name: string;
  79559. /**
  79560. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79561. */
  79562. init(): void;
  79563. /**
  79564. * Called when the behavior is attached to a target
  79565. * @param target defines the target where the behavior is attached to
  79566. */
  79567. attach(target: T): void;
  79568. /**
  79569. * Called when the behavior is detached from its target
  79570. */
  79571. detach(): void;
  79572. }
  79573. /**
  79574. * Interface implemented by classes supporting behaviors
  79575. */
  79576. export interface IBehaviorAware<T> {
  79577. /**
  79578. * Attach a behavior
  79579. * @param behavior defines the behavior to attach
  79580. * @returns the current host
  79581. */
  79582. addBehavior(behavior: Behavior<T>): T;
  79583. /**
  79584. * Remove a behavior from the current object
  79585. * @param behavior defines the behavior to detach
  79586. * @returns the current host
  79587. */
  79588. removeBehavior(behavior: Behavior<T>): T;
  79589. /**
  79590. * Gets a behavior using its name to search
  79591. * @param name defines the name to search
  79592. * @returns the behavior or null if not found
  79593. */
  79594. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79595. }
  79596. }
  79597. declare module BABYLON {
  79598. /**
  79599. * Defines an array and its length.
  79600. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79601. */
  79602. export interface ISmartArrayLike<T> {
  79603. /**
  79604. * The data of the array.
  79605. */
  79606. data: Array<T>;
  79607. /**
  79608. * The active length of the array.
  79609. */
  79610. length: number;
  79611. }
  79612. /**
  79613. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79614. */
  79615. export class SmartArray<T> implements ISmartArrayLike<T> {
  79616. /**
  79617. * The full set of data from the array.
  79618. */
  79619. data: Array<T>;
  79620. /**
  79621. * The active length of the array.
  79622. */
  79623. length: number;
  79624. protected _id: number;
  79625. /**
  79626. * Instantiates a Smart Array.
  79627. * @param capacity defines the default capacity of the array.
  79628. */
  79629. constructor(capacity: number);
  79630. /**
  79631. * Pushes a value at the end of the active data.
  79632. * @param value defines the object to push in the array.
  79633. */
  79634. push(value: T): void;
  79635. /**
  79636. * Iterates over the active data and apply the lambda to them.
  79637. * @param func defines the action to apply on each value.
  79638. */
  79639. forEach(func: (content: T) => void): void;
  79640. /**
  79641. * Sorts the full sets of data.
  79642. * @param compareFn defines the comparison function to apply.
  79643. */
  79644. sort(compareFn: (a: T, b: T) => number): void;
  79645. /**
  79646. * Resets the active data to an empty array.
  79647. */
  79648. reset(): void;
  79649. /**
  79650. * Releases all the data from the array as well as the array.
  79651. */
  79652. dispose(): void;
  79653. /**
  79654. * Concats the active data with a given array.
  79655. * @param array defines the data to concatenate with.
  79656. */
  79657. concat(array: any): void;
  79658. /**
  79659. * Returns the position of a value in the active data.
  79660. * @param value defines the value to find the index for
  79661. * @returns the index if found in the active data otherwise -1
  79662. */
  79663. indexOf(value: T): number;
  79664. /**
  79665. * Returns whether an element is part of the active data.
  79666. * @param value defines the value to look for
  79667. * @returns true if found in the active data otherwise false
  79668. */
  79669. contains(value: T): boolean;
  79670. private static _GlobalId;
  79671. }
  79672. /**
  79673. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79674. * The data in this array can only be present once
  79675. */
  79676. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79677. private _duplicateId;
  79678. /**
  79679. * Pushes a value at the end of the active data.
  79680. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79681. * @param value defines the object to push in the array.
  79682. */
  79683. push(value: T): void;
  79684. /**
  79685. * Pushes a value at the end of the active data.
  79686. * If the data is already present, it won t be added again
  79687. * @param value defines the object to push in the array.
  79688. * @returns true if added false if it was already present
  79689. */
  79690. pushNoDuplicate(value: T): boolean;
  79691. /**
  79692. * Resets the active data to an empty array.
  79693. */
  79694. reset(): void;
  79695. /**
  79696. * Concats the active data with a given array.
  79697. * This ensures no dupplicate will be present in the result.
  79698. * @param array defines the data to concatenate with.
  79699. */
  79700. concatWithNoDuplicate(array: any): void;
  79701. }
  79702. }
  79703. declare module BABYLON {
  79704. /**
  79705. * @ignore
  79706. * This is a list of all the different input types that are available in the application.
  79707. * Fo instance: ArcRotateCameraGamepadInput...
  79708. */
  79709. export var CameraInputTypes: {};
  79710. /**
  79711. * This is the contract to implement in order to create a new input class.
  79712. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79713. */
  79714. export interface ICameraInput<TCamera extends Camera> {
  79715. /**
  79716. * Defines the camera the input is attached to.
  79717. */
  79718. camera: Nullable<TCamera>;
  79719. /**
  79720. * Gets the class name of the current intput.
  79721. * @returns the class name
  79722. */
  79723. getClassName(): string;
  79724. /**
  79725. * Get the friendly name associated with the input class.
  79726. * @returns the input friendly name
  79727. */
  79728. getSimpleName(): string;
  79729. /**
  79730. * Attach the input controls to a specific dom element to get the input from.
  79731. * @param element Defines the element the controls should be listened from
  79732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79733. */
  79734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79735. /**
  79736. * Detach the current controls from the specified dom element.
  79737. * @param element Defines the element to stop listening the inputs from
  79738. */
  79739. detachControl(element: Nullable<HTMLElement>): void;
  79740. /**
  79741. * Update the current camera state depending on the inputs that have been used this frame.
  79742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79743. */
  79744. checkInputs?: () => void;
  79745. }
  79746. /**
  79747. * Represents a map of input types to input instance or input index to input instance.
  79748. */
  79749. export interface CameraInputsMap<TCamera extends Camera> {
  79750. /**
  79751. * Accessor to the input by input type.
  79752. */
  79753. [name: string]: ICameraInput<TCamera>;
  79754. /**
  79755. * Accessor to the input by input index.
  79756. */
  79757. [idx: number]: ICameraInput<TCamera>;
  79758. }
  79759. /**
  79760. * This represents the input manager used within a camera.
  79761. * It helps dealing with all the different kind of input attached to a camera.
  79762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79763. */
  79764. export class CameraInputsManager<TCamera extends Camera> {
  79765. /**
  79766. * Defines the list of inputs attahed to the camera.
  79767. */
  79768. attached: CameraInputsMap<TCamera>;
  79769. /**
  79770. * Defines the dom element the camera is collecting inputs from.
  79771. * This is null if the controls have not been attached.
  79772. */
  79773. attachedElement: Nullable<HTMLElement>;
  79774. /**
  79775. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79776. */
  79777. noPreventDefault: boolean;
  79778. /**
  79779. * Defined the camera the input manager belongs to.
  79780. */
  79781. camera: TCamera;
  79782. /**
  79783. * Update the current camera state depending on the inputs that have been used this frame.
  79784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79785. */
  79786. checkInputs: () => void;
  79787. /**
  79788. * Instantiate a new Camera Input Manager.
  79789. * @param camera Defines the camera the input manager blongs to
  79790. */
  79791. constructor(camera: TCamera);
  79792. /**
  79793. * Add an input method to a camera
  79794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79795. * @param input camera input method
  79796. */
  79797. add(input: ICameraInput<TCamera>): void;
  79798. /**
  79799. * Remove a specific input method from a camera
  79800. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79801. * @param inputToRemove camera input method
  79802. */
  79803. remove(inputToRemove: ICameraInput<TCamera>): void;
  79804. /**
  79805. * Remove a specific input type from a camera
  79806. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79807. * @param inputType the type of the input to remove
  79808. */
  79809. removeByType(inputType: string): void;
  79810. private _addCheckInputs;
  79811. /**
  79812. * Attach the input controls to the currently attached dom element to listen the events from.
  79813. * @param input Defines the input to attach
  79814. */
  79815. attachInput(input: ICameraInput<TCamera>): void;
  79816. /**
  79817. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79818. * @param element Defines the dom element to collect the events from
  79819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79820. */
  79821. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79822. /**
  79823. * Detach the current manager inputs controls from a specific dom element.
  79824. * @param element Defines the dom element to collect the events from
  79825. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79826. */
  79827. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79828. /**
  79829. * Rebuild the dynamic inputCheck function from the current list of
  79830. * defined inputs in the manager.
  79831. */
  79832. rebuildInputCheck(): void;
  79833. /**
  79834. * Remove all attached input methods from a camera
  79835. */
  79836. clear(): void;
  79837. /**
  79838. * Serialize the current input manager attached to a camera.
  79839. * This ensures than once parsed,
  79840. * the input associated to the camera will be identical to the current ones
  79841. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79842. */
  79843. serialize(serializedCamera: any): void;
  79844. /**
  79845. * Parses an input manager serialized JSON to restore the previous list of inputs
  79846. * and states associated to a camera.
  79847. * @param parsedCamera Defines the JSON to parse
  79848. */
  79849. parse(parsedCamera: any): void;
  79850. }
  79851. }
  79852. declare module BABYLON {
  79853. /**
  79854. * Class used to store data that will be store in GPU memory
  79855. */
  79856. export class Buffer {
  79857. private _engine;
  79858. private _buffer;
  79859. /** @hidden */
  79860. _data: Nullable<DataArray>;
  79861. private _updatable;
  79862. private _instanced;
  79863. private _divisor;
  79864. /**
  79865. * Gets the byte stride.
  79866. */
  79867. readonly byteStride: number;
  79868. /**
  79869. * Constructor
  79870. * @param engine the engine
  79871. * @param data the data to use for this buffer
  79872. * @param updatable whether the data is updatable
  79873. * @param stride the stride (optional)
  79874. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79875. * @param instanced whether the buffer is instanced (optional)
  79876. * @param useBytes set to true if the stride in in bytes (optional)
  79877. * @param divisor sets an optional divisor for instances (1 by default)
  79878. */
  79879. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79880. /**
  79881. * Create a new VertexBuffer based on the current buffer
  79882. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79883. * @param offset defines offset in the buffer (0 by default)
  79884. * @param size defines the size in floats of attributes (position is 3 for instance)
  79885. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79886. * @param instanced defines if the vertex buffer contains indexed data
  79887. * @param useBytes defines if the offset and stride are in bytes *
  79888. * @param divisor sets an optional divisor for instances (1 by default)
  79889. * @returns the new vertex buffer
  79890. */
  79891. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79892. /**
  79893. * Gets a boolean indicating if the Buffer is updatable?
  79894. * @returns true if the buffer is updatable
  79895. */
  79896. isUpdatable(): boolean;
  79897. /**
  79898. * Gets current buffer's data
  79899. * @returns a DataArray or null
  79900. */
  79901. getData(): Nullable<DataArray>;
  79902. /**
  79903. * Gets underlying native buffer
  79904. * @returns underlying native buffer
  79905. */
  79906. getBuffer(): Nullable<DataBuffer>;
  79907. /**
  79908. * Gets the stride in float32 units (i.e. byte stride / 4).
  79909. * May not be an integer if the byte stride is not divisible by 4.
  79910. * @returns the stride in float32 units
  79911. * @deprecated Please use byteStride instead.
  79912. */
  79913. getStrideSize(): number;
  79914. /**
  79915. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79916. * @param data defines the data to store
  79917. */
  79918. create(data?: Nullable<DataArray>): void;
  79919. /** @hidden */
  79920. _rebuild(): void;
  79921. /**
  79922. * Update current buffer data
  79923. * @param data defines the data to store
  79924. */
  79925. update(data: DataArray): void;
  79926. /**
  79927. * Updates the data directly.
  79928. * @param data the new data
  79929. * @param offset the new offset
  79930. * @param vertexCount the vertex count (optional)
  79931. * @param useBytes set to true if the offset is in bytes
  79932. */
  79933. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79934. /**
  79935. * Release all resources
  79936. */
  79937. dispose(): void;
  79938. }
  79939. /**
  79940. * Specialized buffer used to store vertex data
  79941. */
  79942. export class VertexBuffer {
  79943. /** @hidden */
  79944. _buffer: Buffer;
  79945. private _kind;
  79946. private _size;
  79947. private _ownsBuffer;
  79948. private _instanced;
  79949. private _instanceDivisor;
  79950. /**
  79951. * The byte type.
  79952. */
  79953. static readonly BYTE: number;
  79954. /**
  79955. * The unsigned byte type.
  79956. */
  79957. static readonly UNSIGNED_BYTE: number;
  79958. /**
  79959. * The short type.
  79960. */
  79961. static readonly SHORT: number;
  79962. /**
  79963. * The unsigned short type.
  79964. */
  79965. static readonly UNSIGNED_SHORT: number;
  79966. /**
  79967. * The integer type.
  79968. */
  79969. static readonly INT: number;
  79970. /**
  79971. * The unsigned integer type.
  79972. */
  79973. static readonly UNSIGNED_INT: number;
  79974. /**
  79975. * The float type.
  79976. */
  79977. static readonly FLOAT: number;
  79978. /**
  79979. * Gets or sets the instance divisor when in instanced mode
  79980. */
  79981. get instanceDivisor(): number;
  79982. set instanceDivisor(value: number);
  79983. /**
  79984. * Gets the byte stride.
  79985. */
  79986. readonly byteStride: number;
  79987. /**
  79988. * Gets the byte offset.
  79989. */
  79990. readonly byteOffset: number;
  79991. /**
  79992. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79993. */
  79994. readonly normalized: boolean;
  79995. /**
  79996. * Gets the data type of each component in the array.
  79997. */
  79998. readonly type: number;
  79999. /**
  80000. * Constructor
  80001. * @param engine the engine
  80002. * @param data the data to use for this vertex buffer
  80003. * @param kind the vertex buffer kind
  80004. * @param updatable whether the data is updatable
  80005. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80006. * @param stride the stride (optional)
  80007. * @param instanced whether the buffer is instanced (optional)
  80008. * @param offset the offset of the data (optional)
  80009. * @param size the number of components (optional)
  80010. * @param type the type of the component (optional)
  80011. * @param normalized whether the data contains normalized data (optional)
  80012. * @param useBytes set to true if stride and offset are in bytes (optional)
  80013. * @param divisor defines the instance divisor to use (1 by default)
  80014. */
  80015. 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);
  80016. /** @hidden */
  80017. _rebuild(): void;
  80018. /**
  80019. * Returns the kind of the VertexBuffer (string)
  80020. * @returns a string
  80021. */
  80022. getKind(): string;
  80023. /**
  80024. * Gets a boolean indicating if the VertexBuffer is updatable?
  80025. * @returns true if the buffer is updatable
  80026. */
  80027. isUpdatable(): boolean;
  80028. /**
  80029. * Gets current buffer's data
  80030. * @returns a DataArray or null
  80031. */
  80032. getData(): Nullable<DataArray>;
  80033. /**
  80034. * Gets underlying native buffer
  80035. * @returns underlying native buffer
  80036. */
  80037. getBuffer(): Nullable<DataBuffer>;
  80038. /**
  80039. * Gets the stride in float32 units (i.e. byte stride / 4).
  80040. * May not be an integer if the byte stride is not divisible by 4.
  80041. * @returns the stride in float32 units
  80042. * @deprecated Please use byteStride instead.
  80043. */
  80044. getStrideSize(): number;
  80045. /**
  80046. * Returns the offset as a multiple of the type byte length.
  80047. * @returns the offset in bytes
  80048. * @deprecated Please use byteOffset instead.
  80049. */
  80050. getOffset(): number;
  80051. /**
  80052. * Returns the number of components per vertex attribute (integer)
  80053. * @returns the size in float
  80054. */
  80055. getSize(): number;
  80056. /**
  80057. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80058. * @returns true if this buffer is instanced
  80059. */
  80060. getIsInstanced(): boolean;
  80061. /**
  80062. * Returns the instancing divisor, zero for non-instanced (integer).
  80063. * @returns a number
  80064. */
  80065. getInstanceDivisor(): number;
  80066. /**
  80067. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80068. * @param data defines the data to store
  80069. */
  80070. create(data?: DataArray): void;
  80071. /**
  80072. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80073. * This function will create a new buffer if the current one is not updatable
  80074. * @param data defines the data to store
  80075. */
  80076. update(data: DataArray): void;
  80077. /**
  80078. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80079. * Returns the directly updated WebGLBuffer.
  80080. * @param data the new data
  80081. * @param offset the new offset
  80082. * @param useBytes set to true if the offset is in bytes
  80083. */
  80084. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80085. /**
  80086. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80087. */
  80088. dispose(): void;
  80089. /**
  80090. * Enumerates each value of this vertex buffer as numbers.
  80091. * @param count the number of values to enumerate
  80092. * @param callback the callback function called for each value
  80093. */
  80094. forEach(count: number, callback: (value: number, index: number) => void): void;
  80095. /**
  80096. * Positions
  80097. */
  80098. static readonly PositionKind: string;
  80099. /**
  80100. * Normals
  80101. */
  80102. static readonly NormalKind: string;
  80103. /**
  80104. * Tangents
  80105. */
  80106. static readonly TangentKind: string;
  80107. /**
  80108. * Texture coordinates
  80109. */
  80110. static readonly UVKind: string;
  80111. /**
  80112. * Texture coordinates 2
  80113. */
  80114. static readonly UV2Kind: string;
  80115. /**
  80116. * Texture coordinates 3
  80117. */
  80118. static readonly UV3Kind: string;
  80119. /**
  80120. * Texture coordinates 4
  80121. */
  80122. static readonly UV4Kind: string;
  80123. /**
  80124. * Texture coordinates 5
  80125. */
  80126. static readonly UV5Kind: string;
  80127. /**
  80128. * Texture coordinates 6
  80129. */
  80130. static readonly UV6Kind: string;
  80131. /**
  80132. * Colors
  80133. */
  80134. static readonly ColorKind: string;
  80135. /**
  80136. * Matrix indices (for bones)
  80137. */
  80138. static readonly MatricesIndicesKind: string;
  80139. /**
  80140. * Matrix weights (for bones)
  80141. */
  80142. static readonly MatricesWeightsKind: string;
  80143. /**
  80144. * Additional matrix indices (for bones)
  80145. */
  80146. static readonly MatricesIndicesExtraKind: string;
  80147. /**
  80148. * Additional matrix weights (for bones)
  80149. */
  80150. static readonly MatricesWeightsExtraKind: string;
  80151. /**
  80152. * Deduces the stride given a kind.
  80153. * @param kind The kind string to deduce
  80154. * @returns The deduced stride
  80155. */
  80156. static DeduceStride(kind: string): number;
  80157. /**
  80158. * Gets the byte length of the given type.
  80159. * @param type the type
  80160. * @returns the number of bytes
  80161. */
  80162. static GetTypeByteLength(type: number): number;
  80163. /**
  80164. * Enumerates each value of the given parameters as numbers.
  80165. * @param data the data to enumerate
  80166. * @param byteOffset the byte offset of the data
  80167. * @param byteStride the byte stride of the data
  80168. * @param componentCount the number of components per element
  80169. * @param componentType the type of the component
  80170. * @param count the number of values to enumerate
  80171. * @param normalized whether the data is normalized
  80172. * @param callback the callback function called for each value
  80173. */
  80174. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80175. private static _GetFloatValue;
  80176. }
  80177. }
  80178. declare module BABYLON {
  80179. /**
  80180. * @hidden
  80181. */
  80182. export class IntersectionInfo {
  80183. bu: Nullable<number>;
  80184. bv: Nullable<number>;
  80185. distance: number;
  80186. faceId: number;
  80187. subMeshId: number;
  80188. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80189. }
  80190. }
  80191. declare module BABYLON {
  80192. /**
  80193. * Represens a plane by the equation ax + by + cz + d = 0
  80194. */
  80195. export class Plane {
  80196. private static _TmpMatrix;
  80197. /**
  80198. * Normal of the plane (a,b,c)
  80199. */
  80200. normal: Vector3;
  80201. /**
  80202. * d component of the plane
  80203. */
  80204. d: number;
  80205. /**
  80206. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80207. * @param a a component of the plane
  80208. * @param b b component of the plane
  80209. * @param c c component of the plane
  80210. * @param d d component of the plane
  80211. */
  80212. constructor(a: number, b: number, c: number, d: number);
  80213. /**
  80214. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80215. */
  80216. asArray(): number[];
  80217. /**
  80218. * @returns a new plane copied from the current Plane.
  80219. */
  80220. clone(): Plane;
  80221. /**
  80222. * @returns the string "Plane".
  80223. */
  80224. getClassName(): string;
  80225. /**
  80226. * @returns the Plane hash code.
  80227. */
  80228. getHashCode(): number;
  80229. /**
  80230. * Normalize the current Plane in place.
  80231. * @returns the updated Plane.
  80232. */
  80233. normalize(): Plane;
  80234. /**
  80235. * Applies a transformation the plane and returns the result
  80236. * @param transformation the transformation matrix to be applied to the plane
  80237. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80238. */
  80239. transform(transformation: DeepImmutable<Matrix>): Plane;
  80240. /**
  80241. * Calcualtte the dot product between the point and the plane normal
  80242. * @param point point to calculate the dot product with
  80243. * @returns the dot product (float) of the point coordinates and the plane normal.
  80244. */
  80245. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80246. /**
  80247. * Updates the current Plane from the plane defined by the three given points.
  80248. * @param point1 one of the points used to contruct the plane
  80249. * @param point2 one of the points used to contruct the plane
  80250. * @param point3 one of the points used to contruct the plane
  80251. * @returns the updated Plane.
  80252. */
  80253. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80254. /**
  80255. * Checks if the plane is facing a given direction
  80256. * @param direction the direction to check if the plane is facing
  80257. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80258. * @returns True is the vector "direction" is the same side than the plane normal.
  80259. */
  80260. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80261. /**
  80262. * Calculates the distance to a point
  80263. * @param point point to calculate distance to
  80264. * @returns the signed distance (float) from the given point to the Plane.
  80265. */
  80266. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80267. /**
  80268. * Creates a plane from an array
  80269. * @param array the array to create a plane from
  80270. * @returns a new Plane from the given array.
  80271. */
  80272. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80273. /**
  80274. * Creates a plane from three points
  80275. * @param point1 point used to create the plane
  80276. * @param point2 point used to create the plane
  80277. * @param point3 point used to create the plane
  80278. * @returns a new Plane defined by the three given points.
  80279. */
  80280. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80281. /**
  80282. * Creates a plane from an origin point and a normal
  80283. * @param origin origin of the plane to be constructed
  80284. * @param normal normal of the plane to be constructed
  80285. * @returns a new Plane the normal vector to this plane at the given origin point.
  80286. * Note : the vector "normal" is updated because normalized.
  80287. */
  80288. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80289. /**
  80290. * Calculates the distance from a plane and a point
  80291. * @param origin origin of the plane to be constructed
  80292. * @param normal normal of the plane to be constructed
  80293. * @param point point to calculate distance to
  80294. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80295. */
  80296. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80297. }
  80298. }
  80299. declare module BABYLON {
  80300. /**
  80301. * Class used to store bounding sphere information
  80302. */
  80303. export class BoundingSphere {
  80304. /**
  80305. * Gets the center of the bounding sphere in local space
  80306. */
  80307. readonly center: Vector3;
  80308. /**
  80309. * Radius of the bounding sphere in local space
  80310. */
  80311. radius: number;
  80312. /**
  80313. * Gets the center of the bounding sphere in world space
  80314. */
  80315. readonly centerWorld: Vector3;
  80316. /**
  80317. * Radius of the bounding sphere in world space
  80318. */
  80319. radiusWorld: number;
  80320. /**
  80321. * Gets the minimum vector in local space
  80322. */
  80323. readonly minimum: Vector3;
  80324. /**
  80325. * Gets the maximum vector in local space
  80326. */
  80327. readonly maximum: Vector3;
  80328. private _worldMatrix;
  80329. private static readonly TmpVector3;
  80330. /**
  80331. * Creates a new bounding sphere
  80332. * @param min defines the minimum vector (in local space)
  80333. * @param max defines the maximum vector (in local space)
  80334. * @param worldMatrix defines the new world matrix
  80335. */
  80336. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80337. /**
  80338. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80339. * @param min defines the new minimum vector (in local space)
  80340. * @param max defines the new maximum vector (in local space)
  80341. * @param worldMatrix defines the new world matrix
  80342. */
  80343. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80344. /**
  80345. * Scale the current bounding sphere by applying a scale factor
  80346. * @param factor defines the scale factor to apply
  80347. * @returns the current bounding box
  80348. */
  80349. scale(factor: number): BoundingSphere;
  80350. /**
  80351. * Gets the world matrix of the bounding box
  80352. * @returns a matrix
  80353. */
  80354. getWorldMatrix(): DeepImmutable<Matrix>;
  80355. /** @hidden */
  80356. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80357. /**
  80358. * Tests if the bounding sphere is intersecting the frustum planes
  80359. * @param frustumPlanes defines the frustum planes to test
  80360. * @returns true if there is an intersection
  80361. */
  80362. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80363. /**
  80364. * Tests if the bounding sphere center is in between the frustum planes.
  80365. * Used for optimistic fast inclusion.
  80366. * @param frustumPlanes defines the frustum planes to test
  80367. * @returns true if the sphere center is in between the frustum planes
  80368. */
  80369. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80370. /**
  80371. * Tests if a point is inside the bounding sphere
  80372. * @param point defines the point to test
  80373. * @returns true if the point is inside the bounding sphere
  80374. */
  80375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80376. /**
  80377. * Checks if two sphere intersct
  80378. * @param sphere0 sphere 0
  80379. * @param sphere1 sphere 1
  80380. * @returns true if the speres intersect
  80381. */
  80382. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80383. }
  80384. }
  80385. declare module BABYLON {
  80386. /**
  80387. * Class used to store bounding box information
  80388. */
  80389. export class BoundingBox implements ICullable {
  80390. /**
  80391. * Gets the 8 vectors representing the bounding box in local space
  80392. */
  80393. readonly vectors: Vector3[];
  80394. /**
  80395. * Gets the center of the bounding box in local space
  80396. */
  80397. readonly center: Vector3;
  80398. /**
  80399. * Gets the center of the bounding box in world space
  80400. */
  80401. readonly centerWorld: Vector3;
  80402. /**
  80403. * Gets the extend size in local space
  80404. */
  80405. readonly extendSize: Vector3;
  80406. /**
  80407. * Gets the extend size in world space
  80408. */
  80409. readonly extendSizeWorld: Vector3;
  80410. /**
  80411. * Gets the OBB (object bounding box) directions
  80412. */
  80413. readonly directions: Vector3[];
  80414. /**
  80415. * Gets the 8 vectors representing the bounding box in world space
  80416. */
  80417. readonly vectorsWorld: Vector3[];
  80418. /**
  80419. * Gets the minimum vector in world space
  80420. */
  80421. readonly minimumWorld: Vector3;
  80422. /**
  80423. * Gets the maximum vector in world space
  80424. */
  80425. readonly maximumWorld: Vector3;
  80426. /**
  80427. * Gets the minimum vector in local space
  80428. */
  80429. readonly minimum: Vector3;
  80430. /**
  80431. * Gets the maximum vector in local space
  80432. */
  80433. readonly maximum: Vector3;
  80434. private _worldMatrix;
  80435. private static readonly TmpVector3;
  80436. /**
  80437. * @hidden
  80438. */
  80439. _tag: number;
  80440. /**
  80441. * Creates a new bounding box
  80442. * @param min defines the minimum vector (in local space)
  80443. * @param max defines the maximum vector (in local space)
  80444. * @param worldMatrix defines the new world matrix
  80445. */
  80446. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80447. /**
  80448. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80449. * @param min defines the new minimum vector (in local space)
  80450. * @param max defines the new maximum vector (in local space)
  80451. * @param worldMatrix defines the new world matrix
  80452. */
  80453. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80454. /**
  80455. * Scale the current bounding box by applying a scale factor
  80456. * @param factor defines the scale factor to apply
  80457. * @returns the current bounding box
  80458. */
  80459. scale(factor: number): BoundingBox;
  80460. /**
  80461. * Gets the world matrix of the bounding box
  80462. * @returns a matrix
  80463. */
  80464. getWorldMatrix(): DeepImmutable<Matrix>;
  80465. /** @hidden */
  80466. _update(world: DeepImmutable<Matrix>): void;
  80467. /**
  80468. * Tests if the bounding box is intersecting the frustum planes
  80469. * @param frustumPlanes defines the frustum planes to test
  80470. * @returns true if there is an intersection
  80471. */
  80472. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80473. /**
  80474. * Tests if the bounding box is entirely inside the frustum planes
  80475. * @param frustumPlanes defines the frustum planes to test
  80476. * @returns true if there is an inclusion
  80477. */
  80478. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80479. /**
  80480. * Tests if a point is inside the bounding box
  80481. * @param point defines the point to test
  80482. * @returns true if the point is inside the bounding box
  80483. */
  80484. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80485. /**
  80486. * Tests if the bounding box intersects with a bounding sphere
  80487. * @param sphere defines the sphere to test
  80488. * @returns true if there is an intersection
  80489. */
  80490. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80491. /**
  80492. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80493. * @param min defines the min vector to use
  80494. * @param max defines the max vector to use
  80495. * @returns true if there is an intersection
  80496. */
  80497. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80498. /**
  80499. * Tests if two bounding boxes are intersections
  80500. * @param box0 defines the first box to test
  80501. * @param box1 defines the second box to test
  80502. * @returns true if there is an intersection
  80503. */
  80504. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80505. /**
  80506. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80507. * @param minPoint defines the minimum vector of the bounding box
  80508. * @param maxPoint defines the maximum vector of the bounding box
  80509. * @param sphereCenter defines the sphere center
  80510. * @param sphereRadius defines the sphere radius
  80511. * @returns true if there is an intersection
  80512. */
  80513. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80514. /**
  80515. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80516. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80517. * @param frustumPlanes defines the frustum planes to test
  80518. * @return true if there is an inclusion
  80519. */
  80520. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80521. /**
  80522. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80523. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80524. * @param frustumPlanes defines the frustum planes to test
  80525. * @return true if there is an intersection
  80526. */
  80527. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80528. }
  80529. }
  80530. declare module BABYLON {
  80531. /** @hidden */
  80532. export class Collider {
  80533. /** Define if a collision was found */
  80534. collisionFound: boolean;
  80535. /**
  80536. * Define last intersection point in local space
  80537. */
  80538. intersectionPoint: Vector3;
  80539. /**
  80540. * Define last collided mesh
  80541. */
  80542. collidedMesh: Nullable<AbstractMesh>;
  80543. private _collisionPoint;
  80544. private _planeIntersectionPoint;
  80545. private _tempVector;
  80546. private _tempVector2;
  80547. private _tempVector3;
  80548. private _tempVector4;
  80549. private _edge;
  80550. private _baseToVertex;
  80551. private _destinationPoint;
  80552. private _slidePlaneNormal;
  80553. private _displacementVector;
  80554. /** @hidden */
  80555. _radius: Vector3;
  80556. /** @hidden */
  80557. _retry: number;
  80558. private _velocity;
  80559. private _basePoint;
  80560. private _epsilon;
  80561. /** @hidden */
  80562. _velocityWorldLength: number;
  80563. /** @hidden */
  80564. _basePointWorld: Vector3;
  80565. private _velocityWorld;
  80566. private _normalizedVelocity;
  80567. /** @hidden */
  80568. _initialVelocity: Vector3;
  80569. /** @hidden */
  80570. _initialPosition: Vector3;
  80571. private _nearestDistance;
  80572. private _collisionMask;
  80573. get collisionMask(): number;
  80574. set collisionMask(mask: number);
  80575. /**
  80576. * Gets the plane normal used to compute the sliding response (in local space)
  80577. */
  80578. get slidePlaneNormal(): Vector3;
  80579. /** @hidden */
  80580. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80581. /** @hidden */
  80582. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80583. /** @hidden */
  80584. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80585. /** @hidden */
  80586. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80587. /** @hidden */
  80588. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80589. /** @hidden */
  80590. _getResponse(pos: Vector3, vel: Vector3): void;
  80591. }
  80592. }
  80593. declare module BABYLON {
  80594. /**
  80595. * Interface for cullable objects
  80596. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80597. */
  80598. export interface ICullable {
  80599. /**
  80600. * Checks if the object or part of the object is in the frustum
  80601. * @param frustumPlanes Camera near/planes
  80602. * @returns true if the object is in frustum otherwise false
  80603. */
  80604. isInFrustum(frustumPlanes: Plane[]): boolean;
  80605. /**
  80606. * Checks if a cullable object (mesh...) is in the camera frustum
  80607. * Unlike isInFrustum this cheks the full bounding box
  80608. * @param frustumPlanes Camera near/planes
  80609. * @returns true if the object is in frustum otherwise false
  80610. */
  80611. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80612. }
  80613. /**
  80614. * Info for a bounding data of a mesh
  80615. */
  80616. export class BoundingInfo implements ICullable {
  80617. /**
  80618. * Bounding box for the mesh
  80619. */
  80620. readonly boundingBox: BoundingBox;
  80621. /**
  80622. * Bounding sphere for the mesh
  80623. */
  80624. readonly boundingSphere: BoundingSphere;
  80625. private _isLocked;
  80626. private static readonly TmpVector3;
  80627. /**
  80628. * Constructs bounding info
  80629. * @param minimum min vector of the bounding box/sphere
  80630. * @param maximum max vector of the bounding box/sphere
  80631. * @param worldMatrix defines the new world matrix
  80632. */
  80633. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80634. /**
  80635. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80636. * @param min defines the new minimum vector (in local space)
  80637. * @param max defines the new maximum vector (in local space)
  80638. * @param worldMatrix defines the new world matrix
  80639. */
  80640. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80641. /**
  80642. * min vector of the bounding box/sphere
  80643. */
  80644. get minimum(): Vector3;
  80645. /**
  80646. * max vector of the bounding box/sphere
  80647. */
  80648. get maximum(): Vector3;
  80649. /**
  80650. * If the info is locked and won't be updated to avoid perf overhead
  80651. */
  80652. get isLocked(): boolean;
  80653. set isLocked(value: boolean);
  80654. /**
  80655. * Updates the bounding sphere and box
  80656. * @param world world matrix to be used to update
  80657. */
  80658. update(world: DeepImmutable<Matrix>): void;
  80659. /**
  80660. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80661. * @param center New center of the bounding info
  80662. * @param extend New extend of the bounding info
  80663. * @returns the current bounding info
  80664. */
  80665. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80666. /**
  80667. * Scale the current bounding info by applying a scale factor
  80668. * @param factor defines the scale factor to apply
  80669. * @returns the current bounding info
  80670. */
  80671. scale(factor: number): BoundingInfo;
  80672. /**
  80673. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80674. * @param frustumPlanes defines the frustum to test
  80675. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80676. * @returns true if the bounding info is in the frustum planes
  80677. */
  80678. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80679. /**
  80680. * Gets the world distance between the min and max points of the bounding box
  80681. */
  80682. get diagonalLength(): number;
  80683. /**
  80684. * Checks if a cullable object (mesh...) is in the camera frustum
  80685. * Unlike isInFrustum this cheks the full bounding box
  80686. * @param frustumPlanes Camera near/planes
  80687. * @returns true if the object is in frustum otherwise false
  80688. */
  80689. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80690. /** @hidden */
  80691. _checkCollision(collider: Collider): boolean;
  80692. /**
  80693. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80694. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80695. * @param point the point to check intersection with
  80696. * @returns if the point intersects
  80697. */
  80698. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80699. /**
  80700. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80701. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80702. * @param boundingInfo the bounding info to check intersection with
  80703. * @param precise if the intersection should be done using OBB
  80704. * @returns if the bounding info intersects
  80705. */
  80706. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80707. }
  80708. }
  80709. declare module BABYLON {
  80710. /**
  80711. * Extracts minimum and maximum values from a list of indexed positions
  80712. * @param positions defines the positions to use
  80713. * @param indices defines the indices to the positions
  80714. * @param indexStart defines the start index
  80715. * @param indexCount defines the end index
  80716. * @param bias defines bias value to add to the result
  80717. * @return minimum and maximum values
  80718. */
  80719. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80720. minimum: Vector3;
  80721. maximum: Vector3;
  80722. };
  80723. /**
  80724. * Extracts minimum and maximum values from a list of positions
  80725. * @param positions defines the positions to use
  80726. * @param start defines the start index in the positions array
  80727. * @param count defines the number of positions to handle
  80728. * @param bias defines bias value to add to the result
  80729. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80730. * @return minimum and maximum values
  80731. */
  80732. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80733. minimum: Vector3;
  80734. maximum: Vector3;
  80735. };
  80736. }
  80737. declare module BABYLON {
  80738. /** @hidden */
  80739. export class WebGLDataBuffer extends DataBuffer {
  80740. private _buffer;
  80741. constructor(resource: WebGLBuffer);
  80742. get underlyingResource(): any;
  80743. }
  80744. }
  80745. declare module BABYLON {
  80746. /** @hidden */
  80747. export class WebGLPipelineContext implements IPipelineContext {
  80748. engine: ThinEngine;
  80749. program: Nullable<WebGLProgram>;
  80750. context?: WebGLRenderingContext;
  80751. vertexShader?: WebGLShader;
  80752. fragmentShader?: WebGLShader;
  80753. isParallelCompiled: boolean;
  80754. onCompiled?: () => void;
  80755. transformFeedback?: WebGLTransformFeedback | null;
  80756. vertexCompilationError: Nullable<string>;
  80757. fragmentCompilationError: Nullable<string>;
  80758. programLinkError: Nullable<string>;
  80759. programValidationError: Nullable<string>;
  80760. get isAsync(): boolean;
  80761. get isReady(): boolean;
  80762. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80763. _getVertexShaderCode(): string | null;
  80764. _getFragmentShaderCode(): string | null;
  80765. }
  80766. }
  80767. declare module BABYLON {
  80768. interface ThinEngine {
  80769. /**
  80770. * Create an uniform buffer
  80771. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80772. * @param elements defines the content of the uniform buffer
  80773. * @returns the webGL uniform buffer
  80774. */
  80775. createUniformBuffer(elements: FloatArray): DataBuffer;
  80776. /**
  80777. * Create a dynamic uniform buffer
  80778. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80779. * @param elements defines the content of the uniform buffer
  80780. * @returns the webGL uniform buffer
  80781. */
  80782. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80783. /**
  80784. * Update an existing uniform buffer
  80785. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80786. * @param uniformBuffer defines the target uniform buffer
  80787. * @param elements defines the content to update
  80788. * @param offset defines the offset in the uniform buffer where update should start
  80789. * @param count defines the size of the data to update
  80790. */
  80791. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80792. /**
  80793. * Bind an uniform buffer to the current webGL context
  80794. * @param buffer defines the buffer to bind
  80795. */
  80796. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80797. /**
  80798. * Bind a buffer to the current webGL context at a given location
  80799. * @param buffer defines the buffer to bind
  80800. * @param location defines the index where to bind the buffer
  80801. */
  80802. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80803. /**
  80804. * Bind a specific block at a given index in a specific shader program
  80805. * @param pipelineContext defines the pipeline context to use
  80806. * @param blockName defines the block name
  80807. * @param index defines the index where to bind the block
  80808. */
  80809. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80810. }
  80811. }
  80812. declare module BABYLON {
  80813. /**
  80814. * Uniform buffer objects.
  80815. *
  80816. * Handles blocks of uniform on the GPU.
  80817. *
  80818. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80819. *
  80820. * For more information, please refer to :
  80821. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80822. */
  80823. export class UniformBuffer {
  80824. private _engine;
  80825. private _buffer;
  80826. private _data;
  80827. private _bufferData;
  80828. private _dynamic?;
  80829. private _uniformLocations;
  80830. private _uniformSizes;
  80831. private _uniformLocationPointer;
  80832. private _needSync;
  80833. private _noUBO;
  80834. private _currentEffect;
  80835. /** @hidden */
  80836. _alreadyBound: boolean;
  80837. private static _MAX_UNIFORM_SIZE;
  80838. private static _tempBuffer;
  80839. /**
  80840. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80841. * This is dynamic to allow compat with webgl 1 and 2.
  80842. * You will need to pass the name of the uniform as well as the value.
  80843. */
  80844. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80845. /**
  80846. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80847. * This is dynamic to allow compat with webgl 1 and 2.
  80848. * You will need to pass the name of the uniform as well as the value.
  80849. */
  80850. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80851. /**
  80852. * Lambda to Update a single float in a uniform buffer.
  80853. * This is dynamic to allow compat with webgl 1 and 2.
  80854. * You will need to pass the name of the uniform as well as the value.
  80855. */
  80856. updateFloat: (name: string, x: number) => void;
  80857. /**
  80858. * Lambda to Update a vec2 of float in a uniform buffer.
  80859. * This is dynamic to allow compat with webgl 1 and 2.
  80860. * You will need to pass the name of the uniform as well as the value.
  80861. */
  80862. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80863. /**
  80864. * Lambda to Update a vec3 of float in a uniform buffer.
  80865. * This is dynamic to allow compat with webgl 1 and 2.
  80866. * You will need to pass the name of the uniform as well as the value.
  80867. */
  80868. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80869. /**
  80870. * Lambda to Update a vec4 of float in a uniform buffer.
  80871. * This is dynamic to allow compat with webgl 1 and 2.
  80872. * You will need to pass the name of the uniform as well as the value.
  80873. */
  80874. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80875. /**
  80876. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80877. * This is dynamic to allow compat with webgl 1 and 2.
  80878. * You will need to pass the name of the uniform as well as the value.
  80879. */
  80880. updateMatrix: (name: string, mat: Matrix) => void;
  80881. /**
  80882. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80883. * This is dynamic to allow compat with webgl 1 and 2.
  80884. * You will need to pass the name of the uniform as well as the value.
  80885. */
  80886. updateVector3: (name: string, vector: Vector3) => void;
  80887. /**
  80888. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80889. * This is dynamic to allow compat with webgl 1 and 2.
  80890. * You will need to pass the name of the uniform as well as the value.
  80891. */
  80892. updateVector4: (name: string, vector: Vector4) => void;
  80893. /**
  80894. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80895. * This is dynamic to allow compat with webgl 1 and 2.
  80896. * You will need to pass the name of the uniform as well as the value.
  80897. */
  80898. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80899. /**
  80900. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80901. * This is dynamic to allow compat with webgl 1 and 2.
  80902. * You will need to pass the name of the uniform as well as the value.
  80903. */
  80904. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80905. /**
  80906. * Instantiates a new Uniform buffer objects.
  80907. *
  80908. * Handles blocks of uniform on the GPU.
  80909. *
  80910. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80911. *
  80912. * For more information, please refer to :
  80913. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80914. * @param engine Define the engine the buffer is associated with
  80915. * @param data Define the data contained in the buffer
  80916. * @param dynamic Define if the buffer is updatable
  80917. */
  80918. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80919. /**
  80920. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80921. * or just falling back on setUniformXXX calls.
  80922. */
  80923. get useUbo(): boolean;
  80924. /**
  80925. * Indicates if the WebGL underlying uniform buffer is in sync
  80926. * with the javascript cache data.
  80927. */
  80928. get isSync(): boolean;
  80929. /**
  80930. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80931. * Also, a dynamic UniformBuffer will disable cache verification and always
  80932. * update the underlying WebGL uniform buffer to the GPU.
  80933. * @returns if Dynamic, otherwise false
  80934. */
  80935. isDynamic(): boolean;
  80936. /**
  80937. * The data cache on JS side.
  80938. * @returns the underlying data as a float array
  80939. */
  80940. getData(): Float32Array;
  80941. /**
  80942. * The underlying WebGL Uniform buffer.
  80943. * @returns the webgl buffer
  80944. */
  80945. getBuffer(): Nullable<DataBuffer>;
  80946. /**
  80947. * std140 layout specifies how to align data within an UBO structure.
  80948. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80949. * for specs.
  80950. */
  80951. private _fillAlignment;
  80952. /**
  80953. * Adds an uniform in the buffer.
  80954. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80955. * for the layout to be correct !
  80956. * @param name Name of the uniform, as used in the uniform block in the shader.
  80957. * @param size Data size, or data directly.
  80958. */
  80959. addUniform(name: string, size: number | number[]): void;
  80960. /**
  80961. * Adds a Matrix 4x4 to the uniform buffer.
  80962. * @param name Name of the uniform, as used in the uniform block in the shader.
  80963. * @param mat A 4x4 matrix.
  80964. */
  80965. addMatrix(name: string, mat: Matrix): void;
  80966. /**
  80967. * Adds a vec2 to the uniform buffer.
  80968. * @param name Name of the uniform, as used in the uniform block in the shader.
  80969. * @param x Define the x component value of the vec2
  80970. * @param y Define the y component value of the vec2
  80971. */
  80972. addFloat2(name: string, x: number, y: number): void;
  80973. /**
  80974. * Adds a vec3 to the uniform buffer.
  80975. * @param name Name of the uniform, as used in the uniform block in the shader.
  80976. * @param x Define the x component value of the vec3
  80977. * @param y Define the y component value of the vec3
  80978. * @param z Define the z component value of the vec3
  80979. */
  80980. addFloat3(name: string, x: number, y: number, z: number): void;
  80981. /**
  80982. * Adds a vec3 to the uniform buffer.
  80983. * @param name Name of the uniform, as used in the uniform block in the shader.
  80984. * @param color Define the vec3 from a Color
  80985. */
  80986. addColor3(name: string, color: Color3): void;
  80987. /**
  80988. * Adds a vec4 to the uniform buffer.
  80989. * @param name Name of the uniform, as used in the uniform block in the shader.
  80990. * @param color Define the rgb components from a Color
  80991. * @param alpha Define the a component of the vec4
  80992. */
  80993. addColor4(name: string, color: Color3, alpha: number): void;
  80994. /**
  80995. * Adds a vec3 to the uniform buffer.
  80996. * @param name Name of the uniform, as used in the uniform block in the shader.
  80997. * @param vector Define the vec3 components from a Vector
  80998. */
  80999. addVector3(name: string, vector: Vector3): void;
  81000. /**
  81001. * Adds a Matrix 3x3 to the uniform buffer.
  81002. * @param name Name of the uniform, as used in the uniform block in the shader.
  81003. */
  81004. addMatrix3x3(name: string): void;
  81005. /**
  81006. * Adds a Matrix 2x2 to the uniform buffer.
  81007. * @param name Name of the uniform, as used in the uniform block in the shader.
  81008. */
  81009. addMatrix2x2(name: string): void;
  81010. /**
  81011. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81012. */
  81013. create(): void;
  81014. /** @hidden */
  81015. _rebuild(): void;
  81016. /**
  81017. * Updates the WebGL Uniform Buffer on the GPU.
  81018. * If the `dynamic` flag is set to true, no cache comparison is done.
  81019. * Otherwise, the buffer will be updated only if the cache differs.
  81020. */
  81021. update(): void;
  81022. /**
  81023. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81024. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81025. * @param data Define the flattened data
  81026. * @param size Define the size of the data.
  81027. */
  81028. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81029. private _valueCache;
  81030. private _cacheMatrix;
  81031. private _updateMatrix3x3ForUniform;
  81032. private _updateMatrix3x3ForEffect;
  81033. private _updateMatrix2x2ForEffect;
  81034. private _updateMatrix2x2ForUniform;
  81035. private _updateFloatForEffect;
  81036. private _updateFloatForUniform;
  81037. private _updateFloat2ForEffect;
  81038. private _updateFloat2ForUniform;
  81039. private _updateFloat3ForEffect;
  81040. private _updateFloat3ForUniform;
  81041. private _updateFloat4ForEffect;
  81042. private _updateFloat4ForUniform;
  81043. private _updateMatrixForEffect;
  81044. private _updateMatrixForUniform;
  81045. private _updateVector3ForEffect;
  81046. private _updateVector3ForUniform;
  81047. private _updateVector4ForEffect;
  81048. private _updateVector4ForUniform;
  81049. private _updateColor3ForEffect;
  81050. private _updateColor3ForUniform;
  81051. private _updateColor4ForEffect;
  81052. private _updateColor4ForUniform;
  81053. /**
  81054. * Sets a sampler uniform on the effect.
  81055. * @param name Define the name of the sampler.
  81056. * @param texture Define the texture to set in the sampler
  81057. */
  81058. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81059. /**
  81060. * Directly updates the value of the uniform in the cache AND on the GPU.
  81061. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81062. * @param data Define the flattened data
  81063. */
  81064. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81065. /**
  81066. * Binds this uniform buffer to an effect.
  81067. * @param effect Define the effect to bind the buffer to
  81068. * @param name Name of the uniform block in the shader.
  81069. */
  81070. bindToEffect(effect: Effect, name: string): void;
  81071. /**
  81072. * Disposes the uniform buffer.
  81073. */
  81074. dispose(): void;
  81075. }
  81076. }
  81077. declare module BABYLON {
  81078. /**
  81079. * Enum that determines the text-wrapping mode to use.
  81080. */
  81081. export enum InspectableType {
  81082. /**
  81083. * Checkbox for booleans
  81084. */
  81085. Checkbox = 0,
  81086. /**
  81087. * Sliders for numbers
  81088. */
  81089. Slider = 1,
  81090. /**
  81091. * Vector3
  81092. */
  81093. Vector3 = 2,
  81094. /**
  81095. * Quaternions
  81096. */
  81097. Quaternion = 3,
  81098. /**
  81099. * Color3
  81100. */
  81101. Color3 = 4,
  81102. /**
  81103. * String
  81104. */
  81105. String = 5
  81106. }
  81107. /**
  81108. * Interface used to define custom inspectable properties.
  81109. * This interface is used by the inspector to display custom property grids
  81110. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81111. */
  81112. export interface IInspectable {
  81113. /**
  81114. * Gets the label to display
  81115. */
  81116. label: string;
  81117. /**
  81118. * Gets the name of the property to edit
  81119. */
  81120. propertyName: string;
  81121. /**
  81122. * Gets the type of the editor to use
  81123. */
  81124. type: InspectableType;
  81125. /**
  81126. * Gets the minimum value of the property when using in "slider" mode
  81127. */
  81128. min?: number;
  81129. /**
  81130. * Gets the maximum value of the property when using in "slider" mode
  81131. */
  81132. max?: number;
  81133. /**
  81134. * Gets the setp to use when using in "slider" mode
  81135. */
  81136. step?: number;
  81137. }
  81138. }
  81139. declare module BABYLON {
  81140. /**
  81141. * Class used to provide helper for timing
  81142. */
  81143. export class TimingTools {
  81144. /**
  81145. * Polyfill for setImmediate
  81146. * @param action defines the action to execute after the current execution block
  81147. */
  81148. static SetImmediate(action: () => void): void;
  81149. }
  81150. }
  81151. declare module BABYLON {
  81152. /**
  81153. * Class used to enable instatition of objects by class name
  81154. */
  81155. export class InstantiationTools {
  81156. /**
  81157. * Use this object to register external classes like custom textures or material
  81158. * to allow the laoders to instantiate them
  81159. */
  81160. static RegisteredExternalClasses: {
  81161. [key: string]: Object;
  81162. };
  81163. /**
  81164. * Tries to instantiate a new object from a given class name
  81165. * @param className defines the class name to instantiate
  81166. * @returns the new object or null if the system was not able to do the instantiation
  81167. */
  81168. static Instantiate(className: string): any;
  81169. }
  81170. }
  81171. declare module BABYLON {
  81172. /**
  81173. * Define options used to create a depth texture
  81174. */
  81175. export class DepthTextureCreationOptions {
  81176. /** Specifies whether or not a stencil should be allocated in the texture */
  81177. generateStencil?: boolean;
  81178. /** Specifies whether or not bilinear filtering is enable on the texture */
  81179. bilinearFiltering?: boolean;
  81180. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81181. comparisonFunction?: number;
  81182. /** Specifies if the created texture is a cube texture */
  81183. isCube?: boolean;
  81184. }
  81185. }
  81186. declare module BABYLON {
  81187. interface ThinEngine {
  81188. /**
  81189. * Creates a depth stencil cube texture.
  81190. * This is only available in WebGL 2.
  81191. * @param size The size of face edge in the cube texture.
  81192. * @param options The options defining the cube texture.
  81193. * @returns The cube texture
  81194. */
  81195. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81196. /**
  81197. * Creates a cube texture
  81198. * @param rootUrl defines the url where the files to load is located
  81199. * @param scene defines the current scene
  81200. * @param files defines the list of files to load (1 per face)
  81201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81202. * @param onLoad defines an optional callback raised when the texture is loaded
  81203. * @param onError defines an optional callback raised if there is an issue to load the texture
  81204. * @param format defines the format of the data
  81205. * @param forcedExtension defines the extension to use to pick the right loader
  81206. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81207. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81208. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81209. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81210. * @returns the cube texture as an InternalTexture
  81211. */
  81212. 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;
  81213. /**
  81214. * Creates a cube texture
  81215. * @param rootUrl defines the url where the files to load is located
  81216. * @param scene defines the current scene
  81217. * @param files defines the list of files to load (1 per face)
  81218. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81219. * @param onLoad defines an optional callback raised when the texture is loaded
  81220. * @param onError defines an optional callback raised if there is an issue to load the texture
  81221. * @param format defines the format of the data
  81222. * @param forcedExtension defines the extension to use to pick the right loader
  81223. * @returns the cube texture as an InternalTexture
  81224. */
  81225. 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;
  81226. /**
  81227. * Creates a cube texture
  81228. * @param rootUrl defines the url where the files to load is located
  81229. * @param scene defines the current scene
  81230. * @param files defines the list of files to load (1 per face)
  81231. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81232. * @param onLoad defines an optional callback raised when the texture is loaded
  81233. * @param onError defines an optional callback raised if there is an issue to load the texture
  81234. * @param format defines the format of the data
  81235. * @param forcedExtension defines the extension to use to pick the right loader
  81236. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81237. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81238. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81239. * @returns the cube texture as an InternalTexture
  81240. */
  81241. 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;
  81242. /** @hidden */
  81243. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81244. /** @hidden */
  81245. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81246. /** @hidden */
  81247. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81248. /** @hidden */
  81249. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81250. /**
  81251. * @hidden
  81252. */
  81253. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81254. }
  81255. }
  81256. declare module BABYLON {
  81257. /**
  81258. * Class for creating a cube texture
  81259. */
  81260. export class CubeTexture extends BaseTexture {
  81261. private _delayedOnLoad;
  81262. /**
  81263. * Observable triggered once the texture has been loaded.
  81264. */
  81265. onLoadObservable: Observable<CubeTexture>;
  81266. /**
  81267. * The url of the texture
  81268. */
  81269. url: string;
  81270. /**
  81271. * Gets or sets the center of the bounding box associated with the cube texture.
  81272. * It must define where the camera used to render the texture was set
  81273. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81274. */
  81275. boundingBoxPosition: Vector3;
  81276. private _boundingBoxSize;
  81277. /**
  81278. * Gets or sets the size of the bounding box associated with the cube texture
  81279. * When defined, the cubemap will switch to local mode
  81280. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81281. * @example https://www.babylonjs-playground.com/#RNASML
  81282. */
  81283. set boundingBoxSize(value: Vector3);
  81284. /**
  81285. * Returns the bounding box size
  81286. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81287. */
  81288. get boundingBoxSize(): Vector3;
  81289. protected _rotationY: number;
  81290. /**
  81291. * Sets texture matrix rotation angle around Y axis in radians.
  81292. */
  81293. set rotationY(value: number);
  81294. /**
  81295. * Gets texture matrix rotation angle around Y axis radians.
  81296. */
  81297. get rotationY(): number;
  81298. /**
  81299. * Are mip maps generated for this texture or not.
  81300. */
  81301. get noMipmap(): boolean;
  81302. private _noMipmap;
  81303. private _files;
  81304. protected _forcedExtension: Nullable<string>;
  81305. private _extensions;
  81306. private _textureMatrix;
  81307. private _format;
  81308. private _createPolynomials;
  81309. /** @hidden */
  81310. _prefiltered: boolean;
  81311. /**
  81312. * Creates a cube texture from an array of image urls
  81313. * @param files defines an array of image urls
  81314. * @param scene defines the hosting scene
  81315. * @param noMipmap specifies if mip maps are not used
  81316. * @returns a cube texture
  81317. */
  81318. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81319. /**
  81320. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81321. * @param url defines the url of the prefiltered texture
  81322. * @param scene defines the scene the texture is attached to
  81323. * @param forcedExtension defines the extension of the file if different from the url
  81324. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81325. * @return the prefiltered texture
  81326. */
  81327. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81328. /**
  81329. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81330. * as prefiltered data.
  81331. * @param rootUrl defines the url of the texture or the root name of the six images
  81332. * @param scene defines the scene the texture is attached to
  81333. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81334. * @param noMipmap defines if mipmaps should be created or not
  81335. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81336. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81337. * @param onError defines a callback triggered in case of error during load
  81338. * @param format defines the internal format to use for the texture once loaded
  81339. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81340. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81341. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81342. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81343. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81344. * @return the cube texture
  81345. */
  81346. 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);
  81347. /**
  81348. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81349. */
  81350. get isPrefiltered(): boolean;
  81351. /**
  81352. * Get the current class name of the texture useful for serialization or dynamic coding.
  81353. * @returns "CubeTexture"
  81354. */
  81355. getClassName(): string;
  81356. /**
  81357. * Update the url (and optional buffer) of this texture if url was null during construction.
  81358. * @param url the url of the texture
  81359. * @param forcedExtension defines the extension to use
  81360. * @param onLoad callback called when the texture is loaded (defaults to null)
  81361. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81362. */
  81363. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81364. /**
  81365. * Delays loading of the cube texture
  81366. * @param forcedExtension defines the extension to use
  81367. */
  81368. delayLoad(forcedExtension?: string): void;
  81369. /**
  81370. * Returns the reflection texture matrix
  81371. * @returns the reflection texture matrix
  81372. */
  81373. getReflectionTextureMatrix(): Matrix;
  81374. /**
  81375. * Sets the reflection texture matrix
  81376. * @param value Reflection texture matrix
  81377. */
  81378. setReflectionTextureMatrix(value: Matrix): void;
  81379. /**
  81380. * Parses text to create a cube texture
  81381. * @param parsedTexture define the serialized text to read from
  81382. * @param scene defines the hosting scene
  81383. * @param rootUrl defines the root url of the cube texture
  81384. * @returns a cube texture
  81385. */
  81386. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81387. /**
  81388. * Makes a clone, or deep copy, of the cube texture
  81389. * @returns a new cube texture
  81390. */
  81391. clone(): CubeTexture;
  81392. }
  81393. }
  81394. declare module BABYLON {
  81395. /**
  81396. * Manages the defines for the Material
  81397. */
  81398. export class MaterialDefines {
  81399. /** @hidden */
  81400. protected _keys: string[];
  81401. private _isDirty;
  81402. /** @hidden */
  81403. _renderId: number;
  81404. /** @hidden */
  81405. _areLightsDirty: boolean;
  81406. /** @hidden */
  81407. _areLightsDisposed: boolean;
  81408. /** @hidden */
  81409. _areAttributesDirty: boolean;
  81410. /** @hidden */
  81411. _areTexturesDirty: boolean;
  81412. /** @hidden */
  81413. _areFresnelDirty: boolean;
  81414. /** @hidden */
  81415. _areMiscDirty: boolean;
  81416. /** @hidden */
  81417. _areImageProcessingDirty: boolean;
  81418. /** @hidden */
  81419. _normals: boolean;
  81420. /** @hidden */
  81421. _uvs: boolean;
  81422. /** @hidden */
  81423. _needNormals: boolean;
  81424. /** @hidden */
  81425. _needUVs: boolean;
  81426. [id: string]: any;
  81427. /**
  81428. * Specifies if the material needs to be re-calculated
  81429. */
  81430. get isDirty(): boolean;
  81431. /**
  81432. * Marks the material to indicate that it has been re-calculated
  81433. */
  81434. markAsProcessed(): void;
  81435. /**
  81436. * Marks the material to indicate that it needs to be re-calculated
  81437. */
  81438. markAsUnprocessed(): void;
  81439. /**
  81440. * Marks the material to indicate all of its defines need to be re-calculated
  81441. */
  81442. markAllAsDirty(): void;
  81443. /**
  81444. * Marks the material to indicate that image processing needs to be re-calculated
  81445. */
  81446. markAsImageProcessingDirty(): void;
  81447. /**
  81448. * Marks the material to indicate the lights need to be re-calculated
  81449. * @param disposed Defines whether the light is dirty due to dispose or not
  81450. */
  81451. markAsLightDirty(disposed?: boolean): void;
  81452. /**
  81453. * Marks the attribute state as changed
  81454. */
  81455. markAsAttributesDirty(): void;
  81456. /**
  81457. * Marks the texture state as changed
  81458. */
  81459. markAsTexturesDirty(): void;
  81460. /**
  81461. * Marks the fresnel state as changed
  81462. */
  81463. markAsFresnelDirty(): void;
  81464. /**
  81465. * Marks the misc state as changed
  81466. */
  81467. markAsMiscDirty(): void;
  81468. /**
  81469. * Rebuilds the material defines
  81470. */
  81471. rebuild(): void;
  81472. /**
  81473. * Specifies if two material defines are equal
  81474. * @param other - A material define instance to compare to
  81475. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81476. */
  81477. isEqual(other: MaterialDefines): boolean;
  81478. /**
  81479. * Clones this instance's defines to another instance
  81480. * @param other - material defines to clone values to
  81481. */
  81482. cloneTo(other: MaterialDefines): void;
  81483. /**
  81484. * Resets the material define values
  81485. */
  81486. reset(): void;
  81487. /**
  81488. * Converts the material define values to a string
  81489. * @returns - String of material define information
  81490. */
  81491. toString(): string;
  81492. }
  81493. }
  81494. declare module BABYLON {
  81495. /**
  81496. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81497. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81498. * 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;
  81499. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81500. */
  81501. export class ColorCurves {
  81502. private _dirty;
  81503. private _tempColor;
  81504. private _globalCurve;
  81505. private _highlightsCurve;
  81506. private _midtonesCurve;
  81507. private _shadowsCurve;
  81508. private _positiveCurve;
  81509. private _negativeCurve;
  81510. private _globalHue;
  81511. private _globalDensity;
  81512. private _globalSaturation;
  81513. private _globalExposure;
  81514. /**
  81515. * Gets the global Hue value.
  81516. * 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).
  81517. */
  81518. get globalHue(): number;
  81519. /**
  81520. * Sets the global Hue value.
  81521. * 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).
  81522. */
  81523. set globalHue(value: number);
  81524. /**
  81525. * Gets the global Density value.
  81526. * 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.
  81527. * Values less than zero provide a filter of opposite hue.
  81528. */
  81529. get globalDensity(): number;
  81530. /**
  81531. * Sets the global Density value.
  81532. * 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.
  81533. * Values less than zero provide a filter of opposite hue.
  81534. */
  81535. set globalDensity(value: number);
  81536. /**
  81537. * Gets the global Saturation value.
  81538. * 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.
  81539. */
  81540. get globalSaturation(): number;
  81541. /**
  81542. * Sets the global Saturation value.
  81543. * 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.
  81544. */
  81545. set globalSaturation(value: number);
  81546. /**
  81547. * Gets the global Exposure value.
  81548. * 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.
  81549. */
  81550. get globalExposure(): number;
  81551. /**
  81552. * Sets the global Exposure value.
  81553. * 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.
  81554. */
  81555. set globalExposure(value: number);
  81556. private _highlightsHue;
  81557. private _highlightsDensity;
  81558. private _highlightsSaturation;
  81559. private _highlightsExposure;
  81560. /**
  81561. * Gets the highlights Hue value.
  81562. * 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).
  81563. */
  81564. get highlightsHue(): number;
  81565. /**
  81566. * Sets the highlights Hue value.
  81567. * 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).
  81568. */
  81569. set highlightsHue(value: number);
  81570. /**
  81571. * Gets the highlights Density value.
  81572. * 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.
  81573. * Values less than zero provide a filter of opposite hue.
  81574. */
  81575. get highlightsDensity(): number;
  81576. /**
  81577. * Sets the highlights Density value.
  81578. * 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.
  81579. * Values less than zero provide a filter of opposite hue.
  81580. */
  81581. set highlightsDensity(value: number);
  81582. /**
  81583. * Gets the highlights Saturation value.
  81584. * 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.
  81585. */
  81586. get highlightsSaturation(): number;
  81587. /**
  81588. * Sets the highlights Saturation value.
  81589. * 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.
  81590. */
  81591. set highlightsSaturation(value: number);
  81592. /**
  81593. * Gets the highlights Exposure value.
  81594. * 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.
  81595. */
  81596. get highlightsExposure(): number;
  81597. /**
  81598. * Sets the highlights Exposure value.
  81599. * 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.
  81600. */
  81601. set highlightsExposure(value: number);
  81602. private _midtonesHue;
  81603. private _midtonesDensity;
  81604. private _midtonesSaturation;
  81605. private _midtonesExposure;
  81606. /**
  81607. * Gets the midtones Hue value.
  81608. * 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).
  81609. */
  81610. get midtonesHue(): number;
  81611. /**
  81612. * Sets the midtones Hue value.
  81613. * 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).
  81614. */
  81615. set midtonesHue(value: number);
  81616. /**
  81617. * Gets the midtones Density value.
  81618. * 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.
  81619. * Values less than zero provide a filter of opposite hue.
  81620. */
  81621. get midtonesDensity(): number;
  81622. /**
  81623. * Sets the midtones Density value.
  81624. * 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.
  81625. * Values less than zero provide a filter of opposite hue.
  81626. */
  81627. set midtonesDensity(value: number);
  81628. /**
  81629. * Gets the midtones Saturation value.
  81630. * 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.
  81631. */
  81632. get midtonesSaturation(): number;
  81633. /**
  81634. * Sets the midtones Saturation value.
  81635. * 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.
  81636. */
  81637. set midtonesSaturation(value: number);
  81638. /**
  81639. * Gets the midtones Exposure value.
  81640. * 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.
  81641. */
  81642. get midtonesExposure(): number;
  81643. /**
  81644. * Sets the midtones Exposure value.
  81645. * 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.
  81646. */
  81647. set midtonesExposure(value: number);
  81648. private _shadowsHue;
  81649. private _shadowsDensity;
  81650. private _shadowsSaturation;
  81651. private _shadowsExposure;
  81652. /**
  81653. * Gets the shadows Hue value.
  81654. * 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).
  81655. */
  81656. get shadowsHue(): number;
  81657. /**
  81658. * Sets the shadows Hue value.
  81659. * 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).
  81660. */
  81661. set shadowsHue(value: number);
  81662. /**
  81663. * Gets the shadows Density value.
  81664. * 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.
  81665. * Values less than zero provide a filter of opposite hue.
  81666. */
  81667. get shadowsDensity(): number;
  81668. /**
  81669. * Sets the shadows Density value.
  81670. * 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.
  81671. * Values less than zero provide a filter of opposite hue.
  81672. */
  81673. set shadowsDensity(value: number);
  81674. /**
  81675. * Gets the shadows Saturation value.
  81676. * 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.
  81677. */
  81678. get shadowsSaturation(): number;
  81679. /**
  81680. * Sets the shadows Saturation value.
  81681. * 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.
  81682. */
  81683. set shadowsSaturation(value: number);
  81684. /**
  81685. * Gets the shadows Exposure value.
  81686. * 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.
  81687. */
  81688. get shadowsExposure(): number;
  81689. /**
  81690. * Sets the shadows Exposure value.
  81691. * 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.
  81692. */
  81693. set shadowsExposure(value: number);
  81694. /**
  81695. * Returns the class name
  81696. * @returns The class name
  81697. */
  81698. getClassName(): string;
  81699. /**
  81700. * Binds the color curves to the shader.
  81701. * @param colorCurves The color curve to bind
  81702. * @param effect The effect to bind to
  81703. * @param positiveUniform The positive uniform shader parameter
  81704. * @param neutralUniform The neutral uniform shader parameter
  81705. * @param negativeUniform The negative uniform shader parameter
  81706. */
  81707. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81708. /**
  81709. * Prepare the list of uniforms associated with the ColorCurves effects.
  81710. * @param uniformsList The list of uniforms used in the effect
  81711. */
  81712. static PrepareUniforms(uniformsList: string[]): void;
  81713. /**
  81714. * Returns color grading data based on a hue, density, saturation and exposure value.
  81715. * @param filterHue The hue of the color filter.
  81716. * @param filterDensity The density of the color filter.
  81717. * @param saturation The saturation.
  81718. * @param exposure The exposure.
  81719. * @param result The result data container.
  81720. */
  81721. private getColorGradingDataToRef;
  81722. /**
  81723. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81724. * @param value The input slider value in range [-100,100].
  81725. * @returns Adjusted value.
  81726. */
  81727. private static applyColorGradingSliderNonlinear;
  81728. /**
  81729. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81730. * @param hue The hue (H) input.
  81731. * @param saturation The saturation (S) input.
  81732. * @param brightness The brightness (B) input.
  81733. * @result An RGBA color represented as Vector4.
  81734. */
  81735. private static fromHSBToRef;
  81736. /**
  81737. * Returns a value clamped between min and max
  81738. * @param value The value to clamp
  81739. * @param min The minimum of value
  81740. * @param max The maximum of value
  81741. * @returns The clamped value.
  81742. */
  81743. private static clamp;
  81744. /**
  81745. * Clones the current color curve instance.
  81746. * @return The cloned curves
  81747. */
  81748. clone(): ColorCurves;
  81749. /**
  81750. * Serializes the current color curve instance to a json representation.
  81751. * @return a JSON representation
  81752. */
  81753. serialize(): any;
  81754. /**
  81755. * Parses the color curve from a json representation.
  81756. * @param source the JSON source to parse
  81757. * @return The parsed curves
  81758. */
  81759. static Parse(source: any): ColorCurves;
  81760. }
  81761. }
  81762. declare module BABYLON {
  81763. /**
  81764. * Interface to follow in your material defines to integrate easily the
  81765. * Image proccessing functions.
  81766. * @hidden
  81767. */
  81768. export interface IImageProcessingConfigurationDefines {
  81769. IMAGEPROCESSING: boolean;
  81770. VIGNETTE: boolean;
  81771. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81772. VIGNETTEBLENDMODEOPAQUE: boolean;
  81773. TONEMAPPING: boolean;
  81774. TONEMAPPING_ACES: boolean;
  81775. CONTRAST: boolean;
  81776. EXPOSURE: boolean;
  81777. COLORCURVES: boolean;
  81778. COLORGRADING: boolean;
  81779. COLORGRADING3D: boolean;
  81780. SAMPLER3DGREENDEPTH: boolean;
  81781. SAMPLER3DBGRMAP: boolean;
  81782. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81783. }
  81784. /**
  81785. * @hidden
  81786. */
  81787. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81788. IMAGEPROCESSING: boolean;
  81789. VIGNETTE: boolean;
  81790. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81791. VIGNETTEBLENDMODEOPAQUE: boolean;
  81792. TONEMAPPING: boolean;
  81793. TONEMAPPING_ACES: boolean;
  81794. CONTRAST: boolean;
  81795. COLORCURVES: boolean;
  81796. COLORGRADING: boolean;
  81797. COLORGRADING3D: boolean;
  81798. SAMPLER3DGREENDEPTH: boolean;
  81799. SAMPLER3DBGRMAP: boolean;
  81800. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81801. EXPOSURE: boolean;
  81802. constructor();
  81803. }
  81804. /**
  81805. * This groups together the common properties used for image processing either in direct forward pass
  81806. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81807. * or not.
  81808. */
  81809. export class ImageProcessingConfiguration {
  81810. /**
  81811. * Default tone mapping applied in BabylonJS.
  81812. */
  81813. static readonly TONEMAPPING_STANDARD: number;
  81814. /**
  81815. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81816. * to other engines rendering to increase portability.
  81817. */
  81818. static readonly TONEMAPPING_ACES: number;
  81819. /**
  81820. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81821. */
  81822. colorCurves: Nullable<ColorCurves>;
  81823. private _colorCurvesEnabled;
  81824. /**
  81825. * Gets wether the color curves effect is enabled.
  81826. */
  81827. get colorCurvesEnabled(): boolean;
  81828. /**
  81829. * Sets wether the color curves effect is enabled.
  81830. */
  81831. set colorCurvesEnabled(value: boolean);
  81832. private _colorGradingTexture;
  81833. /**
  81834. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81835. */
  81836. get colorGradingTexture(): Nullable<BaseTexture>;
  81837. /**
  81838. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81839. */
  81840. set colorGradingTexture(value: Nullable<BaseTexture>);
  81841. private _colorGradingEnabled;
  81842. /**
  81843. * Gets wether the color grading effect is enabled.
  81844. */
  81845. get colorGradingEnabled(): boolean;
  81846. /**
  81847. * Sets wether the color grading effect is enabled.
  81848. */
  81849. set colorGradingEnabled(value: boolean);
  81850. private _colorGradingWithGreenDepth;
  81851. /**
  81852. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81853. */
  81854. get colorGradingWithGreenDepth(): boolean;
  81855. /**
  81856. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81857. */
  81858. set colorGradingWithGreenDepth(value: boolean);
  81859. private _colorGradingBGR;
  81860. /**
  81861. * Gets wether the color grading texture contains BGR values.
  81862. */
  81863. get colorGradingBGR(): boolean;
  81864. /**
  81865. * Sets wether the color grading texture contains BGR values.
  81866. */
  81867. set colorGradingBGR(value: boolean);
  81868. /** @hidden */
  81869. _exposure: number;
  81870. /**
  81871. * Gets the Exposure used in the effect.
  81872. */
  81873. get exposure(): number;
  81874. /**
  81875. * Sets the Exposure used in the effect.
  81876. */
  81877. set exposure(value: number);
  81878. private _toneMappingEnabled;
  81879. /**
  81880. * Gets wether the tone mapping effect is enabled.
  81881. */
  81882. get toneMappingEnabled(): boolean;
  81883. /**
  81884. * Sets wether the tone mapping effect is enabled.
  81885. */
  81886. set toneMappingEnabled(value: boolean);
  81887. private _toneMappingType;
  81888. /**
  81889. * Gets the type of tone mapping effect.
  81890. */
  81891. get toneMappingType(): number;
  81892. /**
  81893. * Sets the type of tone mapping effect used in BabylonJS.
  81894. */
  81895. set toneMappingType(value: number);
  81896. protected _contrast: number;
  81897. /**
  81898. * Gets the contrast used in the effect.
  81899. */
  81900. get contrast(): number;
  81901. /**
  81902. * Sets the contrast used in the effect.
  81903. */
  81904. set contrast(value: number);
  81905. /**
  81906. * Vignette stretch size.
  81907. */
  81908. vignetteStretch: number;
  81909. /**
  81910. * Vignette centre X Offset.
  81911. */
  81912. vignetteCentreX: number;
  81913. /**
  81914. * Vignette centre Y Offset.
  81915. */
  81916. vignetteCentreY: number;
  81917. /**
  81918. * Vignette weight or intensity of the vignette effect.
  81919. */
  81920. vignetteWeight: number;
  81921. /**
  81922. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81923. * if vignetteEnabled is set to true.
  81924. */
  81925. vignetteColor: Color4;
  81926. /**
  81927. * Camera field of view used by the Vignette effect.
  81928. */
  81929. vignetteCameraFov: number;
  81930. private _vignetteBlendMode;
  81931. /**
  81932. * Gets the vignette blend mode allowing different kind of effect.
  81933. */
  81934. get vignetteBlendMode(): number;
  81935. /**
  81936. * Sets the vignette blend mode allowing different kind of effect.
  81937. */
  81938. set vignetteBlendMode(value: number);
  81939. private _vignetteEnabled;
  81940. /**
  81941. * Gets wether the vignette effect is enabled.
  81942. */
  81943. get vignetteEnabled(): boolean;
  81944. /**
  81945. * Sets wether the vignette effect is enabled.
  81946. */
  81947. set vignetteEnabled(value: boolean);
  81948. private _applyByPostProcess;
  81949. /**
  81950. * Gets wether the image processing is applied through a post process or not.
  81951. */
  81952. get applyByPostProcess(): boolean;
  81953. /**
  81954. * Sets wether the image processing is applied through a post process or not.
  81955. */
  81956. set applyByPostProcess(value: boolean);
  81957. private _isEnabled;
  81958. /**
  81959. * Gets wether the image processing is enabled or not.
  81960. */
  81961. get isEnabled(): boolean;
  81962. /**
  81963. * Sets wether the image processing is enabled or not.
  81964. */
  81965. set isEnabled(value: boolean);
  81966. /**
  81967. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81968. */
  81969. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81970. /**
  81971. * Method called each time the image processing information changes requires to recompile the effect.
  81972. */
  81973. protected _updateParameters(): void;
  81974. /**
  81975. * Gets the current class name.
  81976. * @return "ImageProcessingConfiguration"
  81977. */
  81978. getClassName(): string;
  81979. /**
  81980. * Prepare the list of uniforms associated with the Image Processing effects.
  81981. * @param uniforms The list of uniforms used in the effect
  81982. * @param defines the list of defines currently in use
  81983. */
  81984. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81985. /**
  81986. * Prepare the list of samplers associated with the Image Processing effects.
  81987. * @param samplersList The list of uniforms used in the effect
  81988. * @param defines the list of defines currently in use
  81989. */
  81990. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81991. /**
  81992. * Prepare the list of defines associated to the shader.
  81993. * @param defines the list of defines to complete
  81994. * @param forPostProcess Define if we are currently in post process mode or not
  81995. */
  81996. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81997. /**
  81998. * Returns true if all the image processing information are ready.
  81999. * @returns True if ready, otherwise, false
  82000. */
  82001. isReady(): boolean;
  82002. /**
  82003. * Binds the image processing to the shader.
  82004. * @param effect The effect to bind to
  82005. * @param overrideAspectRatio Override the aspect ratio of the effect
  82006. */
  82007. bind(effect: Effect, overrideAspectRatio?: number): void;
  82008. /**
  82009. * Clones the current image processing instance.
  82010. * @return The cloned image processing
  82011. */
  82012. clone(): ImageProcessingConfiguration;
  82013. /**
  82014. * Serializes the current image processing instance to a json representation.
  82015. * @return a JSON representation
  82016. */
  82017. serialize(): any;
  82018. /**
  82019. * Parses the image processing from a json representation.
  82020. * @param source the JSON source to parse
  82021. * @return The parsed image processing
  82022. */
  82023. static Parse(source: any): ImageProcessingConfiguration;
  82024. private static _VIGNETTEMODE_MULTIPLY;
  82025. private static _VIGNETTEMODE_OPAQUE;
  82026. /**
  82027. * Used to apply the vignette as a mix with the pixel color.
  82028. */
  82029. static get VIGNETTEMODE_MULTIPLY(): number;
  82030. /**
  82031. * Used to apply the vignette as a replacement of the pixel color.
  82032. */
  82033. static get VIGNETTEMODE_OPAQUE(): number;
  82034. }
  82035. }
  82036. declare module BABYLON {
  82037. /** @hidden */
  82038. export var postprocessVertexShader: {
  82039. name: string;
  82040. shader: string;
  82041. };
  82042. }
  82043. declare module BABYLON {
  82044. interface ThinEngine {
  82045. /**
  82046. * Creates a new render target texture
  82047. * @param size defines the size of the texture
  82048. * @param options defines the options used to create the texture
  82049. * @returns a new render target texture stored in an InternalTexture
  82050. */
  82051. createRenderTargetTexture(size: number | {
  82052. width: number;
  82053. height: number;
  82054. layers?: number;
  82055. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82056. /**
  82057. * Creates a depth stencil texture.
  82058. * This is only available in WebGL 2 or with the depth texture extension available.
  82059. * @param size The size of face edge in the texture.
  82060. * @param options The options defining the texture.
  82061. * @returns The texture
  82062. */
  82063. createDepthStencilTexture(size: number | {
  82064. width: number;
  82065. height: number;
  82066. layers?: number;
  82067. }, options: DepthTextureCreationOptions): InternalTexture;
  82068. /** @hidden */
  82069. _createDepthStencilTexture(size: number | {
  82070. width: number;
  82071. height: number;
  82072. layers?: number;
  82073. }, options: DepthTextureCreationOptions): InternalTexture;
  82074. }
  82075. }
  82076. declare module BABYLON {
  82077. /** Defines supported spaces */
  82078. export enum Space {
  82079. /** Local (object) space */
  82080. LOCAL = 0,
  82081. /** World space */
  82082. WORLD = 1,
  82083. /** Bone space */
  82084. BONE = 2
  82085. }
  82086. /** Defines the 3 main axes */
  82087. export class Axis {
  82088. /** X axis */
  82089. static X: Vector3;
  82090. /** Y axis */
  82091. static Y: Vector3;
  82092. /** Z axis */
  82093. static Z: Vector3;
  82094. }
  82095. }
  82096. declare module BABYLON {
  82097. /**
  82098. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82099. * This is the base of the follow, arc rotate cameras and Free camera
  82100. * @see http://doc.babylonjs.com/features/cameras
  82101. */
  82102. export class TargetCamera extends Camera {
  82103. private static _RigCamTransformMatrix;
  82104. private static _TargetTransformMatrix;
  82105. private static _TargetFocalPoint;
  82106. /**
  82107. * Define the current direction the camera is moving to
  82108. */
  82109. cameraDirection: Vector3;
  82110. /**
  82111. * Define the current rotation the camera is rotating to
  82112. */
  82113. cameraRotation: Vector2;
  82114. /**
  82115. * When set, the up vector of the camera will be updated by the rotation of the camera
  82116. */
  82117. updateUpVectorFromRotation: boolean;
  82118. private _tmpQuaternion;
  82119. /**
  82120. * Define the current rotation of the camera
  82121. */
  82122. rotation: Vector3;
  82123. /**
  82124. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82125. */
  82126. rotationQuaternion: Quaternion;
  82127. /**
  82128. * Define the current speed of the camera
  82129. */
  82130. speed: number;
  82131. /**
  82132. * Add constraint to the camera to prevent it to move freely in all directions and
  82133. * around all axis.
  82134. */
  82135. noRotationConstraint: boolean;
  82136. /**
  82137. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82138. * panning
  82139. */
  82140. invertRotation: boolean;
  82141. /**
  82142. * Speed multiplier for inverse camera panning
  82143. */
  82144. inverseRotationSpeed: number;
  82145. /**
  82146. * Define the current target of the camera as an object or a position.
  82147. */
  82148. lockedTarget: any;
  82149. /** @hidden */
  82150. _currentTarget: Vector3;
  82151. /** @hidden */
  82152. _initialFocalDistance: number;
  82153. /** @hidden */
  82154. _viewMatrix: Matrix;
  82155. /** @hidden */
  82156. _camMatrix: Matrix;
  82157. /** @hidden */
  82158. _cameraTransformMatrix: Matrix;
  82159. /** @hidden */
  82160. _cameraRotationMatrix: Matrix;
  82161. /** @hidden */
  82162. _referencePoint: Vector3;
  82163. /** @hidden */
  82164. _transformedReferencePoint: Vector3;
  82165. protected _globalCurrentTarget: Vector3;
  82166. protected _globalCurrentUpVector: Vector3;
  82167. /** @hidden */
  82168. _reset: () => void;
  82169. private _defaultUp;
  82170. /**
  82171. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82172. * This is the base of the follow, arc rotate cameras and Free camera
  82173. * @see http://doc.babylonjs.com/features/cameras
  82174. * @param name Defines the name of the camera in the scene
  82175. * @param position Defines the start position of the camera in the scene
  82176. * @param scene Defines the scene the camera belongs to
  82177. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82178. */
  82179. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82180. /**
  82181. * Gets the position in front of the camera at a given distance.
  82182. * @param distance The distance from the camera we want the position to be
  82183. * @returns the position
  82184. */
  82185. getFrontPosition(distance: number): Vector3;
  82186. /** @hidden */
  82187. _getLockedTargetPosition(): Nullable<Vector3>;
  82188. private _storedPosition;
  82189. private _storedRotation;
  82190. private _storedRotationQuaternion;
  82191. /**
  82192. * Store current camera state of the camera (fov, position, rotation, etc..)
  82193. * @returns the camera
  82194. */
  82195. storeState(): Camera;
  82196. /**
  82197. * Restored camera state. You must call storeState() first
  82198. * @returns whether it was successful or not
  82199. * @hidden
  82200. */
  82201. _restoreStateValues(): boolean;
  82202. /** @hidden */
  82203. _initCache(): void;
  82204. /** @hidden */
  82205. _updateCache(ignoreParentClass?: boolean): void;
  82206. /** @hidden */
  82207. _isSynchronizedViewMatrix(): boolean;
  82208. /** @hidden */
  82209. _computeLocalCameraSpeed(): number;
  82210. /**
  82211. * Defines the target the camera should look at.
  82212. * @param target Defines the new target as a Vector or a mesh
  82213. */
  82214. setTarget(target: Vector3): void;
  82215. /**
  82216. * Return the current target position of the camera. This value is expressed in local space.
  82217. * @returns the target position
  82218. */
  82219. getTarget(): Vector3;
  82220. /** @hidden */
  82221. _decideIfNeedsToMove(): boolean;
  82222. /** @hidden */
  82223. _updatePosition(): void;
  82224. /** @hidden */
  82225. _checkInputs(): void;
  82226. protected _updateCameraRotationMatrix(): void;
  82227. /**
  82228. * 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)
  82229. * @returns the current camera
  82230. */
  82231. private _rotateUpVectorWithCameraRotationMatrix;
  82232. private _cachedRotationZ;
  82233. private _cachedQuaternionRotationZ;
  82234. /** @hidden */
  82235. _getViewMatrix(): Matrix;
  82236. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82237. /**
  82238. * @hidden
  82239. */
  82240. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82241. /**
  82242. * @hidden
  82243. */
  82244. _updateRigCameras(): void;
  82245. private _getRigCamPositionAndTarget;
  82246. /**
  82247. * Gets the current object class name.
  82248. * @return the class name
  82249. */
  82250. getClassName(): string;
  82251. }
  82252. }
  82253. declare module BABYLON {
  82254. /**
  82255. * Gather the list of keyboard event types as constants.
  82256. */
  82257. export class KeyboardEventTypes {
  82258. /**
  82259. * The keydown event is fired when a key becomes active (pressed).
  82260. */
  82261. static readonly KEYDOWN: number;
  82262. /**
  82263. * The keyup event is fired when a key has been released.
  82264. */
  82265. static readonly KEYUP: number;
  82266. }
  82267. /**
  82268. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82269. */
  82270. export class KeyboardInfo {
  82271. /**
  82272. * Defines the type of event (KeyboardEventTypes)
  82273. */
  82274. type: number;
  82275. /**
  82276. * Defines the related dom event
  82277. */
  82278. event: KeyboardEvent;
  82279. /**
  82280. * Instantiates a new keyboard info.
  82281. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82282. * @param type Defines the type of event (KeyboardEventTypes)
  82283. * @param event Defines the related dom event
  82284. */
  82285. constructor(
  82286. /**
  82287. * Defines the type of event (KeyboardEventTypes)
  82288. */
  82289. type: number,
  82290. /**
  82291. * Defines the related dom event
  82292. */
  82293. event: KeyboardEvent);
  82294. }
  82295. /**
  82296. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82297. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82298. */
  82299. export class KeyboardInfoPre extends KeyboardInfo {
  82300. /**
  82301. * Defines the type of event (KeyboardEventTypes)
  82302. */
  82303. type: number;
  82304. /**
  82305. * Defines the related dom event
  82306. */
  82307. event: KeyboardEvent;
  82308. /**
  82309. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82310. */
  82311. skipOnPointerObservable: boolean;
  82312. /**
  82313. * Instantiates a new keyboard pre info.
  82314. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82315. * @param type Defines the type of event (KeyboardEventTypes)
  82316. * @param event Defines the related dom event
  82317. */
  82318. constructor(
  82319. /**
  82320. * Defines the type of event (KeyboardEventTypes)
  82321. */
  82322. type: number,
  82323. /**
  82324. * Defines the related dom event
  82325. */
  82326. event: KeyboardEvent);
  82327. }
  82328. }
  82329. declare module BABYLON {
  82330. /**
  82331. * Manage the keyboard inputs to control the movement of a free camera.
  82332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82333. */
  82334. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82335. /**
  82336. * Defines the camera the input is attached to.
  82337. */
  82338. camera: FreeCamera;
  82339. /**
  82340. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82341. */
  82342. keysUp: number[];
  82343. /**
  82344. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  82345. */
  82346. keysUpward: number[];
  82347. /**
  82348. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82349. */
  82350. keysDown: number[];
  82351. /**
  82352. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  82353. */
  82354. keysDownward: number[];
  82355. /**
  82356. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82357. */
  82358. keysLeft: number[];
  82359. /**
  82360. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82361. */
  82362. keysRight: number[];
  82363. private _keys;
  82364. private _onCanvasBlurObserver;
  82365. private _onKeyboardObserver;
  82366. private _engine;
  82367. private _scene;
  82368. /**
  82369. * Attach the input controls to a specific dom element to get the input from.
  82370. * @param element Defines the element the controls should be listened from
  82371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82372. */
  82373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82374. /**
  82375. * Detach the current controls from the specified dom element.
  82376. * @param element Defines the element to stop listening the inputs from
  82377. */
  82378. detachControl(element: Nullable<HTMLElement>): void;
  82379. /**
  82380. * Update the current camera state depending on the inputs that have been used this frame.
  82381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82382. */
  82383. checkInputs(): void;
  82384. /**
  82385. * Gets the class name of the current intput.
  82386. * @returns the class name
  82387. */
  82388. getClassName(): string;
  82389. /** @hidden */
  82390. _onLostFocus(): void;
  82391. /**
  82392. * Get the friendly name associated with the input class.
  82393. * @returns the input friendly name
  82394. */
  82395. getSimpleName(): string;
  82396. }
  82397. }
  82398. declare module BABYLON {
  82399. /**
  82400. * Interface describing all the common properties and methods a shadow light needs to implement.
  82401. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82402. * as well as binding the different shadow properties to the effects.
  82403. */
  82404. export interface IShadowLight extends Light {
  82405. /**
  82406. * The light id in the scene (used in scene.findLighById for instance)
  82407. */
  82408. id: string;
  82409. /**
  82410. * The position the shdow will be casted from.
  82411. */
  82412. position: Vector3;
  82413. /**
  82414. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82415. */
  82416. direction: Vector3;
  82417. /**
  82418. * The transformed position. Position of the light in world space taking parenting in account.
  82419. */
  82420. transformedPosition: Vector3;
  82421. /**
  82422. * The transformed direction. Direction of the light in world space taking parenting in account.
  82423. */
  82424. transformedDirection: Vector3;
  82425. /**
  82426. * The friendly name of the light in the scene.
  82427. */
  82428. name: string;
  82429. /**
  82430. * Defines the shadow projection clipping minimum z value.
  82431. */
  82432. shadowMinZ: number;
  82433. /**
  82434. * Defines the shadow projection clipping maximum z value.
  82435. */
  82436. shadowMaxZ: number;
  82437. /**
  82438. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82439. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82440. */
  82441. computeTransformedInformation(): boolean;
  82442. /**
  82443. * Gets the scene the light belongs to.
  82444. * @returns The scene
  82445. */
  82446. getScene(): Scene;
  82447. /**
  82448. * Callback defining a custom Projection Matrix Builder.
  82449. * This can be used to override the default projection matrix computation.
  82450. */
  82451. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82452. /**
  82453. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82454. * @param matrix The materix to updated with the projection information
  82455. * @param viewMatrix The transform matrix of the light
  82456. * @param renderList The list of mesh to render in the map
  82457. * @returns The current light
  82458. */
  82459. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82460. /**
  82461. * Gets the current depth scale used in ESM.
  82462. * @returns The scale
  82463. */
  82464. getDepthScale(): number;
  82465. /**
  82466. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82467. * @returns true if a cube texture needs to be use
  82468. */
  82469. needCube(): boolean;
  82470. /**
  82471. * Detects if the projection matrix requires to be recomputed this frame.
  82472. * @returns true if it requires to be recomputed otherwise, false.
  82473. */
  82474. needProjectionMatrixCompute(): boolean;
  82475. /**
  82476. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82477. */
  82478. forceProjectionMatrixCompute(): void;
  82479. /**
  82480. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82481. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82482. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82483. */
  82484. getShadowDirection(faceIndex?: number): Vector3;
  82485. /**
  82486. * Gets the minZ used for shadow according to both the scene and the light.
  82487. * @param activeCamera The camera we are returning the min for
  82488. * @returns the depth min z
  82489. */
  82490. getDepthMinZ(activeCamera: Camera): number;
  82491. /**
  82492. * Gets the maxZ used for shadow according to both the scene and the light.
  82493. * @param activeCamera The camera we are returning the max for
  82494. * @returns the depth max z
  82495. */
  82496. getDepthMaxZ(activeCamera: Camera): number;
  82497. }
  82498. /**
  82499. * Base implementation IShadowLight
  82500. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82501. */
  82502. export abstract class ShadowLight extends Light implements IShadowLight {
  82503. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82504. protected _position: Vector3;
  82505. protected _setPosition(value: Vector3): void;
  82506. /**
  82507. * Sets the position the shadow will be casted from. Also use as the light position for both
  82508. * point and spot lights.
  82509. */
  82510. get position(): Vector3;
  82511. /**
  82512. * Sets the position the shadow will be casted from. Also use as the light position for both
  82513. * point and spot lights.
  82514. */
  82515. set position(value: Vector3);
  82516. protected _direction: Vector3;
  82517. protected _setDirection(value: Vector3): void;
  82518. /**
  82519. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82520. * Also use as the light direction on spot and directional lights.
  82521. */
  82522. get direction(): Vector3;
  82523. /**
  82524. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82525. * Also use as the light direction on spot and directional lights.
  82526. */
  82527. set direction(value: Vector3);
  82528. protected _shadowMinZ: number;
  82529. /**
  82530. * Gets the shadow projection clipping minimum z value.
  82531. */
  82532. get shadowMinZ(): number;
  82533. /**
  82534. * Sets the shadow projection clipping minimum z value.
  82535. */
  82536. set shadowMinZ(value: number);
  82537. protected _shadowMaxZ: number;
  82538. /**
  82539. * Sets the shadow projection clipping maximum z value.
  82540. */
  82541. get shadowMaxZ(): number;
  82542. /**
  82543. * Gets the shadow projection clipping maximum z value.
  82544. */
  82545. set shadowMaxZ(value: number);
  82546. /**
  82547. * Callback defining a custom Projection Matrix Builder.
  82548. * This can be used to override the default projection matrix computation.
  82549. */
  82550. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82551. /**
  82552. * The transformed position. Position of the light in world space taking parenting in account.
  82553. */
  82554. transformedPosition: Vector3;
  82555. /**
  82556. * The transformed direction. Direction of the light in world space taking parenting in account.
  82557. */
  82558. transformedDirection: Vector3;
  82559. private _needProjectionMatrixCompute;
  82560. /**
  82561. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82562. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82563. */
  82564. computeTransformedInformation(): boolean;
  82565. /**
  82566. * Return the depth scale used for the shadow map.
  82567. * @returns the depth scale.
  82568. */
  82569. getDepthScale(): number;
  82570. /**
  82571. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82572. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82573. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82574. */
  82575. getShadowDirection(faceIndex?: number): Vector3;
  82576. /**
  82577. * Returns the ShadowLight absolute position in the World.
  82578. * @returns the position vector in world space
  82579. */
  82580. getAbsolutePosition(): Vector3;
  82581. /**
  82582. * Sets the ShadowLight direction toward the passed target.
  82583. * @param target The point to target in local space
  82584. * @returns the updated ShadowLight direction
  82585. */
  82586. setDirectionToTarget(target: Vector3): Vector3;
  82587. /**
  82588. * Returns the light rotation in euler definition.
  82589. * @returns the x y z rotation in local space.
  82590. */
  82591. getRotation(): Vector3;
  82592. /**
  82593. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82594. * @returns true if a cube texture needs to be use
  82595. */
  82596. needCube(): boolean;
  82597. /**
  82598. * Detects if the projection matrix requires to be recomputed this frame.
  82599. * @returns true if it requires to be recomputed otherwise, false.
  82600. */
  82601. needProjectionMatrixCompute(): boolean;
  82602. /**
  82603. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82604. */
  82605. forceProjectionMatrixCompute(): void;
  82606. /** @hidden */
  82607. _initCache(): void;
  82608. /** @hidden */
  82609. _isSynchronized(): boolean;
  82610. /**
  82611. * Computes the world matrix of the node
  82612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82613. * @returns the world matrix
  82614. */
  82615. computeWorldMatrix(force?: boolean): Matrix;
  82616. /**
  82617. * Gets the minZ used for shadow according to both the scene and the light.
  82618. * @param activeCamera The camera we are returning the min for
  82619. * @returns the depth min z
  82620. */
  82621. getDepthMinZ(activeCamera: Camera): number;
  82622. /**
  82623. * Gets the maxZ used for shadow according to both the scene and the light.
  82624. * @param activeCamera The camera we are returning the max for
  82625. * @returns the depth max z
  82626. */
  82627. getDepthMaxZ(activeCamera: Camera): number;
  82628. /**
  82629. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82630. * @param matrix The materix to updated with the projection information
  82631. * @param viewMatrix The transform matrix of the light
  82632. * @param renderList The list of mesh to render in the map
  82633. * @returns The current light
  82634. */
  82635. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82636. }
  82637. }
  82638. declare module BABYLON {
  82639. /**
  82640. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82641. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82642. */
  82643. export class EffectFallbacks implements IEffectFallbacks {
  82644. private _defines;
  82645. private _currentRank;
  82646. private _maxRank;
  82647. private _mesh;
  82648. /**
  82649. * Removes the fallback from the bound mesh.
  82650. */
  82651. unBindMesh(): void;
  82652. /**
  82653. * Adds a fallback on the specified property.
  82654. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82655. * @param define The name of the define in the shader
  82656. */
  82657. addFallback(rank: number, define: string): void;
  82658. /**
  82659. * Sets the mesh to use CPU skinning when needing to fallback.
  82660. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82661. * @param mesh The mesh to use the fallbacks.
  82662. */
  82663. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82664. /**
  82665. * Checks to see if more fallbacks are still availible.
  82666. */
  82667. get hasMoreFallbacks(): boolean;
  82668. /**
  82669. * Removes the defines that should be removed when falling back.
  82670. * @param currentDefines defines the current define statements for the shader.
  82671. * @param effect defines the current effect we try to compile
  82672. * @returns The resulting defines with defines of the current rank removed.
  82673. */
  82674. reduce(currentDefines: string, effect: Effect): string;
  82675. }
  82676. }
  82677. declare module BABYLON {
  82678. /**
  82679. * "Static Class" containing the most commonly used helper while dealing with material for
  82680. * rendering purpose.
  82681. *
  82682. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82683. *
  82684. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82685. */
  82686. export class MaterialHelper {
  82687. /**
  82688. * Bind the current view position to an effect.
  82689. * @param effect The effect to be bound
  82690. * @param scene The scene the eyes position is used from
  82691. */
  82692. static BindEyePosition(effect: Effect, scene: Scene): void;
  82693. /**
  82694. * Helps preparing the defines values about the UVs in used in the effect.
  82695. * UVs are shared as much as we can accross channels in the shaders.
  82696. * @param texture The texture we are preparing the UVs for
  82697. * @param defines The defines to update
  82698. * @param key The channel key "diffuse", "specular"... used in the shader
  82699. */
  82700. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82701. /**
  82702. * Binds a texture matrix value to its corrsponding uniform
  82703. * @param texture The texture to bind the matrix for
  82704. * @param uniformBuffer The uniform buffer receivin the data
  82705. * @param key The channel key "diffuse", "specular"... used in the shader
  82706. */
  82707. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82708. /**
  82709. * Gets the current status of the fog (should it be enabled?)
  82710. * @param mesh defines the mesh to evaluate for fog support
  82711. * @param scene defines the hosting scene
  82712. * @returns true if fog must be enabled
  82713. */
  82714. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82715. /**
  82716. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82717. * @param mesh defines the current mesh
  82718. * @param scene defines the current scene
  82719. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82720. * @param pointsCloud defines if point cloud rendering has to be turned on
  82721. * @param fogEnabled defines if fog has to be turned on
  82722. * @param alphaTest defines if alpha testing has to be turned on
  82723. * @param defines defines the current list of defines
  82724. */
  82725. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82726. /**
  82727. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82728. * @param scene defines the current scene
  82729. * @param engine defines the current engine
  82730. * @param defines specifies the list of active defines
  82731. * @param useInstances defines if instances have to be turned on
  82732. * @param useClipPlane defines if clip plane have to be turned on
  82733. */
  82734. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82735. /**
  82736. * Prepares the defines for bones
  82737. * @param mesh The mesh containing the geometry data we will draw
  82738. * @param defines The defines to update
  82739. */
  82740. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82741. /**
  82742. * Prepares the defines for morph targets
  82743. * @param mesh The mesh containing the geometry data we will draw
  82744. * @param defines The defines to update
  82745. */
  82746. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82747. /**
  82748. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82749. * @param mesh The mesh containing the geometry data we will draw
  82750. * @param defines The defines to update
  82751. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82752. * @param useBones Precise whether bones should be used or not (override mesh info)
  82753. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82754. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82755. * @returns false if defines are considered not dirty and have not been checked
  82756. */
  82757. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82758. /**
  82759. * Prepares the defines related to multiview
  82760. * @param scene The scene we are intending to draw
  82761. * @param defines The defines to update
  82762. */
  82763. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82764. /**
  82765. * Prepares the defines related to the light information passed in parameter
  82766. * @param scene The scene we are intending to draw
  82767. * @param mesh The mesh the effect is compiling for
  82768. * @param light The light the effect is compiling for
  82769. * @param lightIndex The index of the light
  82770. * @param defines The defines to update
  82771. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82772. * @param state Defines the current state regarding what is needed (normals, etc...)
  82773. */
  82774. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82775. needNormals: boolean;
  82776. needRebuild: boolean;
  82777. shadowEnabled: boolean;
  82778. specularEnabled: boolean;
  82779. lightmapMode: boolean;
  82780. }): void;
  82781. /**
  82782. * Prepares the defines related to the light information passed in parameter
  82783. * @param scene The scene we are intending to draw
  82784. * @param mesh The mesh the effect is compiling for
  82785. * @param defines The defines to update
  82786. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82787. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82788. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82789. * @returns true if normals will be required for the rest of the effect
  82790. */
  82791. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82792. /**
  82793. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82794. * @param lightIndex defines the light index
  82795. * @param uniformsList The uniform list
  82796. * @param samplersList The sampler list
  82797. * @param projectedLightTexture defines if projected texture must be used
  82798. * @param uniformBuffersList defines an optional list of uniform buffers
  82799. */
  82800. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82801. /**
  82802. * Prepares the uniforms and samplers list to be used in the effect
  82803. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82804. * @param samplersList The sampler list
  82805. * @param defines The defines helping in the list generation
  82806. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82807. */
  82808. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82809. /**
  82810. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82811. * @param defines The defines to update while falling back
  82812. * @param fallbacks The authorized effect fallbacks
  82813. * @param maxSimultaneousLights The maximum number of lights allowed
  82814. * @param rank the current rank of the Effect
  82815. * @returns The newly affected rank
  82816. */
  82817. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82818. private static _TmpMorphInfluencers;
  82819. /**
  82820. * Prepares the list of attributes required for morph targets according to the effect defines.
  82821. * @param attribs The current list of supported attribs
  82822. * @param mesh The mesh to prepare the morph targets attributes for
  82823. * @param influencers The number of influencers
  82824. */
  82825. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82826. /**
  82827. * Prepares the list of attributes required for morph targets according to the effect defines.
  82828. * @param attribs The current list of supported attribs
  82829. * @param mesh The mesh to prepare the morph targets attributes for
  82830. * @param defines The current Defines of the effect
  82831. */
  82832. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82833. /**
  82834. * Prepares the list of attributes required for bones according to the effect defines.
  82835. * @param attribs The current list of supported attribs
  82836. * @param mesh The mesh to prepare the bones attributes for
  82837. * @param defines The current Defines of the effect
  82838. * @param fallbacks The current efffect fallback strategy
  82839. */
  82840. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82841. /**
  82842. * Check and prepare the list of attributes required for instances according to the effect defines.
  82843. * @param attribs The current list of supported attribs
  82844. * @param defines The current MaterialDefines of the effect
  82845. */
  82846. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82847. /**
  82848. * Add the list of attributes required for instances to the attribs array.
  82849. * @param attribs The current list of supported attribs
  82850. */
  82851. static PushAttributesForInstances(attribs: string[]): void;
  82852. /**
  82853. * Binds the light information to the effect.
  82854. * @param light The light containing the generator
  82855. * @param effect The effect we are binding the data to
  82856. * @param lightIndex The light index in the effect used to render
  82857. */
  82858. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82859. /**
  82860. * Binds the lights information from the scene to the effect for the given mesh.
  82861. * @param light Light to bind
  82862. * @param lightIndex Light index
  82863. * @param scene The scene where the light belongs to
  82864. * @param effect The effect we are binding the data to
  82865. * @param useSpecular Defines if specular is supported
  82866. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82867. */
  82868. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82869. /**
  82870. * Binds the lights information from the scene to the effect for the given mesh.
  82871. * @param scene The scene the lights belongs to
  82872. * @param mesh The mesh we are binding the information to render
  82873. * @param effect The effect we are binding the data to
  82874. * @param defines The generated defines for the effect
  82875. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82876. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82877. */
  82878. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82879. private static _tempFogColor;
  82880. /**
  82881. * Binds the fog information from the scene to the effect for the given mesh.
  82882. * @param scene The scene the lights belongs to
  82883. * @param mesh The mesh we are binding the information to render
  82884. * @param effect The effect we are binding the data to
  82885. * @param linearSpace Defines if the fog effect is applied in linear space
  82886. */
  82887. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82888. /**
  82889. * Binds the bones information from the mesh to the effect.
  82890. * @param mesh The mesh we are binding the information to render
  82891. * @param effect The effect we are binding the data to
  82892. */
  82893. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82894. /**
  82895. * Binds the morph targets information from the mesh to the effect.
  82896. * @param abstractMesh The mesh we are binding the information to render
  82897. * @param effect The effect we are binding the data to
  82898. */
  82899. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82900. /**
  82901. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82902. * @param defines The generated defines used in the effect
  82903. * @param effect The effect we are binding the data to
  82904. * @param scene The scene we are willing to render with logarithmic scale for
  82905. */
  82906. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82907. /**
  82908. * Binds the clip plane information from the scene to the effect.
  82909. * @param scene The scene the clip plane information are extracted from
  82910. * @param effect The effect we are binding the data to
  82911. */
  82912. static BindClipPlane(effect: Effect, scene: Scene): void;
  82913. }
  82914. }
  82915. declare module BABYLON {
  82916. /** @hidden */
  82917. export var packingFunctions: {
  82918. name: string;
  82919. shader: string;
  82920. };
  82921. }
  82922. declare module BABYLON {
  82923. /** @hidden */
  82924. export var clipPlaneFragmentDeclaration: {
  82925. name: string;
  82926. shader: string;
  82927. };
  82928. }
  82929. declare module BABYLON {
  82930. /** @hidden */
  82931. export var clipPlaneFragment: {
  82932. name: string;
  82933. shader: string;
  82934. };
  82935. }
  82936. declare module BABYLON {
  82937. /** @hidden */
  82938. export var shadowMapPixelShader: {
  82939. name: string;
  82940. shader: string;
  82941. };
  82942. }
  82943. declare module BABYLON {
  82944. /** @hidden */
  82945. export var bonesDeclaration: {
  82946. name: string;
  82947. shader: string;
  82948. };
  82949. }
  82950. declare module BABYLON {
  82951. /** @hidden */
  82952. export var morphTargetsVertexGlobalDeclaration: {
  82953. name: string;
  82954. shader: string;
  82955. };
  82956. }
  82957. declare module BABYLON {
  82958. /** @hidden */
  82959. export var morphTargetsVertexDeclaration: {
  82960. name: string;
  82961. shader: string;
  82962. };
  82963. }
  82964. declare module BABYLON {
  82965. /** @hidden */
  82966. export var instancesDeclaration: {
  82967. name: string;
  82968. shader: string;
  82969. };
  82970. }
  82971. declare module BABYLON {
  82972. /** @hidden */
  82973. export var helperFunctions: {
  82974. name: string;
  82975. shader: string;
  82976. };
  82977. }
  82978. declare module BABYLON {
  82979. /** @hidden */
  82980. export var clipPlaneVertexDeclaration: {
  82981. name: string;
  82982. shader: string;
  82983. };
  82984. }
  82985. declare module BABYLON {
  82986. /** @hidden */
  82987. export var morphTargetsVertex: {
  82988. name: string;
  82989. shader: string;
  82990. };
  82991. }
  82992. declare module BABYLON {
  82993. /** @hidden */
  82994. export var instancesVertex: {
  82995. name: string;
  82996. shader: string;
  82997. };
  82998. }
  82999. declare module BABYLON {
  83000. /** @hidden */
  83001. export var bonesVertex: {
  83002. name: string;
  83003. shader: string;
  83004. };
  83005. }
  83006. declare module BABYLON {
  83007. /** @hidden */
  83008. export var clipPlaneVertex: {
  83009. name: string;
  83010. shader: string;
  83011. };
  83012. }
  83013. declare module BABYLON {
  83014. /** @hidden */
  83015. export var shadowMapVertexShader: {
  83016. name: string;
  83017. shader: string;
  83018. };
  83019. }
  83020. declare module BABYLON {
  83021. /** @hidden */
  83022. export var depthBoxBlurPixelShader: {
  83023. name: string;
  83024. shader: string;
  83025. };
  83026. }
  83027. declare module BABYLON {
  83028. /**
  83029. * Class representing a ray with position and direction
  83030. */
  83031. export class Ray {
  83032. /** origin point */
  83033. origin: Vector3;
  83034. /** direction */
  83035. direction: Vector3;
  83036. /** length of the ray */
  83037. length: number;
  83038. private static readonly TmpVector3;
  83039. private _tmpRay;
  83040. /**
  83041. * Creates a new ray
  83042. * @param origin origin point
  83043. * @param direction direction
  83044. * @param length length of the ray
  83045. */
  83046. constructor(
  83047. /** origin point */
  83048. origin: Vector3,
  83049. /** direction */
  83050. direction: Vector3,
  83051. /** length of the ray */
  83052. length?: number);
  83053. /**
  83054. * Checks if the ray intersects a box
  83055. * @param minimum bound of the box
  83056. * @param maximum bound of the box
  83057. * @param intersectionTreshold extra extend to be added to the box in all direction
  83058. * @returns if the box was hit
  83059. */
  83060. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83061. /**
  83062. * Checks if the ray intersects a box
  83063. * @param box the bounding box to check
  83064. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83065. * @returns if the box was hit
  83066. */
  83067. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83068. /**
  83069. * If the ray hits a sphere
  83070. * @param sphere the bounding sphere to check
  83071. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83072. * @returns true if it hits the sphere
  83073. */
  83074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83075. /**
  83076. * If the ray hits a triange
  83077. * @param vertex0 triangle vertex
  83078. * @param vertex1 triangle vertex
  83079. * @param vertex2 triangle vertex
  83080. * @returns intersection information if hit
  83081. */
  83082. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83083. /**
  83084. * Checks if ray intersects a plane
  83085. * @param plane the plane to check
  83086. * @returns the distance away it was hit
  83087. */
  83088. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83089. /**
  83090. * Calculate the intercept of a ray on a given axis
  83091. * @param axis to check 'x' | 'y' | 'z'
  83092. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83093. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83094. */
  83095. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83096. /**
  83097. * Checks if ray intersects a mesh
  83098. * @param mesh the mesh to check
  83099. * @param fastCheck if only the bounding box should checked
  83100. * @returns picking info of the intersecton
  83101. */
  83102. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83103. /**
  83104. * Checks if ray intersects a mesh
  83105. * @param meshes the meshes to check
  83106. * @param fastCheck if only the bounding box should checked
  83107. * @param results array to store result in
  83108. * @returns Array of picking infos
  83109. */
  83110. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83111. private _comparePickingInfo;
  83112. private static smallnum;
  83113. private static rayl;
  83114. /**
  83115. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83116. * @param sega the first point of the segment to test the intersection against
  83117. * @param segb the second point of the segment to test the intersection against
  83118. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83119. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83120. */
  83121. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83122. /**
  83123. * Update the ray from viewport position
  83124. * @param x position
  83125. * @param y y position
  83126. * @param viewportWidth viewport width
  83127. * @param viewportHeight viewport height
  83128. * @param world world matrix
  83129. * @param view view matrix
  83130. * @param projection projection matrix
  83131. * @returns this ray updated
  83132. */
  83133. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83134. /**
  83135. * Creates a ray with origin and direction of 0,0,0
  83136. * @returns the new ray
  83137. */
  83138. static Zero(): Ray;
  83139. /**
  83140. * Creates a new ray from screen space and viewport
  83141. * @param x position
  83142. * @param y y position
  83143. * @param viewportWidth viewport width
  83144. * @param viewportHeight viewport height
  83145. * @param world world matrix
  83146. * @param view view matrix
  83147. * @param projection projection matrix
  83148. * @returns new ray
  83149. */
  83150. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83151. /**
  83152. * 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
  83153. * transformed to the given world matrix.
  83154. * @param origin The origin point
  83155. * @param end The end point
  83156. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83157. * @returns the new ray
  83158. */
  83159. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83160. /**
  83161. * Transforms a ray by a matrix
  83162. * @param ray ray to transform
  83163. * @param matrix matrix to apply
  83164. * @returns the resulting new ray
  83165. */
  83166. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83167. /**
  83168. * Transforms a ray by a matrix
  83169. * @param ray ray to transform
  83170. * @param matrix matrix to apply
  83171. * @param result ray to store result in
  83172. */
  83173. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83174. /**
  83175. * Unproject a ray from screen space to object space
  83176. * @param sourceX defines the screen space x coordinate to use
  83177. * @param sourceY defines the screen space y coordinate to use
  83178. * @param viewportWidth defines the current width of the viewport
  83179. * @param viewportHeight defines the current height of the viewport
  83180. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83181. * @param view defines the view matrix to use
  83182. * @param projection defines the projection matrix to use
  83183. */
  83184. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83185. }
  83186. /**
  83187. * Type used to define predicate used to select faces when a mesh intersection is detected
  83188. */
  83189. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83190. interface Scene {
  83191. /** @hidden */
  83192. _tempPickingRay: Nullable<Ray>;
  83193. /** @hidden */
  83194. _cachedRayForTransform: Ray;
  83195. /** @hidden */
  83196. _pickWithRayInverseMatrix: Matrix;
  83197. /** @hidden */
  83198. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83199. /** @hidden */
  83200. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83201. }
  83202. }
  83203. declare module BABYLON {
  83204. /**
  83205. * Groups all the scene component constants in one place to ease maintenance.
  83206. * @hidden
  83207. */
  83208. export class SceneComponentConstants {
  83209. static readonly NAME_EFFECTLAYER: string;
  83210. static readonly NAME_LAYER: string;
  83211. static readonly NAME_LENSFLARESYSTEM: string;
  83212. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83213. static readonly NAME_PARTICLESYSTEM: string;
  83214. static readonly NAME_GAMEPAD: string;
  83215. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83216. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83217. static readonly NAME_DEPTHRENDERER: string;
  83218. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83219. static readonly NAME_SPRITE: string;
  83220. static readonly NAME_OUTLINERENDERER: string;
  83221. static readonly NAME_PROCEDURALTEXTURE: string;
  83222. static readonly NAME_SHADOWGENERATOR: string;
  83223. static readonly NAME_OCTREE: string;
  83224. static readonly NAME_PHYSICSENGINE: string;
  83225. static readonly NAME_AUDIO: string;
  83226. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83227. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83228. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83229. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83230. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83231. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83232. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83233. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83234. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83235. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83236. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83237. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83238. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83239. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83240. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83241. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83242. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83243. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83244. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83245. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83246. static readonly STEP_AFTERRENDER_AUDIO: number;
  83247. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83248. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83249. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83250. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83251. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83252. static readonly STEP_POINTERMOVE_SPRITE: number;
  83253. static readonly STEP_POINTERDOWN_SPRITE: number;
  83254. static readonly STEP_POINTERUP_SPRITE: number;
  83255. }
  83256. /**
  83257. * This represents a scene component.
  83258. *
  83259. * This is used to decouple the dependency the scene is having on the different workloads like
  83260. * layers, post processes...
  83261. */
  83262. export interface ISceneComponent {
  83263. /**
  83264. * The name of the component. Each component must have a unique name.
  83265. */
  83266. name: string;
  83267. /**
  83268. * The scene the component belongs to.
  83269. */
  83270. scene: Scene;
  83271. /**
  83272. * Register the component to one instance of a scene.
  83273. */
  83274. register(): void;
  83275. /**
  83276. * Rebuilds the elements related to this component in case of
  83277. * context lost for instance.
  83278. */
  83279. rebuild(): void;
  83280. /**
  83281. * Disposes the component and the associated ressources.
  83282. */
  83283. dispose(): void;
  83284. }
  83285. /**
  83286. * This represents a SERIALIZABLE scene component.
  83287. *
  83288. * This extends Scene Component to add Serialization methods on top.
  83289. */
  83290. export interface ISceneSerializableComponent extends ISceneComponent {
  83291. /**
  83292. * Adds all the elements from the container to the scene
  83293. * @param container the container holding the elements
  83294. */
  83295. addFromContainer(container: AbstractScene): void;
  83296. /**
  83297. * Removes all the elements in the container from the scene
  83298. * @param container contains the elements to remove
  83299. * @param dispose if the removed element should be disposed (default: false)
  83300. */
  83301. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83302. /**
  83303. * Serializes the component data to the specified json object
  83304. * @param serializationObject The object to serialize to
  83305. */
  83306. serialize(serializationObject: any): void;
  83307. }
  83308. /**
  83309. * Strong typing of a Mesh related stage step action
  83310. */
  83311. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83312. /**
  83313. * Strong typing of a Evaluate Sub Mesh related stage step action
  83314. */
  83315. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83316. /**
  83317. * Strong typing of a Active Mesh related stage step action
  83318. */
  83319. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83320. /**
  83321. * Strong typing of a Camera related stage step action
  83322. */
  83323. export type CameraStageAction = (camera: Camera) => void;
  83324. /**
  83325. * Strong typing of a Camera Frame buffer related stage step action
  83326. */
  83327. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83328. /**
  83329. * Strong typing of a Render Target related stage step action
  83330. */
  83331. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83332. /**
  83333. * Strong typing of a RenderingGroup related stage step action
  83334. */
  83335. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83336. /**
  83337. * Strong typing of a Mesh Render related stage step action
  83338. */
  83339. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83340. /**
  83341. * Strong typing of a simple stage step action
  83342. */
  83343. export type SimpleStageAction = () => void;
  83344. /**
  83345. * Strong typing of a render target action.
  83346. */
  83347. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83348. /**
  83349. * Strong typing of a pointer move action.
  83350. */
  83351. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83352. /**
  83353. * Strong typing of a pointer up/down action.
  83354. */
  83355. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83356. /**
  83357. * Representation of a stage in the scene (Basically a list of ordered steps)
  83358. * @hidden
  83359. */
  83360. export class Stage<T extends Function> extends Array<{
  83361. index: number;
  83362. component: ISceneComponent;
  83363. action: T;
  83364. }> {
  83365. /**
  83366. * Hide ctor from the rest of the world.
  83367. * @param items The items to add.
  83368. */
  83369. private constructor();
  83370. /**
  83371. * Creates a new Stage.
  83372. * @returns A new instance of a Stage
  83373. */
  83374. static Create<T extends Function>(): Stage<T>;
  83375. /**
  83376. * Registers a step in an ordered way in the targeted stage.
  83377. * @param index Defines the position to register the step in
  83378. * @param component Defines the component attached to the step
  83379. * @param action Defines the action to launch during the step
  83380. */
  83381. registerStep(index: number, component: ISceneComponent, action: T): void;
  83382. /**
  83383. * Clears all the steps from the stage.
  83384. */
  83385. clear(): void;
  83386. }
  83387. }
  83388. declare module BABYLON {
  83389. interface Scene {
  83390. /** @hidden */
  83391. _pointerOverSprite: Nullable<Sprite>;
  83392. /** @hidden */
  83393. _pickedDownSprite: Nullable<Sprite>;
  83394. /** @hidden */
  83395. _tempSpritePickingRay: Nullable<Ray>;
  83396. /**
  83397. * All of the sprite managers added to this scene
  83398. * @see http://doc.babylonjs.com/babylon101/sprites
  83399. */
  83400. spriteManagers: Array<ISpriteManager>;
  83401. /**
  83402. * An event triggered when sprites rendering is about to start
  83403. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83404. */
  83405. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83406. /**
  83407. * An event triggered when sprites rendering is done
  83408. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83409. */
  83410. onAfterSpritesRenderingObservable: Observable<Scene>;
  83411. /** @hidden */
  83412. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83413. /** Launch a ray to try to pick a sprite in the scene
  83414. * @param x position on screen
  83415. * @param y position on screen
  83416. * @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
  83417. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83418. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83419. * @returns a PickingInfo
  83420. */
  83421. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83422. /** Use the given ray to pick a sprite in the scene
  83423. * @param ray The ray (in world space) to use to pick meshes
  83424. * @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
  83425. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83426. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83427. * @returns a PickingInfo
  83428. */
  83429. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83430. /** @hidden */
  83431. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83432. /** Launch a ray to try to pick sprites in the scene
  83433. * @param x position on screen
  83434. * @param y position on screen
  83435. * @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
  83436. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83437. * @returns a PickingInfo array
  83438. */
  83439. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83440. /** Use the given ray to pick sprites in the scene
  83441. * @param ray The ray (in world space) to use to pick meshes
  83442. * @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
  83443. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83444. * @returns a PickingInfo array
  83445. */
  83446. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83447. /**
  83448. * Force the sprite under the pointer
  83449. * @param sprite defines the sprite to use
  83450. */
  83451. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83452. /**
  83453. * Gets the sprite under the pointer
  83454. * @returns a Sprite or null if no sprite is under the pointer
  83455. */
  83456. getPointerOverSprite(): Nullable<Sprite>;
  83457. }
  83458. /**
  83459. * Defines the sprite scene component responsible to manage sprites
  83460. * in a given scene.
  83461. */
  83462. export class SpriteSceneComponent implements ISceneComponent {
  83463. /**
  83464. * The component name helpfull to identify the component in the list of scene components.
  83465. */
  83466. readonly name: string;
  83467. /**
  83468. * The scene the component belongs to.
  83469. */
  83470. scene: Scene;
  83471. /** @hidden */
  83472. private _spritePredicate;
  83473. /**
  83474. * Creates a new instance of the component for the given scene
  83475. * @param scene Defines the scene to register the component in
  83476. */
  83477. constructor(scene: Scene);
  83478. /**
  83479. * Registers the component in a given scene
  83480. */
  83481. register(): void;
  83482. /**
  83483. * Rebuilds the elements related to this component in case of
  83484. * context lost for instance.
  83485. */
  83486. rebuild(): void;
  83487. /**
  83488. * Disposes the component and the associated ressources.
  83489. */
  83490. dispose(): void;
  83491. private _pickSpriteButKeepRay;
  83492. private _pointerMove;
  83493. private _pointerDown;
  83494. private _pointerUp;
  83495. }
  83496. }
  83497. declare module BABYLON {
  83498. /** @hidden */
  83499. export var fogFragmentDeclaration: {
  83500. name: string;
  83501. shader: string;
  83502. };
  83503. }
  83504. declare module BABYLON {
  83505. /** @hidden */
  83506. export var fogFragment: {
  83507. name: string;
  83508. shader: string;
  83509. };
  83510. }
  83511. declare module BABYLON {
  83512. /** @hidden */
  83513. export var spritesPixelShader: {
  83514. name: string;
  83515. shader: string;
  83516. };
  83517. }
  83518. declare module BABYLON {
  83519. /** @hidden */
  83520. export var fogVertexDeclaration: {
  83521. name: string;
  83522. shader: string;
  83523. };
  83524. }
  83525. declare module BABYLON {
  83526. /** @hidden */
  83527. export var spritesVertexShader: {
  83528. name: string;
  83529. shader: string;
  83530. };
  83531. }
  83532. declare module BABYLON {
  83533. /**
  83534. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83535. */
  83536. export interface ISpriteManager extends IDisposable {
  83537. /**
  83538. * Restricts the camera to viewing objects with the same layerMask.
  83539. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83540. */
  83541. layerMask: number;
  83542. /**
  83543. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83544. */
  83545. isPickable: boolean;
  83546. /**
  83547. * Specifies the rendering group id for this mesh (0 by default)
  83548. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83549. */
  83550. renderingGroupId: number;
  83551. /**
  83552. * Defines the list of sprites managed by the manager.
  83553. */
  83554. sprites: Array<Sprite>;
  83555. /**
  83556. * Tests the intersection of a sprite with a specific ray.
  83557. * @param ray The ray we are sending to test the collision
  83558. * @param camera The camera space we are sending rays in
  83559. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83560. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83561. * @returns picking info or null.
  83562. */
  83563. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83564. /**
  83565. * Intersects the sprites with a ray
  83566. * @param ray defines the ray to intersect with
  83567. * @param camera defines the current active camera
  83568. * @param predicate defines a predicate used to select candidate sprites
  83569. * @returns null if no hit or a PickingInfo array
  83570. */
  83571. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83572. /**
  83573. * Renders the list of sprites on screen.
  83574. */
  83575. render(): void;
  83576. }
  83577. /**
  83578. * Class used to manage multiple sprites on the same spritesheet
  83579. * @see http://doc.babylonjs.com/babylon101/sprites
  83580. */
  83581. export class SpriteManager implements ISpriteManager {
  83582. /** defines the manager's name */
  83583. name: string;
  83584. /** Gets the list of sprites */
  83585. sprites: Sprite[];
  83586. /** Gets or sets the rendering group id (0 by default) */
  83587. renderingGroupId: number;
  83588. /** Gets or sets camera layer mask */
  83589. layerMask: number;
  83590. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83591. fogEnabled: boolean;
  83592. /** Gets or sets a boolean indicating if the sprites are pickable */
  83593. isPickable: boolean;
  83594. /** Defines the default width of a cell in the spritesheet */
  83595. cellWidth: number;
  83596. /** Defines the default height of a cell in the spritesheet */
  83597. cellHeight: number;
  83598. /** Associative array from JSON sprite data file */
  83599. private _cellData;
  83600. /** Array of sprite names from JSON sprite data file */
  83601. private _spriteMap;
  83602. /** True when packed cell data from JSON file is ready*/
  83603. private _packedAndReady;
  83604. /**
  83605. * An event triggered when the manager is disposed.
  83606. */
  83607. onDisposeObservable: Observable<SpriteManager>;
  83608. private _onDisposeObserver;
  83609. /**
  83610. * Callback called when the manager is disposed
  83611. */
  83612. set onDispose(callback: () => void);
  83613. private _capacity;
  83614. private _fromPacked;
  83615. private _spriteTexture;
  83616. private _epsilon;
  83617. private _scene;
  83618. private _vertexData;
  83619. private _buffer;
  83620. private _vertexBuffers;
  83621. private _indexBuffer;
  83622. private _effectBase;
  83623. private _effectFog;
  83624. /**
  83625. * Gets or sets the spritesheet texture
  83626. */
  83627. get texture(): Texture;
  83628. set texture(value: Texture);
  83629. private _blendMode;
  83630. /**
  83631. * Blend mode use to render the particle, it can be any of
  83632. * the static Constants.ALPHA_x properties provided in this class.
  83633. * Default value is Constants.ALPHA_COMBINE
  83634. */
  83635. get blendMode(): number;
  83636. set blendMode(blendMode: number);
  83637. /** Disables writing to the depth buffer when rendering the sprites.
  83638. * It can be handy to disable depth writing when using textures without alpha channel
  83639. * and setting some specific blend modes.
  83640. */
  83641. disableDepthWrite: boolean;
  83642. /**
  83643. * Creates a new sprite manager
  83644. * @param name defines the manager's name
  83645. * @param imgUrl defines the sprite sheet url
  83646. * @param capacity defines the maximum allowed number of sprites
  83647. * @param cellSize defines the size of a sprite cell
  83648. * @param scene defines the hosting scene
  83649. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83650. * @param samplingMode defines the smapling mode to use with spritesheet
  83651. * @param fromPacked set to false; do not alter
  83652. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83653. */
  83654. constructor(
  83655. /** defines the manager's name */
  83656. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83657. private _makePacked;
  83658. private _appendSpriteVertex;
  83659. /**
  83660. * Intersects the sprites with a ray
  83661. * @param ray defines the ray to intersect with
  83662. * @param camera defines the current active camera
  83663. * @param predicate defines a predicate used to select candidate sprites
  83664. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83665. * @returns null if no hit or a PickingInfo
  83666. */
  83667. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83668. /**
  83669. * Intersects the sprites with a ray
  83670. * @param ray defines the ray to intersect with
  83671. * @param camera defines the current active camera
  83672. * @param predicate defines a predicate used to select candidate sprites
  83673. * @returns null if no hit or a PickingInfo array
  83674. */
  83675. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83676. /**
  83677. * Render all child sprites
  83678. */
  83679. render(): void;
  83680. /**
  83681. * Release associated resources
  83682. */
  83683. dispose(): void;
  83684. }
  83685. }
  83686. declare module BABYLON {
  83687. /** Interface used by value gradients (color, factor, ...) */
  83688. export interface IValueGradient {
  83689. /**
  83690. * Gets or sets the gradient value (between 0 and 1)
  83691. */
  83692. gradient: number;
  83693. }
  83694. /** Class used to store color4 gradient */
  83695. export class ColorGradient implements IValueGradient {
  83696. /**
  83697. * Gets or sets the gradient value (between 0 and 1)
  83698. */
  83699. gradient: number;
  83700. /**
  83701. * Gets or sets first associated color
  83702. */
  83703. color1: Color4;
  83704. /**
  83705. * Gets or sets second associated color
  83706. */
  83707. color2?: Color4;
  83708. /**
  83709. * Will get a color picked randomly between color1 and color2.
  83710. * If color2 is undefined then color1 will be used
  83711. * @param result defines the target Color4 to store the result in
  83712. */
  83713. getColorToRef(result: Color4): void;
  83714. }
  83715. /** Class used to store color 3 gradient */
  83716. export class Color3Gradient implements IValueGradient {
  83717. /**
  83718. * Gets or sets the gradient value (between 0 and 1)
  83719. */
  83720. gradient: number;
  83721. /**
  83722. * Gets or sets the associated color
  83723. */
  83724. color: Color3;
  83725. }
  83726. /** Class used to store factor gradient */
  83727. export class FactorGradient implements IValueGradient {
  83728. /**
  83729. * Gets or sets the gradient value (between 0 and 1)
  83730. */
  83731. gradient: number;
  83732. /**
  83733. * Gets or sets first associated factor
  83734. */
  83735. factor1: number;
  83736. /**
  83737. * Gets or sets second associated factor
  83738. */
  83739. factor2?: number;
  83740. /**
  83741. * Will get a number picked randomly between factor1 and factor2.
  83742. * If factor2 is undefined then factor1 will be used
  83743. * @returns the picked number
  83744. */
  83745. getFactor(): number;
  83746. }
  83747. /**
  83748. * Helper used to simplify some generic gradient tasks
  83749. */
  83750. export class GradientHelper {
  83751. /**
  83752. * Gets the current gradient from an array of IValueGradient
  83753. * @param ratio defines the current ratio to get
  83754. * @param gradients defines the array of IValueGradient
  83755. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83756. */
  83757. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83758. }
  83759. }
  83760. declare module BABYLON {
  83761. /**
  83762. * Interface for the size containing width and height
  83763. */
  83764. export interface ISize {
  83765. /**
  83766. * Width
  83767. */
  83768. width: number;
  83769. /**
  83770. * Heighht
  83771. */
  83772. height: number;
  83773. }
  83774. /**
  83775. * Size containing widht and height
  83776. */
  83777. export class Size implements ISize {
  83778. /**
  83779. * Width
  83780. */
  83781. width: number;
  83782. /**
  83783. * Height
  83784. */
  83785. height: number;
  83786. /**
  83787. * Creates a Size object from the given width and height (floats).
  83788. * @param width width of the new size
  83789. * @param height height of the new size
  83790. */
  83791. constructor(width: number, height: number);
  83792. /**
  83793. * Returns a string with the Size width and height
  83794. * @returns a string with the Size width and height
  83795. */
  83796. toString(): string;
  83797. /**
  83798. * "Size"
  83799. * @returns the string "Size"
  83800. */
  83801. getClassName(): string;
  83802. /**
  83803. * Returns the Size hash code.
  83804. * @returns a hash code for a unique width and height
  83805. */
  83806. getHashCode(): number;
  83807. /**
  83808. * Updates the current size from the given one.
  83809. * @param src the given size
  83810. */
  83811. copyFrom(src: Size): void;
  83812. /**
  83813. * Updates in place the current Size from the given floats.
  83814. * @param width width of the new size
  83815. * @param height height of the new size
  83816. * @returns the updated Size.
  83817. */
  83818. copyFromFloats(width: number, height: number): Size;
  83819. /**
  83820. * Updates in place the current Size from the given floats.
  83821. * @param width width to set
  83822. * @param height height to set
  83823. * @returns the updated Size.
  83824. */
  83825. set(width: number, height: number): Size;
  83826. /**
  83827. * Multiplies the width and height by numbers
  83828. * @param w factor to multiple the width by
  83829. * @param h factor to multiple the height by
  83830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83831. */
  83832. multiplyByFloats(w: number, h: number): Size;
  83833. /**
  83834. * Clones the size
  83835. * @returns a new Size copied from the given one.
  83836. */
  83837. clone(): Size;
  83838. /**
  83839. * True if the current Size and the given one width and height are strictly equal.
  83840. * @param other the other size to compare against
  83841. * @returns True if the current Size and the given one width and height are strictly equal.
  83842. */
  83843. equals(other: Size): boolean;
  83844. /**
  83845. * The surface of the Size : width * height (float).
  83846. */
  83847. get surface(): number;
  83848. /**
  83849. * Create a new size of zero
  83850. * @returns a new Size set to (0.0, 0.0)
  83851. */
  83852. static Zero(): Size;
  83853. /**
  83854. * Sums the width and height of two sizes
  83855. * @param otherSize size to add to this size
  83856. * @returns a new Size set as the addition result of the current Size and the given one.
  83857. */
  83858. add(otherSize: Size): Size;
  83859. /**
  83860. * Subtracts the width and height of two
  83861. * @param otherSize size to subtract to this size
  83862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83863. */
  83864. subtract(otherSize: Size): Size;
  83865. /**
  83866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83867. * @param start starting size to lerp between
  83868. * @param end end size to lerp between
  83869. * @param amount amount to lerp between the start and end values
  83870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83871. */
  83872. static Lerp(start: Size, end: Size, amount: number): Size;
  83873. }
  83874. }
  83875. declare module BABYLON {
  83876. interface ThinEngine {
  83877. /**
  83878. * Creates a dynamic texture
  83879. * @param width defines the width of the texture
  83880. * @param height defines the height of the texture
  83881. * @param generateMipMaps defines if the engine should generate the mip levels
  83882. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83883. * @returns the dynamic texture inside an InternalTexture
  83884. */
  83885. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83886. /**
  83887. * Update the content of a dynamic texture
  83888. * @param texture defines the texture to update
  83889. * @param canvas defines the canvas containing the source
  83890. * @param invertY defines if data must be stored with Y axis inverted
  83891. * @param premulAlpha defines if alpha is stored as premultiplied
  83892. * @param format defines the format of the data
  83893. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83894. */
  83895. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83896. }
  83897. }
  83898. declare module BABYLON {
  83899. /**
  83900. * Helper class used to generate a canvas to manipulate images
  83901. */
  83902. export class CanvasGenerator {
  83903. /**
  83904. * Create a new canvas (or offscreen canvas depending on the context)
  83905. * @param width defines the expected width
  83906. * @param height defines the expected height
  83907. * @return a new canvas or offscreen canvas
  83908. */
  83909. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83910. }
  83911. }
  83912. declare module BABYLON {
  83913. /**
  83914. * A class extending Texture allowing drawing on a texture
  83915. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83916. */
  83917. export class DynamicTexture extends Texture {
  83918. private _generateMipMaps;
  83919. private _canvas;
  83920. private _context;
  83921. private _engine;
  83922. /**
  83923. * Creates a DynamicTexture
  83924. * @param name defines the name of the texture
  83925. * @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
  83926. * @param scene defines the scene where you want the texture
  83927. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83928. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83929. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83930. */
  83931. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83932. /**
  83933. * Get the current class name of the texture useful for serialization or dynamic coding.
  83934. * @returns "DynamicTexture"
  83935. */
  83936. getClassName(): string;
  83937. /**
  83938. * Gets the current state of canRescale
  83939. */
  83940. get canRescale(): boolean;
  83941. private _recreate;
  83942. /**
  83943. * Scales the texture
  83944. * @param ratio the scale factor to apply to both width and height
  83945. */
  83946. scale(ratio: number): void;
  83947. /**
  83948. * Resizes the texture
  83949. * @param width the new width
  83950. * @param height the new height
  83951. */
  83952. scaleTo(width: number, height: number): void;
  83953. /**
  83954. * Gets the context of the canvas used by the texture
  83955. * @returns the canvas context of the dynamic texture
  83956. */
  83957. getContext(): CanvasRenderingContext2D;
  83958. /**
  83959. * Clears the texture
  83960. */
  83961. clear(): void;
  83962. /**
  83963. * Updates the texture
  83964. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83965. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83966. */
  83967. update(invertY?: boolean, premulAlpha?: boolean): void;
  83968. /**
  83969. * Draws text onto the texture
  83970. * @param text defines the text to be drawn
  83971. * @param x defines the placement of the text from the left
  83972. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83973. * @param font defines the font to be used with font-style, font-size, font-name
  83974. * @param color defines the color used for the text
  83975. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83976. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83977. * @param update defines whether texture is immediately update (default is true)
  83978. */
  83979. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83980. /**
  83981. * Clones the texture
  83982. * @returns the clone of the texture.
  83983. */
  83984. clone(): DynamicTexture;
  83985. /**
  83986. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83987. * @returns a serialized dynamic texture object
  83988. */
  83989. serialize(): any;
  83990. /** @hidden */
  83991. _rebuild(): void;
  83992. }
  83993. }
  83994. declare module BABYLON {
  83995. interface Engine {
  83996. /**
  83997. * Creates a raw texture
  83998. * @param data defines the data to store in the texture
  83999. * @param width defines the width of the texture
  84000. * @param height defines the height of the texture
  84001. * @param format defines the format of the data
  84002. * @param generateMipMaps defines if the engine should generate the mip levels
  84003. * @param invertY defines if data must be stored with Y axis inverted
  84004. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84005. * @param compression defines the compression used (null by default)
  84006. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84007. * @returns the raw texture inside an InternalTexture
  84008. */
  84009. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84010. /**
  84011. * Update a raw texture
  84012. * @param texture defines the texture to update
  84013. * @param data defines the data to store in the texture
  84014. * @param format defines the format of the data
  84015. * @param invertY defines if data must be stored with Y axis inverted
  84016. */
  84017. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84018. /**
  84019. * Update a raw texture
  84020. * @param texture defines the texture to update
  84021. * @param data defines the data to store in the texture
  84022. * @param format defines the format of the data
  84023. * @param invertY defines if data must be stored with Y axis inverted
  84024. * @param compression defines the compression used (null by default)
  84025. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84026. */
  84027. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84028. /**
  84029. * Creates a new raw cube texture
  84030. * @param data defines the array of data to use to create each face
  84031. * @param size defines the size of the textures
  84032. * @param format defines the format of the data
  84033. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84034. * @param generateMipMaps defines if the engine should generate the mip levels
  84035. * @param invertY defines if data must be stored with Y axis inverted
  84036. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84037. * @param compression defines the compression used (null by default)
  84038. * @returns the cube texture as an InternalTexture
  84039. */
  84040. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84041. /**
  84042. * Update a raw cube texture
  84043. * @param texture defines the texture to udpdate
  84044. * @param data defines the data to store
  84045. * @param format defines the data format
  84046. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84047. * @param invertY defines if data must be stored with Y axis inverted
  84048. */
  84049. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84050. /**
  84051. * Update a raw cube texture
  84052. * @param texture defines the texture to udpdate
  84053. * @param data defines the data to store
  84054. * @param format defines the data format
  84055. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84056. * @param invertY defines if data must be stored with Y axis inverted
  84057. * @param compression defines the compression used (null by default)
  84058. */
  84059. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84060. /**
  84061. * Update a raw cube texture
  84062. * @param texture defines the texture to udpdate
  84063. * @param data defines the data to store
  84064. * @param format defines the data format
  84065. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84066. * @param invertY defines if data must be stored with Y axis inverted
  84067. * @param compression defines the compression used (null by default)
  84068. * @param level defines which level of the texture to update
  84069. */
  84070. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84071. /**
  84072. * Creates a new raw cube texture from a specified url
  84073. * @param url defines the url where the data is located
  84074. * @param scene defines the current scene
  84075. * @param size defines the size of the textures
  84076. * @param format defines the format of the data
  84077. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84078. * @param noMipmap defines if the engine should avoid generating the mip levels
  84079. * @param callback defines a callback used to extract texture data from loaded data
  84080. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84081. * @param onLoad defines a callback called when texture is loaded
  84082. * @param onError defines a callback called if there is an error
  84083. * @returns the cube texture as an InternalTexture
  84084. */
  84085. 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;
  84086. /**
  84087. * Creates a new raw cube texture from a specified url
  84088. * @param url defines the url where the data is located
  84089. * @param scene defines the current scene
  84090. * @param size defines the size of the textures
  84091. * @param format defines the format of the data
  84092. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84093. * @param noMipmap defines if the engine should avoid generating the mip levels
  84094. * @param callback defines a callback used to extract texture data from loaded data
  84095. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84096. * @param onLoad defines a callback called when texture is loaded
  84097. * @param onError defines a callback called if there is an error
  84098. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84099. * @param invertY defines if data must be stored with Y axis inverted
  84100. * @returns the cube texture as an InternalTexture
  84101. */
  84102. 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;
  84103. /**
  84104. * Creates a new raw 3D texture
  84105. * @param data defines the data used to create the texture
  84106. * @param width defines the width of the texture
  84107. * @param height defines the height of the texture
  84108. * @param depth defines the depth of the texture
  84109. * @param format defines the format of the texture
  84110. * @param generateMipMaps defines if the engine must generate mip levels
  84111. * @param invertY defines if data must be stored with Y axis inverted
  84112. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84113. * @param compression defines the compressed used (can be null)
  84114. * @param textureType defines the compressed used (can be null)
  84115. * @returns a new raw 3D texture (stored in an InternalTexture)
  84116. */
  84117. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84118. /**
  84119. * Update a raw 3D texture
  84120. * @param texture defines the texture to update
  84121. * @param data defines the data to store
  84122. * @param format defines the data format
  84123. * @param invertY defines if data must be stored with Y axis inverted
  84124. */
  84125. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84126. /**
  84127. * Update a raw 3D texture
  84128. * @param texture defines the texture to update
  84129. * @param data defines the data to store
  84130. * @param format defines the data format
  84131. * @param invertY defines if data must be stored with Y axis inverted
  84132. * @param compression defines the used compression (can be null)
  84133. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84134. */
  84135. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84136. /**
  84137. * Creates a new raw 2D array texture
  84138. * @param data defines the data used to create the texture
  84139. * @param width defines the width of the texture
  84140. * @param height defines the height of the texture
  84141. * @param depth defines the number of layers of the texture
  84142. * @param format defines the format of the texture
  84143. * @param generateMipMaps defines if the engine must generate mip levels
  84144. * @param invertY defines if data must be stored with Y axis inverted
  84145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84146. * @param compression defines the compressed used (can be null)
  84147. * @param textureType defines the compressed used (can be null)
  84148. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84149. */
  84150. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84151. /**
  84152. * Update a raw 2D array texture
  84153. * @param texture defines the texture to update
  84154. * @param data defines the data to store
  84155. * @param format defines the data format
  84156. * @param invertY defines if data must be stored with Y axis inverted
  84157. */
  84158. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84159. /**
  84160. * Update a raw 2D array texture
  84161. * @param texture defines the texture to update
  84162. * @param data defines the data to store
  84163. * @param format defines the data format
  84164. * @param invertY defines if data must be stored with Y axis inverted
  84165. * @param compression defines the used compression (can be null)
  84166. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84167. */
  84168. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84169. }
  84170. }
  84171. declare module BABYLON {
  84172. /**
  84173. * Raw texture can help creating a texture directly from an array of data.
  84174. * This can be super useful if you either get the data from an uncompressed source or
  84175. * if you wish to create your texture pixel by pixel.
  84176. */
  84177. export class RawTexture extends Texture {
  84178. /**
  84179. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84180. */
  84181. format: number;
  84182. private _engine;
  84183. /**
  84184. * Instantiates a new RawTexture.
  84185. * Raw texture can help creating a texture directly from an array of data.
  84186. * This can be super useful if you either get the data from an uncompressed source or
  84187. * if you wish to create your texture pixel by pixel.
  84188. * @param data define the array of data to use to create the texture
  84189. * @param width define the width of the texture
  84190. * @param height define the height of the texture
  84191. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84192. * @param scene define the scene the texture belongs to
  84193. * @param generateMipMaps define whether mip maps should be generated or not
  84194. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84195. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84196. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84197. */
  84198. constructor(data: ArrayBufferView, width: number, height: number,
  84199. /**
  84200. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84201. */
  84202. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84203. /**
  84204. * Updates the texture underlying data.
  84205. * @param data Define the new data of the texture
  84206. */
  84207. update(data: ArrayBufferView): void;
  84208. /**
  84209. * Creates a luminance texture from some data.
  84210. * @param data Define the texture data
  84211. * @param width Define the width of the texture
  84212. * @param height Define the height of the texture
  84213. * @param scene Define the scene the texture belongs to
  84214. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84215. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84216. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84217. * @returns the luminance texture
  84218. */
  84219. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84220. /**
  84221. * Creates a luminance alpha texture from some data.
  84222. * @param data Define the texture data
  84223. * @param width Define the width of the texture
  84224. * @param height Define the height of the texture
  84225. * @param scene Define the scene the texture belongs to
  84226. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84227. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84228. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84229. * @returns the luminance alpha texture
  84230. */
  84231. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84232. /**
  84233. * Creates an alpha texture from some data.
  84234. * @param data Define the texture data
  84235. * @param width Define the width of the texture
  84236. * @param height Define the height of the texture
  84237. * @param scene Define the scene the texture belongs to
  84238. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84239. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84240. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84241. * @returns the alpha texture
  84242. */
  84243. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84244. /**
  84245. * Creates a RGB texture from some data.
  84246. * @param data Define the texture data
  84247. * @param width Define the width of the texture
  84248. * @param height Define the height of the texture
  84249. * @param scene Define the scene the texture belongs to
  84250. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84251. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84252. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84253. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84254. * @returns the RGB alpha texture
  84255. */
  84256. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84257. /**
  84258. * Creates a RGBA texture from some data.
  84259. * @param data Define the texture data
  84260. * @param width Define the width of the texture
  84261. * @param height Define the height of the texture
  84262. * @param scene Define the scene the texture belongs to
  84263. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84266. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84267. * @returns the RGBA texture
  84268. */
  84269. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84270. /**
  84271. * Creates a R texture from some data.
  84272. * @param data Define the texture data
  84273. * @param width Define the width of the texture
  84274. * @param height Define the height of the texture
  84275. * @param scene Define the scene the texture belongs to
  84276. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84277. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84278. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84279. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84280. * @returns the R texture
  84281. */
  84282. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84283. }
  84284. }
  84285. declare module BABYLON {
  84286. interface AbstractScene {
  84287. /**
  84288. * The list of procedural textures added to the scene
  84289. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84290. */
  84291. proceduralTextures: Array<ProceduralTexture>;
  84292. }
  84293. /**
  84294. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84295. * in a given scene.
  84296. */
  84297. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84298. /**
  84299. * The component name helpfull to identify the component in the list of scene components.
  84300. */
  84301. readonly name: string;
  84302. /**
  84303. * The scene the component belongs to.
  84304. */
  84305. scene: Scene;
  84306. /**
  84307. * Creates a new instance of the component for the given scene
  84308. * @param scene Defines the scene to register the component in
  84309. */
  84310. constructor(scene: Scene);
  84311. /**
  84312. * Registers the component in a given scene
  84313. */
  84314. register(): void;
  84315. /**
  84316. * Rebuilds the elements related to this component in case of
  84317. * context lost for instance.
  84318. */
  84319. rebuild(): void;
  84320. /**
  84321. * Disposes the component and the associated ressources.
  84322. */
  84323. dispose(): void;
  84324. private _beforeClear;
  84325. }
  84326. }
  84327. declare module BABYLON {
  84328. interface ThinEngine {
  84329. /**
  84330. * Creates a new render target cube texture
  84331. * @param size defines the size of the texture
  84332. * @param options defines the options used to create the texture
  84333. * @returns a new render target cube texture stored in an InternalTexture
  84334. */
  84335. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /** @hidden */
  84340. export var proceduralVertexShader: {
  84341. name: string;
  84342. shader: string;
  84343. };
  84344. }
  84345. declare module BABYLON {
  84346. /**
  84347. * 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.
  84348. * This is the base class of any Procedural texture and contains most of the shareable code.
  84349. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84350. */
  84351. export class ProceduralTexture extends Texture {
  84352. isCube: boolean;
  84353. /**
  84354. * Define if the texture is enabled or not (disabled texture will not render)
  84355. */
  84356. isEnabled: boolean;
  84357. /**
  84358. * Define if the texture must be cleared before rendering (default is true)
  84359. */
  84360. autoClear: boolean;
  84361. /**
  84362. * Callback called when the texture is generated
  84363. */
  84364. onGenerated: () => void;
  84365. /**
  84366. * Event raised when the texture is generated
  84367. */
  84368. onGeneratedObservable: Observable<ProceduralTexture>;
  84369. /** @hidden */
  84370. _generateMipMaps: boolean;
  84371. /** @hidden **/
  84372. _effect: Effect;
  84373. /** @hidden */
  84374. _textures: {
  84375. [key: string]: Texture;
  84376. };
  84377. private _size;
  84378. private _currentRefreshId;
  84379. private _frameId;
  84380. private _refreshRate;
  84381. private _vertexBuffers;
  84382. private _indexBuffer;
  84383. private _uniforms;
  84384. private _samplers;
  84385. private _fragment;
  84386. private _floats;
  84387. private _ints;
  84388. private _floatsArrays;
  84389. private _colors3;
  84390. private _colors4;
  84391. private _vectors2;
  84392. private _vectors3;
  84393. private _matrices;
  84394. private _fallbackTexture;
  84395. private _fallbackTextureUsed;
  84396. private _engine;
  84397. private _cachedDefines;
  84398. private _contentUpdateId;
  84399. private _contentData;
  84400. /**
  84401. * Instantiates a new procedural texture.
  84402. * 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.
  84403. * This is the base class of any Procedural texture and contains most of the shareable code.
  84404. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84405. * @param name Define the name of the texture
  84406. * @param size Define the size of the texture to create
  84407. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84408. * @param scene Define the scene the texture belongs to
  84409. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84410. * @param generateMipMaps Define if the texture should creates mip maps or not
  84411. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84412. */
  84413. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84414. /**
  84415. * The effect that is created when initializing the post process.
  84416. * @returns The created effect corresponding the the postprocess.
  84417. */
  84418. getEffect(): Effect;
  84419. /**
  84420. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84421. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84422. */
  84423. getContent(): Nullable<ArrayBufferView>;
  84424. private _createIndexBuffer;
  84425. /** @hidden */
  84426. _rebuild(): void;
  84427. /**
  84428. * Resets the texture in order to recreate its associated resources.
  84429. * This can be called in case of context loss
  84430. */
  84431. reset(): void;
  84432. protected _getDefines(): string;
  84433. /**
  84434. * Is the texture ready to be used ? (rendered at least once)
  84435. * @returns true if ready, otherwise, false.
  84436. */
  84437. isReady(): boolean;
  84438. /**
  84439. * Resets the refresh counter of the texture and start bak from scratch.
  84440. * Could be useful to regenerate the texture if it is setup to render only once.
  84441. */
  84442. resetRefreshCounter(): void;
  84443. /**
  84444. * Set the fragment shader to use in order to render the texture.
  84445. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84446. */
  84447. setFragment(fragment: any): void;
  84448. /**
  84449. * Define the refresh rate of the texture or the rendering frequency.
  84450. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84451. */
  84452. get refreshRate(): number;
  84453. set refreshRate(value: number);
  84454. /** @hidden */
  84455. _shouldRender(): boolean;
  84456. /**
  84457. * Get the size the texture is rendering at.
  84458. * @returns the size (texture is always squared)
  84459. */
  84460. getRenderSize(): number;
  84461. /**
  84462. * Resize the texture to new value.
  84463. * @param size Define the new size the texture should have
  84464. * @param generateMipMaps Define whether the new texture should create mip maps
  84465. */
  84466. resize(size: number, generateMipMaps: boolean): void;
  84467. private _checkUniform;
  84468. /**
  84469. * Set a texture in the shader program used to render.
  84470. * @param name Define the name of the uniform samplers as defined in the shader
  84471. * @param texture Define the texture to bind to this sampler
  84472. * @return the texture itself allowing "fluent" like uniform updates
  84473. */
  84474. setTexture(name: string, texture: Texture): ProceduralTexture;
  84475. /**
  84476. * Set a float in the shader.
  84477. * @param name Define the name of the uniform as defined in the shader
  84478. * @param value Define the value to give to the uniform
  84479. * @return the texture itself allowing "fluent" like uniform updates
  84480. */
  84481. setFloat(name: string, value: number): ProceduralTexture;
  84482. /**
  84483. * Set a int in the shader.
  84484. * @param name Define the name of the uniform as defined in the shader
  84485. * @param value Define the value to give to the uniform
  84486. * @return the texture itself allowing "fluent" like uniform updates
  84487. */
  84488. setInt(name: string, value: number): ProceduralTexture;
  84489. /**
  84490. * Set an array of floats in the shader.
  84491. * @param name Define the name of the uniform as defined in the shader
  84492. * @param value Define the value to give to the uniform
  84493. * @return the texture itself allowing "fluent" like uniform updates
  84494. */
  84495. setFloats(name: string, value: number[]): ProceduralTexture;
  84496. /**
  84497. * Set a vec3 in the shader from a Color3.
  84498. * @param name Define the name of the uniform as defined in the shader
  84499. * @param value Define the value to give to the uniform
  84500. * @return the texture itself allowing "fluent" like uniform updates
  84501. */
  84502. setColor3(name: string, value: Color3): ProceduralTexture;
  84503. /**
  84504. * Set a vec4 in the shader from a Color4.
  84505. * @param name Define the name of the uniform as defined in the shader
  84506. * @param value Define the value to give to the uniform
  84507. * @return the texture itself allowing "fluent" like uniform updates
  84508. */
  84509. setColor4(name: string, value: Color4): ProceduralTexture;
  84510. /**
  84511. * Set a vec2 in the shader from a Vector2.
  84512. * @param name Define the name of the uniform as defined in the shader
  84513. * @param value Define the value to give to the uniform
  84514. * @return the texture itself allowing "fluent" like uniform updates
  84515. */
  84516. setVector2(name: string, value: Vector2): ProceduralTexture;
  84517. /**
  84518. * Set a vec3 in the shader from a Vector3.
  84519. * @param name Define the name of the uniform as defined in the shader
  84520. * @param value Define the value to give to the uniform
  84521. * @return the texture itself allowing "fluent" like uniform updates
  84522. */
  84523. setVector3(name: string, value: Vector3): ProceduralTexture;
  84524. /**
  84525. * Set a mat4 in the shader from a MAtrix.
  84526. * @param name Define the name of the uniform as defined in the shader
  84527. * @param value Define the value to give to the uniform
  84528. * @return the texture itself allowing "fluent" like uniform updates
  84529. */
  84530. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84531. /**
  84532. * Render the texture to its associated render target.
  84533. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84534. */
  84535. render(useCameraPostProcess?: boolean): void;
  84536. /**
  84537. * Clone the texture.
  84538. * @returns the cloned texture
  84539. */
  84540. clone(): ProceduralTexture;
  84541. /**
  84542. * Dispose the texture and release its asoociated resources.
  84543. */
  84544. dispose(): void;
  84545. }
  84546. }
  84547. declare module BABYLON {
  84548. /**
  84549. * This represents the base class for particle system in Babylon.
  84550. * 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.
  84551. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84552. * @example https://doc.babylonjs.com/babylon101/particles
  84553. */
  84554. export class BaseParticleSystem {
  84555. /**
  84556. * Source color is added to the destination color without alpha affecting the result
  84557. */
  84558. static BLENDMODE_ONEONE: number;
  84559. /**
  84560. * Blend current color and particle color using particle’s alpha
  84561. */
  84562. static BLENDMODE_STANDARD: number;
  84563. /**
  84564. * Add current color and particle color multiplied by particle’s alpha
  84565. */
  84566. static BLENDMODE_ADD: number;
  84567. /**
  84568. * Multiply current color with particle color
  84569. */
  84570. static BLENDMODE_MULTIPLY: number;
  84571. /**
  84572. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84573. */
  84574. static BLENDMODE_MULTIPLYADD: number;
  84575. /**
  84576. * List of animations used by the particle system.
  84577. */
  84578. animations: Animation[];
  84579. /**
  84580. * The id of the Particle system.
  84581. */
  84582. id: string;
  84583. /**
  84584. * The friendly name of the Particle system.
  84585. */
  84586. name: string;
  84587. /**
  84588. * The rendering group used by the Particle system to chose when to render.
  84589. */
  84590. renderingGroupId: number;
  84591. /**
  84592. * The emitter represents the Mesh or position we are attaching the particle system to.
  84593. */
  84594. emitter: Nullable<AbstractMesh | Vector3>;
  84595. /**
  84596. * The maximum number of particles to emit per frame
  84597. */
  84598. emitRate: number;
  84599. /**
  84600. * If you want to launch only a few particles at once, that can be done, as well.
  84601. */
  84602. manualEmitCount: number;
  84603. /**
  84604. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84605. */
  84606. updateSpeed: number;
  84607. /**
  84608. * The amount of time the particle system is running (depends of the overall update speed).
  84609. */
  84610. targetStopDuration: number;
  84611. /**
  84612. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84613. */
  84614. disposeOnStop: boolean;
  84615. /**
  84616. * Minimum power of emitting particles.
  84617. */
  84618. minEmitPower: number;
  84619. /**
  84620. * Maximum power of emitting particles.
  84621. */
  84622. maxEmitPower: number;
  84623. /**
  84624. * Minimum life time of emitting particles.
  84625. */
  84626. minLifeTime: number;
  84627. /**
  84628. * Maximum life time of emitting particles.
  84629. */
  84630. maxLifeTime: number;
  84631. /**
  84632. * Minimum Size of emitting particles.
  84633. */
  84634. minSize: number;
  84635. /**
  84636. * Maximum Size of emitting particles.
  84637. */
  84638. maxSize: number;
  84639. /**
  84640. * Minimum scale of emitting particles on X axis.
  84641. */
  84642. minScaleX: number;
  84643. /**
  84644. * Maximum scale of emitting particles on X axis.
  84645. */
  84646. maxScaleX: number;
  84647. /**
  84648. * Minimum scale of emitting particles on Y axis.
  84649. */
  84650. minScaleY: number;
  84651. /**
  84652. * Maximum scale of emitting particles on Y axis.
  84653. */
  84654. maxScaleY: number;
  84655. /**
  84656. * Gets or sets the minimal initial rotation in radians.
  84657. */
  84658. minInitialRotation: number;
  84659. /**
  84660. * Gets or sets the maximal initial rotation in radians.
  84661. */
  84662. maxInitialRotation: number;
  84663. /**
  84664. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84665. */
  84666. minAngularSpeed: number;
  84667. /**
  84668. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84669. */
  84670. maxAngularSpeed: number;
  84671. /**
  84672. * The texture used to render each particle. (this can be a spritesheet)
  84673. */
  84674. particleTexture: Nullable<Texture>;
  84675. /**
  84676. * The layer mask we are rendering the particles through.
  84677. */
  84678. layerMask: number;
  84679. /**
  84680. * This can help using your own shader to render the particle system.
  84681. * The according effect will be created
  84682. */
  84683. customShader: any;
  84684. /**
  84685. * By default particle system starts as soon as they are created. This prevents the
  84686. * automatic start to happen and let you decide when to start emitting particles.
  84687. */
  84688. preventAutoStart: boolean;
  84689. private _noiseTexture;
  84690. /**
  84691. * Gets or sets a texture used to add random noise to particle positions
  84692. */
  84693. get noiseTexture(): Nullable<ProceduralTexture>;
  84694. set noiseTexture(value: Nullable<ProceduralTexture>);
  84695. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84696. noiseStrength: Vector3;
  84697. /**
  84698. * Callback triggered when the particle animation is ending.
  84699. */
  84700. onAnimationEnd: Nullable<() => void>;
  84701. /**
  84702. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84703. */
  84704. blendMode: number;
  84705. /**
  84706. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84707. * to override the particles.
  84708. */
  84709. forceDepthWrite: boolean;
  84710. /** 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 */
  84711. preWarmCycles: number;
  84712. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84713. preWarmStepOffset: number;
  84714. /**
  84715. * 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)
  84716. */
  84717. spriteCellChangeSpeed: number;
  84718. /**
  84719. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84720. */
  84721. startSpriteCellID: number;
  84722. /**
  84723. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84724. */
  84725. endSpriteCellID: number;
  84726. /**
  84727. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84728. */
  84729. spriteCellWidth: number;
  84730. /**
  84731. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84732. */
  84733. spriteCellHeight: number;
  84734. /**
  84735. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84736. */
  84737. spriteRandomStartCell: boolean;
  84738. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84739. translationPivot: Vector2;
  84740. /** @hidden */
  84741. protected _isAnimationSheetEnabled: boolean;
  84742. /**
  84743. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84744. */
  84745. beginAnimationOnStart: boolean;
  84746. /**
  84747. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84748. */
  84749. beginAnimationFrom: number;
  84750. /**
  84751. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84752. */
  84753. beginAnimationTo: number;
  84754. /**
  84755. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84756. */
  84757. beginAnimationLoop: boolean;
  84758. /**
  84759. * Gets or sets a world offset applied to all particles
  84760. */
  84761. worldOffset: Vector3;
  84762. /**
  84763. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84764. */
  84765. get isAnimationSheetEnabled(): boolean;
  84766. set isAnimationSheetEnabled(value: boolean);
  84767. /**
  84768. * Get hosting scene
  84769. * @returns the scene
  84770. */
  84771. getScene(): Scene;
  84772. /**
  84773. * You can use gravity if you want to give an orientation to your particles.
  84774. */
  84775. gravity: Vector3;
  84776. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84777. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84778. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84779. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84780. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84781. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84782. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84783. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84784. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84785. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84786. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84787. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84788. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84789. /**
  84790. * Defines the delay in milliseconds before starting the system (0 by default)
  84791. */
  84792. startDelay: number;
  84793. /**
  84794. * Gets the current list of drag gradients.
  84795. * You must use addDragGradient and removeDragGradient to udpate this list
  84796. * @returns the list of drag gradients
  84797. */
  84798. getDragGradients(): Nullable<Array<FactorGradient>>;
  84799. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84800. limitVelocityDamping: number;
  84801. /**
  84802. * Gets the current list of limit velocity gradients.
  84803. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84804. * @returns the list of limit velocity gradients
  84805. */
  84806. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84807. /**
  84808. * Gets the current list of color gradients.
  84809. * You must use addColorGradient and removeColorGradient to udpate this list
  84810. * @returns the list of color gradients
  84811. */
  84812. getColorGradients(): Nullable<Array<ColorGradient>>;
  84813. /**
  84814. * Gets the current list of size gradients.
  84815. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84816. * @returns the list of size gradients
  84817. */
  84818. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84819. /**
  84820. * Gets the current list of color remap gradients.
  84821. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84822. * @returns the list of color remap gradients
  84823. */
  84824. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84825. /**
  84826. * Gets the current list of alpha remap gradients.
  84827. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84828. * @returns the list of alpha remap gradients
  84829. */
  84830. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84831. /**
  84832. * Gets the current list of life time gradients.
  84833. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84834. * @returns the list of life time gradients
  84835. */
  84836. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84837. /**
  84838. * Gets the current list of angular speed gradients.
  84839. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84840. * @returns the list of angular speed gradients
  84841. */
  84842. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84843. /**
  84844. * Gets the current list of velocity gradients.
  84845. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84846. * @returns the list of velocity gradients
  84847. */
  84848. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84849. /**
  84850. * Gets the current list of start size gradients.
  84851. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84852. * @returns the list of start size gradients
  84853. */
  84854. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84855. /**
  84856. * Gets the current list of emit rate gradients.
  84857. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84858. * @returns the list of emit rate gradients
  84859. */
  84860. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84861. /**
  84862. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84863. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84864. */
  84865. get direction1(): Vector3;
  84866. set direction1(value: Vector3);
  84867. /**
  84868. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84869. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84870. */
  84871. get direction2(): Vector3;
  84872. set direction2(value: Vector3);
  84873. /**
  84874. * 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.
  84875. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84876. */
  84877. get minEmitBox(): Vector3;
  84878. set minEmitBox(value: Vector3);
  84879. /**
  84880. * 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.
  84881. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84882. */
  84883. get maxEmitBox(): Vector3;
  84884. set maxEmitBox(value: Vector3);
  84885. /**
  84886. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84887. */
  84888. color1: Color4;
  84889. /**
  84890. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84891. */
  84892. color2: Color4;
  84893. /**
  84894. * Color the particle will have at the end of its lifetime
  84895. */
  84896. colorDead: Color4;
  84897. /**
  84898. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84899. */
  84900. textureMask: Color4;
  84901. /**
  84902. * The particle emitter type defines the emitter used by the particle system.
  84903. * It can be for example box, sphere, or cone...
  84904. */
  84905. particleEmitterType: IParticleEmitterType;
  84906. /** @hidden */
  84907. _isSubEmitter: boolean;
  84908. /**
  84909. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84910. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84911. */
  84912. billboardMode: number;
  84913. protected _isBillboardBased: boolean;
  84914. /**
  84915. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84916. */
  84917. get isBillboardBased(): boolean;
  84918. set isBillboardBased(value: boolean);
  84919. /**
  84920. * The scene the particle system belongs to.
  84921. */
  84922. protected _scene: Scene;
  84923. /**
  84924. * Local cache of defines for image processing.
  84925. */
  84926. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84927. /**
  84928. * Default configuration related to image processing available in the standard Material.
  84929. */
  84930. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84931. /**
  84932. * Gets the image processing configuration used either in this material.
  84933. */
  84934. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84935. /**
  84936. * Sets the Default image processing configuration used either in the this material.
  84937. *
  84938. * If sets to null, the scene one is in use.
  84939. */
  84940. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84941. /**
  84942. * Attaches a new image processing configuration to the Standard Material.
  84943. * @param configuration
  84944. */
  84945. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84946. /** @hidden */
  84947. protected _reset(): void;
  84948. /** @hidden */
  84949. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84950. /**
  84951. * Instantiates a particle system.
  84952. * 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.
  84953. * @param name The name of the particle system
  84954. */
  84955. constructor(name: string);
  84956. /**
  84957. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84958. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84959. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84960. * @returns the emitter
  84961. */
  84962. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84963. /**
  84964. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84965. * @param radius The radius of the hemisphere to emit from
  84966. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84967. * @returns the emitter
  84968. */
  84969. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84970. /**
  84971. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84972. * @param radius The radius of the sphere to emit from
  84973. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84974. * @returns the emitter
  84975. */
  84976. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84977. /**
  84978. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84979. * @param radius The radius of the sphere to emit from
  84980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84982. * @returns the emitter
  84983. */
  84984. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84985. /**
  84986. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84987. * @param radius The radius of the emission cylinder
  84988. * @param height The height of the emission cylinder
  84989. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84990. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84991. * @returns the emitter
  84992. */
  84993. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84994. /**
  84995. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84996. * @param radius The radius of the cylinder to emit from
  84997. * @param height The height of the emission cylinder
  84998. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84999. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85000. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85001. * @returns the emitter
  85002. */
  85003. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85004. /**
  85005. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85006. * @param radius The radius of the cone to emit from
  85007. * @param angle The base angle of the cone
  85008. * @returns the emitter
  85009. */
  85010. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85011. /**
  85012. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85013. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85014. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85015. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85016. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85017. * @returns the emitter
  85018. */
  85019. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85020. }
  85021. }
  85022. declare module BABYLON {
  85023. /**
  85024. * Type of sub emitter
  85025. */
  85026. export enum SubEmitterType {
  85027. /**
  85028. * Attached to the particle over it's lifetime
  85029. */
  85030. ATTACHED = 0,
  85031. /**
  85032. * Created when the particle dies
  85033. */
  85034. END = 1
  85035. }
  85036. /**
  85037. * Sub emitter class used to emit particles from an existing particle
  85038. */
  85039. export class SubEmitter {
  85040. /**
  85041. * the particle system to be used by the sub emitter
  85042. */
  85043. particleSystem: ParticleSystem;
  85044. /**
  85045. * Type of the submitter (Default: END)
  85046. */
  85047. type: SubEmitterType;
  85048. /**
  85049. * 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)
  85050. * Note: This only is supported when using an emitter of type Mesh
  85051. */
  85052. inheritDirection: boolean;
  85053. /**
  85054. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85055. */
  85056. inheritedVelocityAmount: number;
  85057. /**
  85058. * Creates a sub emitter
  85059. * @param particleSystem the particle system to be used by the sub emitter
  85060. */
  85061. constructor(
  85062. /**
  85063. * the particle system to be used by the sub emitter
  85064. */
  85065. particleSystem: ParticleSystem);
  85066. /**
  85067. * Clones the sub emitter
  85068. * @returns the cloned sub emitter
  85069. */
  85070. clone(): SubEmitter;
  85071. /**
  85072. * Serialize current object to a JSON object
  85073. * @returns the serialized object
  85074. */
  85075. serialize(): any;
  85076. /** @hidden */
  85077. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85078. /**
  85079. * Creates a new SubEmitter from a serialized JSON version
  85080. * @param serializationObject defines the JSON object to read from
  85081. * @param scene defines the hosting scene
  85082. * @param rootUrl defines the rootUrl for data loading
  85083. * @returns a new SubEmitter
  85084. */
  85085. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85086. /** Release associated resources */
  85087. dispose(): void;
  85088. }
  85089. }
  85090. declare module BABYLON {
  85091. /** @hidden */
  85092. export var imageProcessingDeclaration: {
  85093. name: string;
  85094. shader: string;
  85095. };
  85096. }
  85097. declare module BABYLON {
  85098. /** @hidden */
  85099. export var imageProcessingFunctions: {
  85100. name: string;
  85101. shader: string;
  85102. };
  85103. }
  85104. declare module BABYLON {
  85105. /** @hidden */
  85106. export var particlesPixelShader: {
  85107. name: string;
  85108. shader: string;
  85109. };
  85110. }
  85111. declare module BABYLON {
  85112. /** @hidden */
  85113. export var particlesVertexShader: {
  85114. name: string;
  85115. shader: string;
  85116. };
  85117. }
  85118. declare module BABYLON {
  85119. /**
  85120. * This represents a particle system in Babylon.
  85121. * 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.
  85122. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85123. * @example https://doc.babylonjs.com/babylon101/particles
  85124. */
  85125. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85126. /**
  85127. * Billboard mode will only apply to Y axis
  85128. */
  85129. static readonly BILLBOARDMODE_Y: number;
  85130. /**
  85131. * Billboard mode will apply to all axes
  85132. */
  85133. static readonly BILLBOARDMODE_ALL: number;
  85134. /**
  85135. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85136. */
  85137. static readonly BILLBOARDMODE_STRETCHED: number;
  85138. /**
  85139. * This function can be defined to provide custom update for active particles.
  85140. * This function will be called instead of regular update (age, position, color, etc.).
  85141. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85142. */
  85143. updateFunction: (particles: Particle[]) => void;
  85144. private _emitterWorldMatrix;
  85145. /**
  85146. * This function can be defined to specify initial direction for every new particle.
  85147. * It by default use the emitterType defined function
  85148. */
  85149. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85150. /**
  85151. * This function can be defined to specify initial position for every new particle.
  85152. * It by default use the emitterType defined function
  85153. */
  85154. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85155. /**
  85156. * @hidden
  85157. */
  85158. _inheritedVelocityOffset: Vector3;
  85159. /**
  85160. * An event triggered when the system is disposed
  85161. */
  85162. onDisposeObservable: Observable<ParticleSystem>;
  85163. private _onDisposeObserver;
  85164. /**
  85165. * Sets a callback that will be triggered when the system is disposed
  85166. */
  85167. set onDispose(callback: () => void);
  85168. private _particles;
  85169. private _epsilon;
  85170. private _capacity;
  85171. private _stockParticles;
  85172. private _newPartsExcess;
  85173. private _vertexData;
  85174. private _vertexBuffer;
  85175. private _vertexBuffers;
  85176. private _spriteBuffer;
  85177. private _indexBuffer;
  85178. private _effect;
  85179. private _customEffect;
  85180. private _cachedDefines;
  85181. private _scaledColorStep;
  85182. private _colorDiff;
  85183. private _scaledDirection;
  85184. private _scaledGravity;
  85185. private _currentRenderId;
  85186. private _alive;
  85187. private _useInstancing;
  85188. private _started;
  85189. private _stopped;
  85190. private _actualFrame;
  85191. private _scaledUpdateSpeed;
  85192. private _vertexBufferSize;
  85193. /** @hidden */
  85194. _currentEmitRateGradient: Nullable<FactorGradient>;
  85195. /** @hidden */
  85196. _currentEmitRate1: number;
  85197. /** @hidden */
  85198. _currentEmitRate2: number;
  85199. /** @hidden */
  85200. _currentStartSizeGradient: Nullable<FactorGradient>;
  85201. /** @hidden */
  85202. _currentStartSize1: number;
  85203. /** @hidden */
  85204. _currentStartSize2: number;
  85205. private readonly _rawTextureWidth;
  85206. private _rampGradientsTexture;
  85207. private _useRampGradients;
  85208. /** Gets or sets a boolean indicating that ramp gradients must be used
  85209. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85210. */
  85211. get useRampGradients(): boolean;
  85212. set useRampGradients(value: boolean);
  85213. /**
  85214. * 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.
  85215. * 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: [])
  85216. */
  85217. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85218. private _subEmitters;
  85219. /**
  85220. * @hidden
  85221. * If the particle systems emitter should be disposed when the particle system is disposed
  85222. */
  85223. _disposeEmitterOnDispose: boolean;
  85224. /**
  85225. * The current active Sub-systems, this property is used by the root particle system only.
  85226. */
  85227. activeSubSystems: Array<ParticleSystem>;
  85228. /**
  85229. * Specifies if the particles are updated in emitter local space or world space
  85230. */
  85231. isLocal: boolean;
  85232. private _rootParticleSystem;
  85233. /**
  85234. * Gets the current list of active particles
  85235. */
  85236. get particles(): Particle[];
  85237. /**
  85238. * Returns the string "ParticleSystem"
  85239. * @returns a string containing the class name
  85240. */
  85241. getClassName(): string;
  85242. /**
  85243. * Instantiates a particle system.
  85244. * 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.
  85245. * @param name The name of the particle system
  85246. * @param capacity The max number of particles alive at the same time
  85247. * @param scene The scene the particle system belongs to
  85248. * @param customEffect a custom effect used to change the way particles are rendered by default
  85249. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85250. * @param epsilon Offset used to render the particles
  85251. */
  85252. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85253. private _addFactorGradient;
  85254. private _removeFactorGradient;
  85255. /**
  85256. * Adds a new life time gradient
  85257. * @param gradient defines the gradient to use (between 0 and 1)
  85258. * @param factor defines the life time factor to affect to the specified gradient
  85259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85260. * @returns the current particle system
  85261. */
  85262. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85263. /**
  85264. * Remove a specific life time gradient
  85265. * @param gradient defines the gradient to remove
  85266. * @returns the current particle system
  85267. */
  85268. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85269. /**
  85270. * Adds a new size gradient
  85271. * @param gradient defines the gradient to use (between 0 and 1)
  85272. * @param factor defines the size factor to affect to the specified gradient
  85273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85274. * @returns the current particle system
  85275. */
  85276. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85277. /**
  85278. * Remove a specific size gradient
  85279. * @param gradient defines the gradient to remove
  85280. * @returns the current particle system
  85281. */
  85282. removeSizeGradient(gradient: number): IParticleSystem;
  85283. /**
  85284. * Adds a new color remap gradient
  85285. * @param gradient defines the gradient to use (between 0 and 1)
  85286. * @param min defines the color remap minimal range
  85287. * @param max defines the color remap maximal range
  85288. * @returns the current particle system
  85289. */
  85290. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85291. /**
  85292. * Remove a specific color remap gradient
  85293. * @param gradient defines the gradient to remove
  85294. * @returns the current particle system
  85295. */
  85296. removeColorRemapGradient(gradient: number): IParticleSystem;
  85297. /**
  85298. * Adds a new alpha remap gradient
  85299. * @param gradient defines the gradient to use (between 0 and 1)
  85300. * @param min defines the alpha remap minimal range
  85301. * @param max defines the alpha remap maximal range
  85302. * @returns the current particle system
  85303. */
  85304. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85305. /**
  85306. * Remove a specific alpha remap gradient
  85307. * @param gradient defines the gradient to remove
  85308. * @returns the current particle system
  85309. */
  85310. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85311. /**
  85312. * Adds a new angular speed gradient
  85313. * @param gradient defines the gradient to use (between 0 and 1)
  85314. * @param factor defines the angular speed to affect to the specified gradient
  85315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85316. * @returns the current particle system
  85317. */
  85318. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85319. /**
  85320. * Remove a specific angular speed gradient
  85321. * @param gradient defines the gradient to remove
  85322. * @returns the current particle system
  85323. */
  85324. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85325. /**
  85326. * Adds a new velocity gradient
  85327. * @param gradient defines the gradient to use (between 0 and 1)
  85328. * @param factor defines the velocity to affect to the specified gradient
  85329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85330. * @returns the current particle system
  85331. */
  85332. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85333. /**
  85334. * Remove a specific velocity gradient
  85335. * @param gradient defines the gradient to remove
  85336. * @returns the current particle system
  85337. */
  85338. removeVelocityGradient(gradient: number): IParticleSystem;
  85339. /**
  85340. * Adds a new limit velocity gradient
  85341. * @param gradient defines the gradient to use (between 0 and 1)
  85342. * @param factor defines the limit velocity value to affect to the specified gradient
  85343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85344. * @returns the current particle system
  85345. */
  85346. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85347. /**
  85348. * Remove a specific limit velocity gradient
  85349. * @param gradient defines the gradient to remove
  85350. * @returns the current particle system
  85351. */
  85352. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85353. /**
  85354. * Adds a new drag gradient
  85355. * @param gradient defines the gradient to use (between 0 and 1)
  85356. * @param factor defines the drag value to affect to the specified gradient
  85357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85358. * @returns the current particle system
  85359. */
  85360. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85361. /**
  85362. * Remove a specific drag gradient
  85363. * @param gradient defines the gradient to remove
  85364. * @returns the current particle system
  85365. */
  85366. removeDragGradient(gradient: number): IParticleSystem;
  85367. /**
  85368. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85369. * @param gradient defines the gradient to use (between 0 and 1)
  85370. * @param factor defines the emit rate value to affect to the specified gradient
  85371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85372. * @returns the current particle system
  85373. */
  85374. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85375. /**
  85376. * Remove a specific emit rate gradient
  85377. * @param gradient defines the gradient to remove
  85378. * @returns the current particle system
  85379. */
  85380. removeEmitRateGradient(gradient: number): IParticleSystem;
  85381. /**
  85382. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85383. * @param gradient defines the gradient to use (between 0 and 1)
  85384. * @param factor defines the start size value to affect to the specified gradient
  85385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85386. * @returns the current particle system
  85387. */
  85388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85389. /**
  85390. * Remove a specific start size gradient
  85391. * @param gradient defines the gradient to remove
  85392. * @returns the current particle system
  85393. */
  85394. removeStartSizeGradient(gradient: number): IParticleSystem;
  85395. private _createRampGradientTexture;
  85396. /**
  85397. * Gets the current list of ramp gradients.
  85398. * You must use addRampGradient and removeRampGradient to udpate this list
  85399. * @returns the list of ramp gradients
  85400. */
  85401. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85402. /**
  85403. * Adds a new ramp gradient used to remap particle colors
  85404. * @param gradient defines the gradient to use (between 0 and 1)
  85405. * @param color defines the color to affect to the specified gradient
  85406. * @returns the current particle system
  85407. */
  85408. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85409. /**
  85410. * Remove a specific ramp gradient
  85411. * @param gradient defines the gradient to remove
  85412. * @returns the current particle system
  85413. */
  85414. removeRampGradient(gradient: number): ParticleSystem;
  85415. /**
  85416. * Adds a new color gradient
  85417. * @param gradient defines the gradient to use (between 0 and 1)
  85418. * @param color1 defines the color to affect to the specified gradient
  85419. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85420. * @returns this particle system
  85421. */
  85422. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85423. /**
  85424. * Remove a specific color gradient
  85425. * @param gradient defines the gradient to remove
  85426. * @returns this particle system
  85427. */
  85428. removeColorGradient(gradient: number): IParticleSystem;
  85429. private _fetchR;
  85430. protected _reset(): void;
  85431. private _resetEffect;
  85432. private _createVertexBuffers;
  85433. private _createIndexBuffer;
  85434. /**
  85435. * Gets the maximum number of particles active at the same time.
  85436. * @returns The max number of active particles.
  85437. */
  85438. getCapacity(): number;
  85439. /**
  85440. * Gets whether there are still active particles in the system.
  85441. * @returns True if it is alive, otherwise false.
  85442. */
  85443. isAlive(): boolean;
  85444. /**
  85445. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85446. * @returns True if it has been started, otherwise false.
  85447. */
  85448. isStarted(): boolean;
  85449. private _prepareSubEmitterInternalArray;
  85450. /**
  85451. * Starts the particle system and begins to emit
  85452. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85453. */
  85454. start(delay?: number): void;
  85455. /**
  85456. * Stops the particle system.
  85457. * @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.
  85458. */
  85459. stop(stopSubEmitters?: boolean): void;
  85460. /**
  85461. * Remove all active particles
  85462. */
  85463. reset(): void;
  85464. /**
  85465. * @hidden (for internal use only)
  85466. */
  85467. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85468. /**
  85469. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85470. * Its lifetime will start back at 0.
  85471. */
  85472. recycleParticle: (particle: Particle) => void;
  85473. private _stopSubEmitters;
  85474. private _createParticle;
  85475. private _removeFromRoot;
  85476. private _emitFromParticle;
  85477. private _update;
  85478. /** @hidden */
  85479. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85480. /** @hidden */
  85481. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85482. /** @hidden */
  85483. private _getEffect;
  85484. /**
  85485. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85486. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85487. */
  85488. animate(preWarmOnly?: boolean): void;
  85489. private _appendParticleVertices;
  85490. /**
  85491. * Rebuilds the particle system.
  85492. */
  85493. rebuild(): void;
  85494. /**
  85495. * Is this system ready to be used/rendered
  85496. * @return true if the system is ready
  85497. */
  85498. isReady(): boolean;
  85499. private _render;
  85500. /**
  85501. * Renders the particle system in its current state.
  85502. * @returns the current number of particles
  85503. */
  85504. render(): number;
  85505. /**
  85506. * Disposes the particle system and free the associated resources
  85507. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85508. */
  85509. dispose(disposeTexture?: boolean): void;
  85510. /**
  85511. * Clones the particle system.
  85512. * @param name The name of the cloned object
  85513. * @param newEmitter The new emitter to use
  85514. * @returns the cloned particle system
  85515. */
  85516. clone(name: string, newEmitter: any): ParticleSystem;
  85517. /**
  85518. * Serializes the particle system to a JSON object.
  85519. * @returns the JSON object
  85520. */
  85521. serialize(): any;
  85522. /** @hidden */
  85523. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85524. /** @hidden */
  85525. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85526. /**
  85527. * Parses a JSON object to create a particle system.
  85528. * @param parsedParticleSystem The JSON object to parse
  85529. * @param scene The scene to create the particle system in
  85530. * @param rootUrl The root url to use to load external dependencies like texture
  85531. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85532. * @returns the Parsed particle system
  85533. */
  85534. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85535. }
  85536. }
  85537. declare module BABYLON {
  85538. /**
  85539. * A particle represents one of the element emitted by a particle system.
  85540. * This is mainly define by its coordinates, direction, velocity and age.
  85541. */
  85542. export class Particle {
  85543. /**
  85544. * The particle system the particle belongs to.
  85545. */
  85546. particleSystem: ParticleSystem;
  85547. private static _Count;
  85548. /**
  85549. * Unique ID of the particle
  85550. */
  85551. id: number;
  85552. /**
  85553. * The world position of the particle in the scene.
  85554. */
  85555. position: Vector3;
  85556. /**
  85557. * The world direction of the particle in the scene.
  85558. */
  85559. direction: Vector3;
  85560. /**
  85561. * The color of the particle.
  85562. */
  85563. color: Color4;
  85564. /**
  85565. * The color change of the particle per step.
  85566. */
  85567. colorStep: Color4;
  85568. /**
  85569. * Defines how long will the life of the particle be.
  85570. */
  85571. lifeTime: number;
  85572. /**
  85573. * The current age of the particle.
  85574. */
  85575. age: number;
  85576. /**
  85577. * The current size of the particle.
  85578. */
  85579. size: number;
  85580. /**
  85581. * The current scale of the particle.
  85582. */
  85583. scale: Vector2;
  85584. /**
  85585. * The current angle of the particle.
  85586. */
  85587. angle: number;
  85588. /**
  85589. * Defines how fast is the angle changing.
  85590. */
  85591. angularSpeed: number;
  85592. /**
  85593. * Defines the cell index used by the particle to be rendered from a sprite.
  85594. */
  85595. cellIndex: number;
  85596. /**
  85597. * The information required to support color remapping
  85598. */
  85599. remapData: Vector4;
  85600. /** @hidden */
  85601. _randomCellOffset?: number;
  85602. /** @hidden */
  85603. _initialDirection: Nullable<Vector3>;
  85604. /** @hidden */
  85605. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85606. /** @hidden */
  85607. _initialStartSpriteCellID: number;
  85608. /** @hidden */
  85609. _initialEndSpriteCellID: number;
  85610. /** @hidden */
  85611. _currentColorGradient: Nullable<ColorGradient>;
  85612. /** @hidden */
  85613. _currentColor1: Color4;
  85614. /** @hidden */
  85615. _currentColor2: Color4;
  85616. /** @hidden */
  85617. _currentSizeGradient: Nullable<FactorGradient>;
  85618. /** @hidden */
  85619. _currentSize1: number;
  85620. /** @hidden */
  85621. _currentSize2: number;
  85622. /** @hidden */
  85623. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85624. /** @hidden */
  85625. _currentAngularSpeed1: number;
  85626. /** @hidden */
  85627. _currentAngularSpeed2: number;
  85628. /** @hidden */
  85629. _currentVelocityGradient: Nullable<FactorGradient>;
  85630. /** @hidden */
  85631. _currentVelocity1: number;
  85632. /** @hidden */
  85633. _currentVelocity2: number;
  85634. /** @hidden */
  85635. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85636. /** @hidden */
  85637. _currentLimitVelocity1: number;
  85638. /** @hidden */
  85639. _currentLimitVelocity2: number;
  85640. /** @hidden */
  85641. _currentDragGradient: Nullable<FactorGradient>;
  85642. /** @hidden */
  85643. _currentDrag1: number;
  85644. /** @hidden */
  85645. _currentDrag2: number;
  85646. /** @hidden */
  85647. _randomNoiseCoordinates1: Vector3;
  85648. /** @hidden */
  85649. _randomNoiseCoordinates2: Vector3;
  85650. /** @hidden */
  85651. _localPosition?: Vector3;
  85652. /**
  85653. * Creates a new instance Particle
  85654. * @param particleSystem the particle system the particle belongs to
  85655. */
  85656. constructor(
  85657. /**
  85658. * The particle system the particle belongs to.
  85659. */
  85660. particleSystem: ParticleSystem);
  85661. private updateCellInfoFromSystem;
  85662. /**
  85663. * Defines how the sprite cell index is updated for the particle
  85664. */
  85665. updateCellIndex(): void;
  85666. /** @hidden */
  85667. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85668. /** @hidden */
  85669. _inheritParticleInfoToSubEmitters(): void;
  85670. /** @hidden */
  85671. _reset(): void;
  85672. /**
  85673. * Copy the properties of particle to another one.
  85674. * @param other the particle to copy the information to.
  85675. */
  85676. copyTo(other: Particle): void;
  85677. }
  85678. }
  85679. declare module BABYLON {
  85680. /**
  85681. * Particle emitter represents a volume emitting particles.
  85682. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85683. */
  85684. export interface IParticleEmitterType {
  85685. /**
  85686. * Called by the particle System when the direction is computed for the created particle.
  85687. * @param worldMatrix is the world matrix of the particle system
  85688. * @param directionToUpdate is the direction vector to update with the result
  85689. * @param particle is the particle we are computed the direction for
  85690. * @param isLocal defines if the direction should be set in local space
  85691. */
  85692. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85693. /**
  85694. * Called by the particle System when the position is computed for the created particle.
  85695. * @param worldMatrix is the world matrix of the particle system
  85696. * @param positionToUpdate is the position vector to update with the result
  85697. * @param particle is the particle we are computed the position for
  85698. * @param isLocal defines if the position should be set in local space
  85699. */
  85700. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85701. /**
  85702. * Clones the current emitter and returns a copy of it
  85703. * @returns the new emitter
  85704. */
  85705. clone(): IParticleEmitterType;
  85706. /**
  85707. * Called by the GPUParticleSystem to setup the update shader
  85708. * @param effect defines the update shader
  85709. */
  85710. applyToShader(effect: Effect): void;
  85711. /**
  85712. * Returns a string to use to update the GPU particles update shader
  85713. * @returns the effect defines string
  85714. */
  85715. getEffectDefines(): string;
  85716. /**
  85717. * Returns a string representing the class name
  85718. * @returns a string containing the class name
  85719. */
  85720. getClassName(): string;
  85721. /**
  85722. * Serializes the particle system to a JSON object.
  85723. * @returns the JSON object
  85724. */
  85725. serialize(): any;
  85726. /**
  85727. * Parse properties from a JSON object
  85728. * @param serializationObject defines the JSON object
  85729. * @param scene defines the hosting scene
  85730. */
  85731. parse(serializationObject: any, scene: Scene): void;
  85732. }
  85733. }
  85734. declare module BABYLON {
  85735. /**
  85736. * Particle emitter emitting particles from the inside of a box.
  85737. * It emits the particles randomly between 2 given directions.
  85738. */
  85739. export class BoxParticleEmitter implements IParticleEmitterType {
  85740. /**
  85741. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85742. */
  85743. direction1: Vector3;
  85744. /**
  85745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85746. */
  85747. direction2: Vector3;
  85748. /**
  85749. * 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.
  85750. */
  85751. minEmitBox: Vector3;
  85752. /**
  85753. * 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.
  85754. */
  85755. maxEmitBox: Vector3;
  85756. /**
  85757. * Creates a new instance BoxParticleEmitter
  85758. */
  85759. constructor();
  85760. /**
  85761. * Called by the particle System when the direction is computed for the created particle.
  85762. * @param worldMatrix is the world matrix of the particle system
  85763. * @param directionToUpdate is the direction vector to update with the result
  85764. * @param particle is the particle we are computed the direction for
  85765. * @param isLocal defines if the direction should be set in local space
  85766. */
  85767. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85768. /**
  85769. * Called by the particle System when the position is computed for the created particle.
  85770. * @param worldMatrix is the world matrix of the particle system
  85771. * @param positionToUpdate is the position vector to update with the result
  85772. * @param particle is the particle we are computed the position for
  85773. * @param isLocal defines if the position should be set in local space
  85774. */
  85775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85776. /**
  85777. * Clones the current emitter and returns a copy of it
  85778. * @returns the new emitter
  85779. */
  85780. clone(): BoxParticleEmitter;
  85781. /**
  85782. * Called by the GPUParticleSystem to setup the update shader
  85783. * @param effect defines the update shader
  85784. */
  85785. applyToShader(effect: Effect): void;
  85786. /**
  85787. * Returns a string to use to update the GPU particles update shader
  85788. * @returns a string containng the defines string
  85789. */
  85790. getEffectDefines(): string;
  85791. /**
  85792. * Returns the string "BoxParticleEmitter"
  85793. * @returns a string containing the class name
  85794. */
  85795. getClassName(): string;
  85796. /**
  85797. * Serializes the particle system to a JSON object.
  85798. * @returns the JSON object
  85799. */
  85800. serialize(): any;
  85801. /**
  85802. * Parse properties from a JSON object
  85803. * @param serializationObject defines the JSON object
  85804. */
  85805. parse(serializationObject: any): void;
  85806. }
  85807. }
  85808. declare module BABYLON {
  85809. /**
  85810. * Particle emitter emitting particles from the inside of a cone.
  85811. * It emits the particles alongside the cone volume from the base to the particle.
  85812. * The emission direction might be randomized.
  85813. */
  85814. export class ConeParticleEmitter implements IParticleEmitterType {
  85815. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85816. directionRandomizer: number;
  85817. private _radius;
  85818. private _angle;
  85819. private _height;
  85820. /**
  85821. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85822. */
  85823. radiusRange: number;
  85824. /**
  85825. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85826. */
  85827. heightRange: number;
  85828. /**
  85829. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85830. */
  85831. emitFromSpawnPointOnly: boolean;
  85832. /**
  85833. * Gets or sets the radius of the emission cone
  85834. */
  85835. get radius(): number;
  85836. set radius(value: number);
  85837. /**
  85838. * Gets or sets the angle of the emission cone
  85839. */
  85840. get angle(): number;
  85841. set angle(value: number);
  85842. private _buildHeight;
  85843. /**
  85844. * Creates a new instance ConeParticleEmitter
  85845. * @param radius the radius of the emission cone (1 by default)
  85846. * @param angle the cone base angle (PI by default)
  85847. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85848. */
  85849. constructor(radius?: number, angle?: number,
  85850. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85851. directionRandomizer?: number);
  85852. /**
  85853. * Called by the particle System when the direction is computed for the created particle.
  85854. * @param worldMatrix is the world matrix of the particle system
  85855. * @param directionToUpdate is the direction vector to update with the result
  85856. * @param particle is the particle we are computed the direction for
  85857. * @param isLocal defines if the direction should be set in local space
  85858. */
  85859. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85860. /**
  85861. * Called by the particle System when the position is computed for the created particle.
  85862. * @param worldMatrix is the world matrix of the particle system
  85863. * @param positionToUpdate is the position vector to update with the result
  85864. * @param particle is the particle we are computed the position for
  85865. * @param isLocal defines if the position should be set in local space
  85866. */
  85867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85868. /**
  85869. * Clones the current emitter and returns a copy of it
  85870. * @returns the new emitter
  85871. */
  85872. clone(): ConeParticleEmitter;
  85873. /**
  85874. * Called by the GPUParticleSystem to setup the update shader
  85875. * @param effect defines the update shader
  85876. */
  85877. applyToShader(effect: Effect): void;
  85878. /**
  85879. * Returns a string to use to update the GPU particles update shader
  85880. * @returns a string containng the defines string
  85881. */
  85882. getEffectDefines(): string;
  85883. /**
  85884. * Returns the string "ConeParticleEmitter"
  85885. * @returns a string containing the class name
  85886. */
  85887. getClassName(): string;
  85888. /**
  85889. * Serializes the particle system to a JSON object.
  85890. * @returns the JSON object
  85891. */
  85892. serialize(): any;
  85893. /**
  85894. * Parse properties from a JSON object
  85895. * @param serializationObject defines the JSON object
  85896. */
  85897. parse(serializationObject: any): void;
  85898. }
  85899. }
  85900. declare module BABYLON {
  85901. /**
  85902. * Particle emitter emitting particles from the inside of a cylinder.
  85903. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85904. */
  85905. export class CylinderParticleEmitter implements IParticleEmitterType {
  85906. /**
  85907. * The radius of the emission cylinder.
  85908. */
  85909. radius: number;
  85910. /**
  85911. * The height of the emission cylinder.
  85912. */
  85913. height: number;
  85914. /**
  85915. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85916. */
  85917. radiusRange: number;
  85918. /**
  85919. * How much to randomize the particle direction [0-1].
  85920. */
  85921. directionRandomizer: number;
  85922. /**
  85923. * Creates a new instance CylinderParticleEmitter
  85924. * @param radius the radius of the emission cylinder (1 by default)
  85925. * @param height the height of the emission cylinder (1 by default)
  85926. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85927. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85928. */
  85929. constructor(
  85930. /**
  85931. * The radius of the emission cylinder.
  85932. */
  85933. radius?: number,
  85934. /**
  85935. * The height of the emission cylinder.
  85936. */
  85937. height?: number,
  85938. /**
  85939. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85940. */
  85941. radiusRange?: number,
  85942. /**
  85943. * How much to randomize the particle direction [0-1].
  85944. */
  85945. directionRandomizer?: number);
  85946. /**
  85947. * Called by the particle System when the direction is computed for the created particle.
  85948. * @param worldMatrix is the world matrix of the particle system
  85949. * @param directionToUpdate is the direction vector to update with the result
  85950. * @param particle is the particle we are computed the direction for
  85951. * @param isLocal defines if the direction should be set in local space
  85952. */
  85953. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85954. /**
  85955. * Called by the particle System when the position is computed for the created particle.
  85956. * @param worldMatrix is the world matrix of the particle system
  85957. * @param positionToUpdate is the position vector to update with the result
  85958. * @param particle is the particle we are computed the position for
  85959. * @param isLocal defines if the position should be set in local space
  85960. */
  85961. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85962. /**
  85963. * Clones the current emitter and returns a copy of it
  85964. * @returns the new emitter
  85965. */
  85966. clone(): CylinderParticleEmitter;
  85967. /**
  85968. * Called by the GPUParticleSystem to setup the update shader
  85969. * @param effect defines the update shader
  85970. */
  85971. applyToShader(effect: Effect): void;
  85972. /**
  85973. * Returns a string to use to update the GPU particles update shader
  85974. * @returns a string containng the defines string
  85975. */
  85976. getEffectDefines(): string;
  85977. /**
  85978. * Returns the string "CylinderParticleEmitter"
  85979. * @returns a string containing the class name
  85980. */
  85981. getClassName(): string;
  85982. /**
  85983. * Serializes the particle system to a JSON object.
  85984. * @returns the JSON object
  85985. */
  85986. serialize(): any;
  85987. /**
  85988. * Parse properties from a JSON object
  85989. * @param serializationObject defines the JSON object
  85990. */
  85991. parse(serializationObject: any): void;
  85992. }
  85993. /**
  85994. * Particle emitter emitting particles from the inside of a cylinder.
  85995. * It emits the particles randomly between two vectors.
  85996. */
  85997. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85998. /**
  85999. * The min limit of the emission direction.
  86000. */
  86001. direction1: Vector3;
  86002. /**
  86003. * The max limit of the emission direction.
  86004. */
  86005. direction2: Vector3;
  86006. /**
  86007. * Creates a new instance CylinderDirectedParticleEmitter
  86008. * @param radius the radius of the emission cylinder (1 by default)
  86009. * @param height the height of the emission cylinder (1 by default)
  86010. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86011. * @param direction1 the min limit of the emission direction (up vector by default)
  86012. * @param direction2 the max limit of the emission direction (up vector by default)
  86013. */
  86014. constructor(radius?: number, height?: number, radiusRange?: number,
  86015. /**
  86016. * The min limit of the emission direction.
  86017. */
  86018. direction1?: Vector3,
  86019. /**
  86020. * The max limit of the emission direction.
  86021. */
  86022. direction2?: Vector3);
  86023. /**
  86024. * Called by the particle System when the direction is computed for the created particle.
  86025. * @param worldMatrix is the world matrix of the particle system
  86026. * @param directionToUpdate is the direction vector to update with the result
  86027. * @param particle is the particle we are computed the direction for
  86028. */
  86029. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86030. /**
  86031. * Clones the current emitter and returns a copy of it
  86032. * @returns the new emitter
  86033. */
  86034. clone(): CylinderDirectedParticleEmitter;
  86035. /**
  86036. * Called by the GPUParticleSystem to setup the update shader
  86037. * @param effect defines the update shader
  86038. */
  86039. applyToShader(effect: Effect): void;
  86040. /**
  86041. * Returns a string to use to update the GPU particles update shader
  86042. * @returns a string containng the defines string
  86043. */
  86044. getEffectDefines(): string;
  86045. /**
  86046. * Returns the string "CylinderDirectedParticleEmitter"
  86047. * @returns a string containing the class name
  86048. */
  86049. getClassName(): string;
  86050. /**
  86051. * Serializes the particle system to a JSON object.
  86052. * @returns the JSON object
  86053. */
  86054. serialize(): any;
  86055. /**
  86056. * Parse properties from a JSON object
  86057. * @param serializationObject defines the JSON object
  86058. */
  86059. parse(serializationObject: any): void;
  86060. }
  86061. }
  86062. declare module BABYLON {
  86063. /**
  86064. * Particle emitter emitting particles from the inside of a hemisphere.
  86065. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86066. */
  86067. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86068. /**
  86069. * The radius of the emission hemisphere.
  86070. */
  86071. radius: number;
  86072. /**
  86073. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86074. */
  86075. radiusRange: number;
  86076. /**
  86077. * How much to randomize the particle direction [0-1].
  86078. */
  86079. directionRandomizer: number;
  86080. /**
  86081. * Creates a new instance HemisphericParticleEmitter
  86082. * @param radius the radius of the emission hemisphere (1 by default)
  86083. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86084. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86085. */
  86086. constructor(
  86087. /**
  86088. * The radius of the emission hemisphere.
  86089. */
  86090. radius?: number,
  86091. /**
  86092. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86093. */
  86094. radiusRange?: number,
  86095. /**
  86096. * How much to randomize the particle direction [0-1].
  86097. */
  86098. directionRandomizer?: number);
  86099. /**
  86100. * Called by the particle System when the direction is computed for the created particle.
  86101. * @param worldMatrix is the world matrix of the particle system
  86102. * @param directionToUpdate is the direction vector to update with the result
  86103. * @param particle is the particle we are computed the direction for
  86104. * @param isLocal defines if the direction should be set in local space
  86105. */
  86106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86107. /**
  86108. * Called by the particle System when the position is computed for the created particle.
  86109. * @param worldMatrix is the world matrix of the particle system
  86110. * @param positionToUpdate is the position vector to update with the result
  86111. * @param particle is the particle we are computed the position for
  86112. * @param isLocal defines if the position should be set in local space
  86113. */
  86114. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86115. /**
  86116. * Clones the current emitter and returns a copy of it
  86117. * @returns the new emitter
  86118. */
  86119. clone(): HemisphericParticleEmitter;
  86120. /**
  86121. * Called by the GPUParticleSystem to setup the update shader
  86122. * @param effect defines the update shader
  86123. */
  86124. applyToShader(effect: Effect): void;
  86125. /**
  86126. * Returns a string to use to update the GPU particles update shader
  86127. * @returns a string containng the defines string
  86128. */
  86129. getEffectDefines(): string;
  86130. /**
  86131. * Returns the string "HemisphericParticleEmitter"
  86132. * @returns a string containing the class name
  86133. */
  86134. getClassName(): string;
  86135. /**
  86136. * Serializes the particle system to a JSON object.
  86137. * @returns the JSON object
  86138. */
  86139. serialize(): any;
  86140. /**
  86141. * Parse properties from a JSON object
  86142. * @param serializationObject defines the JSON object
  86143. */
  86144. parse(serializationObject: any): void;
  86145. }
  86146. }
  86147. declare module BABYLON {
  86148. /**
  86149. * Particle emitter emitting particles from a point.
  86150. * It emits the particles randomly between 2 given directions.
  86151. */
  86152. export class PointParticleEmitter implements IParticleEmitterType {
  86153. /**
  86154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86155. */
  86156. direction1: Vector3;
  86157. /**
  86158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86159. */
  86160. direction2: Vector3;
  86161. /**
  86162. * Creates a new instance PointParticleEmitter
  86163. */
  86164. constructor();
  86165. /**
  86166. * Called by the particle System when the direction is computed for the created particle.
  86167. * @param worldMatrix is the world matrix of the particle system
  86168. * @param directionToUpdate is the direction vector to update with the result
  86169. * @param particle is the particle we are computed the direction for
  86170. * @param isLocal defines if the direction should be set in local space
  86171. */
  86172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86173. /**
  86174. * Called by the particle System when the position is computed for the created particle.
  86175. * @param worldMatrix is the world matrix of the particle system
  86176. * @param positionToUpdate is the position vector to update with the result
  86177. * @param particle is the particle we are computed the position for
  86178. * @param isLocal defines if the position should be set in local space
  86179. */
  86180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86181. /**
  86182. * Clones the current emitter and returns a copy of it
  86183. * @returns the new emitter
  86184. */
  86185. clone(): PointParticleEmitter;
  86186. /**
  86187. * Called by the GPUParticleSystem to setup the update shader
  86188. * @param effect defines the update shader
  86189. */
  86190. applyToShader(effect: Effect): void;
  86191. /**
  86192. * Returns a string to use to update the GPU particles update shader
  86193. * @returns a string containng the defines string
  86194. */
  86195. getEffectDefines(): string;
  86196. /**
  86197. * Returns the string "PointParticleEmitter"
  86198. * @returns a string containing the class name
  86199. */
  86200. getClassName(): string;
  86201. /**
  86202. * Serializes the particle system to a JSON object.
  86203. * @returns the JSON object
  86204. */
  86205. serialize(): any;
  86206. /**
  86207. * Parse properties from a JSON object
  86208. * @param serializationObject defines the JSON object
  86209. */
  86210. parse(serializationObject: any): void;
  86211. }
  86212. }
  86213. declare module BABYLON {
  86214. /**
  86215. * Particle emitter emitting particles from the inside of a sphere.
  86216. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86217. */
  86218. export class SphereParticleEmitter implements IParticleEmitterType {
  86219. /**
  86220. * The radius of the emission sphere.
  86221. */
  86222. radius: number;
  86223. /**
  86224. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86225. */
  86226. radiusRange: number;
  86227. /**
  86228. * How much to randomize the particle direction [0-1].
  86229. */
  86230. directionRandomizer: number;
  86231. /**
  86232. * Creates a new instance SphereParticleEmitter
  86233. * @param radius the radius of the emission sphere (1 by default)
  86234. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86235. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86236. */
  86237. constructor(
  86238. /**
  86239. * The radius of the emission sphere.
  86240. */
  86241. radius?: number,
  86242. /**
  86243. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86244. */
  86245. radiusRange?: number,
  86246. /**
  86247. * How much to randomize the particle direction [0-1].
  86248. */
  86249. directionRandomizer?: number);
  86250. /**
  86251. * Called by the particle System when the direction is computed for the created particle.
  86252. * @param worldMatrix is the world matrix of the particle system
  86253. * @param directionToUpdate is the direction vector to update with the result
  86254. * @param particle is the particle we are computed the direction for
  86255. * @param isLocal defines if the direction should be set in local space
  86256. */
  86257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86258. /**
  86259. * Called by the particle System when the position is computed for the created particle.
  86260. * @param worldMatrix is the world matrix of the particle system
  86261. * @param positionToUpdate is the position vector to update with the result
  86262. * @param particle is the particle we are computed the position for
  86263. * @param isLocal defines if the position should be set in local space
  86264. */
  86265. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86266. /**
  86267. * Clones the current emitter and returns a copy of it
  86268. * @returns the new emitter
  86269. */
  86270. clone(): SphereParticleEmitter;
  86271. /**
  86272. * Called by the GPUParticleSystem to setup the update shader
  86273. * @param effect defines the update shader
  86274. */
  86275. applyToShader(effect: Effect): void;
  86276. /**
  86277. * Returns a string to use to update the GPU particles update shader
  86278. * @returns a string containng the defines string
  86279. */
  86280. getEffectDefines(): string;
  86281. /**
  86282. * Returns the string "SphereParticleEmitter"
  86283. * @returns a string containing the class name
  86284. */
  86285. getClassName(): string;
  86286. /**
  86287. * Serializes the particle system to a JSON object.
  86288. * @returns the JSON object
  86289. */
  86290. serialize(): any;
  86291. /**
  86292. * Parse properties from a JSON object
  86293. * @param serializationObject defines the JSON object
  86294. */
  86295. parse(serializationObject: any): void;
  86296. }
  86297. /**
  86298. * Particle emitter emitting particles from the inside of a sphere.
  86299. * It emits the particles randomly between two vectors.
  86300. */
  86301. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86302. /**
  86303. * The min limit of the emission direction.
  86304. */
  86305. direction1: Vector3;
  86306. /**
  86307. * The max limit of the emission direction.
  86308. */
  86309. direction2: Vector3;
  86310. /**
  86311. * Creates a new instance SphereDirectedParticleEmitter
  86312. * @param radius the radius of the emission sphere (1 by default)
  86313. * @param direction1 the min limit of the emission direction (up vector by default)
  86314. * @param direction2 the max limit of the emission direction (up vector by default)
  86315. */
  86316. constructor(radius?: number,
  86317. /**
  86318. * The min limit of the emission direction.
  86319. */
  86320. direction1?: Vector3,
  86321. /**
  86322. * The max limit of the emission direction.
  86323. */
  86324. direction2?: Vector3);
  86325. /**
  86326. * Called by the particle System when the direction is computed for the created particle.
  86327. * @param worldMatrix is the world matrix of the particle system
  86328. * @param directionToUpdate is the direction vector to update with the result
  86329. * @param particle is the particle we are computed the direction for
  86330. */
  86331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86332. /**
  86333. * Clones the current emitter and returns a copy of it
  86334. * @returns the new emitter
  86335. */
  86336. clone(): SphereDirectedParticleEmitter;
  86337. /**
  86338. * Called by the GPUParticleSystem to setup the update shader
  86339. * @param effect defines the update shader
  86340. */
  86341. applyToShader(effect: Effect): void;
  86342. /**
  86343. * Returns a string to use to update the GPU particles update shader
  86344. * @returns a string containng the defines string
  86345. */
  86346. getEffectDefines(): string;
  86347. /**
  86348. * Returns the string "SphereDirectedParticleEmitter"
  86349. * @returns a string containing the class name
  86350. */
  86351. getClassName(): string;
  86352. /**
  86353. * Serializes the particle system to a JSON object.
  86354. * @returns the JSON object
  86355. */
  86356. serialize(): any;
  86357. /**
  86358. * Parse properties from a JSON object
  86359. * @param serializationObject defines the JSON object
  86360. */
  86361. parse(serializationObject: any): void;
  86362. }
  86363. }
  86364. declare module BABYLON {
  86365. /**
  86366. * Particle emitter emitting particles from a custom list of positions.
  86367. */
  86368. export class CustomParticleEmitter implements IParticleEmitterType {
  86369. /**
  86370. * Gets or sets the position generator that will create the inital position of each particle.
  86371. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86372. */
  86373. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86374. /**
  86375. * Gets or sets the destination generator that will create the final destination of each particle.
  86376. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86377. */
  86378. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86379. /**
  86380. * Creates a new instance CustomParticleEmitter
  86381. */
  86382. constructor();
  86383. /**
  86384. * Called by the particle System when the direction is computed for the created particle.
  86385. * @param worldMatrix is the world matrix of the particle system
  86386. * @param directionToUpdate is the direction vector to update with the result
  86387. * @param particle is the particle we are computed the direction for
  86388. * @param isLocal defines if the direction should be set in local space
  86389. */
  86390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86391. /**
  86392. * Called by the particle System when the position is computed for the created particle.
  86393. * @param worldMatrix is the world matrix of the particle system
  86394. * @param positionToUpdate is the position vector to update with the result
  86395. * @param particle is the particle we are computed the position for
  86396. * @param isLocal defines if the position should be set in local space
  86397. */
  86398. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86399. /**
  86400. * Clones the current emitter and returns a copy of it
  86401. * @returns the new emitter
  86402. */
  86403. clone(): CustomParticleEmitter;
  86404. /**
  86405. * Called by the GPUParticleSystem to setup the update shader
  86406. * @param effect defines the update shader
  86407. */
  86408. applyToShader(effect: Effect): void;
  86409. /**
  86410. * Returns a string to use to update the GPU particles update shader
  86411. * @returns a string containng the defines string
  86412. */
  86413. getEffectDefines(): string;
  86414. /**
  86415. * Returns the string "PointParticleEmitter"
  86416. * @returns a string containing the class name
  86417. */
  86418. getClassName(): string;
  86419. /**
  86420. * Serializes the particle system to a JSON object.
  86421. * @returns the JSON object
  86422. */
  86423. serialize(): any;
  86424. /**
  86425. * Parse properties from a JSON object
  86426. * @param serializationObject defines the JSON object
  86427. */
  86428. parse(serializationObject: any): void;
  86429. }
  86430. }
  86431. declare module BABYLON {
  86432. /**
  86433. * Particle emitter emitting particles from the inside of a box.
  86434. * It emits the particles randomly between 2 given directions.
  86435. */
  86436. export class MeshParticleEmitter implements IParticleEmitterType {
  86437. private _indices;
  86438. private _positions;
  86439. private _normals;
  86440. private _storedNormal;
  86441. private _mesh;
  86442. /**
  86443. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86444. */
  86445. direction1: Vector3;
  86446. /**
  86447. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86448. */
  86449. direction2: Vector3;
  86450. /**
  86451. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86452. */
  86453. useMeshNormalsForDirection: boolean;
  86454. /** Defines the mesh to use as source */
  86455. get mesh(): Nullable<AbstractMesh>;
  86456. set mesh(value: Nullable<AbstractMesh>);
  86457. /**
  86458. * Creates a new instance MeshParticleEmitter
  86459. * @param mesh defines the mesh to use as source
  86460. */
  86461. constructor(mesh?: Nullable<AbstractMesh>);
  86462. /**
  86463. * Called by the particle System when the direction is computed for the created particle.
  86464. * @param worldMatrix is the world matrix of the particle system
  86465. * @param directionToUpdate is the direction vector to update with the result
  86466. * @param particle is the particle we are computed the direction for
  86467. * @param isLocal defines if the direction should be set in local space
  86468. */
  86469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86470. /**
  86471. * Called by the particle System when the position is computed for the created particle.
  86472. * @param worldMatrix is the world matrix of the particle system
  86473. * @param positionToUpdate is the position vector to update with the result
  86474. * @param particle is the particle we are computed the position for
  86475. * @param isLocal defines if the position should be set in local space
  86476. */
  86477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86478. /**
  86479. * Clones the current emitter and returns a copy of it
  86480. * @returns the new emitter
  86481. */
  86482. clone(): MeshParticleEmitter;
  86483. /**
  86484. * Called by the GPUParticleSystem to setup the update shader
  86485. * @param effect defines the update shader
  86486. */
  86487. applyToShader(effect: Effect): void;
  86488. /**
  86489. * Returns a string to use to update the GPU particles update shader
  86490. * @returns a string containng the defines string
  86491. */
  86492. getEffectDefines(): string;
  86493. /**
  86494. * Returns the string "BoxParticleEmitter"
  86495. * @returns a string containing the class name
  86496. */
  86497. getClassName(): string;
  86498. /**
  86499. * Serializes the particle system to a JSON object.
  86500. * @returns the JSON object
  86501. */
  86502. serialize(): any;
  86503. /**
  86504. * Parse properties from a JSON object
  86505. * @param serializationObject defines the JSON object
  86506. * @param scene defines the hosting scene
  86507. */
  86508. parse(serializationObject: any, scene: Scene): void;
  86509. }
  86510. }
  86511. declare module BABYLON {
  86512. /**
  86513. * Interface representing a particle system in Babylon.js.
  86514. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86515. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86516. */
  86517. export interface IParticleSystem {
  86518. /**
  86519. * List of animations used by the particle system.
  86520. */
  86521. animations: Animation[];
  86522. /**
  86523. * The id of the Particle system.
  86524. */
  86525. id: string;
  86526. /**
  86527. * The name of the Particle system.
  86528. */
  86529. name: string;
  86530. /**
  86531. * The emitter represents the Mesh or position we are attaching the particle system to.
  86532. */
  86533. emitter: Nullable<AbstractMesh | Vector3>;
  86534. /**
  86535. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86536. */
  86537. isBillboardBased: boolean;
  86538. /**
  86539. * The rendering group used by the Particle system to chose when to render.
  86540. */
  86541. renderingGroupId: number;
  86542. /**
  86543. * The layer mask we are rendering the particles through.
  86544. */
  86545. layerMask: number;
  86546. /**
  86547. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86548. */
  86549. updateSpeed: number;
  86550. /**
  86551. * The amount of time the particle system is running (depends of the overall update speed).
  86552. */
  86553. targetStopDuration: number;
  86554. /**
  86555. * The texture used to render each particle. (this can be a spritesheet)
  86556. */
  86557. particleTexture: Nullable<Texture>;
  86558. /**
  86559. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86560. */
  86561. blendMode: number;
  86562. /**
  86563. * Minimum life time of emitting particles.
  86564. */
  86565. minLifeTime: number;
  86566. /**
  86567. * Maximum life time of emitting particles.
  86568. */
  86569. maxLifeTime: number;
  86570. /**
  86571. * Minimum Size of emitting particles.
  86572. */
  86573. minSize: number;
  86574. /**
  86575. * Maximum Size of emitting particles.
  86576. */
  86577. maxSize: number;
  86578. /**
  86579. * Minimum scale of emitting particles on X axis.
  86580. */
  86581. minScaleX: number;
  86582. /**
  86583. * Maximum scale of emitting particles on X axis.
  86584. */
  86585. maxScaleX: number;
  86586. /**
  86587. * Minimum scale of emitting particles on Y axis.
  86588. */
  86589. minScaleY: number;
  86590. /**
  86591. * Maximum scale of emitting particles on Y axis.
  86592. */
  86593. maxScaleY: number;
  86594. /**
  86595. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86596. */
  86597. color1: Color4;
  86598. /**
  86599. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86600. */
  86601. color2: Color4;
  86602. /**
  86603. * Color the particle will have at the end of its lifetime.
  86604. */
  86605. colorDead: Color4;
  86606. /**
  86607. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86608. */
  86609. emitRate: number;
  86610. /**
  86611. * You can use gravity if you want to give an orientation to your particles.
  86612. */
  86613. gravity: Vector3;
  86614. /**
  86615. * Minimum power of emitting particles.
  86616. */
  86617. minEmitPower: number;
  86618. /**
  86619. * Maximum power of emitting particles.
  86620. */
  86621. maxEmitPower: number;
  86622. /**
  86623. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86624. */
  86625. minAngularSpeed: number;
  86626. /**
  86627. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86628. */
  86629. maxAngularSpeed: number;
  86630. /**
  86631. * Gets or sets the minimal initial rotation in radians.
  86632. */
  86633. minInitialRotation: number;
  86634. /**
  86635. * Gets or sets the maximal initial rotation in radians.
  86636. */
  86637. maxInitialRotation: number;
  86638. /**
  86639. * The particle emitter type defines the emitter used by the particle system.
  86640. * It can be for example box, sphere, or cone...
  86641. */
  86642. particleEmitterType: Nullable<IParticleEmitterType>;
  86643. /**
  86644. * Defines the delay in milliseconds before starting the system (0 by default)
  86645. */
  86646. startDelay: number;
  86647. /**
  86648. * 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
  86649. */
  86650. preWarmCycles: number;
  86651. /**
  86652. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86653. */
  86654. preWarmStepOffset: number;
  86655. /**
  86656. * 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)
  86657. */
  86658. spriteCellChangeSpeed: number;
  86659. /**
  86660. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86661. */
  86662. startSpriteCellID: number;
  86663. /**
  86664. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86665. */
  86666. endSpriteCellID: number;
  86667. /**
  86668. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86669. */
  86670. spriteCellWidth: number;
  86671. /**
  86672. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86673. */
  86674. spriteCellHeight: number;
  86675. /**
  86676. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86677. */
  86678. spriteRandomStartCell: boolean;
  86679. /**
  86680. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86681. */
  86682. isAnimationSheetEnabled: boolean;
  86683. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86684. translationPivot: Vector2;
  86685. /**
  86686. * Gets or sets a texture used to add random noise to particle positions
  86687. */
  86688. noiseTexture: Nullable<BaseTexture>;
  86689. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86690. noiseStrength: Vector3;
  86691. /**
  86692. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86693. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86694. */
  86695. billboardMode: number;
  86696. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86697. limitVelocityDamping: number;
  86698. /**
  86699. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86700. */
  86701. beginAnimationOnStart: boolean;
  86702. /**
  86703. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86704. */
  86705. beginAnimationFrom: number;
  86706. /**
  86707. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86708. */
  86709. beginAnimationTo: number;
  86710. /**
  86711. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86712. */
  86713. beginAnimationLoop: boolean;
  86714. /**
  86715. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86716. */
  86717. disposeOnStop: boolean;
  86718. /**
  86719. * Specifies if the particles are updated in emitter local space or world space
  86720. */
  86721. isLocal: boolean;
  86722. /**
  86723. * Gets the maximum number of particles active at the same time.
  86724. * @returns The max number of active particles.
  86725. */
  86726. getCapacity(): number;
  86727. /**
  86728. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86729. * @returns True if it has been started, otherwise false.
  86730. */
  86731. isStarted(): boolean;
  86732. /**
  86733. * Animates the particle system for this frame.
  86734. */
  86735. animate(): void;
  86736. /**
  86737. * Renders the particle system in its current state.
  86738. * @returns the current number of particles
  86739. */
  86740. render(): number;
  86741. /**
  86742. * Dispose the particle system and frees its associated resources.
  86743. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86744. */
  86745. dispose(disposeTexture?: boolean): void;
  86746. /**
  86747. * Clones the particle system.
  86748. * @param name The name of the cloned object
  86749. * @param newEmitter The new emitter to use
  86750. * @returns the cloned particle system
  86751. */
  86752. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86753. /**
  86754. * Serializes the particle system to a JSON object.
  86755. * @returns the JSON object
  86756. */
  86757. serialize(): any;
  86758. /**
  86759. * Rebuild the particle system
  86760. */
  86761. rebuild(): void;
  86762. /**
  86763. * Starts the particle system and begins to emit
  86764. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86765. */
  86766. start(delay?: number): void;
  86767. /**
  86768. * Stops the particle system.
  86769. */
  86770. stop(): void;
  86771. /**
  86772. * Remove all active particles
  86773. */
  86774. reset(): void;
  86775. /**
  86776. * Is this system ready to be used/rendered
  86777. * @return true if the system is ready
  86778. */
  86779. isReady(): boolean;
  86780. /**
  86781. * Returns the string "ParticleSystem"
  86782. * @returns a string containing the class name
  86783. */
  86784. getClassName(): string;
  86785. /**
  86786. * Adds a new color gradient
  86787. * @param gradient defines the gradient to use (between 0 and 1)
  86788. * @param color1 defines the color to affect to the specified gradient
  86789. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86790. * @returns the current particle system
  86791. */
  86792. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86793. /**
  86794. * Remove a specific color gradient
  86795. * @param gradient defines the gradient to remove
  86796. * @returns the current particle system
  86797. */
  86798. removeColorGradient(gradient: number): IParticleSystem;
  86799. /**
  86800. * Adds a new size gradient
  86801. * @param gradient defines the gradient to use (between 0 and 1)
  86802. * @param factor defines the size factor to affect to the specified gradient
  86803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86804. * @returns the current particle system
  86805. */
  86806. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86807. /**
  86808. * Remove a specific size gradient
  86809. * @param gradient defines the gradient to remove
  86810. * @returns the current particle system
  86811. */
  86812. removeSizeGradient(gradient: number): IParticleSystem;
  86813. /**
  86814. * Gets the current list of color gradients.
  86815. * You must use addColorGradient and removeColorGradient to udpate this list
  86816. * @returns the list of color gradients
  86817. */
  86818. getColorGradients(): Nullable<Array<ColorGradient>>;
  86819. /**
  86820. * Gets the current list of size gradients.
  86821. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86822. * @returns the list of size gradients
  86823. */
  86824. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86825. /**
  86826. * Gets the current list of angular speed gradients.
  86827. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86828. * @returns the list of angular speed gradients
  86829. */
  86830. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86831. /**
  86832. * Adds a new angular speed gradient
  86833. * @param gradient defines the gradient to use (between 0 and 1)
  86834. * @param factor defines the angular speed to affect to the specified gradient
  86835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86836. * @returns the current particle system
  86837. */
  86838. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86839. /**
  86840. * Remove a specific angular speed gradient
  86841. * @param gradient defines the gradient to remove
  86842. * @returns the current particle system
  86843. */
  86844. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86845. /**
  86846. * Gets the current list of velocity gradients.
  86847. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86848. * @returns the list of velocity gradients
  86849. */
  86850. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86851. /**
  86852. * Adds a new velocity gradient
  86853. * @param gradient defines the gradient to use (between 0 and 1)
  86854. * @param factor defines the velocity to affect to the specified gradient
  86855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86856. * @returns the current particle system
  86857. */
  86858. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86859. /**
  86860. * Remove a specific velocity gradient
  86861. * @param gradient defines the gradient to remove
  86862. * @returns the current particle system
  86863. */
  86864. removeVelocityGradient(gradient: number): IParticleSystem;
  86865. /**
  86866. * Gets the current list of limit velocity gradients.
  86867. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86868. * @returns the list of limit velocity gradients
  86869. */
  86870. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86871. /**
  86872. * Adds a new limit velocity gradient
  86873. * @param gradient defines the gradient to use (between 0 and 1)
  86874. * @param factor defines the limit velocity to affect to the specified gradient
  86875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86876. * @returns the current particle system
  86877. */
  86878. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86879. /**
  86880. * Remove a specific limit velocity gradient
  86881. * @param gradient defines the gradient to remove
  86882. * @returns the current particle system
  86883. */
  86884. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86885. /**
  86886. * Adds a new drag gradient
  86887. * @param gradient defines the gradient to use (between 0 and 1)
  86888. * @param factor defines the drag to affect to the specified gradient
  86889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86890. * @returns the current particle system
  86891. */
  86892. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86893. /**
  86894. * Remove a specific drag gradient
  86895. * @param gradient defines the gradient to remove
  86896. * @returns the current particle system
  86897. */
  86898. removeDragGradient(gradient: number): IParticleSystem;
  86899. /**
  86900. * Gets the current list of drag gradients.
  86901. * You must use addDragGradient and removeDragGradient to udpate this list
  86902. * @returns the list of drag gradients
  86903. */
  86904. getDragGradients(): Nullable<Array<FactorGradient>>;
  86905. /**
  86906. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86907. * @param gradient defines the gradient to use (between 0 and 1)
  86908. * @param factor defines the emit rate to affect to the specified gradient
  86909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86910. * @returns the current particle system
  86911. */
  86912. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86913. /**
  86914. * Remove a specific emit rate gradient
  86915. * @param gradient defines the gradient to remove
  86916. * @returns the current particle system
  86917. */
  86918. removeEmitRateGradient(gradient: number): IParticleSystem;
  86919. /**
  86920. * Gets the current list of emit rate gradients.
  86921. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86922. * @returns the list of emit rate gradients
  86923. */
  86924. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86925. /**
  86926. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86927. * @param gradient defines the gradient to use (between 0 and 1)
  86928. * @param factor defines the start size to affect to the specified gradient
  86929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86930. * @returns the current particle system
  86931. */
  86932. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86933. /**
  86934. * Remove a specific start size gradient
  86935. * @param gradient defines the gradient to remove
  86936. * @returns the current particle system
  86937. */
  86938. removeStartSizeGradient(gradient: number): IParticleSystem;
  86939. /**
  86940. * Gets the current list of start size gradients.
  86941. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86942. * @returns the list of start size gradients
  86943. */
  86944. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86945. /**
  86946. * Adds a new life time gradient
  86947. * @param gradient defines the gradient to use (between 0 and 1)
  86948. * @param factor defines the life time factor to affect to the specified gradient
  86949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86950. * @returns the current particle system
  86951. */
  86952. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86953. /**
  86954. * Remove a specific life time gradient
  86955. * @param gradient defines the gradient to remove
  86956. * @returns the current particle system
  86957. */
  86958. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86959. /**
  86960. * Gets the current list of life time gradients.
  86961. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86962. * @returns the list of life time gradients
  86963. */
  86964. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86965. /**
  86966. * Gets the current list of color gradients.
  86967. * You must use addColorGradient and removeColorGradient to udpate this list
  86968. * @returns the list of color gradients
  86969. */
  86970. getColorGradients(): Nullable<Array<ColorGradient>>;
  86971. /**
  86972. * Adds a new ramp gradient used to remap particle colors
  86973. * @param gradient defines the gradient to use (between 0 and 1)
  86974. * @param color defines the color to affect to the specified gradient
  86975. * @returns the current particle system
  86976. */
  86977. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86978. /**
  86979. * Gets the current list of ramp gradients.
  86980. * You must use addRampGradient and removeRampGradient to udpate this list
  86981. * @returns the list of ramp gradients
  86982. */
  86983. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86984. /** Gets or sets a boolean indicating that ramp gradients must be used
  86985. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86986. */
  86987. useRampGradients: boolean;
  86988. /**
  86989. * Adds a new color remap gradient
  86990. * @param gradient defines the gradient to use (between 0 and 1)
  86991. * @param min defines the color remap minimal range
  86992. * @param max defines the color remap maximal range
  86993. * @returns the current particle system
  86994. */
  86995. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86996. /**
  86997. * Gets the current list of color remap gradients.
  86998. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86999. * @returns the list of color remap gradients
  87000. */
  87001. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87002. /**
  87003. * Adds a new alpha remap gradient
  87004. * @param gradient defines the gradient to use (between 0 and 1)
  87005. * @param min defines the alpha remap minimal range
  87006. * @param max defines the alpha remap maximal range
  87007. * @returns the current particle system
  87008. */
  87009. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87010. /**
  87011. * Gets the current list of alpha remap gradients.
  87012. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87013. * @returns the list of alpha remap gradients
  87014. */
  87015. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87016. /**
  87017. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87018. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87019. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87020. * @returns the emitter
  87021. */
  87022. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87023. /**
  87024. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87025. * @param radius The radius of the hemisphere to emit from
  87026. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87027. * @returns the emitter
  87028. */
  87029. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87030. /**
  87031. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87032. * @param radius The radius of the sphere to emit from
  87033. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87034. * @returns the emitter
  87035. */
  87036. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87037. /**
  87038. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87039. * @param radius The radius of the sphere to emit from
  87040. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87041. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87042. * @returns the emitter
  87043. */
  87044. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87045. /**
  87046. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87047. * @param radius The radius of the emission cylinder
  87048. * @param height The height of the emission cylinder
  87049. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87050. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87051. * @returns the emitter
  87052. */
  87053. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87054. /**
  87055. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87056. * @param radius The radius of the cylinder to emit from
  87057. * @param height The height of the emission cylinder
  87058. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87059. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87060. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87061. * @returns the emitter
  87062. */
  87063. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87064. /**
  87065. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87066. * @param radius The radius of the cone to emit from
  87067. * @param angle The base angle of the cone
  87068. * @returns the emitter
  87069. */
  87070. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87071. /**
  87072. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87073. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87074. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87075. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87076. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87077. * @returns the emitter
  87078. */
  87079. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87080. /**
  87081. * Get hosting scene
  87082. * @returns the scene
  87083. */
  87084. getScene(): Scene;
  87085. }
  87086. }
  87087. declare module BABYLON {
  87088. /**
  87089. * 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.
  87090. * @see https://doc.babylonjs.com/how_to/transformnode
  87091. */
  87092. export class TransformNode extends Node {
  87093. /**
  87094. * Object will not rotate to face the camera
  87095. */
  87096. static BILLBOARDMODE_NONE: number;
  87097. /**
  87098. * Object will rotate to face the camera but only on the x axis
  87099. */
  87100. static BILLBOARDMODE_X: number;
  87101. /**
  87102. * Object will rotate to face the camera but only on the y axis
  87103. */
  87104. static BILLBOARDMODE_Y: number;
  87105. /**
  87106. * Object will rotate to face the camera but only on the z axis
  87107. */
  87108. static BILLBOARDMODE_Z: number;
  87109. /**
  87110. * Object will rotate to face the camera
  87111. */
  87112. static BILLBOARDMODE_ALL: number;
  87113. /**
  87114. * Object will rotate to face the camera's position instead of orientation
  87115. */
  87116. static BILLBOARDMODE_USE_POSITION: number;
  87117. private _forward;
  87118. private _forwardInverted;
  87119. private _up;
  87120. private _right;
  87121. private _rightInverted;
  87122. private _position;
  87123. private _rotation;
  87124. private _rotationQuaternion;
  87125. protected _scaling: Vector3;
  87126. protected _isDirty: boolean;
  87127. private _transformToBoneReferal;
  87128. private _isAbsoluteSynced;
  87129. private _billboardMode;
  87130. /**
  87131. * Gets or sets the billboard mode. Default is 0.
  87132. *
  87133. * | Value | Type | Description |
  87134. * | --- | --- | --- |
  87135. * | 0 | BILLBOARDMODE_NONE | |
  87136. * | 1 | BILLBOARDMODE_X | |
  87137. * | 2 | BILLBOARDMODE_Y | |
  87138. * | 4 | BILLBOARDMODE_Z | |
  87139. * | 7 | BILLBOARDMODE_ALL | |
  87140. *
  87141. */
  87142. get billboardMode(): number;
  87143. set billboardMode(value: number);
  87144. private _preserveParentRotationForBillboard;
  87145. /**
  87146. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87147. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87148. */
  87149. get preserveParentRotationForBillboard(): boolean;
  87150. set preserveParentRotationForBillboard(value: boolean);
  87151. /**
  87152. * 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
  87153. */
  87154. scalingDeterminant: number;
  87155. private _infiniteDistance;
  87156. /**
  87157. * Gets or sets the distance of the object to max, often used by skybox
  87158. */
  87159. get infiniteDistance(): boolean;
  87160. set infiniteDistance(value: boolean);
  87161. /**
  87162. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87163. * By default the system will update normals to compensate
  87164. */
  87165. ignoreNonUniformScaling: boolean;
  87166. /**
  87167. * 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
  87168. */
  87169. reIntegrateRotationIntoRotationQuaternion: boolean;
  87170. /** @hidden */
  87171. _poseMatrix: Nullable<Matrix>;
  87172. /** @hidden */
  87173. _localMatrix: Matrix;
  87174. private _usePivotMatrix;
  87175. private _absolutePosition;
  87176. private _absoluteScaling;
  87177. private _absoluteRotationQuaternion;
  87178. private _pivotMatrix;
  87179. private _pivotMatrixInverse;
  87180. protected _postMultiplyPivotMatrix: boolean;
  87181. protected _isWorldMatrixFrozen: boolean;
  87182. /** @hidden */
  87183. _indexInSceneTransformNodesArray: number;
  87184. /**
  87185. * An event triggered after the world matrix is updated
  87186. */
  87187. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87188. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87189. /**
  87190. * Gets a string identifying the name of the class
  87191. * @returns "TransformNode" string
  87192. */
  87193. getClassName(): string;
  87194. /**
  87195. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87196. */
  87197. get position(): Vector3;
  87198. set position(newPosition: Vector3);
  87199. /**
  87200. * 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)).
  87201. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87202. */
  87203. get rotation(): Vector3;
  87204. set rotation(newRotation: Vector3);
  87205. /**
  87206. * 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)).
  87207. */
  87208. get scaling(): Vector3;
  87209. set scaling(newScaling: Vector3);
  87210. /**
  87211. * 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).
  87212. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87213. */
  87214. get rotationQuaternion(): Nullable<Quaternion>;
  87215. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87216. /**
  87217. * The forward direction of that transform in world space.
  87218. */
  87219. get forward(): Vector3;
  87220. /**
  87221. * The up direction of that transform in world space.
  87222. */
  87223. get up(): Vector3;
  87224. /**
  87225. * The right direction of that transform in world space.
  87226. */
  87227. get right(): Vector3;
  87228. /**
  87229. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87230. * @param matrix the matrix to copy the pose from
  87231. * @returns this TransformNode.
  87232. */
  87233. updatePoseMatrix(matrix: Matrix): TransformNode;
  87234. /**
  87235. * Returns the mesh Pose matrix.
  87236. * @returns the pose matrix
  87237. */
  87238. getPoseMatrix(): Matrix;
  87239. /** @hidden */
  87240. _isSynchronized(): boolean;
  87241. /** @hidden */
  87242. _initCache(): void;
  87243. /**
  87244. * Flag the transform node as dirty (Forcing it to update everything)
  87245. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87246. * @returns this transform node
  87247. */
  87248. markAsDirty(property: string): TransformNode;
  87249. /**
  87250. * Returns the current mesh absolute position.
  87251. * Returns a Vector3.
  87252. */
  87253. get absolutePosition(): Vector3;
  87254. /**
  87255. * Returns the current mesh absolute scaling.
  87256. * Returns a Vector3.
  87257. */
  87258. get absoluteScaling(): Vector3;
  87259. /**
  87260. * Returns the current mesh absolute rotation.
  87261. * Returns a Quaternion.
  87262. */
  87263. get absoluteRotationQuaternion(): Quaternion;
  87264. /**
  87265. * Sets a new matrix to apply before all other transformation
  87266. * @param matrix defines the transform matrix
  87267. * @returns the current TransformNode
  87268. */
  87269. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87270. /**
  87271. * Sets a new pivot matrix to the current node
  87272. * @param matrix defines the new pivot matrix to use
  87273. * @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
  87274. * @returns the current TransformNode
  87275. */
  87276. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87277. /**
  87278. * Returns the mesh pivot matrix.
  87279. * Default : Identity.
  87280. * @returns the matrix
  87281. */
  87282. getPivotMatrix(): Matrix;
  87283. /**
  87284. * Instantiate (when possible) or clone that node with its hierarchy
  87285. * @param newParent defines the new parent to use for the instance (or clone)
  87286. * @param options defines options to configure how copy is done
  87287. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87288. * @returns an instance (or a clone) of the current node with its hiearchy
  87289. */
  87290. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87291. doNotInstantiate: boolean;
  87292. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87293. /**
  87294. * Prevents the World matrix to be computed any longer
  87295. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87296. * @returns the TransformNode.
  87297. */
  87298. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87299. /**
  87300. * Allows back the World matrix computation.
  87301. * @returns the TransformNode.
  87302. */
  87303. unfreezeWorldMatrix(): this;
  87304. /**
  87305. * True if the World matrix has been frozen.
  87306. */
  87307. get isWorldMatrixFrozen(): boolean;
  87308. /**
  87309. * Retuns the mesh absolute position in the World.
  87310. * @returns a Vector3.
  87311. */
  87312. getAbsolutePosition(): Vector3;
  87313. /**
  87314. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87315. * @param absolutePosition the absolute position to set
  87316. * @returns the TransformNode.
  87317. */
  87318. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87319. /**
  87320. * Sets the mesh position in its local space.
  87321. * @param vector3 the position to set in localspace
  87322. * @returns the TransformNode.
  87323. */
  87324. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87325. /**
  87326. * Returns the mesh position in the local space from the current World matrix values.
  87327. * @returns a new Vector3.
  87328. */
  87329. getPositionExpressedInLocalSpace(): Vector3;
  87330. /**
  87331. * Translates the mesh along the passed Vector3 in its local space.
  87332. * @param vector3 the distance to translate in localspace
  87333. * @returns the TransformNode.
  87334. */
  87335. locallyTranslate(vector3: Vector3): TransformNode;
  87336. private static _lookAtVectorCache;
  87337. /**
  87338. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87339. * @param targetPoint the position (must be in same space as current mesh) to look at
  87340. * @param yawCor optional yaw (y-axis) correction in radians
  87341. * @param pitchCor optional pitch (x-axis) correction in radians
  87342. * @param rollCor optional roll (z-axis) correction in radians
  87343. * @param space the choosen space of the target
  87344. * @returns the TransformNode.
  87345. */
  87346. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87347. /**
  87348. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87349. * This Vector3 is expressed in the World space.
  87350. * @param localAxis axis to rotate
  87351. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87352. */
  87353. getDirection(localAxis: Vector3): Vector3;
  87354. /**
  87355. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87356. * localAxis is expressed in the mesh local space.
  87357. * result is computed in the Wordl space from the mesh World matrix.
  87358. * @param localAxis axis to rotate
  87359. * @param result the resulting transformnode
  87360. * @returns this TransformNode.
  87361. */
  87362. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87363. /**
  87364. * Sets this transform node rotation to the given local axis.
  87365. * @param localAxis the axis in local space
  87366. * @param yawCor optional yaw (y-axis) correction in radians
  87367. * @param pitchCor optional pitch (x-axis) correction in radians
  87368. * @param rollCor optional roll (z-axis) correction in radians
  87369. * @returns this TransformNode
  87370. */
  87371. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87372. /**
  87373. * Sets a new pivot point to the current node
  87374. * @param point defines the new pivot point to use
  87375. * @param space defines if the point is in world or local space (local by default)
  87376. * @returns the current TransformNode
  87377. */
  87378. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87379. /**
  87380. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87381. * @returns the pivot point
  87382. */
  87383. getPivotPoint(): Vector3;
  87384. /**
  87385. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87386. * @param result the vector3 to store the result
  87387. * @returns this TransformNode.
  87388. */
  87389. getPivotPointToRef(result: Vector3): TransformNode;
  87390. /**
  87391. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87392. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87393. */
  87394. getAbsolutePivotPoint(): Vector3;
  87395. /**
  87396. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87397. * @param result vector3 to store the result
  87398. * @returns this TransformNode.
  87399. */
  87400. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87401. /**
  87402. * Defines the passed node as the parent of the current node.
  87403. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87404. * @see https://doc.babylonjs.com/how_to/parenting
  87405. * @param node the node ot set as the parent
  87406. * @returns this TransformNode.
  87407. */
  87408. setParent(node: Nullable<Node>): TransformNode;
  87409. private _nonUniformScaling;
  87410. /**
  87411. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87412. */
  87413. get nonUniformScaling(): boolean;
  87414. /** @hidden */
  87415. _updateNonUniformScalingState(value: boolean): boolean;
  87416. /**
  87417. * Attach the current TransformNode to another TransformNode associated with a bone
  87418. * @param bone Bone affecting the TransformNode
  87419. * @param affectedTransformNode TransformNode associated with the bone
  87420. * @returns this object
  87421. */
  87422. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87423. /**
  87424. * Detach the transform node if its associated with a bone
  87425. * @returns this object
  87426. */
  87427. detachFromBone(): TransformNode;
  87428. private static _rotationAxisCache;
  87429. /**
  87430. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87431. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87432. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87433. * The passed axis is also normalized.
  87434. * @param axis the axis to rotate around
  87435. * @param amount the amount to rotate in radians
  87436. * @param space Space to rotate in (Default: local)
  87437. * @returns the TransformNode.
  87438. */
  87439. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87440. /**
  87441. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87442. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87443. * The passed axis is also normalized. .
  87444. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87445. * @param point the point to rotate around
  87446. * @param axis the axis to rotate around
  87447. * @param amount the amount to rotate in radians
  87448. * @returns the TransformNode
  87449. */
  87450. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87451. /**
  87452. * Translates the mesh along the axis vector for the passed distance in the given space.
  87453. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87454. * @param axis the axis to translate in
  87455. * @param distance the distance to translate
  87456. * @param space Space to rotate in (Default: local)
  87457. * @returns the TransformNode.
  87458. */
  87459. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87460. /**
  87461. * Adds a rotation step to the mesh current rotation.
  87462. * x, y, z are Euler angles expressed in radians.
  87463. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87464. * This means this rotation is made in the mesh local space only.
  87465. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87466. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87467. * ```javascript
  87468. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87469. * ```
  87470. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87471. * 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.
  87472. * @param x Rotation to add
  87473. * @param y Rotation to add
  87474. * @param z Rotation to add
  87475. * @returns the TransformNode.
  87476. */
  87477. addRotation(x: number, y: number, z: number): TransformNode;
  87478. /**
  87479. * @hidden
  87480. */
  87481. protected _getEffectiveParent(): Nullable<Node>;
  87482. /**
  87483. * Computes the world matrix of the node
  87484. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87485. * @returns the world matrix
  87486. */
  87487. computeWorldMatrix(force?: boolean): Matrix;
  87488. /**
  87489. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87490. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87491. */
  87492. resetLocalMatrix(independentOfChildren?: boolean): void;
  87493. protected _afterComputeWorldMatrix(): void;
  87494. /**
  87495. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87496. * @param func callback function to add
  87497. *
  87498. * @returns the TransformNode.
  87499. */
  87500. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87501. /**
  87502. * Removes a registered callback function.
  87503. * @param func callback function to remove
  87504. * @returns the TransformNode.
  87505. */
  87506. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87507. /**
  87508. * Gets the position of the current mesh in camera space
  87509. * @param camera defines the camera to use
  87510. * @returns a position
  87511. */
  87512. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87513. /**
  87514. * Returns the distance from the mesh to the active camera
  87515. * @param camera defines the camera to use
  87516. * @returns the distance
  87517. */
  87518. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87519. /**
  87520. * Clone the current transform node
  87521. * @param name Name of the new clone
  87522. * @param newParent New parent for the clone
  87523. * @param doNotCloneChildren Do not clone children hierarchy
  87524. * @returns the new transform node
  87525. */
  87526. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87527. /**
  87528. * Serializes the objects information.
  87529. * @param currentSerializationObject defines the object to serialize in
  87530. * @returns the serialized object
  87531. */
  87532. serialize(currentSerializationObject?: any): any;
  87533. /**
  87534. * Returns a new TransformNode object parsed from the source provided.
  87535. * @param parsedTransformNode is the source.
  87536. * @param scene the scne the object belongs to
  87537. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87538. * @returns a new TransformNode object parsed from the source provided.
  87539. */
  87540. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87541. /**
  87542. * Get all child-transformNodes of this node
  87543. * @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
  87544. * @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
  87545. * @returns an array of TransformNode
  87546. */
  87547. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87548. /**
  87549. * Releases resources associated with this transform node.
  87550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87552. */
  87553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87554. /**
  87555. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87556. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87557. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87558. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87559. * @returns the current mesh
  87560. */
  87561. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87562. private _syncAbsoluteScalingAndRotation;
  87563. }
  87564. }
  87565. declare module BABYLON {
  87566. /**
  87567. * Class used to override all child animations of a given target
  87568. */
  87569. export class AnimationPropertiesOverride {
  87570. /**
  87571. * Gets or sets a value indicating if animation blending must be used
  87572. */
  87573. enableBlending: boolean;
  87574. /**
  87575. * Gets or sets the blending speed to use when enableBlending is true
  87576. */
  87577. blendingSpeed: number;
  87578. /**
  87579. * Gets or sets the default loop mode to use
  87580. */
  87581. loopMode: number;
  87582. }
  87583. }
  87584. declare module BABYLON {
  87585. /**
  87586. * Class used to store bone information
  87587. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87588. */
  87589. export class Bone extends Node {
  87590. /**
  87591. * defines the bone name
  87592. */
  87593. name: string;
  87594. private static _tmpVecs;
  87595. private static _tmpQuat;
  87596. private static _tmpMats;
  87597. /**
  87598. * Gets the list of child bones
  87599. */
  87600. children: Bone[];
  87601. /** Gets the animations associated with this bone */
  87602. animations: Animation[];
  87603. /**
  87604. * Gets or sets bone length
  87605. */
  87606. length: number;
  87607. /**
  87608. * @hidden Internal only
  87609. * Set this value to map this bone to a different index in the transform matrices
  87610. * Set this value to -1 to exclude the bone from the transform matrices
  87611. */
  87612. _index: Nullable<number>;
  87613. private _skeleton;
  87614. private _localMatrix;
  87615. private _restPose;
  87616. private _baseMatrix;
  87617. private _absoluteTransform;
  87618. private _invertedAbsoluteTransform;
  87619. private _parent;
  87620. private _scalingDeterminant;
  87621. private _worldTransform;
  87622. private _localScaling;
  87623. private _localRotation;
  87624. private _localPosition;
  87625. private _needToDecompose;
  87626. private _needToCompose;
  87627. /** @hidden */
  87628. _linkedTransformNode: Nullable<TransformNode>;
  87629. /** @hidden */
  87630. _waitingTransformNodeId: Nullable<string>;
  87631. /** @hidden */
  87632. get _matrix(): Matrix;
  87633. /** @hidden */
  87634. set _matrix(value: Matrix);
  87635. /**
  87636. * Create a new bone
  87637. * @param name defines the bone name
  87638. * @param skeleton defines the parent skeleton
  87639. * @param parentBone defines the parent (can be null if the bone is the root)
  87640. * @param localMatrix defines the local matrix
  87641. * @param restPose defines the rest pose matrix
  87642. * @param baseMatrix defines the base matrix
  87643. * @param index defines index of the bone in the hiearchy
  87644. */
  87645. constructor(
  87646. /**
  87647. * defines the bone name
  87648. */
  87649. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87650. /**
  87651. * Gets the current object class name.
  87652. * @return the class name
  87653. */
  87654. getClassName(): string;
  87655. /**
  87656. * Gets the parent skeleton
  87657. * @returns a skeleton
  87658. */
  87659. getSkeleton(): Skeleton;
  87660. /**
  87661. * Gets parent bone
  87662. * @returns a bone or null if the bone is the root of the bone hierarchy
  87663. */
  87664. getParent(): Nullable<Bone>;
  87665. /**
  87666. * Returns an array containing the root bones
  87667. * @returns an array containing the root bones
  87668. */
  87669. getChildren(): Array<Bone>;
  87670. /**
  87671. * Gets the node index in matrix array generated for rendering
  87672. * @returns the node index
  87673. */
  87674. getIndex(): number;
  87675. /**
  87676. * Sets the parent bone
  87677. * @param parent defines the parent (can be null if the bone is the root)
  87678. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87679. */
  87680. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87681. /**
  87682. * Gets the local matrix
  87683. * @returns a matrix
  87684. */
  87685. getLocalMatrix(): Matrix;
  87686. /**
  87687. * Gets the base matrix (initial matrix which remains unchanged)
  87688. * @returns a matrix
  87689. */
  87690. getBaseMatrix(): Matrix;
  87691. /**
  87692. * Gets the rest pose matrix
  87693. * @returns a matrix
  87694. */
  87695. getRestPose(): Matrix;
  87696. /**
  87697. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87698. */
  87699. getWorldMatrix(): Matrix;
  87700. /**
  87701. * Sets the local matrix to rest pose matrix
  87702. */
  87703. returnToRest(): void;
  87704. /**
  87705. * Gets the inverse of the absolute transform matrix.
  87706. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87707. * @returns a matrix
  87708. */
  87709. getInvertedAbsoluteTransform(): Matrix;
  87710. /**
  87711. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87712. * @returns a matrix
  87713. */
  87714. getAbsoluteTransform(): Matrix;
  87715. /**
  87716. * Links with the given transform node.
  87717. * The local matrix of this bone is copied from the transform node every frame.
  87718. * @param transformNode defines the transform node to link to
  87719. */
  87720. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87721. /**
  87722. * Gets the node used to drive the bone's transformation
  87723. * @returns a transform node or null
  87724. */
  87725. getTransformNode(): Nullable<TransformNode>;
  87726. /** Gets or sets current position (in local space) */
  87727. get position(): Vector3;
  87728. set position(newPosition: Vector3);
  87729. /** Gets or sets current rotation (in local space) */
  87730. get rotation(): Vector3;
  87731. set rotation(newRotation: Vector3);
  87732. /** Gets or sets current rotation quaternion (in local space) */
  87733. get rotationQuaternion(): Quaternion;
  87734. set rotationQuaternion(newRotation: Quaternion);
  87735. /** Gets or sets current scaling (in local space) */
  87736. get scaling(): Vector3;
  87737. set scaling(newScaling: Vector3);
  87738. /**
  87739. * Gets the animation properties override
  87740. */
  87741. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87742. private _decompose;
  87743. private _compose;
  87744. /**
  87745. * Update the base and local matrices
  87746. * @param matrix defines the new base or local matrix
  87747. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87748. * @param updateLocalMatrix defines if the local matrix should be updated
  87749. */
  87750. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87751. /** @hidden */
  87752. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87753. /**
  87754. * Flag the bone as dirty (Forcing it to update everything)
  87755. */
  87756. markAsDirty(): void;
  87757. /** @hidden */
  87758. _markAsDirtyAndCompose(): void;
  87759. private _markAsDirtyAndDecompose;
  87760. /**
  87761. * Translate the bone in local or world space
  87762. * @param vec The amount to translate the bone
  87763. * @param space The space that the translation is in
  87764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87765. */
  87766. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87767. /**
  87768. * Set the postion of the bone in local or world space
  87769. * @param position The position to set the bone
  87770. * @param space The space that the position is in
  87771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87772. */
  87773. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87774. /**
  87775. * Set the absolute position of the bone (world space)
  87776. * @param position The position to set the bone
  87777. * @param mesh The mesh that this bone is attached to
  87778. */
  87779. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87780. /**
  87781. * Scale the bone on the x, y and z axes (in local space)
  87782. * @param x The amount to scale the bone on the x axis
  87783. * @param y The amount to scale the bone on the y axis
  87784. * @param z The amount to scale the bone on the z axis
  87785. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87786. */
  87787. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87788. /**
  87789. * Set the bone scaling in local space
  87790. * @param scale defines the scaling vector
  87791. */
  87792. setScale(scale: Vector3): void;
  87793. /**
  87794. * Gets the current scaling in local space
  87795. * @returns the current scaling vector
  87796. */
  87797. getScale(): Vector3;
  87798. /**
  87799. * Gets the current scaling in local space and stores it in a target vector
  87800. * @param result defines the target vector
  87801. */
  87802. getScaleToRef(result: Vector3): void;
  87803. /**
  87804. * Set the yaw, pitch, and roll of the bone in local or world space
  87805. * @param yaw The rotation of the bone on the y axis
  87806. * @param pitch The rotation of the bone on the x axis
  87807. * @param roll The rotation of the bone on the z axis
  87808. * @param space The space that the axes of rotation are in
  87809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87810. */
  87811. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87812. /**
  87813. * Add a rotation to the bone on an axis in local or world space
  87814. * @param axis The axis to rotate the bone on
  87815. * @param amount The amount to rotate the bone
  87816. * @param space The space that the axis is in
  87817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87818. */
  87819. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87820. /**
  87821. * Set the rotation of the bone to a particular axis angle in local or world space
  87822. * @param axis The axis to rotate the bone on
  87823. * @param angle The angle that the bone should be rotated to
  87824. * @param space The space that the axis is in
  87825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87826. */
  87827. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87828. /**
  87829. * Set the euler rotation of the bone in local of world space
  87830. * @param rotation The euler rotation that the bone should be set to
  87831. * @param space The space that the rotation is in
  87832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87833. */
  87834. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87835. /**
  87836. * Set the quaternion rotation of the bone in local of world space
  87837. * @param quat The quaternion rotation that the bone should be set to
  87838. * @param space The space that the rotation is in
  87839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87840. */
  87841. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87842. /**
  87843. * Set the rotation matrix of the bone in local of world space
  87844. * @param rotMat The rotation matrix that the bone should be set to
  87845. * @param space The space that the rotation is in
  87846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87847. */
  87848. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87849. private _rotateWithMatrix;
  87850. private _getNegativeRotationToRef;
  87851. /**
  87852. * Get the position of the bone in local or world space
  87853. * @param space The space that the returned position is in
  87854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87855. * @returns The position of the bone
  87856. */
  87857. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87858. /**
  87859. * Copy the position of the bone to a vector3 in local or world space
  87860. * @param space The space that the returned position is in
  87861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87862. * @param result The vector3 to copy the position to
  87863. */
  87864. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87865. /**
  87866. * Get the absolute position of the bone (world space)
  87867. * @param mesh The mesh that this bone is attached to
  87868. * @returns The absolute position of the bone
  87869. */
  87870. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87871. /**
  87872. * Copy the absolute position of the bone (world space) to the result param
  87873. * @param mesh The mesh that this bone is attached to
  87874. * @param result The vector3 to copy the absolute position to
  87875. */
  87876. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87877. /**
  87878. * Compute the absolute transforms of this bone and its children
  87879. */
  87880. computeAbsoluteTransforms(): void;
  87881. /**
  87882. * Get the world direction from an axis that is in the local space of the bone
  87883. * @param localAxis The local direction that is used to compute the world direction
  87884. * @param mesh The mesh that this bone is attached to
  87885. * @returns The world direction
  87886. */
  87887. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87888. /**
  87889. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87890. * @param localAxis The local direction that is used to compute the world direction
  87891. * @param mesh The mesh that this bone is attached to
  87892. * @param result The vector3 that the world direction will be copied to
  87893. */
  87894. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87895. /**
  87896. * Get the euler rotation of the bone in local or world space
  87897. * @param space The space that the rotation should be in
  87898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87899. * @returns The euler rotation
  87900. */
  87901. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87902. /**
  87903. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87904. * @param space The space that the rotation should be in
  87905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87906. * @param result The vector3 that the rotation should be copied to
  87907. */
  87908. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87909. /**
  87910. * Get the quaternion rotation of the bone in either local or world space
  87911. * @param space The space that the rotation should be in
  87912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87913. * @returns The quaternion rotation
  87914. */
  87915. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87916. /**
  87917. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87918. * @param space The space that the rotation should be in
  87919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87920. * @param result The quaternion that the rotation should be copied to
  87921. */
  87922. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87923. /**
  87924. * Get the rotation matrix of the bone in local or world space
  87925. * @param space The space that the rotation should be in
  87926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87927. * @returns The rotation matrix
  87928. */
  87929. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87930. /**
  87931. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87932. * @param space The space that the rotation should be in
  87933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87934. * @param result The quaternion that the rotation should be copied to
  87935. */
  87936. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87937. /**
  87938. * Get the world position of a point that is in the local space of the bone
  87939. * @param position The local position
  87940. * @param mesh The mesh that this bone is attached to
  87941. * @returns The world position
  87942. */
  87943. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87944. /**
  87945. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87946. * @param position The local position
  87947. * @param mesh The mesh that this bone is attached to
  87948. * @param result The vector3 that the world position should be copied to
  87949. */
  87950. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87951. /**
  87952. * Get the local position of a point that is in world space
  87953. * @param position The world position
  87954. * @param mesh The mesh that this bone is attached to
  87955. * @returns The local position
  87956. */
  87957. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87958. /**
  87959. * Get the local position of a point that is in world space and copy it to the result param
  87960. * @param position The world position
  87961. * @param mesh The mesh that this bone is attached to
  87962. * @param result The vector3 that the local position should be copied to
  87963. */
  87964. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87965. }
  87966. }
  87967. declare module BABYLON {
  87968. /**
  87969. * Defines a runtime animation
  87970. */
  87971. export class RuntimeAnimation {
  87972. private _events;
  87973. /**
  87974. * The current frame of the runtime animation
  87975. */
  87976. private _currentFrame;
  87977. /**
  87978. * The animation used by the runtime animation
  87979. */
  87980. private _animation;
  87981. /**
  87982. * The target of the runtime animation
  87983. */
  87984. private _target;
  87985. /**
  87986. * The initiating animatable
  87987. */
  87988. private _host;
  87989. /**
  87990. * The original value of the runtime animation
  87991. */
  87992. private _originalValue;
  87993. /**
  87994. * The original blend value of the runtime animation
  87995. */
  87996. private _originalBlendValue;
  87997. /**
  87998. * The offsets cache of the runtime animation
  87999. */
  88000. private _offsetsCache;
  88001. /**
  88002. * The high limits cache of the runtime animation
  88003. */
  88004. private _highLimitsCache;
  88005. /**
  88006. * Specifies if the runtime animation has been stopped
  88007. */
  88008. private _stopped;
  88009. /**
  88010. * The blending factor of the runtime animation
  88011. */
  88012. private _blendingFactor;
  88013. /**
  88014. * The BabylonJS scene
  88015. */
  88016. private _scene;
  88017. /**
  88018. * The current value of the runtime animation
  88019. */
  88020. private _currentValue;
  88021. /** @hidden */
  88022. _animationState: _IAnimationState;
  88023. /**
  88024. * The active target of the runtime animation
  88025. */
  88026. private _activeTargets;
  88027. private _currentActiveTarget;
  88028. private _directTarget;
  88029. /**
  88030. * The target path of the runtime animation
  88031. */
  88032. private _targetPath;
  88033. /**
  88034. * The weight of the runtime animation
  88035. */
  88036. private _weight;
  88037. /**
  88038. * The ratio offset of the runtime animation
  88039. */
  88040. private _ratioOffset;
  88041. /**
  88042. * The previous delay of the runtime animation
  88043. */
  88044. private _previousDelay;
  88045. /**
  88046. * The previous ratio of the runtime animation
  88047. */
  88048. private _previousRatio;
  88049. private _enableBlending;
  88050. private _keys;
  88051. private _minFrame;
  88052. private _maxFrame;
  88053. private _minValue;
  88054. private _maxValue;
  88055. private _targetIsArray;
  88056. /**
  88057. * Gets the current frame of the runtime animation
  88058. */
  88059. get currentFrame(): number;
  88060. /**
  88061. * Gets the weight of the runtime animation
  88062. */
  88063. get weight(): number;
  88064. /**
  88065. * Gets the current value of the runtime animation
  88066. */
  88067. get currentValue(): any;
  88068. /**
  88069. * Gets the target path of the runtime animation
  88070. */
  88071. get targetPath(): string;
  88072. /**
  88073. * Gets the actual target of the runtime animation
  88074. */
  88075. get target(): any;
  88076. /** @hidden */
  88077. _onLoop: () => void;
  88078. /**
  88079. * Create a new RuntimeAnimation object
  88080. * @param target defines the target of the animation
  88081. * @param animation defines the source animation object
  88082. * @param scene defines the hosting scene
  88083. * @param host defines the initiating Animatable
  88084. */
  88085. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88086. private _preparePath;
  88087. /**
  88088. * Gets the animation from the runtime animation
  88089. */
  88090. get animation(): Animation;
  88091. /**
  88092. * Resets the runtime animation to the beginning
  88093. * @param restoreOriginal defines whether to restore the target property to the original value
  88094. */
  88095. reset(restoreOriginal?: boolean): void;
  88096. /**
  88097. * Specifies if the runtime animation is stopped
  88098. * @returns Boolean specifying if the runtime animation is stopped
  88099. */
  88100. isStopped(): boolean;
  88101. /**
  88102. * Disposes of the runtime animation
  88103. */
  88104. dispose(): void;
  88105. /**
  88106. * Apply the interpolated value to the target
  88107. * @param currentValue defines the value computed by the animation
  88108. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88109. */
  88110. setValue(currentValue: any, weight: number): void;
  88111. private _getOriginalValues;
  88112. private _setValue;
  88113. /**
  88114. * Gets the loop pmode of the runtime animation
  88115. * @returns Loop Mode
  88116. */
  88117. private _getCorrectLoopMode;
  88118. /**
  88119. * Move the current animation to a given frame
  88120. * @param frame defines the frame to move to
  88121. */
  88122. goToFrame(frame: number): void;
  88123. /**
  88124. * @hidden Internal use only
  88125. */
  88126. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88127. /**
  88128. * Execute the current animation
  88129. * @param delay defines the delay to add to the current frame
  88130. * @param from defines the lower bound of the animation range
  88131. * @param to defines the upper bound of the animation range
  88132. * @param loop defines if the current animation must loop
  88133. * @param speedRatio defines the current speed ratio
  88134. * @param weight defines the weight of the animation (default is -1 so no weight)
  88135. * @param onLoop optional callback called when animation loops
  88136. * @returns a boolean indicating if the animation is running
  88137. */
  88138. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88139. }
  88140. }
  88141. declare module BABYLON {
  88142. /**
  88143. * Class used to store an actual running animation
  88144. */
  88145. export class Animatable {
  88146. /** defines the target object */
  88147. target: any;
  88148. /** defines the starting frame number (default is 0) */
  88149. fromFrame: number;
  88150. /** defines the ending frame number (default is 100) */
  88151. toFrame: number;
  88152. /** defines if the animation must loop (default is false) */
  88153. loopAnimation: boolean;
  88154. /** defines a callback to call when animation ends if it is not looping */
  88155. onAnimationEnd?: (() => void) | null | undefined;
  88156. /** defines a callback to call when animation loops */
  88157. onAnimationLoop?: (() => void) | null | undefined;
  88158. private _localDelayOffset;
  88159. private _pausedDelay;
  88160. private _runtimeAnimations;
  88161. private _paused;
  88162. private _scene;
  88163. private _speedRatio;
  88164. private _weight;
  88165. private _syncRoot;
  88166. /**
  88167. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88168. * This will only apply for non looping animation (default is true)
  88169. */
  88170. disposeOnEnd: boolean;
  88171. /**
  88172. * Gets a boolean indicating if the animation has started
  88173. */
  88174. animationStarted: boolean;
  88175. /**
  88176. * Observer raised when the animation ends
  88177. */
  88178. onAnimationEndObservable: Observable<Animatable>;
  88179. /**
  88180. * Observer raised when the animation loops
  88181. */
  88182. onAnimationLoopObservable: Observable<Animatable>;
  88183. /**
  88184. * Gets the root Animatable used to synchronize and normalize animations
  88185. */
  88186. get syncRoot(): Nullable<Animatable>;
  88187. /**
  88188. * Gets the current frame of the first RuntimeAnimation
  88189. * Used to synchronize Animatables
  88190. */
  88191. get masterFrame(): number;
  88192. /**
  88193. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88194. */
  88195. get weight(): number;
  88196. set weight(value: number);
  88197. /**
  88198. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88199. */
  88200. get speedRatio(): number;
  88201. set speedRatio(value: number);
  88202. /**
  88203. * Creates a new Animatable
  88204. * @param scene defines the hosting scene
  88205. * @param target defines the target object
  88206. * @param fromFrame defines the starting frame number (default is 0)
  88207. * @param toFrame defines the ending frame number (default is 100)
  88208. * @param loopAnimation defines if the animation must loop (default is false)
  88209. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88210. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88211. * @param animations defines a group of animation to add to the new Animatable
  88212. * @param onAnimationLoop defines a callback to call when animation loops
  88213. */
  88214. constructor(scene: Scene,
  88215. /** defines the target object */
  88216. target: any,
  88217. /** defines the starting frame number (default is 0) */
  88218. fromFrame?: number,
  88219. /** defines the ending frame number (default is 100) */
  88220. toFrame?: number,
  88221. /** defines if the animation must loop (default is false) */
  88222. loopAnimation?: boolean, speedRatio?: number,
  88223. /** defines a callback to call when animation ends if it is not looping */
  88224. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88225. /** defines a callback to call when animation loops */
  88226. onAnimationLoop?: (() => void) | null | undefined);
  88227. /**
  88228. * Synchronize and normalize current Animatable with a source Animatable
  88229. * This is useful when using animation weights and when animations are not of the same length
  88230. * @param root defines the root Animatable to synchronize with
  88231. * @returns the current Animatable
  88232. */
  88233. syncWith(root: Animatable): Animatable;
  88234. /**
  88235. * Gets the list of runtime animations
  88236. * @returns an array of RuntimeAnimation
  88237. */
  88238. getAnimations(): RuntimeAnimation[];
  88239. /**
  88240. * Adds more animations to the current animatable
  88241. * @param target defines the target of the animations
  88242. * @param animations defines the new animations to add
  88243. */
  88244. appendAnimations(target: any, animations: Animation[]): void;
  88245. /**
  88246. * Gets the source animation for a specific property
  88247. * @param property defines the propertyu to look for
  88248. * @returns null or the source animation for the given property
  88249. */
  88250. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88251. /**
  88252. * Gets the runtime animation for a specific property
  88253. * @param property defines the propertyu to look for
  88254. * @returns null or the runtime animation for the given property
  88255. */
  88256. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88257. /**
  88258. * Resets the animatable to its original state
  88259. */
  88260. reset(): void;
  88261. /**
  88262. * Allows the animatable to blend with current running animations
  88263. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88264. * @param blendingSpeed defines the blending speed to use
  88265. */
  88266. enableBlending(blendingSpeed: number): void;
  88267. /**
  88268. * Disable animation blending
  88269. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88270. */
  88271. disableBlending(): void;
  88272. /**
  88273. * Jump directly to a given frame
  88274. * @param frame defines the frame to jump to
  88275. */
  88276. goToFrame(frame: number): void;
  88277. /**
  88278. * Pause the animation
  88279. */
  88280. pause(): void;
  88281. /**
  88282. * Restart the animation
  88283. */
  88284. restart(): void;
  88285. private _raiseOnAnimationEnd;
  88286. /**
  88287. * Stop and delete the current animation
  88288. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88289. * @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)
  88290. */
  88291. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88292. /**
  88293. * Wait asynchronously for the animation to end
  88294. * @returns a promise which will be fullfilled when the animation ends
  88295. */
  88296. waitAsync(): Promise<Animatable>;
  88297. /** @hidden */
  88298. _animate(delay: number): boolean;
  88299. }
  88300. interface Scene {
  88301. /** @hidden */
  88302. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88303. /** @hidden */
  88304. _processLateAnimationBindingsForMatrices(holder: {
  88305. totalWeight: number;
  88306. animations: RuntimeAnimation[];
  88307. originalValue: Matrix;
  88308. }): any;
  88309. /** @hidden */
  88310. _processLateAnimationBindingsForQuaternions(holder: {
  88311. totalWeight: number;
  88312. animations: RuntimeAnimation[];
  88313. originalValue: Quaternion;
  88314. }, refQuaternion: Quaternion): Quaternion;
  88315. /** @hidden */
  88316. _processLateAnimationBindings(): void;
  88317. /**
  88318. * Will start the animation sequence of a given target
  88319. * @param target defines the target
  88320. * @param from defines from which frame should animation start
  88321. * @param to defines until which frame should animation run.
  88322. * @param weight defines the weight to apply to the animation (1.0 by default)
  88323. * @param loop defines if the animation loops
  88324. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88325. * @param onAnimationEnd defines the function to be executed when the animation ends
  88326. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88327. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88328. * @param onAnimationLoop defines the callback to call when an animation loops
  88329. * @returns the animatable object created for this animation
  88330. */
  88331. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88332. /**
  88333. * Will start the animation sequence of a given target
  88334. * @param target defines the target
  88335. * @param from defines from which frame should animation start
  88336. * @param to defines until which frame should animation run.
  88337. * @param loop defines if the animation loops
  88338. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88339. * @param onAnimationEnd defines the function to be executed when the animation ends
  88340. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88341. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88342. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88343. * @param onAnimationLoop defines the callback to call when an animation loops
  88344. * @returns the animatable object created for this animation
  88345. */
  88346. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88347. /**
  88348. * Will start the animation sequence of a given target and its hierarchy
  88349. * @param target defines the target
  88350. * @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.
  88351. * @param from defines from which frame should animation start
  88352. * @param to defines until which frame should animation run.
  88353. * @param loop defines if the animation loops
  88354. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88355. * @param onAnimationEnd defines the function to be executed when the animation ends
  88356. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88357. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88358. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88359. * @param onAnimationLoop defines the callback to call when an animation loops
  88360. * @returns the list of created animatables
  88361. */
  88362. 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): Animatable[];
  88363. /**
  88364. * Begin a new animation on a given node
  88365. * @param target defines the target where the animation will take place
  88366. * @param animations defines the list of animations to start
  88367. * @param from defines the initial value
  88368. * @param to defines the final value
  88369. * @param loop defines if you want animation to loop (off by default)
  88370. * @param speedRatio defines the speed ratio to apply to all animations
  88371. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88372. * @param onAnimationLoop defines the callback to call when an animation loops
  88373. * @returns the list of created animatables
  88374. */
  88375. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88376. /**
  88377. * Begin a new animation on a given node and its hierarchy
  88378. * @param target defines the root node where the animation will take place
  88379. * @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.
  88380. * @param animations defines the list of animations to start
  88381. * @param from defines the initial value
  88382. * @param to defines the final value
  88383. * @param loop defines if you want animation to loop (off by default)
  88384. * @param speedRatio defines the speed ratio to apply to all animations
  88385. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88386. * @param onAnimationLoop defines the callback to call when an animation loops
  88387. * @returns the list of animatables created for all nodes
  88388. */
  88389. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88390. /**
  88391. * Gets the animatable associated with a specific target
  88392. * @param target defines the target of the animatable
  88393. * @returns the required animatable if found
  88394. */
  88395. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88396. /**
  88397. * Gets all animatables associated with a given target
  88398. * @param target defines the target to look animatables for
  88399. * @returns an array of Animatables
  88400. */
  88401. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88402. /**
  88403. * Stops and removes all animations that have been applied to the scene
  88404. */
  88405. stopAllAnimations(): void;
  88406. /**
  88407. * Gets the current delta time used by animation engine
  88408. */
  88409. deltaTime: number;
  88410. }
  88411. interface Bone {
  88412. /**
  88413. * Copy an animation range from another bone
  88414. * @param source defines the source bone
  88415. * @param rangeName defines the range name to copy
  88416. * @param frameOffset defines the frame offset
  88417. * @param rescaleAsRequired defines if rescaling must be applied if required
  88418. * @param skelDimensionsRatio defines the scaling ratio
  88419. * @returns true if operation was successful
  88420. */
  88421. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88422. }
  88423. }
  88424. declare module BABYLON {
  88425. /**
  88426. * Class used to handle skinning animations
  88427. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88428. */
  88429. export class Skeleton implements IAnimatable {
  88430. /** defines the skeleton name */
  88431. name: string;
  88432. /** defines the skeleton Id */
  88433. id: string;
  88434. /**
  88435. * Defines the list of child bones
  88436. */
  88437. bones: Bone[];
  88438. /**
  88439. * Defines an estimate of the dimension of the skeleton at rest
  88440. */
  88441. dimensionsAtRest: Vector3;
  88442. /**
  88443. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88444. */
  88445. needInitialSkinMatrix: boolean;
  88446. /**
  88447. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88448. */
  88449. overrideMesh: Nullable<AbstractMesh>;
  88450. /**
  88451. * Gets the list of animations attached to this skeleton
  88452. */
  88453. animations: Array<Animation>;
  88454. private _scene;
  88455. private _isDirty;
  88456. private _transformMatrices;
  88457. private _transformMatrixTexture;
  88458. private _meshesWithPoseMatrix;
  88459. private _animatables;
  88460. private _identity;
  88461. private _synchronizedWithMesh;
  88462. private _ranges;
  88463. private _lastAbsoluteTransformsUpdateId;
  88464. private _canUseTextureForBones;
  88465. private _uniqueId;
  88466. /** @hidden */
  88467. _numBonesWithLinkedTransformNode: number;
  88468. /** @hidden */
  88469. _hasWaitingData: Nullable<boolean>;
  88470. /**
  88471. * Specifies if the skeleton should be serialized
  88472. */
  88473. doNotSerialize: boolean;
  88474. private _useTextureToStoreBoneMatrices;
  88475. /**
  88476. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88477. * Please note that this option is not available if the hardware does not support it
  88478. */
  88479. get useTextureToStoreBoneMatrices(): boolean;
  88480. set useTextureToStoreBoneMatrices(value: boolean);
  88481. private _animationPropertiesOverride;
  88482. /**
  88483. * Gets or sets the animation properties override
  88484. */
  88485. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88486. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88487. /**
  88488. * List of inspectable custom properties (used by the Inspector)
  88489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88490. */
  88491. inspectableCustomProperties: IInspectable[];
  88492. /**
  88493. * An observable triggered before computing the skeleton's matrices
  88494. */
  88495. onBeforeComputeObservable: Observable<Skeleton>;
  88496. /**
  88497. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88498. */
  88499. get isUsingTextureForMatrices(): boolean;
  88500. /**
  88501. * Gets the unique ID of this skeleton
  88502. */
  88503. get uniqueId(): number;
  88504. /**
  88505. * Creates a new skeleton
  88506. * @param name defines the skeleton name
  88507. * @param id defines the skeleton Id
  88508. * @param scene defines the hosting scene
  88509. */
  88510. constructor(
  88511. /** defines the skeleton name */
  88512. name: string,
  88513. /** defines the skeleton Id */
  88514. id: string, scene: Scene);
  88515. /**
  88516. * Gets the current object class name.
  88517. * @return the class name
  88518. */
  88519. getClassName(): string;
  88520. /**
  88521. * Returns an array containing the root bones
  88522. * @returns an array containing the root bones
  88523. */
  88524. getChildren(): Array<Bone>;
  88525. /**
  88526. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88527. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88528. * @returns a Float32Array containing matrices data
  88529. */
  88530. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88531. /**
  88532. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88533. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88534. * @returns a raw texture containing the data
  88535. */
  88536. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88537. /**
  88538. * Gets the current hosting scene
  88539. * @returns a scene object
  88540. */
  88541. getScene(): Scene;
  88542. /**
  88543. * Gets a string representing the current skeleton data
  88544. * @param fullDetails defines a boolean indicating if we want a verbose version
  88545. * @returns a string representing the current skeleton data
  88546. */
  88547. toString(fullDetails?: boolean): string;
  88548. /**
  88549. * Get bone's index searching by name
  88550. * @param name defines bone's name to search for
  88551. * @return the indice of the bone. Returns -1 if not found
  88552. */
  88553. getBoneIndexByName(name: string): number;
  88554. /**
  88555. * Creater a new animation range
  88556. * @param name defines the name of the range
  88557. * @param from defines the start key
  88558. * @param to defines the end key
  88559. */
  88560. createAnimationRange(name: string, from: number, to: number): void;
  88561. /**
  88562. * Delete a specific animation range
  88563. * @param name defines the name of the range
  88564. * @param deleteFrames defines if frames must be removed as well
  88565. */
  88566. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88567. /**
  88568. * Gets a specific animation range
  88569. * @param name defines the name of the range to look for
  88570. * @returns the requested animation range or null if not found
  88571. */
  88572. getAnimationRange(name: string): Nullable<AnimationRange>;
  88573. /**
  88574. * Gets the list of all animation ranges defined on this skeleton
  88575. * @returns an array
  88576. */
  88577. getAnimationRanges(): Nullable<AnimationRange>[];
  88578. /**
  88579. * Copy animation range from a source skeleton.
  88580. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88581. * @param source defines the source skeleton
  88582. * @param name defines the name of the range to copy
  88583. * @param rescaleAsRequired defines if rescaling must be applied if required
  88584. * @returns true if operation was successful
  88585. */
  88586. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88587. /**
  88588. * Forces the skeleton to go to rest pose
  88589. */
  88590. returnToRest(): void;
  88591. private _getHighestAnimationFrame;
  88592. /**
  88593. * Begin a specific animation range
  88594. * @param name defines the name of the range to start
  88595. * @param loop defines if looping must be turned on (false by default)
  88596. * @param speedRatio defines the speed ratio to apply (1 by default)
  88597. * @param onAnimationEnd defines a callback which will be called when animation will end
  88598. * @returns a new animatable
  88599. */
  88600. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88601. /** @hidden */
  88602. _markAsDirty(): void;
  88603. /** @hidden */
  88604. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88605. /** @hidden */
  88606. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88607. private _computeTransformMatrices;
  88608. /**
  88609. * Build all resources required to render a skeleton
  88610. */
  88611. prepare(): void;
  88612. /**
  88613. * Gets the list of animatables currently running for this skeleton
  88614. * @returns an array of animatables
  88615. */
  88616. getAnimatables(): IAnimatable[];
  88617. /**
  88618. * Clone the current skeleton
  88619. * @param name defines the name of the new skeleton
  88620. * @param id defines the id of the new skeleton
  88621. * @returns the new skeleton
  88622. */
  88623. clone(name: string, id?: string): Skeleton;
  88624. /**
  88625. * Enable animation blending for this skeleton
  88626. * @param blendingSpeed defines the blending speed to apply
  88627. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88628. */
  88629. enableBlending(blendingSpeed?: number): void;
  88630. /**
  88631. * Releases all resources associated with the current skeleton
  88632. */
  88633. dispose(): void;
  88634. /**
  88635. * Serialize the skeleton in a JSON object
  88636. * @returns a JSON object
  88637. */
  88638. serialize(): any;
  88639. /**
  88640. * Creates a new skeleton from serialized data
  88641. * @param parsedSkeleton defines the serialized data
  88642. * @param scene defines the hosting scene
  88643. * @returns a new skeleton
  88644. */
  88645. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88646. /**
  88647. * Compute all node absolute transforms
  88648. * @param forceUpdate defines if computation must be done even if cache is up to date
  88649. */
  88650. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88651. /**
  88652. * Gets the root pose matrix
  88653. * @returns a matrix
  88654. */
  88655. getPoseMatrix(): Nullable<Matrix>;
  88656. /**
  88657. * Sorts bones per internal index
  88658. */
  88659. sortBones(): void;
  88660. private _sortBones;
  88661. }
  88662. }
  88663. declare module BABYLON {
  88664. /**
  88665. * Creates an instance based on a source mesh.
  88666. */
  88667. export class InstancedMesh extends AbstractMesh {
  88668. private _sourceMesh;
  88669. private _currentLOD;
  88670. /** @hidden */
  88671. _indexInSourceMeshInstanceArray: number;
  88672. constructor(name: string, source: Mesh);
  88673. /**
  88674. * Returns the string "InstancedMesh".
  88675. */
  88676. getClassName(): string;
  88677. /** Gets the list of lights affecting that mesh */
  88678. get lightSources(): Light[];
  88679. _resyncLightSources(): void;
  88680. _resyncLightSource(light: Light): void;
  88681. _removeLightSource(light: Light, dispose: boolean): void;
  88682. /**
  88683. * If the source mesh receives shadows
  88684. */
  88685. get receiveShadows(): boolean;
  88686. /**
  88687. * The material of the source mesh
  88688. */
  88689. get material(): Nullable<Material>;
  88690. /**
  88691. * Visibility of the source mesh
  88692. */
  88693. get visibility(): number;
  88694. /**
  88695. * Skeleton of the source mesh
  88696. */
  88697. get skeleton(): Nullable<Skeleton>;
  88698. /**
  88699. * Rendering ground id of the source mesh
  88700. */
  88701. get renderingGroupId(): number;
  88702. set renderingGroupId(value: number);
  88703. /**
  88704. * Returns the total number of vertices (integer).
  88705. */
  88706. getTotalVertices(): number;
  88707. /**
  88708. * Returns a positive integer : the total number of indices in this mesh geometry.
  88709. * @returns the numner of indices or zero if the mesh has no geometry.
  88710. */
  88711. getTotalIndices(): number;
  88712. /**
  88713. * The source mesh of the instance
  88714. */
  88715. get sourceMesh(): Mesh;
  88716. /**
  88717. * Is this node ready to be used/rendered
  88718. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88719. * @return {boolean} is it ready
  88720. */
  88721. isReady(completeCheck?: boolean): boolean;
  88722. /**
  88723. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88724. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88725. * @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.
  88726. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88727. */
  88728. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88729. /**
  88730. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88731. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88732. * The `data` are either a numeric array either a Float32Array.
  88733. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88734. * 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).
  88735. * Note that a new underlying VertexBuffer object is created each call.
  88736. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88737. *
  88738. * Possible `kind` values :
  88739. * - VertexBuffer.PositionKind
  88740. * - VertexBuffer.UVKind
  88741. * - VertexBuffer.UV2Kind
  88742. * - VertexBuffer.UV3Kind
  88743. * - VertexBuffer.UV4Kind
  88744. * - VertexBuffer.UV5Kind
  88745. * - VertexBuffer.UV6Kind
  88746. * - VertexBuffer.ColorKind
  88747. * - VertexBuffer.MatricesIndicesKind
  88748. * - VertexBuffer.MatricesIndicesExtraKind
  88749. * - VertexBuffer.MatricesWeightsKind
  88750. * - VertexBuffer.MatricesWeightsExtraKind
  88751. *
  88752. * Returns the Mesh.
  88753. */
  88754. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88755. /**
  88756. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88757. * If the mesh has no geometry, it is simply returned as it is.
  88758. * The `data` are either a numeric array either a Float32Array.
  88759. * No new underlying VertexBuffer object is created.
  88760. * 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.
  88761. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88762. *
  88763. * Possible `kind` values :
  88764. * - VertexBuffer.PositionKind
  88765. * - VertexBuffer.UVKind
  88766. * - VertexBuffer.UV2Kind
  88767. * - VertexBuffer.UV3Kind
  88768. * - VertexBuffer.UV4Kind
  88769. * - VertexBuffer.UV5Kind
  88770. * - VertexBuffer.UV6Kind
  88771. * - VertexBuffer.ColorKind
  88772. * - VertexBuffer.MatricesIndicesKind
  88773. * - VertexBuffer.MatricesIndicesExtraKind
  88774. * - VertexBuffer.MatricesWeightsKind
  88775. * - VertexBuffer.MatricesWeightsExtraKind
  88776. *
  88777. * Returns the Mesh.
  88778. */
  88779. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88780. /**
  88781. * Sets the mesh indices.
  88782. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88783. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88784. * This method creates a new index buffer each call.
  88785. * Returns the Mesh.
  88786. */
  88787. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88788. /**
  88789. * Boolean : True if the mesh owns the requested kind of data.
  88790. */
  88791. isVerticesDataPresent(kind: string): boolean;
  88792. /**
  88793. * Returns an array of indices (IndicesArray).
  88794. */
  88795. getIndices(): Nullable<IndicesArray>;
  88796. get _positions(): Nullable<Vector3[]>;
  88797. /**
  88798. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88799. * This means the mesh underlying bounding box and sphere are recomputed.
  88800. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88801. * @returns the current mesh
  88802. */
  88803. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88804. /** @hidden */
  88805. _preActivate(): InstancedMesh;
  88806. /** @hidden */
  88807. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88808. /** @hidden */
  88809. _postActivate(): void;
  88810. getWorldMatrix(): Matrix;
  88811. get isAnInstance(): boolean;
  88812. /**
  88813. * Returns the current associated LOD AbstractMesh.
  88814. */
  88815. getLOD(camera: Camera): AbstractMesh;
  88816. /** @hidden */
  88817. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88818. /** @hidden */
  88819. _syncSubMeshes(): InstancedMesh;
  88820. /** @hidden */
  88821. _generatePointsArray(): boolean;
  88822. /**
  88823. * Creates a new InstancedMesh from the current mesh.
  88824. * - name (string) : the cloned mesh name
  88825. * - newParent (optional Node) : the optional Node to parent the clone to.
  88826. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88827. *
  88828. * Returns the clone.
  88829. */
  88830. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88831. /**
  88832. * Disposes the InstancedMesh.
  88833. * Returns nothing.
  88834. */
  88835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88836. }
  88837. interface Mesh {
  88838. /**
  88839. * Register a custom buffer that will be instanced
  88840. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88841. * @param kind defines the buffer kind
  88842. * @param stride defines the stride in floats
  88843. */
  88844. registerInstancedBuffer(kind: string, stride: number): void;
  88845. /** @hidden */
  88846. _userInstancedBuffersStorage: {
  88847. data: {
  88848. [key: string]: Float32Array;
  88849. };
  88850. sizes: {
  88851. [key: string]: number;
  88852. };
  88853. vertexBuffers: {
  88854. [key: string]: Nullable<VertexBuffer>;
  88855. };
  88856. strides: {
  88857. [key: string]: number;
  88858. };
  88859. };
  88860. }
  88861. interface AbstractMesh {
  88862. /**
  88863. * Object used to store instanced buffers defined by user
  88864. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88865. */
  88866. instancedBuffers: {
  88867. [key: string]: any;
  88868. };
  88869. }
  88870. }
  88871. declare module BABYLON {
  88872. /**
  88873. * Defines the options associated with the creation of a shader material.
  88874. */
  88875. export interface IShaderMaterialOptions {
  88876. /**
  88877. * Does the material work in alpha blend mode
  88878. */
  88879. needAlphaBlending: boolean;
  88880. /**
  88881. * Does the material work in alpha test mode
  88882. */
  88883. needAlphaTesting: boolean;
  88884. /**
  88885. * The list of attribute names used in the shader
  88886. */
  88887. attributes: string[];
  88888. /**
  88889. * The list of unifrom names used in the shader
  88890. */
  88891. uniforms: string[];
  88892. /**
  88893. * The list of UBO names used in the shader
  88894. */
  88895. uniformBuffers: string[];
  88896. /**
  88897. * The list of sampler names used in the shader
  88898. */
  88899. samplers: string[];
  88900. /**
  88901. * The list of defines used in the shader
  88902. */
  88903. defines: string[];
  88904. }
  88905. /**
  88906. * 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.
  88907. *
  88908. * This returned material effects how the mesh will look based on the code in the shaders.
  88909. *
  88910. * @see http://doc.babylonjs.com/how_to/shader_material
  88911. */
  88912. export class ShaderMaterial extends Material {
  88913. private _shaderPath;
  88914. private _options;
  88915. private _textures;
  88916. private _textureArrays;
  88917. private _floats;
  88918. private _ints;
  88919. private _floatsArrays;
  88920. private _colors3;
  88921. private _colors3Arrays;
  88922. private _colors4;
  88923. private _colors4Arrays;
  88924. private _vectors2;
  88925. private _vectors3;
  88926. private _vectors4;
  88927. private _matrices;
  88928. private _matrixArrays;
  88929. private _matrices3x3;
  88930. private _matrices2x2;
  88931. private _vectors2Arrays;
  88932. private _vectors3Arrays;
  88933. private _vectors4Arrays;
  88934. private _cachedWorldViewMatrix;
  88935. private _cachedWorldViewProjectionMatrix;
  88936. private _renderId;
  88937. private _multiview;
  88938. /**
  88939. * Instantiate a new shader material.
  88940. * 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.
  88941. * This returned material effects how the mesh will look based on the code in the shaders.
  88942. * @see http://doc.babylonjs.com/how_to/shader_material
  88943. * @param name Define the name of the material in the scene
  88944. * @param scene Define the scene the material belongs to
  88945. * @param shaderPath Defines the route to the shader code in one of three ways:
  88946. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88947. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88948. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88949. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88950. * @param options Define the options used to create the shader
  88951. */
  88952. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88953. /**
  88954. * Gets the shader path used to define the shader code
  88955. * It can be modified to trigger a new compilation
  88956. */
  88957. get shaderPath(): any;
  88958. /**
  88959. * Sets the shader path used to define the shader code
  88960. * It can be modified to trigger a new compilation
  88961. */
  88962. set shaderPath(shaderPath: any);
  88963. /**
  88964. * Gets the options used to compile the shader.
  88965. * They can be modified to trigger a new compilation
  88966. */
  88967. get options(): IShaderMaterialOptions;
  88968. /**
  88969. * Gets the current class name of the material e.g. "ShaderMaterial"
  88970. * Mainly use in serialization.
  88971. * @returns the class name
  88972. */
  88973. getClassName(): string;
  88974. /**
  88975. * Specifies if the material will require alpha blending
  88976. * @returns a boolean specifying if alpha blending is needed
  88977. */
  88978. needAlphaBlending(): boolean;
  88979. /**
  88980. * Specifies if this material should be rendered in alpha test mode
  88981. * @returns a boolean specifying if an alpha test is needed.
  88982. */
  88983. needAlphaTesting(): boolean;
  88984. private _checkUniform;
  88985. /**
  88986. * Set a texture in the shader.
  88987. * @param name Define the name of the uniform samplers as defined in the shader
  88988. * @param texture Define the texture to bind to this sampler
  88989. * @return the material itself allowing "fluent" like uniform updates
  88990. */
  88991. setTexture(name: string, texture: Texture): ShaderMaterial;
  88992. /**
  88993. * Set a texture array in the shader.
  88994. * @param name Define the name of the uniform sampler array as defined in the shader
  88995. * @param textures Define the list of textures to bind to this sampler
  88996. * @return the material itself allowing "fluent" like uniform updates
  88997. */
  88998. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88999. /**
  89000. * Set a float in the shader.
  89001. * @param name Define the name of the uniform as defined in the shader
  89002. * @param value Define the value to give to the uniform
  89003. * @return the material itself allowing "fluent" like uniform updates
  89004. */
  89005. setFloat(name: string, value: number): ShaderMaterial;
  89006. /**
  89007. * Set a int in the shader.
  89008. * @param name Define the name of the uniform as defined in the shader
  89009. * @param value Define the value to give to the uniform
  89010. * @return the material itself allowing "fluent" like uniform updates
  89011. */
  89012. setInt(name: string, value: number): ShaderMaterial;
  89013. /**
  89014. * Set an array of floats in the shader.
  89015. * @param name Define the name of the uniform as defined in the shader
  89016. * @param value Define the value to give to the uniform
  89017. * @return the material itself allowing "fluent" like uniform updates
  89018. */
  89019. setFloats(name: string, value: number[]): ShaderMaterial;
  89020. /**
  89021. * Set a vec3 in the shader from a Color3.
  89022. * @param name Define the name of the uniform as defined in the shader
  89023. * @param value Define the value to give to the uniform
  89024. * @return the material itself allowing "fluent" like uniform updates
  89025. */
  89026. setColor3(name: string, value: Color3): ShaderMaterial;
  89027. /**
  89028. * Set a vec3 array in the shader from a Color3 array.
  89029. * @param name Define the name of the uniform as defined in the shader
  89030. * @param value Define the value to give to the uniform
  89031. * @return the material itself allowing "fluent" like uniform updates
  89032. */
  89033. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89034. /**
  89035. * Set a vec4 in the shader from a Color4.
  89036. * @param name Define the name of the uniform as defined in the shader
  89037. * @param value Define the value to give to the uniform
  89038. * @return the material itself allowing "fluent" like uniform updates
  89039. */
  89040. setColor4(name: string, value: Color4): ShaderMaterial;
  89041. /**
  89042. * Set a vec4 array in the shader from a Color4 array.
  89043. * @param name Define the name of the uniform as defined in the shader
  89044. * @param value Define the value to give to the uniform
  89045. * @return the material itself allowing "fluent" like uniform updates
  89046. */
  89047. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89048. /**
  89049. * Set a vec2 in the shader from a Vector2.
  89050. * @param name Define the name of the uniform as defined in the shader
  89051. * @param value Define the value to give to the uniform
  89052. * @return the material itself allowing "fluent" like uniform updates
  89053. */
  89054. setVector2(name: string, value: Vector2): ShaderMaterial;
  89055. /**
  89056. * Set a vec3 in the shader from a Vector3.
  89057. * @param name Define the name of the uniform as defined in the shader
  89058. * @param value Define the value to give to the uniform
  89059. * @return the material itself allowing "fluent" like uniform updates
  89060. */
  89061. setVector3(name: string, value: Vector3): ShaderMaterial;
  89062. /**
  89063. * Set a vec4 in the shader from a Vector4.
  89064. * @param name Define the name of the uniform as defined in the shader
  89065. * @param value Define the value to give to the uniform
  89066. * @return the material itself allowing "fluent" like uniform updates
  89067. */
  89068. setVector4(name: string, value: Vector4): ShaderMaterial;
  89069. /**
  89070. * Set a mat4 in the shader from a Matrix.
  89071. * @param name Define the name of the uniform as defined in the shader
  89072. * @param value Define the value to give to the uniform
  89073. * @return the material itself allowing "fluent" like uniform updates
  89074. */
  89075. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89076. /**
  89077. * Set a float32Array in the shader from a matrix array.
  89078. * @param name Define the name of the uniform as defined in the shader
  89079. * @param value Define the value to give to the uniform
  89080. * @return the material itself allowing "fluent" like uniform updates
  89081. */
  89082. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89083. /**
  89084. * Set a mat3 in the shader from a Float32Array.
  89085. * @param name Define the name of the uniform as defined in the shader
  89086. * @param value Define the value to give to the uniform
  89087. * @return the material itself allowing "fluent" like uniform updates
  89088. */
  89089. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89090. /**
  89091. * Set a mat2 in the shader from a Float32Array.
  89092. * @param name Define the name of the uniform as defined in the shader
  89093. * @param value Define the value to give to the uniform
  89094. * @return the material itself allowing "fluent" like uniform updates
  89095. */
  89096. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89097. /**
  89098. * Set a vec2 array in the shader from a number array.
  89099. * @param name Define the name of the uniform as defined in the shader
  89100. * @param value Define the value to give to the uniform
  89101. * @return the material itself allowing "fluent" like uniform updates
  89102. */
  89103. setArray2(name: string, value: number[]): ShaderMaterial;
  89104. /**
  89105. * Set a vec3 array in the shader from a number array.
  89106. * @param name Define the name of the uniform as defined in the shader
  89107. * @param value Define the value to give to the uniform
  89108. * @return the material itself allowing "fluent" like uniform updates
  89109. */
  89110. setArray3(name: string, value: number[]): ShaderMaterial;
  89111. /**
  89112. * Set a vec4 array in the shader from a number array.
  89113. * @param name Define the name of the uniform as defined in the shader
  89114. * @param value Define the value to give to the uniform
  89115. * @return the material itself allowing "fluent" like uniform updates
  89116. */
  89117. setArray4(name: string, value: number[]): ShaderMaterial;
  89118. private _checkCache;
  89119. /**
  89120. * Specifies that the submesh is ready to be used
  89121. * @param mesh defines the mesh to check
  89122. * @param subMesh defines which submesh to check
  89123. * @param useInstances specifies that instances should be used
  89124. * @returns a boolean indicating that the submesh is ready or not
  89125. */
  89126. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89127. /**
  89128. * Checks if the material is ready to render the requested mesh
  89129. * @param mesh Define the mesh to render
  89130. * @param useInstances Define whether or not the material is used with instances
  89131. * @returns true if ready, otherwise false
  89132. */
  89133. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89134. /**
  89135. * Binds the world matrix to the material
  89136. * @param world defines the world transformation matrix
  89137. */
  89138. bindOnlyWorldMatrix(world: Matrix): void;
  89139. /**
  89140. * Binds the material to the mesh
  89141. * @param world defines the world transformation matrix
  89142. * @param mesh defines the mesh to bind the material to
  89143. */
  89144. bind(world: Matrix, mesh?: Mesh): void;
  89145. /**
  89146. * Gets the active textures from the material
  89147. * @returns an array of textures
  89148. */
  89149. getActiveTextures(): BaseTexture[];
  89150. /**
  89151. * Specifies if the material uses a texture
  89152. * @param texture defines the texture to check against the material
  89153. * @returns a boolean specifying if the material uses the texture
  89154. */
  89155. hasTexture(texture: BaseTexture): boolean;
  89156. /**
  89157. * Makes a duplicate of the material, and gives it a new name
  89158. * @param name defines the new name for the duplicated material
  89159. * @returns the cloned material
  89160. */
  89161. clone(name: string): ShaderMaterial;
  89162. /**
  89163. * Disposes the material
  89164. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89165. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89166. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89167. */
  89168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89169. /**
  89170. * Serializes this material in a JSON representation
  89171. * @returns the serialized material object
  89172. */
  89173. serialize(): any;
  89174. /**
  89175. * Creates a shader material from parsed shader material data
  89176. * @param source defines the JSON represnetation of the material
  89177. * @param scene defines the hosting scene
  89178. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89179. * @returns a new material
  89180. */
  89181. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89182. }
  89183. }
  89184. declare module BABYLON {
  89185. /** @hidden */
  89186. export var colorPixelShader: {
  89187. name: string;
  89188. shader: string;
  89189. };
  89190. }
  89191. declare module BABYLON {
  89192. /** @hidden */
  89193. export var colorVertexShader: {
  89194. name: string;
  89195. shader: string;
  89196. };
  89197. }
  89198. declare module BABYLON {
  89199. /**
  89200. * Line mesh
  89201. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89202. */
  89203. export class LinesMesh extends Mesh {
  89204. /**
  89205. * If vertex color should be applied to the mesh
  89206. */
  89207. readonly useVertexColor?: boolean | undefined;
  89208. /**
  89209. * If vertex alpha should be applied to the mesh
  89210. */
  89211. readonly useVertexAlpha?: boolean | undefined;
  89212. /**
  89213. * Color of the line (Default: White)
  89214. */
  89215. color: Color3;
  89216. /**
  89217. * Alpha of the line (Default: 1)
  89218. */
  89219. alpha: number;
  89220. /**
  89221. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89222. * This margin is expressed in world space coordinates, so its value may vary.
  89223. * Default value is 0.1
  89224. */
  89225. intersectionThreshold: number;
  89226. private _colorShader;
  89227. private color4;
  89228. /**
  89229. * Creates a new LinesMesh
  89230. * @param name defines the name
  89231. * @param scene defines the hosting scene
  89232. * @param parent defines the parent mesh if any
  89233. * @param source defines the optional source LinesMesh used to clone data from
  89234. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89235. * When false, achieved by calling a clone(), also passing False.
  89236. * This will make creation of children, recursive.
  89237. * @param useVertexColor defines if this LinesMesh supports vertex color
  89238. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89239. */
  89240. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89241. /**
  89242. * If vertex color should be applied to the mesh
  89243. */
  89244. useVertexColor?: boolean | undefined,
  89245. /**
  89246. * If vertex alpha should be applied to the mesh
  89247. */
  89248. useVertexAlpha?: boolean | undefined);
  89249. private _addClipPlaneDefine;
  89250. private _removeClipPlaneDefine;
  89251. isReady(): boolean;
  89252. /**
  89253. * Returns the string "LineMesh"
  89254. */
  89255. getClassName(): string;
  89256. /**
  89257. * @hidden
  89258. */
  89259. get material(): Material;
  89260. /**
  89261. * @hidden
  89262. */
  89263. set material(value: Material);
  89264. /**
  89265. * @hidden
  89266. */
  89267. get checkCollisions(): boolean;
  89268. /** @hidden */
  89269. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89270. /** @hidden */
  89271. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89272. /**
  89273. * Disposes of the line mesh
  89274. * @param doNotRecurse If children should be disposed
  89275. */
  89276. dispose(doNotRecurse?: boolean): void;
  89277. /**
  89278. * Returns a new LineMesh object cloned from the current one.
  89279. */
  89280. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89281. /**
  89282. * Creates a new InstancedLinesMesh object from the mesh model.
  89283. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89284. * @param name defines the name of the new instance
  89285. * @returns a new InstancedLinesMesh
  89286. */
  89287. createInstance(name: string): InstancedLinesMesh;
  89288. }
  89289. /**
  89290. * Creates an instance based on a source LinesMesh
  89291. */
  89292. export class InstancedLinesMesh extends InstancedMesh {
  89293. /**
  89294. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89295. * This margin is expressed in world space coordinates, so its value may vary.
  89296. * Initilized with the intersectionThreshold value of the source LinesMesh
  89297. */
  89298. intersectionThreshold: number;
  89299. constructor(name: string, source: LinesMesh);
  89300. /**
  89301. * Returns the string "InstancedLinesMesh".
  89302. */
  89303. getClassName(): string;
  89304. }
  89305. }
  89306. declare module BABYLON {
  89307. /** @hidden */
  89308. export var linePixelShader: {
  89309. name: string;
  89310. shader: string;
  89311. };
  89312. }
  89313. declare module BABYLON {
  89314. /** @hidden */
  89315. export var lineVertexShader: {
  89316. name: string;
  89317. shader: string;
  89318. };
  89319. }
  89320. declare module BABYLON {
  89321. interface AbstractMesh {
  89322. /**
  89323. * Gets the edgesRenderer associated with the mesh
  89324. */
  89325. edgesRenderer: Nullable<EdgesRenderer>;
  89326. }
  89327. interface LinesMesh {
  89328. /**
  89329. * Enables the edge rendering mode on the mesh.
  89330. * This mode makes the mesh edges visible
  89331. * @param epsilon defines the maximal distance between two angles to detect a face
  89332. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89333. * @returns the currentAbstractMesh
  89334. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89335. */
  89336. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89337. }
  89338. interface InstancedLinesMesh {
  89339. /**
  89340. * Enables the edge rendering mode on the mesh.
  89341. * This mode makes the mesh edges visible
  89342. * @param epsilon defines the maximal distance between two angles to detect a face
  89343. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89344. * @returns the current InstancedLinesMesh
  89345. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89346. */
  89347. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89348. }
  89349. /**
  89350. * Defines the minimum contract an Edges renderer should follow.
  89351. */
  89352. export interface IEdgesRenderer extends IDisposable {
  89353. /**
  89354. * Gets or sets a boolean indicating if the edgesRenderer is active
  89355. */
  89356. isEnabled: boolean;
  89357. /**
  89358. * Renders the edges of the attached mesh,
  89359. */
  89360. render(): void;
  89361. /**
  89362. * Checks wether or not the edges renderer is ready to render.
  89363. * @return true if ready, otherwise false.
  89364. */
  89365. isReady(): boolean;
  89366. }
  89367. /**
  89368. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89369. */
  89370. export class EdgesRenderer implements IEdgesRenderer {
  89371. /**
  89372. * Define the size of the edges with an orthographic camera
  89373. */
  89374. edgesWidthScalerForOrthographic: number;
  89375. /**
  89376. * Define the size of the edges with a perspective camera
  89377. */
  89378. edgesWidthScalerForPerspective: number;
  89379. protected _source: AbstractMesh;
  89380. protected _linesPositions: number[];
  89381. protected _linesNormals: number[];
  89382. protected _linesIndices: number[];
  89383. protected _epsilon: number;
  89384. protected _indicesCount: number;
  89385. protected _lineShader: ShaderMaterial;
  89386. protected _ib: DataBuffer;
  89387. protected _buffers: {
  89388. [key: string]: Nullable<VertexBuffer>;
  89389. };
  89390. protected _checkVerticesInsteadOfIndices: boolean;
  89391. private _meshRebuildObserver;
  89392. private _meshDisposeObserver;
  89393. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89394. isEnabled: boolean;
  89395. /**
  89396. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89397. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89398. * @param source Mesh used to create edges
  89399. * @param epsilon sum of angles in adjacency to check for edge
  89400. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89401. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89402. */
  89403. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89404. protected _prepareRessources(): void;
  89405. /** @hidden */
  89406. _rebuild(): void;
  89407. /**
  89408. * Releases the required resources for the edges renderer
  89409. */
  89410. dispose(): void;
  89411. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89412. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89413. /**
  89414. * Checks if the pair of p0 and p1 is en edge
  89415. * @param faceIndex
  89416. * @param edge
  89417. * @param faceNormals
  89418. * @param p0
  89419. * @param p1
  89420. * @private
  89421. */
  89422. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89423. /**
  89424. * push line into the position, normal and index buffer
  89425. * @protected
  89426. */
  89427. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89428. /**
  89429. * Generates lines edges from adjacencjes
  89430. * @private
  89431. */
  89432. _generateEdgesLines(): void;
  89433. /**
  89434. * Checks wether or not the edges renderer is ready to render.
  89435. * @return true if ready, otherwise false.
  89436. */
  89437. isReady(): boolean;
  89438. /**
  89439. * Renders the edges of the attached mesh,
  89440. */
  89441. render(): void;
  89442. }
  89443. /**
  89444. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89445. */
  89446. export class LineEdgesRenderer extends EdgesRenderer {
  89447. /**
  89448. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89449. * @param source LineMesh used to generate edges
  89450. * @param epsilon not important (specified angle for edge detection)
  89451. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89452. */
  89453. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89454. /**
  89455. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89456. */
  89457. _generateEdgesLines(): void;
  89458. }
  89459. }
  89460. declare module BABYLON {
  89461. /**
  89462. * This represents the object necessary to create a rendering group.
  89463. * This is exclusively used and created by the rendering manager.
  89464. * To modify the behavior, you use the available helpers in your scene or meshes.
  89465. * @hidden
  89466. */
  89467. export class RenderingGroup {
  89468. index: number;
  89469. private static _zeroVector;
  89470. private _scene;
  89471. private _opaqueSubMeshes;
  89472. private _transparentSubMeshes;
  89473. private _alphaTestSubMeshes;
  89474. private _depthOnlySubMeshes;
  89475. private _particleSystems;
  89476. private _spriteManagers;
  89477. private _opaqueSortCompareFn;
  89478. private _alphaTestSortCompareFn;
  89479. private _transparentSortCompareFn;
  89480. private _renderOpaque;
  89481. private _renderAlphaTest;
  89482. private _renderTransparent;
  89483. /** @hidden */
  89484. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89485. onBeforeTransparentRendering: () => void;
  89486. /**
  89487. * Set the opaque sort comparison function.
  89488. * If null the sub meshes will be render in the order they were created
  89489. */
  89490. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89491. /**
  89492. * Set the alpha test sort comparison function.
  89493. * If null the sub meshes will be render in the order they were created
  89494. */
  89495. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89496. /**
  89497. * Set the transparent sort comparison function.
  89498. * If null the sub meshes will be render in the order they were created
  89499. */
  89500. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89501. /**
  89502. * Creates a new rendering group.
  89503. * @param index The rendering group index
  89504. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89505. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89506. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89507. */
  89508. 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>);
  89509. /**
  89510. * Render all the sub meshes contained in the group.
  89511. * @param customRenderFunction Used to override the default render behaviour of the group.
  89512. * @returns true if rendered some submeshes.
  89513. */
  89514. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89515. /**
  89516. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89517. * @param subMeshes The submeshes to render
  89518. */
  89519. private renderOpaqueSorted;
  89520. /**
  89521. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89522. * @param subMeshes The submeshes to render
  89523. */
  89524. private renderAlphaTestSorted;
  89525. /**
  89526. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89527. * @param subMeshes The submeshes to render
  89528. */
  89529. private renderTransparentSorted;
  89530. /**
  89531. * Renders the submeshes in a specified order.
  89532. * @param subMeshes The submeshes to sort before render
  89533. * @param sortCompareFn The comparison function use to sort
  89534. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89535. * @param transparent Specifies to activate blending if true
  89536. */
  89537. private static renderSorted;
  89538. /**
  89539. * Renders the submeshes in the order they were dispatched (no sort applied).
  89540. * @param subMeshes The submeshes to render
  89541. */
  89542. private static renderUnsorted;
  89543. /**
  89544. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89545. * are rendered back to front if in the same alpha index.
  89546. *
  89547. * @param a The first submesh
  89548. * @param b The second submesh
  89549. * @returns The result of the comparison
  89550. */
  89551. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89552. /**
  89553. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89554. * are rendered back to front.
  89555. *
  89556. * @param a The first submesh
  89557. * @param b The second submesh
  89558. * @returns The result of the comparison
  89559. */
  89560. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89561. /**
  89562. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89563. * are rendered front to back (prevent overdraw).
  89564. *
  89565. * @param a The first submesh
  89566. * @param b The second submesh
  89567. * @returns The result of the comparison
  89568. */
  89569. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89570. /**
  89571. * Resets the different lists of submeshes to prepare a new frame.
  89572. */
  89573. prepare(): void;
  89574. dispose(): void;
  89575. /**
  89576. * Inserts the submesh in its correct queue depending on its material.
  89577. * @param subMesh The submesh to dispatch
  89578. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89579. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89580. */
  89581. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89582. dispatchSprites(spriteManager: ISpriteManager): void;
  89583. dispatchParticles(particleSystem: IParticleSystem): void;
  89584. private _renderParticles;
  89585. private _renderSprites;
  89586. }
  89587. }
  89588. declare module BABYLON {
  89589. /**
  89590. * Interface describing the different options available in the rendering manager
  89591. * regarding Auto Clear between groups.
  89592. */
  89593. export interface IRenderingManagerAutoClearSetup {
  89594. /**
  89595. * Defines whether or not autoclear is enable.
  89596. */
  89597. autoClear: boolean;
  89598. /**
  89599. * Defines whether or not to autoclear the depth buffer.
  89600. */
  89601. depth: boolean;
  89602. /**
  89603. * Defines whether or not to autoclear the stencil buffer.
  89604. */
  89605. stencil: boolean;
  89606. }
  89607. /**
  89608. * This class is used by the onRenderingGroupObservable
  89609. */
  89610. export class RenderingGroupInfo {
  89611. /**
  89612. * The Scene that being rendered
  89613. */
  89614. scene: Scene;
  89615. /**
  89616. * The camera currently used for the rendering pass
  89617. */
  89618. camera: Nullable<Camera>;
  89619. /**
  89620. * The ID of the renderingGroup being processed
  89621. */
  89622. renderingGroupId: number;
  89623. }
  89624. /**
  89625. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89626. * It is enable to manage the different groups as well as the different necessary sort functions.
  89627. * This should not be used directly aside of the few static configurations
  89628. */
  89629. export class RenderingManager {
  89630. /**
  89631. * The max id used for rendering groups (not included)
  89632. */
  89633. static MAX_RENDERINGGROUPS: number;
  89634. /**
  89635. * The min id used for rendering groups (included)
  89636. */
  89637. static MIN_RENDERINGGROUPS: number;
  89638. /**
  89639. * Used to globally prevent autoclearing scenes.
  89640. */
  89641. static AUTOCLEAR: boolean;
  89642. /**
  89643. * @hidden
  89644. */
  89645. _useSceneAutoClearSetup: boolean;
  89646. private _scene;
  89647. private _renderingGroups;
  89648. private _depthStencilBufferAlreadyCleaned;
  89649. private _autoClearDepthStencil;
  89650. private _customOpaqueSortCompareFn;
  89651. private _customAlphaTestSortCompareFn;
  89652. private _customTransparentSortCompareFn;
  89653. private _renderingGroupInfo;
  89654. /**
  89655. * Instantiates a new rendering group for a particular scene
  89656. * @param scene Defines the scene the groups belongs to
  89657. */
  89658. constructor(scene: Scene);
  89659. private _clearDepthStencilBuffer;
  89660. /**
  89661. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89662. * @hidden
  89663. */
  89664. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89665. /**
  89666. * Resets the different information of the group to prepare a new frame
  89667. * @hidden
  89668. */
  89669. reset(): void;
  89670. /**
  89671. * Dispose and release the group and its associated resources.
  89672. * @hidden
  89673. */
  89674. dispose(): void;
  89675. /**
  89676. * Clear the info related to rendering groups preventing retention points during dispose.
  89677. */
  89678. freeRenderingGroups(): void;
  89679. private _prepareRenderingGroup;
  89680. /**
  89681. * Add a sprite manager to the rendering manager in order to render it this frame.
  89682. * @param spriteManager Define the sprite manager to render
  89683. */
  89684. dispatchSprites(spriteManager: ISpriteManager): void;
  89685. /**
  89686. * Add a particle system to the rendering manager in order to render it this frame.
  89687. * @param particleSystem Define the particle system to render
  89688. */
  89689. dispatchParticles(particleSystem: IParticleSystem): void;
  89690. /**
  89691. * Add a submesh to the manager in order to render it this frame
  89692. * @param subMesh The submesh to dispatch
  89693. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89694. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89695. */
  89696. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89697. /**
  89698. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89699. * This allowed control for front to back rendering or reversly depending of the special needs.
  89700. *
  89701. * @param renderingGroupId The rendering group id corresponding to its index
  89702. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89703. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89704. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89705. */
  89706. 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;
  89707. /**
  89708. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89709. *
  89710. * @param renderingGroupId The rendering group id corresponding to its index
  89711. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89712. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89713. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89714. */
  89715. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89716. /**
  89717. * Gets the current auto clear configuration for one rendering group of the rendering
  89718. * manager.
  89719. * @param index the rendering group index to get the information for
  89720. * @returns The auto clear setup for the requested rendering group
  89721. */
  89722. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89723. }
  89724. }
  89725. declare module BABYLON {
  89726. /**
  89727. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89728. */
  89729. export interface ICustomShaderOptions {
  89730. /**
  89731. * Gets or sets the custom shader name to use
  89732. */
  89733. shaderName: string;
  89734. /**
  89735. * The list of attribute names used in the shader
  89736. */
  89737. attributes?: string[];
  89738. /**
  89739. * The list of unifrom names used in the shader
  89740. */
  89741. uniforms?: string[];
  89742. /**
  89743. * The list of sampler names used in the shader
  89744. */
  89745. samplers?: string[];
  89746. /**
  89747. * The list of defines used in the shader
  89748. */
  89749. defines?: string[];
  89750. }
  89751. /**
  89752. * Interface to implement to create a shadow generator compatible with BJS.
  89753. */
  89754. export interface IShadowGenerator {
  89755. /**
  89756. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89757. * @returns The render target texture if present otherwise, null
  89758. */
  89759. getShadowMap(): Nullable<RenderTargetTexture>;
  89760. /**
  89761. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89762. * @param subMesh The submesh we want to render in the shadow map
  89763. * @param useInstances Defines wether will draw in the map using instances
  89764. * @returns true if ready otherwise, false
  89765. */
  89766. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89767. /**
  89768. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89769. * @param defines Defines of the material we want to update
  89770. * @param lightIndex Index of the light in the enabled light list of the material
  89771. */
  89772. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89773. /**
  89774. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89775. * defined in the generator but impacting the effect).
  89776. * It implies the unifroms available on the materials are the standard BJS ones.
  89777. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89778. * @param effect The effect we are binfing the information for
  89779. */
  89780. bindShadowLight(lightIndex: string, effect: Effect): void;
  89781. /**
  89782. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89783. * (eq to shadow prjection matrix * light transform matrix)
  89784. * @returns The transform matrix used to create the shadow map
  89785. */
  89786. getTransformMatrix(): Matrix;
  89787. /**
  89788. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89789. * Cube and 2D textures for instance.
  89790. */
  89791. recreateShadowMap(): void;
  89792. /**
  89793. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89794. * @param onCompiled Callback triggered at the and of the effects compilation
  89795. * @param options Sets of optional options forcing the compilation with different modes
  89796. */
  89797. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89798. useInstances: boolean;
  89799. }>): void;
  89800. /**
  89801. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89802. * @param options Sets of optional options forcing the compilation with different modes
  89803. * @returns A promise that resolves when the compilation completes
  89804. */
  89805. forceCompilationAsync(options?: Partial<{
  89806. useInstances: boolean;
  89807. }>): Promise<void>;
  89808. /**
  89809. * Serializes the shadow generator setup to a json object.
  89810. * @returns The serialized JSON object
  89811. */
  89812. serialize(): any;
  89813. /**
  89814. * Disposes the Shadow map and related Textures and effects.
  89815. */
  89816. dispose(): void;
  89817. }
  89818. /**
  89819. * Default implementation IShadowGenerator.
  89820. * This is the main object responsible of generating shadows in the framework.
  89821. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89822. */
  89823. export class ShadowGenerator implements IShadowGenerator {
  89824. /**
  89825. * Name of the shadow generator class
  89826. */
  89827. static CLASSNAME: string;
  89828. /**
  89829. * Shadow generator mode None: no filtering applied.
  89830. */
  89831. static readonly FILTER_NONE: number;
  89832. /**
  89833. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89834. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89835. */
  89836. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89837. /**
  89838. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89839. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89840. */
  89841. static readonly FILTER_POISSONSAMPLING: number;
  89842. /**
  89843. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89844. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89845. */
  89846. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89847. /**
  89848. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89849. * edge artifacts on steep falloff.
  89850. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89851. */
  89852. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89853. /**
  89854. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89855. * edge artifacts on steep falloff.
  89856. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89857. */
  89858. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89859. /**
  89860. * Shadow generator mode PCF: Percentage Closer Filtering
  89861. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89862. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89863. */
  89864. static readonly FILTER_PCF: number;
  89865. /**
  89866. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89867. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89868. * Contact Hardening
  89869. */
  89870. static readonly FILTER_PCSS: number;
  89871. /**
  89872. * Reserved for PCF and PCSS
  89873. * Highest Quality.
  89874. *
  89875. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89876. *
  89877. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89878. */
  89879. static readonly QUALITY_HIGH: number;
  89880. /**
  89881. * Reserved for PCF and PCSS
  89882. * Good tradeoff for quality/perf cross devices
  89883. *
  89884. * Execute PCF on a 3*3 kernel.
  89885. *
  89886. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89887. */
  89888. static readonly QUALITY_MEDIUM: number;
  89889. /**
  89890. * Reserved for PCF and PCSS
  89891. * The lowest quality but the fastest.
  89892. *
  89893. * Execute PCF on a 1*1 kernel.
  89894. *
  89895. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89896. */
  89897. static readonly QUALITY_LOW: number;
  89898. /** Gets or sets the custom shader name to use */
  89899. customShaderOptions: ICustomShaderOptions;
  89900. /**
  89901. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89902. */
  89903. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89904. /**
  89905. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89906. */
  89907. onAfterShadowMapRenderObservable: Observable<Effect>;
  89908. /**
  89909. * Observable triggered before a mesh is rendered in the shadow map.
  89910. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89911. */
  89912. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89913. /**
  89914. * Observable triggered after a mesh is rendered in the shadow map.
  89915. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89916. */
  89917. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89918. protected _bias: number;
  89919. /**
  89920. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89921. */
  89922. get bias(): number;
  89923. /**
  89924. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89925. */
  89926. set bias(bias: number);
  89927. protected _normalBias: number;
  89928. /**
  89929. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89930. */
  89931. get normalBias(): number;
  89932. /**
  89933. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89934. */
  89935. set normalBias(normalBias: number);
  89936. protected _blurBoxOffset: number;
  89937. /**
  89938. * Gets the blur box offset: offset applied during the blur pass.
  89939. * Only useful if useKernelBlur = false
  89940. */
  89941. get blurBoxOffset(): number;
  89942. /**
  89943. * Sets the blur box offset: offset applied during the blur pass.
  89944. * Only useful if useKernelBlur = false
  89945. */
  89946. set blurBoxOffset(value: number);
  89947. protected _blurScale: number;
  89948. /**
  89949. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89950. * 2 means half of the size.
  89951. */
  89952. get blurScale(): number;
  89953. /**
  89954. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89955. * 2 means half of the size.
  89956. */
  89957. set blurScale(value: number);
  89958. protected _blurKernel: number;
  89959. /**
  89960. * Gets the blur kernel: kernel size of the blur pass.
  89961. * Only useful if useKernelBlur = true
  89962. */
  89963. get blurKernel(): number;
  89964. /**
  89965. * Sets the blur kernel: kernel size of the blur pass.
  89966. * Only useful if useKernelBlur = true
  89967. */
  89968. set blurKernel(value: number);
  89969. protected _useKernelBlur: boolean;
  89970. /**
  89971. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89972. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89973. */
  89974. get useKernelBlur(): boolean;
  89975. /**
  89976. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89977. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89978. */
  89979. set useKernelBlur(value: boolean);
  89980. protected _depthScale: number;
  89981. /**
  89982. * Gets the depth scale used in ESM mode.
  89983. */
  89984. get depthScale(): number;
  89985. /**
  89986. * Sets the depth scale used in ESM mode.
  89987. * This can override the scale stored on the light.
  89988. */
  89989. set depthScale(value: number);
  89990. protected _validateFilter(filter: number): number;
  89991. protected _filter: number;
  89992. /**
  89993. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89994. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89995. */
  89996. get filter(): number;
  89997. /**
  89998. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89999. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90000. */
  90001. set filter(value: number);
  90002. /**
  90003. * Gets if the current filter is set to Poisson Sampling.
  90004. */
  90005. get usePoissonSampling(): boolean;
  90006. /**
  90007. * Sets the current filter to Poisson Sampling.
  90008. */
  90009. set usePoissonSampling(value: boolean);
  90010. /**
  90011. * Gets if the current filter is set to ESM.
  90012. */
  90013. get useExponentialShadowMap(): boolean;
  90014. /**
  90015. * Sets the current filter is to ESM.
  90016. */
  90017. set useExponentialShadowMap(value: boolean);
  90018. /**
  90019. * Gets if the current filter is set to filtered ESM.
  90020. */
  90021. get useBlurExponentialShadowMap(): boolean;
  90022. /**
  90023. * Gets if the current filter is set to filtered ESM.
  90024. */
  90025. set useBlurExponentialShadowMap(value: boolean);
  90026. /**
  90027. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90028. * exponential to prevent steep falloff artifacts).
  90029. */
  90030. get useCloseExponentialShadowMap(): boolean;
  90031. /**
  90032. * Sets the current filter to "close ESM" (using the inverse of the
  90033. * exponential to prevent steep falloff artifacts).
  90034. */
  90035. set useCloseExponentialShadowMap(value: boolean);
  90036. /**
  90037. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90038. * exponential to prevent steep falloff artifacts).
  90039. */
  90040. get useBlurCloseExponentialShadowMap(): boolean;
  90041. /**
  90042. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90043. * exponential to prevent steep falloff artifacts).
  90044. */
  90045. set useBlurCloseExponentialShadowMap(value: boolean);
  90046. /**
  90047. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90048. */
  90049. get usePercentageCloserFiltering(): boolean;
  90050. /**
  90051. * Sets the current filter to "PCF" (percentage closer filtering).
  90052. */
  90053. set usePercentageCloserFiltering(value: boolean);
  90054. protected _filteringQuality: number;
  90055. /**
  90056. * Gets the PCF or PCSS Quality.
  90057. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90058. */
  90059. get filteringQuality(): number;
  90060. /**
  90061. * Sets the PCF or PCSS Quality.
  90062. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90063. */
  90064. set filteringQuality(filteringQuality: number);
  90065. /**
  90066. * Gets if the current filter is set to "PCSS" (contact hardening).
  90067. */
  90068. get useContactHardeningShadow(): boolean;
  90069. /**
  90070. * Sets the current filter to "PCSS" (contact hardening).
  90071. */
  90072. set useContactHardeningShadow(value: boolean);
  90073. protected _contactHardeningLightSizeUVRatio: number;
  90074. /**
  90075. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90076. * Using a ratio helps keeping shape stability independently of the map size.
  90077. *
  90078. * It does not account for the light projection as it was having too much
  90079. * instability during the light setup or during light position changes.
  90080. *
  90081. * Only valid if useContactHardeningShadow is true.
  90082. */
  90083. get contactHardeningLightSizeUVRatio(): number;
  90084. /**
  90085. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90086. * Using a ratio helps keeping shape stability independently of the map size.
  90087. *
  90088. * It does not account for the light projection as it was having too much
  90089. * instability during the light setup or during light position changes.
  90090. *
  90091. * Only valid if useContactHardeningShadow is true.
  90092. */
  90093. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90094. protected _darkness: number;
  90095. /** Gets or sets the actual darkness of a shadow */
  90096. get darkness(): number;
  90097. set darkness(value: number);
  90098. /**
  90099. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90100. * 0 means strongest and 1 would means no shadow.
  90101. * @returns the darkness.
  90102. */
  90103. getDarkness(): number;
  90104. /**
  90105. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90106. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90107. * @returns the shadow generator allowing fluent coding.
  90108. */
  90109. setDarkness(darkness: number): ShadowGenerator;
  90110. protected _transparencyShadow: boolean;
  90111. /** Gets or sets the ability to have transparent shadow */
  90112. get transparencyShadow(): boolean;
  90113. set transparencyShadow(value: boolean);
  90114. /**
  90115. * Sets the ability to have transparent shadow (boolean).
  90116. * @param transparent True if transparent else False
  90117. * @returns the shadow generator allowing fluent coding
  90118. */
  90119. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90120. protected _shadowMap: Nullable<RenderTargetTexture>;
  90121. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90122. /**
  90123. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90124. * @returns The render target texture if present otherwise, null
  90125. */
  90126. getShadowMap(): Nullable<RenderTargetTexture>;
  90127. /**
  90128. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90129. * @returns The render target texture if the shadow map is present otherwise, null
  90130. */
  90131. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90132. /**
  90133. * Gets the class name of that object
  90134. * @returns "ShadowGenerator"
  90135. */
  90136. getClassName(): string;
  90137. /**
  90138. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90139. * @param mesh Mesh to add
  90140. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90141. * @returns the Shadow Generator itself
  90142. */
  90143. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90144. /**
  90145. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90146. * @param mesh Mesh to remove
  90147. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90148. * @returns the Shadow Generator itself
  90149. */
  90150. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90151. /**
  90152. * Controls the extent to which the shadows fade out at the edge of the frustum
  90153. */
  90154. frustumEdgeFalloff: number;
  90155. protected _light: IShadowLight;
  90156. /**
  90157. * Returns the associated light object.
  90158. * @returns the light generating the shadow
  90159. */
  90160. getLight(): IShadowLight;
  90161. /**
  90162. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90163. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90164. * It might on the other hand introduce peter panning.
  90165. */
  90166. forceBackFacesOnly: boolean;
  90167. protected _scene: Scene;
  90168. protected _lightDirection: Vector3;
  90169. protected _effect: Effect;
  90170. protected _viewMatrix: Matrix;
  90171. protected _projectionMatrix: Matrix;
  90172. protected _transformMatrix: Matrix;
  90173. protected _cachedPosition: Vector3;
  90174. protected _cachedDirection: Vector3;
  90175. protected _cachedDefines: string;
  90176. protected _currentRenderID: number;
  90177. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90178. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90179. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90180. protected _blurPostProcesses: PostProcess[];
  90181. protected _mapSize: number;
  90182. protected _currentFaceIndex: number;
  90183. protected _currentFaceIndexCache: number;
  90184. protected _textureType: number;
  90185. protected _defaultTextureMatrix: Matrix;
  90186. protected _storedUniqueId: Nullable<number>;
  90187. /** @hidden */
  90188. static _SceneComponentInitialization: (scene: Scene) => void;
  90189. /**
  90190. * Creates a ShadowGenerator object.
  90191. * A ShadowGenerator is the required tool to use the shadows.
  90192. * Each light casting shadows needs to use its own ShadowGenerator.
  90193. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  90194. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  90195. * @param light The light object generating the shadows.
  90196. * @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.
  90197. */
  90198. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  90199. protected _initializeGenerator(): void;
  90200. protected _createTargetRenderTexture(): void;
  90201. protected _initializeShadowMap(): void;
  90202. protected _initializeBlurRTTAndPostProcesses(): void;
  90203. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  90204. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  90205. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  90206. protected _applyFilterValues(): void;
  90207. /**
  90208. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90209. * @param onCompiled Callback triggered at the and of the effects compilation
  90210. * @param options Sets of optional options forcing the compilation with different modes
  90211. */
  90212. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90213. useInstances: boolean;
  90214. }>): void;
  90215. /**
  90216. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90217. * @param options Sets of optional options forcing the compilation with different modes
  90218. * @returns A promise that resolves when the compilation completes
  90219. */
  90220. forceCompilationAsync(options?: Partial<{
  90221. useInstances: boolean;
  90222. }>): Promise<void>;
  90223. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90224. /**
  90225. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90226. * @param subMesh The submesh we want to render in the shadow map
  90227. * @param useInstances Defines wether will draw in the map using instances
  90228. * @returns true if ready otherwise, false
  90229. */
  90230. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90231. /**
  90232. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90233. * @param defines Defines of the material we want to update
  90234. * @param lightIndex Index of the light in the enabled light list of the material
  90235. */
  90236. prepareDefines(defines: any, lightIndex: number): void;
  90237. /**
  90238. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90239. * defined in the generator but impacting the effect).
  90240. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90241. * @param effect The effect we are binfing the information for
  90242. */
  90243. bindShadowLight(lightIndex: string, effect: Effect): void;
  90244. /**
  90245. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90246. * (eq to shadow prjection matrix * light transform matrix)
  90247. * @returns The transform matrix used to create the shadow map
  90248. */
  90249. getTransformMatrix(): Matrix;
  90250. /**
  90251. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90252. * Cube and 2D textures for instance.
  90253. */
  90254. recreateShadowMap(): void;
  90255. protected _disposeBlurPostProcesses(): void;
  90256. protected _disposeRTTandPostProcesses(): void;
  90257. /**
  90258. * Disposes the ShadowGenerator.
  90259. * Returns nothing.
  90260. */
  90261. dispose(): void;
  90262. /**
  90263. * Serializes the shadow generator setup to a json object.
  90264. * @returns The serialized JSON object
  90265. */
  90266. serialize(): any;
  90267. /**
  90268. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90269. * @param parsedShadowGenerator The JSON object to parse
  90270. * @param scene The scene to create the shadow map for
  90271. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90272. * @returns The parsed shadow generator
  90273. */
  90274. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90275. }
  90276. }
  90277. declare module BABYLON {
  90278. /**
  90279. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90280. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90281. * 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.
  90282. */
  90283. export abstract class Light extends Node {
  90284. /**
  90285. * Falloff Default: light is falling off following the material specification:
  90286. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90287. */
  90288. static readonly FALLOFF_DEFAULT: number;
  90289. /**
  90290. * Falloff Physical: light is falling off following the inverse squared distance law.
  90291. */
  90292. static readonly FALLOFF_PHYSICAL: number;
  90293. /**
  90294. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90295. * to enhance interoperability with other engines.
  90296. */
  90297. static readonly FALLOFF_GLTF: number;
  90298. /**
  90299. * Falloff Standard: light is falling off like in the standard material
  90300. * to enhance interoperability with other materials.
  90301. */
  90302. static readonly FALLOFF_STANDARD: number;
  90303. /**
  90304. * If every light affecting the material is in this lightmapMode,
  90305. * material.lightmapTexture adds or multiplies
  90306. * (depends on material.useLightmapAsShadowmap)
  90307. * after every other light calculations.
  90308. */
  90309. static readonly LIGHTMAP_DEFAULT: number;
  90310. /**
  90311. * material.lightmapTexture as only diffuse lighting from this light
  90312. * adds only specular lighting from this light
  90313. * adds dynamic shadows
  90314. */
  90315. static readonly LIGHTMAP_SPECULAR: number;
  90316. /**
  90317. * material.lightmapTexture as only lighting
  90318. * no light calculation from this light
  90319. * only adds dynamic shadows from this light
  90320. */
  90321. static readonly LIGHTMAP_SHADOWSONLY: number;
  90322. /**
  90323. * Each light type uses the default quantity according to its type:
  90324. * point/spot lights use luminous intensity
  90325. * directional lights use illuminance
  90326. */
  90327. static readonly INTENSITYMODE_AUTOMATIC: number;
  90328. /**
  90329. * lumen (lm)
  90330. */
  90331. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90332. /**
  90333. * candela (lm/sr)
  90334. */
  90335. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90336. /**
  90337. * lux (lm/m^2)
  90338. */
  90339. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90340. /**
  90341. * nit (cd/m^2)
  90342. */
  90343. static readonly INTENSITYMODE_LUMINANCE: number;
  90344. /**
  90345. * Light type const id of the point light.
  90346. */
  90347. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90348. /**
  90349. * Light type const id of the directional light.
  90350. */
  90351. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90352. /**
  90353. * Light type const id of the spot light.
  90354. */
  90355. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90356. /**
  90357. * Light type const id of the hemispheric light.
  90358. */
  90359. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90360. /**
  90361. * Diffuse gives the basic color to an object.
  90362. */
  90363. diffuse: Color3;
  90364. /**
  90365. * Specular produces a highlight color on an object.
  90366. * Note: This is note affecting PBR materials.
  90367. */
  90368. specular: Color3;
  90369. /**
  90370. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90371. * falling off base on range or angle.
  90372. * This can be set to any values in Light.FALLOFF_x.
  90373. *
  90374. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90375. * other types of materials.
  90376. */
  90377. falloffType: number;
  90378. /**
  90379. * Strength of the light.
  90380. * Note: By default it is define in the framework own unit.
  90381. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90382. */
  90383. intensity: number;
  90384. private _range;
  90385. protected _inverseSquaredRange: number;
  90386. /**
  90387. * Defines how far from the source the light is impacting in scene units.
  90388. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90389. */
  90390. get range(): number;
  90391. /**
  90392. * Defines how far from the source the light is impacting in scene units.
  90393. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90394. */
  90395. set range(value: number);
  90396. /**
  90397. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90398. * of light.
  90399. */
  90400. private _photometricScale;
  90401. private _intensityMode;
  90402. /**
  90403. * Gets the photometric scale used to interpret the intensity.
  90404. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90405. */
  90406. get intensityMode(): number;
  90407. /**
  90408. * Sets the photometric scale used to interpret the intensity.
  90409. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90410. */
  90411. set intensityMode(value: number);
  90412. private _radius;
  90413. /**
  90414. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90415. */
  90416. get radius(): number;
  90417. /**
  90418. * sets the light radius used by PBR Materials to simulate soft area lights.
  90419. */
  90420. set radius(value: number);
  90421. private _renderPriority;
  90422. /**
  90423. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90424. * exceeding the number allowed of the materials.
  90425. */
  90426. renderPriority: number;
  90427. private _shadowEnabled;
  90428. /**
  90429. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90430. * the current shadow generator.
  90431. */
  90432. get shadowEnabled(): boolean;
  90433. /**
  90434. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90435. * the current shadow generator.
  90436. */
  90437. set shadowEnabled(value: boolean);
  90438. private _includedOnlyMeshes;
  90439. /**
  90440. * Gets the only meshes impacted by this light.
  90441. */
  90442. get includedOnlyMeshes(): AbstractMesh[];
  90443. /**
  90444. * Sets the only meshes impacted by this light.
  90445. */
  90446. set includedOnlyMeshes(value: AbstractMesh[]);
  90447. private _excludedMeshes;
  90448. /**
  90449. * Gets the meshes not impacted by this light.
  90450. */
  90451. get excludedMeshes(): AbstractMesh[];
  90452. /**
  90453. * Sets the meshes not impacted by this light.
  90454. */
  90455. set excludedMeshes(value: AbstractMesh[]);
  90456. private _excludeWithLayerMask;
  90457. /**
  90458. * Gets the layer id use to find what meshes are not impacted by the light.
  90459. * Inactive if 0
  90460. */
  90461. get excludeWithLayerMask(): number;
  90462. /**
  90463. * Sets the layer id use to find what meshes are not impacted by the light.
  90464. * Inactive if 0
  90465. */
  90466. set excludeWithLayerMask(value: number);
  90467. private _includeOnlyWithLayerMask;
  90468. /**
  90469. * Gets the layer id use to find what meshes are impacted by the light.
  90470. * Inactive if 0
  90471. */
  90472. get includeOnlyWithLayerMask(): number;
  90473. /**
  90474. * Sets the layer id use to find what meshes are impacted by the light.
  90475. * Inactive if 0
  90476. */
  90477. set includeOnlyWithLayerMask(value: number);
  90478. private _lightmapMode;
  90479. /**
  90480. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90481. */
  90482. get lightmapMode(): number;
  90483. /**
  90484. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90485. */
  90486. set lightmapMode(value: number);
  90487. /**
  90488. * Shadow generator associted to the light.
  90489. * @hidden Internal use only.
  90490. */
  90491. _shadowGenerator: Nullable<IShadowGenerator>;
  90492. /**
  90493. * @hidden Internal use only.
  90494. */
  90495. _excludedMeshesIds: string[];
  90496. /**
  90497. * @hidden Internal use only.
  90498. */
  90499. _includedOnlyMeshesIds: string[];
  90500. /**
  90501. * The current light unifom buffer.
  90502. * @hidden Internal use only.
  90503. */
  90504. _uniformBuffer: UniformBuffer;
  90505. /** @hidden */
  90506. _renderId: number;
  90507. /**
  90508. * Creates a Light object in the scene.
  90509. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90510. * @param name The firendly name of the light
  90511. * @param scene The scene the light belongs too
  90512. */
  90513. constructor(name: string, scene: Scene);
  90514. protected abstract _buildUniformLayout(): void;
  90515. /**
  90516. * Sets the passed Effect "effect" with the Light information.
  90517. * @param effect The effect to update
  90518. * @param lightIndex The index of the light in the effect to update
  90519. * @returns The light
  90520. */
  90521. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90522. /**
  90523. * Sets the passed Effect "effect" with the Light textures.
  90524. * @param effect The effect to update
  90525. * @param lightIndex The index of the light in the effect to update
  90526. * @returns The light
  90527. */
  90528. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90529. /**
  90530. * Binds the lights information from the scene to the effect for the given mesh.
  90531. * @param lightIndex Light index
  90532. * @param scene The scene where the light belongs to
  90533. * @param effect The effect we are binding the data to
  90534. * @param useSpecular Defines if specular is supported
  90535. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90536. */
  90537. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90538. /**
  90539. * Sets the passed Effect "effect" with the Light information.
  90540. * @param effect The effect to update
  90541. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90542. * @returns The light
  90543. */
  90544. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90545. /**
  90546. * Returns the string "Light".
  90547. * @returns the class name
  90548. */
  90549. getClassName(): string;
  90550. /** @hidden */
  90551. readonly _isLight: boolean;
  90552. /**
  90553. * Converts the light information to a readable string for debug purpose.
  90554. * @param fullDetails Supports for multiple levels of logging within scene loading
  90555. * @returns the human readable light info
  90556. */
  90557. toString(fullDetails?: boolean): string;
  90558. /** @hidden */
  90559. protected _syncParentEnabledState(): void;
  90560. /**
  90561. * Set the enabled state of this node.
  90562. * @param value - the new enabled state
  90563. */
  90564. setEnabled(value: boolean): void;
  90565. /**
  90566. * Returns the Light associated shadow generator if any.
  90567. * @return the associated shadow generator.
  90568. */
  90569. getShadowGenerator(): Nullable<IShadowGenerator>;
  90570. /**
  90571. * Returns a Vector3, the absolute light position in the World.
  90572. * @returns the world space position of the light
  90573. */
  90574. getAbsolutePosition(): Vector3;
  90575. /**
  90576. * Specifies if the light will affect the passed mesh.
  90577. * @param mesh The mesh to test against the light
  90578. * @return true the mesh is affected otherwise, false.
  90579. */
  90580. canAffectMesh(mesh: AbstractMesh): boolean;
  90581. /**
  90582. * Sort function to order lights for rendering.
  90583. * @param a First Light object to compare to second.
  90584. * @param b Second Light object to compare first.
  90585. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90586. */
  90587. static CompareLightsPriority(a: Light, b: Light): number;
  90588. /**
  90589. * Releases resources associated with this node.
  90590. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90591. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90592. */
  90593. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90594. /**
  90595. * Returns the light type ID (integer).
  90596. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90597. */
  90598. getTypeID(): number;
  90599. /**
  90600. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90601. * @returns the scaled intensity in intensity mode unit
  90602. */
  90603. getScaledIntensity(): number;
  90604. /**
  90605. * Returns a new Light object, named "name", from the current one.
  90606. * @param name The name of the cloned light
  90607. * @returns the new created light
  90608. */
  90609. clone(name: string): Nullable<Light>;
  90610. /**
  90611. * Serializes the current light into a Serialization object.
  90612. * @returns the serialized object.
  90613. */
  90614. serialize(): any;
  90615. /**
  90616. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90617. * This new light is named "name" and added to the passed scene.
  90618. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90619. * @param name The friendly name of the light
  90620. * @param scene The scene the new light will belong to
  90621. * @returns the constructor function
  90622. */
  90623. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90624. /**
  90625. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90626. * @param parsedLight The JSON representation of the light
  90627. * @param scene The scene to create the parsed light in
  90628. * @returns the created light after parsing
  90629. */
  90630. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90631. private _hookArrayForExcluded;
  90632. private _hookArrayForIncludedOnly;
  90633. private _resyncMeshes;
  90634. /**
  90635. * Forces the meshes to update their light related information in their rendering used effects
  90636. * @hidden Internal Use Only
  90637. */
  90638. _markMeshesAsLightDirty(): void;
  90639. /**
  90640. * Recomputes the cached photometric scale if needed.
  90641. */
  90642. private _computePhotometricScale;
  90643. /**
  90644. * Returns the Photometric Scale according to the light type and intensity mode.
  90645. */
  90646. private _getPhotometricScale;
  90647. /**
  90648. * Reorder the light in the scene according to their defined priority.
  90649. * @hidden Internal Use Only
  90650. */
  90651. _reorderLightsInScene(): void;
  90652. /**
  90653. * Prepares the list of defines specific to the light type.
  90654. * @param defines the list of defines
  90655. * @param lightIndex defines the index of the light for the effect
  90656. */
  90657. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90658. }
  90659. }
  90660. declare module BABYLON {
  90661. /**
  90662. * Interface used to define Action
  90663. */
  90664. export interface IAction {
  90665. /**
  90666. * Trigger for the action
  90667. */
  90668. trigger: number;
  90669. /** Options of the trigger */
  90670. triggerOptions: any;
  90671. /**
  90672. * Gets the trigger parameters
  90673. * @returns the trigger parameters
  90674. */
  90675. getTriggerParameter(): any;
  90676. /**
  90677. * Internal only - executes current action event
  90678. * @hidden
  90679. */
  90680. _executeCurrent(evt?: ActionEvent): void;
  90681. /**
  90682. * Serialize placeholder for child classes
  90683. * @param parent of child
  90684. * @returns the serialized object
  90685. */
  90686. serialize(parent: any): any;
  90687. /**
  90688. * Internal only
  90689. * @hidden
  90690. */
  90691. _prepare(): void;
  90692. /**
  90693. * Internal only - manager for action
  90694. * @hidden
  90695. */
  90696. _actionManager: AbstractActionManager;
  90697. /**
  90698. * Adds action to chain of actions, may be a DoNothingAction
  90699. * @param action defines the next action to execute
  90700. * @returns The action passed in
  90701. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90702. */
  90703. then(action: IAction): IAction;
  90704. }
  90705. /**
  90706. * The action to be carried out following a trigger
  90707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90708. */
  90709. export class Action implements IAction {
  90710. /** the trigger, with or without parameters, for the action */
  90711. triggerOptions: any;
  90712. /**
  90713. * Trigger for the action
  90714. */
  90715. trigger: number;
  90716. /**
  90717. * Internal only - manager for action
  90718. * @hidden
  90719. */
  90720. _actionManager: ActionManager;
  90721. private _nextActiveAction;
  90722. private _child;
  90723. private _condition?;
  90724. private _triggerParameter;
  90725. /**
  90726. * An event triggered prior to action being executed.
  90727. */
  90728. onBeforeExecuteObservable: Observable<Action>;
  90729. /**
  90730. * Creates a new Action
  90731. * @param triggerOptions the trigger, with or without parameters, for the action
  90732. * @param condition an optional determinant of action
  90733. */
  90734. constructor(
  90735. /** the trigger, with or without parameters, for the action */
  90736. triggerOptions: any, condition?: Condition);
  90737. /**
  90738. * Internal only
  90739. * @hidden
  90740. */
  90741. _prepare(): void;
  90742. /**
  90743. * Gets the trigger parameters
  90744. * @returns the trigger parameters
  90745. */
  90746. getTriggerParameter(): any;
  90747. /**
  90748. * Internal only - executes current action event
  90749. * @hidden
  90750. */
  90751. _executeCurrent(evt?: ActionEvent): void;
  90752. /**
  90753. * Execute placeholder for child classes
  90754. * @param evt optional action event
  90755. */
  90756. execute(evt?: ActionEvent): void;
  90757. /**
  90758. * Skips to next active action
  90759. */
  90760. skipToNextActiveAction(): void;
  90761. /**
  90762. * Adds action to chain of actions, may be a DoNothingAction
  90763. * @param action defines the next action to execute
  90764. * @returns The action passed in
  90765. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90766. */
  90767. then(action: Action): Action;
  90768. /**
  90769. * Internal only
  90770. * @hidden
  90771. */
  90772. _getProperty(propertyPath: string): string;
  90773. /**
  90774. * Internal only
  90775. * @hidden
  90776. */
  90777. _getEffectiveTarget(target: any, propertyPath: string): any;
  90778. /**
  90779. * Serialize placeholder for child classes
  90780. * @param parent of child
  90781. * @returns the serialized object
  90782. */
  90783. serialize(parent: any): any;
  90784. /**
  90785. * Internal only called by serialize
  90786. * @hidden
  90787. */
  90788. protected _serialize(serializedAction: any, parent?: any): any;
  90789. /**
  90790. * Internal only
  90791. * @hidden
  90792. */
  90793. static _SerializeValueAsString: (value: any) => string;
  90794. /**
  90795. * Internal only
  90796. * @hidden
  90797. */
  90798. static _GetTargetProperty: (target: Node | Scene) => {
  90799. name: string;
  90800. targetType: string;
  90801. value: string;
  90802. };
  90803. }
  90804. }
  90805. declare module BABYLON {
  90806. /**
  90807. * A Condition applied to an Action
  90808. */
  90809. export class Condition {
  90810. /**
  90811. * Internal only - manager for action
  90812. * @hidden
  90813. */
  90814. _actionManager: ActionManager;
  90815. /**
  90816. * Internal only
  90817. * @hidden
  90818. */
  90819. _evaluationId: number;
  90820. /**
  90821. * Internal only
  90822. * @hidden
  90823. */
  90824. _currentResult: boolean;
  90825. /**
  90826. * Creates a new Condition
  90827. * @param actionManager the manager of the action the condition is applied to
  90828. */
  90829. constructor(actionManager: ActionManager);
  90830. /**
  90831. * Check if the current condition is valid
  90832. * @returns a boolean
  90833. */
  90834. isValid(): boolean;
  90835. /**
  90836. * Internal only
  90837. * @hidden
  90838. */
  90839. _getProperty(propertyPath: string): string;
  90840. /**
  90841. * Internal only
  90842. * @hidden
  90843. */
  90844. _getEffectiveTarget(target: any, propertyPath: string): any;
  90845. /**
  90846. * Serialize placeholder for child classes
  90847. * @returns the serialized object
  90848. */
  90849. serialize(): any;
  90850. /**
  90851. * Internal only
  90852. * @hidden
  90853. */
  90854. protected _serialize(serializedCondition: any): any;
  90855. }
  90856. /**
  90857. * Defines specific conditional operators as extensions of Condition
  90858. */
  90859. export class ValueCondition extends Condition {
  90860. /** path to specify the property of the target the conditional operator uses */
  90861. propertyPath: string;
  90862. /** the value compared by the conditional operator against the current value of the property */
  90863. value: any;
  90864. /** the conditional operator, default ValueCondition.IsEqual */
  90865. operator: number;
  90866. /**
  90867. * Internal only
  90868. * @hidden
  90869. */
  90870. private static _IsEqual;
  90871. /**
  90872. * Internal only
  90873. * @hidden
  90874. */
  90875. private static _IsDifferent;
  90876. /**
  90877. * Internal only
  90878. * @hidden
  90879. */
  90880. private static _IsGreater;
  90881. /**
  90882. * Internal only
  90883. * @hidden
  90884. */
  90885. private static _IsLesser;
  90886. /**
  90887. * returns the number for IsEqual
  90888. */
  90889. static get IsEqual(): number;
  90890. /**
  90891. * Returns the number for IsDifferent
  90892. */
  90893. static get IsDifferent(): number;
  90894. /**
  90895. * Returns the number for IsGreater
  90896. */
  90897. static get IsGreater(): number;
  90898. /**
  90899. * Returns the number for IsLesser
  90900. */
  90901. static get IsLesser(): number;
  90902. /**
  90903. * Internal only The action manager for the condition
  90904. * @hidden
  90905. */
  90906. _actionManager: ActionManager;
  90907. /**
  90908. * Internal only
  90909. * @hidden
  90910. */
  90911. private _target;
  90912. /**
  90913. * Internal only
  90914. * @hidden
  90915. */
  90916. private _effectiveTarget;
  90917. /**
  90918. * Internal only
  90919. * @hidden
  90920. */
  90921. private _property;
  90922. /**
  90923. * Creates a new ValueCondition
  90924. * @param actionManager manager for the action the condition applies to
  90925. * @param target for the action
  90926. * @param propertyPath path to specify the property of the target the conditional operator uses
  90927. * @param value the value compared by the conditional operator against the current value of the property
  90928. * @param operator the conditional operator, default ValueCondition.IsEqual
  90929. */
  90930. constructor(actionManager: ActionManager, target: any,
  90931. /** path to specify the property of the target the conditional operator uses */
  90932. propertyPath: string,
  90933. /** the value compared by the conditional operator against the current value of the property */
  90934. value: any,
  90935. /** the conditional operator, default ValueCondition.IsEqual */
  90936. operator?: number);
  90937. /**
  90938. * Compares the given value with the property value for the specified conditional operator
  90939. * @returns the result of the comparison
  90940. */
  90941. isValid(): boolean;
  90942. /**
  90943. * Serialize the ValueCondition into a JSON compatible object
  90944. * @returns serialization object
  90945. */
  90946. serialize(): any;
  90947. /**
  90948. * Gets the name of the conditional operator for the ValueCondition
  90949. * @param operator the conditional operator
  90950. * @returns the name
  90951. */
  90952. static GetOperatorName(operator: number): string;
  90953. }
  90954. /**
  90955. * Defines a predicate condition as an extension of Condition
  90956. */
  90957. export class PredicateCondition extends Condition {
  90958. /** defines the predicate function used to validate the condition */
  90959. predicate: () => boolean;
  90960. /**
  90961. * Internal only - manager for action
  90962. * @hidden
  90963. */
  90964. _actionManager: ActionManager;
  90965. /**
  90966. * Creates a new PredicateCondition
  90967. * @param actionManager manager for the action the condition applies to
  90968. * @param predicate defines the predicate function used to validate the condition
  90969. */
  90970. constructor(actionManager: ActionManager,
  90971. /** defines the predicate function used to validate the condition */
  90972. predicate: () => boolean);
  90973. /**
  90974. * @returns the validity of the predicate condition
  90975. */
  90976. isValid(): boolean;
  90977. }
  90978. /**
  90979. * Defines a state condition as an extension of Condition
  90980. */
  90981. export class StateCondition extends Condition {
  90982. /** Value to compare with target state */
  90983. value: string;
  90984. /**
  90985. * Internal only - manager for action
  90986. * @hidden
  90987. */
  90988. _actionManager: ActionManager;
  90989. /**
  90990. * Internal only
  90991. * @hidden
  90992. */
  90993. private _target;
  90994. /**
  90995. * Creates a new StateCondition
  90996. * @param actionManager manager for the action the condition applies to
  90997. * @param target of the condition
  90998. * @param value to compare with target state
  90999. */
  91000. constructor(actionManager: ActionManager, target: any,
  91001. /** Value to compare with target state */
  91002. value: string);
  91003. /**
  91004. * Gets a boolean indicating if the current condition is met
  91005. * @returns the validity of the state
  91006. */
  91007. isValid(): boolean;
  91008. /**
  91009. * Serialize the StateCondition into a JSON compatible object
  91010. * @returns serialization object
  91011. */
  91012. serialize(): any;
  91013. }
  91014. }
  91015. declare module BABYLON {
  91016. /**
  91017. * This defines an action responsible to toggle a boolean once triggered.
  91018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91019. */
  91020. export class SwitchBooleanAction extends Action {
  91021. /**
  91022. * The path to the boolean property in the target object
  91023. */
  91024. propertyPath: string;
  91025. private _target;
  91026. private _effectiveTarget;
  91027. private _property;
  91028. /**
  91029. * Instantiate the action
  91030. * @param triggerOptions defines the trigger options
  91031. * @param target defines the object containing the boolean
  91032. * @param propertyPath defines the path to the boolean property in the target object
  91033. * @param condition defines the trigger related conditions
  91034. */
  91035. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91036. /** @hidden */
  91037. _prepare(): void;
  91038. /**
  91039. * Execute the action toggle the boolean value.
  91040. */
  91041. execute(): void;
  91042. /**
  91043. * Serializes the actions and its related information.
  91044. * @param parent defines the object to serialize in
  91045. * @returns the serialized object
  91046. */
  91047. serialize(parent: any): any;
  91048. }
  91049. /**
  91050. * This defines an action responsible to set a the state field of the target
  91051. * to a desired value once triggered.
  91052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91053. */
  91054. export class SetStateAction extends Action {
  91055. /**
  91056. * The value to store in the state field.
  91057. */
  91058. value: string;
  91059. private _target;
  91060. /**
  91061. * Instantiate the action
  91062. * @param triggerOptions defines the trigger options
  91063. * @param target defines the object containing the state property
  91064. * @param value defines the value to store in the state field
  91065. * @param condition defines the trigger related conditions
  91066. */
  91067. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91068. /**
  91069. * Execute the action and store the value on the target state property.
  91070. */
  91071. execute(): void;
  91072. /**
  91073. * Serializes the actions and its related information.
  91074. * @param parent defines the object to serialize in
  91075. * @returns the serialized object
  91076. */
  91077. serialize(parent: any): any;
  91078. }
  91079. /**
  91080. * This defines an action responsible to set a property of the target
  91081. * to a desired value once triggered.
  91082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91083. */
  91084. export class SetValueAction extends Action {
  91085. /**
  91086. * The path of the property to set in the target.
  91087. */
  91088. propertyPath: string;
  91089. /**
  91090. * The value to set in the property
  91091. */
  91092. value: any;
  91093. private _target;
  91094. private _effectiveTarget;
  91095. private _property;
  91096. /**
  91097. * Instantiate the action
  91098. * @param triggerOptions defines the trigger options
  91099. * @param target defines the object containing the property
  91100. * @param propertyPath defines the path of the property to set in the target
  91101. * @param value defines the value to set in the property
  91102. * @param condition defines the trigger related conditions
  91103. */
  91104. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91105. /** @hidden */
  91106. _prepare(): void;
  91107. /**
  91108. * Execute the action and set the targetted property to the desired value.
  91109. */
  91110. execute(): void;
  91111. /**
  91112. * Serializes the actions and its related information.
  91113. * @param parent defines the object to serialize in
  91114. * @returns the serialized object
  91115. */
  91116. serialize(parent: any): any;
  91117. }
  91118. /**
  91119. * This defines an action responsible to increment the target value
  91120. * to a desired value once triggered.
  91121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91122. */
  91123. export class IncrementValueAction extends Action {
  91124. /**
  91125. * The path of the property to increment in the target.
  91126. */
  91127. propertyPath: string;
  91128. /**
  91129. * The value we should increment the property by.
  91130. */
  91131. value: any;
  91132. private _target;
  91133. private _effectiveTarget;
  91134. private _property;
  91135. /**
  91136. * Instantiate the action
  91137. * @param triggerOptions defines the trigger options
  91138. * @param target defines the object containing the property
  91139. * @param propertyPath defines the path of the property to increment in the target
  91140. * @param value defines the value value we should increment the property by
  91141. * @param condition defines the trigger related conditions
  91142. */
  91143. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91144. /** @hidden */
  91145. _prepare(): void;
  91146. /**
  91147. * Execute the action and increment the target of the value amount.
  91148. */
  91149. execute(): void;
  91150. /**
  91151. * Serializes the actions and its related information.
  91152. * @param parent defines the object to serialize in
  91153. * @returns the serialized object
  91154. */
  91155. serialize(parent: any): any;
  91156. }
  91157. /**
  91158. * This defines an action responsible to start an animation once triggered.
  91159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91160. */
  91161. export class PlayAnimationAction extends Action {
  91162. /**
  91163. * Where the animation should start (animation frame)
  91164. */
  91165. from: number;
  91166. /**
  91167. * Where the animation should stop (animation frame)
  91168. */
  91169. to: number;
  91170. /**
  91171. * Define if the animation should loop or stop after the first play.
  91172. */
  91173. loop?: boolean;
  91174. private _target;
  91175. /**
  91176. * Instantiate the action
  91177. * @param triggerOptions defines the trigger options
  91178. * @param target defines the target animation or animation name
  91179. * @param from defines from where the animation should start (animation frame)
  91180. * @param end defines where the animation should stop (animation frame)
  91181. * @param loop defines if the animation should loop or stop after the first play
  91182. * @param condition defines the trigger related conditions
  91183. */
  91184. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91185. /** @hidden */
  91186. _prepare(): void;
  91187. /**
  91188. * Execute the action and play the animation.
  91189. */
  91190. execute(): void;
  91191. /**
  91192. * Serializes the actions and its related information.
  91193. * @param parent defines the object to serialize in
  91194. * @returns the serialized object
  91195. */
  91196. serialize(parent: any): any;
  91197. }
  91198. /**
  91199. * This defines an action responsible to stop an animation once triggered.
  91200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91201. */
  91202. export class StopAnimationAction extends Action {
  91203. private _target;
  91204. /**
  91205. * Instantiate the action
  91206. * @param triggerOptions defines the trigger options
  91207. * @param target defines the target animation or animation name
  91208. * @param condition defines the trigger related conditions
  91209. */
  91210. constructor(triggerOptions: any, target: any, condition?: Condition);
  91211. /** @hidden */
  91212. _prepare(): void;
  91213. /**
  91214. * Execute the action and stop the animation.
  91215. */
  91216. execute(): void;
  91217. /**
  91218. * Serializes the actions and its related information.
  91219. * @param parent defines the object to serialize in
  91220. * @returns the serialized object
  91221. */
  91222. serialize(parent: any): any;
  91223. }
  91224. /**
  91225. * This defines an action responsible that does nothing once triggered.
  91226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91227. */
  91228. export class DoNothingAction extends Action {
  91229. /**
  91230. * Instantiate the action
  91231. * @param triggerOptions defines the trigger options
  91232. * @param condition defines the trigger related conditions
  91233. */
  91234. constructor(triggerOptions?: any, condition?: Condition);
  91235. /**
  91236. * Execute the action and do nothing.
  91237. */
  91238. execute(): void;
  91239. /**
  91240. * Serializes the actions and its related information.
  91241. * @param parent defines the object to serialize in
  91242. * @returns the serialized object
  91243. */
  91244. serialize(parent: any): any;
  91245. }
  91246. /**
  91247. * This defines an action responsible to trigger several actions once triggered.
  91248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91249. */
  91250. export class CombineAction extends Action {
  91251. /**
  91252. * The list of aggregated animations to run.
  91253. */
  91254. children: Action[];
  91255. /**
  91256. * Instantiate the action
  91257. * @param triggerOptions defines the trigger options
  91258. * @param children defines the list of aggregated animations to run
  91259. * @param condition defines the trigger related conditions
  91260. */
  91261. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91262. /** @hidden */
  91263. _prepare(): void;
  91264. /**
  91265. * Execute the action and executes all the aggregated actions.
  91266. */
  91267. execute(evt: ActionEvent): void;
  91268. /**
  91269. * Serializes the actions and its related information.
  91270. * @param parent defines the object to serialize in
  91271. * @returns the serialized object
  91272. */
  91273. serialize(parent: any): any;
  91274. }
  91275. /**
  91276. * This defines an action responsible to run code (external event) once triggered.
  91277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91278. */
  91279. export class ExecuteCodeAction extends Action {
  91280. /**
  91281. * The callback function to run.
  91282. */
  91283. func: (evt: ActionEvent) => void;
  91284. /**
  91285. * Instantiate the action
  91286. * @param triggerOptions defines the trigger options
  91287. * @param func defines the callback function to run
  91288. * @param condition defines the trigger related conditions
  91289. */
  91290. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91291. /**
  91292. * Execute the action and run the attached code.
  91293. */
  91294. execute(evt: ActionEvent): void;
  91295. }
  91296. /**
  91297. * This defines an action responsible to set the parent property of the target once triggered.
  91298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91299. */
  91300. export class SetParentAction extends Action {
  91301. private _parent;
  91302. private _target;
  91303. /**
  91304. * Instantiate the action
  91305. * @param triggerOptions defines the trigger options
  91306. * @param target defines the target containing the parent property
  91307. * @param parent defines from where the animation should start (animation frame)
  91308. * @param condition defines the trigger related conditions
  91309. */
  91310. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91311. /** @hidden */
  91312. _prepare(): void;
  91313. /**
  91314. * Execute the action and set the parent property.
  91315. */
  91316. execute(): void;
  91317. /**
  91318. * Serializes the actions and its related information.
  91319. * @param parent defines the object to serialize in
  91320. * @returns the serialized object
  91321. */
  91322. serialize(parent: any): any;
  91323. }
  91324. }
  91325. declare module BABYLON {
  91326. /**
  91327. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91328. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91330. */
  91331. export class ActionManager extends AbstractActionManager {
  91332. /**
  91333. * Nothing
  91334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91335. */
  91336. static readonly NothingTrigger: number;
  91337. /**
  91338. * On pick
  91339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91340. */
  91341. static readonly OnPickTrigger: number;
  91342. /**
  91343. * On left pick
  91344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91345. */
  91346. static readonly OnLeftPickTrigger: number;
  91347. /**
  91348. * On right pick
  91349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91350. */
  91351. static readonly OnRightPickTrigger: number;
  91352. /**
  91353. * On center pick
  91354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91355. */
  91356. static readonly OnCenterPickTrigger: number;
  91357. /**
  91358. * On pick down
  91359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91360. */
  91361. static readonly OnPickDownTrigger: number;
  91362. /**
  91363. * On double pick
  91364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91365. */
  91366. static readonly OnDoublePickTrigger: number;
  91367. /**
  91368. * On pick up
  91369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91370. */
  91371. static readonly OnPickUpTrigger: number;
  91372. /**
  91373. * On pick out.
  91374. * This trigger will only be raised if you also declared a OnPickDown
  91375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91376. */
  91377. static readonly OnPickOutTrigger: number;
  91378. /**
  91379. * On long press
  91380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91381. */
  91382. static readonly OnLongPressTrigger: number;
  91383. /**
  91384. * On pointer over
  91385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91386. */
  91387. static readonly OnPointerOverTrigger: number;
  91388. /**
  91389. * On pointer out
  91390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91391. */
  91392. static readonly OnPointerOutTrigger: number;
  91393. /**
  91394. * On every frame
  91395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91396. */
  91397. static readonly OnEveryFrameTrigger: number;
  91398. /**
  91399. * On intersection enter
  91400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91401. */
  91402. static readonly OnIntersectionEnterTrigger: number;
  91403. /**
  91404. * On intersection exit
  91405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91406. */
  91407. static readonly OnIntersectionExitTrigger: number;
  91408. /**
  91409. * On key down
  91410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91411. */
  91412. static readonly OnKeyDownTrigger: number;
  91413. /**
  91414. * On key up
  91415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91416. */
  91417. static readonly OnKeyUpTrigger: number;
  91418. private _scene;
  91419. /**
  91420. * Creates a new action manager
  91421. * @param scene defines the hosting scene
  91422. */
  91423. constructor(scene: Scene);
  91424. /**
  91425. * Releases all associated resources
  91426. */
  91427. dispose(): void;
  91428. /**
  91429. * Gets hosting scene
  91430. * @returns the hosting scene
  91431. */
  91432. getScene(): Scene;
  91433. /**
  91434. * Does this action manager handles actions of any of the given triggers
  91435. * @param triggers defines the triggers to be tested
  91436. * @return a boolean indicating whether one (or more) of the triggers is handled
  91437. */
  91438. hasSpecificTriggers(triggers: number[]): boolean;
  91439. /**
  91440. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91441. * speed.
  91442. * @param triggerA defines the trigger to be tested
  91443. * @param triggerB defines the trigger to be tested
  91444. * @return a boolean indicating whether one (or more) of the triggers is handled
  91445. */
  91446. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91447. /**
  91448. * Does this action manager handles actions of a given trigger
  91449. * @param trigger defines the trigger to be tested
  91450. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91451. * @return whether the trigger is handled
  91452. */
  91453. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91454. /**
  91455. * Does this action manager has pointer triggers
  91456. */
  91457. get hasPointerTriggers(): boolean;
  91458. /**
  91459. * Does this action manager has pick triggers
  91460. */
  91461. get hasPickTriggers(): boolean;
  91462. /**
  91463. * Registers an action to this action manager
  91464. * @param action defines the action to be registered
  91465. * @return the action amended (prepared) after registration
  91466. */
  91467. registerAction(action: IAction): Nullable<IAction>;
  91468. /**
  91469. * Unregisters an action to this action manager
  91470. * @param action defines the action to be unregistered
  91471. * @return a boolean indicating whether the action has been unregistered
  91472. */
  91473. unregisterAction(action: IAction): Boolean;
  91474. /**
  91475. * Process a specific trigger
  91476. * @param trigger defines the trigger to process
  91477. * @param evt defines the event details to be processed
  91478. */
  91479. processTrigger(trigger: number, evt?: IActionEvent): void;
  91480. /** @hidden */
  91481. _getEffectiveTarget(target: any, propertyPath: string): any;
  91482. /** @hidden */
  91483. _getProperty(propertyPath: string): string;
  91484. /**
  91485. * Serialize this manager to a JSON object
  91486. * @param name defines the property name to store this manager
  91487. * @returns a JSON representation of this manager
  91488. */
  91489. serialize(name: string): any;
  91490. /**
  91491. * Creates a new ActionManager from a JSON data
  91492. * @param parsedActions defines the JSON data to read from
  91493. * @param object defines the hosting mesh
  91494. * @param scene defines the hosting scene
  91495. */
  91496. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91497. /**
  91498. * Get a trigger name by index
  91499. * @param trigger defines the trigger index
  91500. * @returns a trigger name
  91501. */
  91502. static GetTriggerName(trigger: number): string;
  91503. }
  91504. }
  91505. declare module BABYLON {
  91506. /**
  91507. * Class used to represent a sprite
  91508. * @see http://doc.babylonjs.com/babylon101/sprites
  91509. */
  91510. export class Sprite {
  91511. /** defines the name */
  91512. name: string;
  91513. /** Gets or sets the current world position */
  91514. position: Vector3;
  91515. /** Gets or sets the main color */
  91516. color: Color4;
  91517. /** Gets or sets the width */
  91518. width: number;
  91519. /** Gets or sets the height */
  91520. height: number;
  91521. /** Gets or sets rotation angle */
  91522. angle: number;
  91523. /** Gets or sets the cell index in the sprite sheet */
  91524. cellIndex: number;
  91525. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91526. cellRef: string;
  91527. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91528. invertU: number;
  91529. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91530. invertV: number;
  91531. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91532. disposeWhenFinishedAnimating: boolean;
  91533. /** Gets the list of attached animations */
  91534. animations: Animation[];
  91535. /** Gets or sets a boolean indicating if the sprite can be picked */
  91536. isPickable: boolean;
  91537. /**
  91538. * Gets or sets the associated action manager
  91539. */
  91540. actionManager: Nullable<ActionManager>;
  91541. private _animationStarted;
  91542. private _loopAnimation;
  91543. private _fromIndex;
  91544. private _toIndex;
  91545. private _delay;
  91546. private _direction;
  91547. private _manager;
  91548. private _time;
  91549. private _onAnimationEnd;
  91550. /**
  91551. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91552. */
  91553. isVisible: boolean;
  91554. /**
  91555. * Gets or sets the sprite size
  91556. */
  91557. get size(): number;
  91558. set size(value: number);
  91559. /**
  91560. * Creates a new Sprite
  91561. * @param name defines the name
  91562. * @param manager defines the manager
  91563. */
  91564. constructor(
  91565. /** defines the name */
  91566. name: string, manager: ISpriteManager);
  91567. /**
  91568. * Starts an animation
  91569. * @param from defines the initial key
  91570. * @param to defines the end key
  91571. * @param loop defines if the animation must loop
  91572. * @param delay defines the start delay (in ms)
  91573. * @param onAnimationEnd defines a callback to call when animation ends
  91574. */
  91575. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91576. /** Stops current animation (if any) */
  91577. stopAnimation(): void;
  91578. /** @hidden */
  91579. _animate(deltaTime: number): void;
  91580. /** Release associated resources */
  91581. dispose(): void;
  91582. }
  91583. }
  91584. declare module BABYLON {
  91585. /**
  91586. * Information about the result of picking within a scene
  91587. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91588. */
  91589. export class PickingInfo {
  91590. /** @hidden */
  91591. _pickingUnavailable: boolean;
  91592. /**
  91593. * If the pick collided with an object
  91594. */
  91595. hit: boolean;
  91596. /**
  91597. * Distance away where the pick collided
  91598. */
  91599. distance: number;
  91600. /**
  91601. * The location of pick collision
  91602. */
  91603. pickedPoint: Nullable<Vector3>;
  91604. /**
  91605. * The mesh corresponding the the pick collision
  91606. */
  91607. pickedMesh: Nullable<AbstractMesh>;
  91608. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91609. bu: number;
  91610. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91611. bv: number;
  91612. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91613. faceId: number;
  91614. /** Id of the the submesh that was picked */
  91615. subMeshId: number;
  91616. /** If a sprite was picked, this will be the sprite the pick collided with */
  91617. pickedSprite: Nullable<Sprite>;
  91618. /**
  91619. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91620. */
  91621. originMesh: Nullable<AbstractMesh>;
  91622. /**
  91623. * The ray that was used to perform the picking.
  91624. */
  91625. ray: Nullable<Ray>;
  91626. /**
  91627. * Gets the normal correspodning to the face the pick collided with
  91628. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91629. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91630. * @returns The normal correspodning to the face the pick collided with
  91631. */
  91632. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91633. /**
  91634. * Gets the texture coordinates of where the pick occured
  91635. * @returns the vector containing the coordnates of the texture
  91636. */
  91637. getTextureCoordinates(): Nullable<Vector2>;
  91638. }
  91639. }
  91640. declare module BABYLON {
  91641. /**
  91642. * Gather the list of pointer event types as constants.
  91643. */
  91644. export class PointerEventTypes {
  91645. /**
  91646. * 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.
  91647. */
  91648. static readonly POINTERDOWN: number;
  91649. /**
  91650. * The pointerup event is fired when a pointer is no longer active.
  91651. */
  91652. static readonly POINTERUP: number;
  91653. /**
  91654. * The pointermove event is fired when a pointer changes coordinates.
  91655. */
  91656. static readonly POINTERMOVE: number;
  91657. /**
  91658. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91659. */
  91660. static readonly POINTERWHEEL: number;
  91661. /**
  91662. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91663. */
  91664. static readonly POINTERPICK: number;
  91665. /**
  91666. * The pointertap event is fired when a the object has been touched and released without drag.
  91667. */
  91668. static readonly POINTERTAP: number;
  91669. /**
  91670. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91671. */
  91672. static readonly POINTERDOUBLETAP: number;
  91673. }
  91674. /**
  91675. * Base class of pointer info types.
  91676. */
  91677. export class PointerInfoBase {
  91678. /**
  91679. * Defines the type of event (PointerEventTypes)
  91680. */
  91681. type: number;
  91682. /**
  91683. * Defines the related dom event
  91684. */
  91685. event: PointerEvent | MouseWheelEvent;
  91686. /**
  91687. * Instantiates the base class of pointers info.
  91688. * @param type Defines the type of event (PointerEventTypes)
  91689. * @param event Defines the related dom event
  91690. */
  91691. constructor(
  91692. /**
  91693. * Defines the type of event (PointerEventTypes)
  91694. */
  91695. type: number,
  91696. /**
  91697. * Defines the related dom event
  91698. */
  91699. event: PointerEvent | MouseWheelEvent);
  91700. }
  91701. /**
  91702. * This class is used to store pointer related info for the onPrePointerObservable event.
  91703. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91704. */
  91705. export class PointerInfoPre extends PointerInfoBase {
  91706. /**
  91707. * Ray from a pointer if availible (eg. 6dof controller)
  91708. */
  91709. ray: Nullable<Ray>;
  91710. /**
  91711. * Defines the local position of the pointer on the canvas.
  91712. */
  91713. localPosition: Vector2;
  91714. /**
  91715. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91716. */
  91717. skipOnPointerObservable: boolean;
  91718. /**
  91719. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91720. * @param type Defines the type of event (PointerEventTypes)
  91721. * @param event Defines the related dom event
  91722. * @param localX Defines the local x coordinates of the pointer when the event occured
  91723. * @param localY Defines the local y coordinates of the pointer when the event occured
  91724. */
  91725. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91726. }
  91727. /**
  91728. * This type contains all the data related to a pointer event in Babylon.js.
  91729. * 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.
  91730. */
  91731. export class PointerInfo extends PointerInfoBase {
  91732. /**
  91733. * Defines the picking info associated to the info (if any)\
  91734. */
  91735. pickInfo: Nullable<PickingInfo>;
  91736. /**
  91737. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91738. * @param type Defines the type of event (PointerEventTypes)
  91739. * @param event Defines the related dom event
  91740. * @param pickInfo Defines the picking info associated to the info (if any)\
  91741. */
  91742. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91743. /**
  91744. * Defines the picking info associated to the info (if any)\
  91745. */
  91746. pickInfo: Nullable<PickingInfo>);
  91747. }
  91748. /**
  91749. * Data relating to a touch event on the screen.
  91750. */
  91751. export interface PointerTouch {
  91752. /**
  91753. * X coordinate of touch.
  91754. */
  91755. x: number;
  91756. /**
  91757. * Y coordinate of touch.
  91758. */
  91759. y: number;
  91760. /**
  91761. * Id of touch. Unique for each finger.
  91762. */
  91763. pointerId: number;
  91764. /**
  91765. * Event type passed from DOM.
  91766. */
  91767. type: any;
  91768. }
  91769. }
  91770. declare module BABYLON {
  91771. /**
  91772. * Manage the mouse inputs to control the movement of a free camera.
  91773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91774. */
  91775. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91776. /**
  91777. * Define if touch is enabled in the mouse input
  91778. */
  91779. touchEnabled: boolean;
  91780. /**
  91781. * Defines the camera the input is attached to.
  91782. */
  91783. camera: FreeCamera;
  91784. /**
  91785. * Defines the buttons associated with the input to handle camera move.
  91786. */
  91787. buttons: number[];
  91788. /**
  91789. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91790. */
  91791. angularSensibility: number;
  91792. private _pointerInput;
  91793. private _onMouseMove;
  91794. private _observer;
  91795. private previousPosition;
  91796. /**
  91797. * Observable for when a pointer move event occurs containing the move offset
  91798. */
  91799. onPointerMovedObservable: Observable<{
  91800. offsetX: number;
  91801. offsetY: number;
  91802. }>;
  91803. /**
  91804. * @hidden
  91805. * If the camera should be rotated automatically based on pointer movement
  91806. */
  91807. _allowCameraRotation: boolean;
  91808. /**
  91809. * Manage the mouse inputs to control the movement of a free camera.
  91810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91811. * @param touchEnabled Defines if touch is enabled or not
  91812. */
  91813. constructor(
  91814. /**
  91815. * Define if touch is enabled in the mouse input
  91816. */
  91817. touchEnabled?: boolean);
  91818. /**
  91819. * Attach the input controls to a specific dom element to get the input from.
  91820. * @param element Defines the element the controls should be listened from
  91821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91822. */
  91823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91824. /**
  91825. * Called on JS contextmenu event.
  91826. * Override this method to provide functionality.
  91827. */
  91828. protected onContextMenu(evt: PointerEvent): void;
  91829. /**
  91830. * Detach the current controls from the specified dom element.
  91831. * @param element Defines the element to stop listening the inputs from
  91832. */
  91833. detachControl(element: Nullable<HTMLElement>): void;
  91834. /**
  91835. * Gets the class name of the current intput.
  91836. * @returns the class name
  91837. */
  91838. getClassName(): string;
  91839. /**
  91840. * Get the friendly name associated with the input class.
  91841. * @returns the input friendly name
  91842. */
  91843. getSimpleName(): string;
  91844. }
  91845. }
  91846. declare module BABYLON {
  91847. /**
  91848. * Manage the touch inputs to control the movement of a free camera.
  91849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91850. */
  91851. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91852. /**
  91853. * Defines the camera the input is attached to.
  91854. */
  91855. camera: FreeCamera;
  91856. /**
  91857. * Defines the touch sensibility for rotation.
  91858. * The higher the faster.
  91859. */
  91860. touchAngularSensibility: number;
  91861. /**
  91862. * Defines the touch sensibility for move.
  91863. * The higher the faster.
  91864. */
  91865. touchMoveSensibility: number;
  91866. private _offsetX;
  91867. private _offsetY;
  91868. private _pointerPressed;
  91869. private _pointerInput;
  91870. private _observer;
  91871. private _onLostFocus;
  91872. /**
  91873. * Attach the input controls to a specific dom element to get the input from.
  91874. * @param element Defines the element the controls should be listened from
  91875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91876. */
  91877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91878. /**
  91879. * Detach the current controls from the specified dom element.
  91880. * @param element Defines the element to stop listening the inputs from
  91881. */
  91882. detachControl(element: Nullable<HTMLElement>): void;
  91883. /**
  91884. * Update the current camera state depending on the inputs that have been used this frame.
  91885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91886. */
  91887. checkInputs(): void;
  91888. /**
  91889. * Gets the class name of the current intput.
  91890. * @returns the class name
  91891. */
  91892. getClassName(): string;
  91893. /**
  91894. * Get the friendly name associated with the input class.
  91895. * @returns the input friendly name
  91896. */
  91897. getSimpleName(): string;
  91898. }
  91899. }
  91900. declare module BABYLON {
  91901. /**
  91902. * Default Inputs manager for the FreeCamera.
  91903. * It groups all the default supported inputs for ease of use.
  91904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91905. */
  91906. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91907. /**
  91908. * @hidden
  91909. */
  91910. _mouseInput: Nullable<FreeCameraMouseInput>;
  91911. /**
  91912. * Instantiates a new FreeCameraInputsManager.
  91913. * @param camera Defines the camera the inputs belong to
  91914. */
  91915. constructor(camera: FreeCamera);
  91916. /**
  91917. * Add keyboard input support to the input manager.
  91918. * @returns the current input manager
  91919. */
  91920. addKeyboard(): FreeCameraInputsManager;
  91921. /**
  91922. * Add mouse input support to the input manager.
  91923. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91924. * @returns the current input manager
  91925. */
  91926. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91927. /**
  91928. * Removes the mouse input support from the manager
  91929. * @returns the current input manager
  91930. */
  91931. removeMouse(): FreeCameraInputsManager;
  91932. /**
  91933. * Add touch input support to the input manager.
  91934. * @returns the current input manager
  91935. */
  91936. addTouch(): FreeCameraInputsManager;
  91937. /**
  91938. * Remove all attached input methods from a camera
  91939. */
  91940. clear(): void;
  91941. }
  91942. }
  91943. declare module BABYLON {
  91944. /**
  91945. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91946. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91948. */
  91949. export class FreeCamera extends TargetCamera {
  91950. /**
  91951. * Define the collision ellipsoid of the camera.
  91952. * This is helpful to simulate a camera body like the player body around the camera
  91953. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91954. */
  91955. ellipsoid: Vector3;
  91956. /**
  91957. * Define an offset for the position of the ellipsoid around the camera.
  91958. * This can be helpful to determine the center of the body near the gravity center of the body
  91959. * instead of its head.
  91960. */
  91961. ellipsoidOffset: Vector3;
  91962. /**
  91963. * Enable or disable collisions of the camera with the rest of the scene objects.
  91964. */
  91965. checkCollisions: boolean;
  91966. /**
  91967. * Enable or disable gravity on the camera.
  91968. */
  91969. applyGravity: boolean;
  91970. /**
  91971. * Define the input manager associated to the camera.
  91972. */
  91973. inputs: FreeCameraInputsManager;
  91974. /**
  91975. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91976. * Higher values reduce sensitivity.
  91977. */
  91978. get angularSensibility(): number;
  91979. /**
  91980. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91981. * Higher values reduce sensitivity.
  91982. */
  91983. set angularSensibility(value: number);
  91984. /**
  91985. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91986. */
  91987. get keysUp(): number[];
  91988. set keysUp(value: number[]);
  91989. /**
  91990. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  91991. */
  91992. get keysUpward(): number[];
  91993. set keysUpward(value: number[]);
  91994. /**
  91995. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91996. */
  91997. get keysDown(): number[];
  91998. set keysDown(value: number[]);
  91999. /**
  92000. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92001. */
  92002. get keysDownward(): number[];
  92003. set keysDownward(value: number[]);
  92004. /**
  92005. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92006. */
  92007. get keysLeft(): number[];
  92008. set keysLeft(value: number[]);
  92009. /**
  92010. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92011. */
  92012. get keysRight(): number[];
  92013. set keysRight(value: number[]);
  92014. /**
  92015. * Event raised when the camera collide with a mesh in the scene.
  92016. */
  92017. onCollide: (collidedMesh: AbstractMesh) => void;
  92018. private _collider;
  92019. private _needMoveForGravity;
  92020. private _oldPosition;
  92021. private _diffPosition;
  92022. private _newPosition;
  92023. /** @hidden */
  92024. _localDirection: Vector3;
  92025. /** @hidden */
  92026. _transformedDirection: Vector3;
  92027. /**
  92028. * Instantiates a Free Camera.
  92029. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92030. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92031. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92032. * @param name Define the name of the camera in the scene
  92033. * @param position Define the start position of the camera in the scene
  92034. * @param scene Define the scene the camera belongs to
  92035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92036. */
  92037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92038. /**
  92039. * Attached controls to the current camera.
  92040. * @param element Defines the element the controls should be listened from
  92041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92042. */
  92043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92044. /**
  92045. * Detach the current controls from the camera.
  92046. * The camera will stop reacting to inputs.
  92047. * @param element Defines the element to stop listening the inputs from
  92048. */
  92049. detachControl(element: HTMLElement): void;
  92050. private _collisionMask;
  92051. /**
  92052. * Define a collision mask to limit the list of object the camera can collide with
  92053. */
  92054. get collisionMask(): number;
  92055. set collisionMask(mask: number);
  92056. /** @hidden */
  92057. _collideWithWorld(displacement: Vector3): void;
  92058. private _onCollisionPositionChange;
  92059. /** @hidden */
  92060. _checkInputs(): void;
  92061. /** @hidden */
  92062. _decideIfNeedsToMove(): boolean;
  92063. /** @hidden */
  92064. _updatePosition(): void;
  92065. /**
  92066. * Destroy the camera and release the current resources hold by it.
  92067. */
  92068. dispose(): void;
  92069. /**
  92070. * Gets the current object class name.
  92071. * @return the class name
  92072. */
  92073. getClassName(): string;
  92074. }
  92075. }
  92076. declare module BABYLON {
  92077. /**
  92078. * Represents a gamepad control stick position
  92079. */
  92080. export class StickValues {
  92081. /**
  92082. * The x component of the control stick
  92083. */
  92084. x: number;
  92085. /**
  92086. * The y component of the control stick
  92087. */
  92088. y: number;
  92089. /**
  92090. * Initializes the gamepad x and y control stick values
  92091. * @param x The x component of the gamepad control stick value
  92092. * @param y The y component of the gamepad control stick value
  92093. */
  92094. constructor(
  92095. /**
  92096. * The x component of the control stick
  92097. */
  92098. x: number,
  92099. /**
  92100. * The y component of the control stick
  92101. */
  92102. y: number);
  92103. }
  92104. /**
  92105. * An interface which manages callbacks for gamepad button changes
  92106. */
  92107. export interface GamepadButtonChanges {
  92108. /**
  92109. * Called when a gamepad has been changed
  92110. */
  92111. changed: boolean;
  92112. /**
  92113. * Called when a gamepad press event has been triggered
  92114. */
  92115. pressChanged: boolean;
  92116. /**
  92117. * Called when a touch event has been triggered
  92118. */
  92119. touchChanged: boolean;
  92120. /**
  92121. * Called when a value has changed
  92122. */
  92123. valueChanged: boolean;
  92124. }
  92125. /**
  92126. * Represents a gamepad
  92127. */
  92128. export class Gamepad {
  92129. /**
  92130. * The id of the gamepad
  92131. */
  92132. id: string;
  92133. /**
  92134. * The index of the gamepad
  92135. */
  92136. index: number;
  92137. /**
  92138. * The browser gamepad
  92139. */
  92140. browserGamepad: any;
  92141. /**
  92142. * Specifies what type of gamepad this represents
  92143. */
  92144. type: number;
  92145. private _leftStick;
  92146. private _rightStick;
  92147. /** @hidden */
  92148. _isConnected: boolean;
  92149. private _leftStickAxisX;
  92150. private _leftStickAxisY;
  92151. private _rightStickAxisX;
  92152. private _rightStickAxisY;
  92153. /**
  92154. * Triggered when the left control stick has been changed
  92155. */
  92156. private _onleftstickchanged;
  92157. /**
  92158. * Triggered when the right control stick has been changed
  92159. */
  92160. private _onrightstickchanged;
  92161. /**
  92162. * Represents a gamepad controller
  92163. */
  92164. static GAMEPAD: number;
  92165. /**
  92166. * Represents a generic controller
  92167. */
  92168. static GENERIC: number;
  92169. /**
  92170. * Represents an XBox controller
  92171. */
  92172. static XBOX: number;
  92173. /**
  92174. * Represents a pose-enabled controller
  92175. */
  92176. static POSE_ENABLED: number;
  92177. /**
  92178. * Represents an Dual Shock controller
  92179. */
  92180. static DUALSHOCK: number;
  92181. /**
  92182. * Specifies whether the left control stick should be Y-inverted
  92183. */
  92184. protected _invertLeftStickY: boolean;
  92185. /**
  92186. * Specifies if the gamepad has been connected
  92187. */
  92188. get isConnected(): boolean;
  92189. /**
  92190. * Initializes the gamepad
  92191. * @param id The id of the gamepad
  92192. * @param index The index of the gamepad
  92193. * @param browserGamepad The browser gamepad
  92194. * @param leftStickX The x component of the left joystick
  92195. * @param leftStickY The y component of the left joystick
  92196. * @param rightStickX The x component of the right joystick
  92197. * @param rightStickY The y component of the right joystick
  92198. */
  92199. constructor(
  92200. /**
  92201. * The id of the gamepad
  92202. */
  92203. id: string,
  92204. /**
  92205. * The index of the gamepad
  92206. */
  92207. index: number,
  92208. /**
  92209. * The browser gamepad
  92210. */
  92211. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  92212. /**
  92213. * Callback triggered when the left joystick has changed
  92214. * @param callback
  92215. */
  92216. onleftstickchanged(callback: (values: StickValues) => void): void;
  92217. /**
  92218. * Callback triggered when the right joystick has changed
  92219. * @param callback
  92220. */
  92221. onrightstickchanged(callback: (values: StickValues) => void): void;
  92222. /**
  92223. * Gets the left joystick
  92224. */
  92225. get leftStick(): StickValues;
  92226. /**
  92227. * Sets the left joystick values
  92228. */
  92229. set leftStick(newValues: StickValues);
  92230. /**
  92231. * Gets the right joystick
  92232. */
  92233. get rightStick(): StickValues;
  92234. /**
  92235. * Sets the right joystick value
  92236. */
  92237. set rightStick(newValues: StickValues);
  92238. /**
  92239. * Updates the gamepad joystick positions
  92240. */
  92241. update(): void;
  92242. /**
  92243. * Disposes the gamepad
  92244. */
  92245. dispose(): void;
  92246. }
  92247. /**
  92248. * Represents a generic gamepad
  92249. */
  92250. export class GenericPad extends Gamepad {
  92251. private _buttons;
  92252. private _onbuttondown;
  92253. private _onbuttonup;
  92254. /**
  92255. * Observable triggered when a button has been pressed
  92256. */
  92257. onButtonDownObservable: Observable<number>;
  92258. /**
  92259. * Observable triggered when a button has been released
  92260. */
  92261. onButtonUpObservable: Observable<number>;
  92262. /**
  92263. * Callback triggered when a button has been pressed
  92264. * @param callback Called when a button has been pressed
  92265. */
  92266. onbuttondown(callback: (buttonPressed: number) => void): void;
  92267. /**
  92268. * Callback triggered when a button has been released
  92269. * @param callback Called when a button has been released
  92270. */
  92271. onbuttonup(callback: (buttonReleased: number) => void): void;
  92272. /**
  92273. * Initializes the generic gamepad
  92274. * @param id The id of the generic gamepad
  92275. * @param index The index of the generic gamepad
  92276. * @param browserGamepad The browser gamepad
  92277. */
  92278. constructor(id: string, index: number, browserGamepad: any);
  92279. private _setButtonValue;
  92280. /**
  92281. * Updates the generic gamepad
  92282. */
  92283. update(): void;
  92284. /**
  92285. * Disposes the generic gamepad
  92286. */
  92287. dispose(): void;
  92288. }
  92289. }
  92290. declare module BABYLON {
  92291. /**
  92292. * Defines the types of pose enabled controllers that are supported
  92293. */
  92294. export enum PoseEnabledControllerType {
  92295. /**
  92296. * HTC Vive
  92297. */
  92298. VIVE = 0,
  92299. /**
  92300. * Oculus Rift
  92301. */
  92302. OCULUS = 1,
  92303. /**
  92304. * Windows mixed reality
  92305. */
  92306. WINDOWS = 2,
  92307. /**
  92308. * Samsung gear VR
  92309. */
  92310. GEAR_VR = 3,
  92311. /**
  92312. * Google Daydream
  92313. */
  92314. DAYDREAM = 4,
  92315. /**
  92316. * Generic
  92317. */
  92318. GENERIC = 5
  92319. }
  92320. /**
  92321. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92322. */
  92323. export interface MutableGamepadButton {
  92324. /**
  92325. * Value of the button/trigger
  92326. */
  92327. value: number;
  92328. /**
  92329. * If the button/trigger is currently touched
  92330. */
  92331. touched: boolean;
  92332. /**
  92333. * If the button/trigger is currently pressed
  92334. */
  92335. pressed: boolean;
  92336. }
  92337. /**
  92338. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92339. * @hidden
  92340. */
  92341. export interface ExtendedGamepadButton extends GamepadButton {
  92342. /**
  92343. * If the button/trigger is currently pressed
  92344. */
  92345. readonly pressed: boolean;
  92346. /**
  92347. * If the button/trigger is currently touched
  92348. */
  92349. readonly touched: boolean;
  92350. /**
  92351. * Value of the button/trigger
  92352. */
  92353. readonly value: number;
  92354. }
  92355. /** @hidden */
  92356. export interface _GamePadFactory {
  92357. /**
  92358. * Returns whether or not the current gamepad can be created for this type of controller.
  92359. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92360. * @returns true if it can be created, otherwise false
  92361. */
  92362. canCreate(gamepadInfo: any): boolean;
  92363. /**
  92364. * Creates a new instance of the Gamepad.
  92365. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92366. * @returns the new gamepad instance
  92367. */
  92368. create(gamepadInfo: any): Gamepad;
  92369. }
  92370. /**
  92371. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92372. */
  92373. export class PoseEnabledControllerHelper {
  92374. /** @hidden */
  92375. static _ControllerFactories: _GamePadFactory[];
  92376. /** @hidden */
  92377. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92378. /**
  92379. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92380. * @param vrGamepad the gamepad to initialized
  92381. * @returns a vr controller of the type the gamepad identified as
  92382. */
  92383. static InitiateController(vrGamepad: any): Gamepad;
  92384. }
  92385. /**
  92386. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92387. */
  92388. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92389. /**
  92390. * If the controller is used in a webXR session
  92391. */
  92392. isXR: boolean;
  92393. private _deviceRoomPosition;
  92394. private _deviceRoomRotationQuaternion;
  92395. /**
  92396. * The device position in babylon space
  92397. */
  92398. devicePosition: Vector3;
  92399. /**
  92400. * The device rotation in babylon space
  92401. */
  92402. deviceRotationQuaternion: Quaternion;
  92403. /**
  92404. * The scale factor of the device in babylon space
  92405. */
  92406. deviceScaleFactor: number;
  92407. /**
  92408. * (Likely devicePosition should be used instead) The device position in its room space
  92409. */
  92410. position: Vector3;
  92411. /**
  92412. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92413. */
  92414. rotationQuaternion: Quaternion;
  92415. /**
  92416. * The type of controller (Eg. Windows mixed reality)
  92417. */
  92418. controllerType: PoseEnabledControllerType;
  92419. protected _calculatedPosition: Vector3;
  92420. private _calculatedRotation;
  92421. /**
  92422. * The raw pose from the device
  92423. */
  92424. rawPose: DevicePose;
  92425. private _trackPosition;
  92426. private _maxRotationDistFromHeadset;
  92427. private _draggedRoomRotation;
  92428. /**
  92429. * @hidden
  92430. */
  92431. _disableTrackPosition(fixedPosition: Vector3): void;
  92432. /**
  92433. * Internal, the mesh attached to the controller
  92434. * @hidden
  92435. */
  92436. _mesh: Nullable<AbstractMesh>;
  92437. private _poseControlledCamera;
  92438. private _leftHandSystemQuaternion;
  92439. /**
  92440. * Internal, matrix used to convert room space to babylon space
  92441. * @hidden
  92442. */
  92443. _deviceToWorld: Matrix;
  92444. /**
  92445. * Node to be used when casting a ray from the controller
  92446. * @hidden
  92447. */
  92448. _pointingPoseNode: Nullable<TransformNode>;
  92449. /**
  92450. * Name of the child mesh that can be used to cast a ray from the controller
  92451. */
  92452. static readonly POINTING_POSE: string;
  92453. /**
  92454. * Creates a new PoseEnabledController from a gamepad
  92455. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92456. */
  92457. constructor(browserGamepad: any);
  92458. private _workingMatrix;
  92459. /**
  92460. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92461. */
  92462. update(): void;
  92463. /**
  92464. * Updates only the pose device and mesh without doing any button event checking
  92465. */
  92466. protected _updatePoseAndMesh(): void;
  92467. /**
  92468. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92469. * @param poseData raw pose fromthe device
  92470. */
  92471. updateFromDevice(poseData: DevicePose): void;
  92472. /**
  92473. * @hidden
  92474. */
  92475. _meshAttachedObservable: Observable<AbstractMesh>;
  92476. /**
  92477. * Attaches a mesh to the controller
  92478. * @param mesh the mesh to be attached
  92479. */
  92480. attachToMesh(mesh: AbstractMesh): void;
  92481. /**
  92482. * Attaches the controllers mesh to a camera
  92483. * @param camera the camera the mesh should be attached to
  92484. */
  92485. attachToPoseControlledCamera(camera: TargetCamera): void;
  92486. /**
  92487. * Disposes of the controller
  92488. */
  92489. dispose(): void;
  92490. /**
  92491. * The mesh that is attached to the controller
  92492. */
  92493. get mesh(): Nullable<AbstractMesh>;
  92494. /**
  92495. * Gets the ray of the controller in the direction the controller is pointing
  92496. * @param length the length the resulting ray should be
  92497. * @returns a ray in the direction the controller is pointing
  92498. */
  92499. getForwardRay(length?: number): Ray;
  92500. }
  92501. }
  92502. declare module BABYLON {
  92503. /**
  92504. * Defines the WebVRController object that represents controllers tracked in 3D space
  92505. */
  92506. export abstract class WebVRController extends PoseEnabledController {
  92507. /**
  92508. * Internal, the default controller model for the controller
  92509. */
  92510. protected _defaultModel: Nullable<AbstractMesh>;
  92511. /**
  92512. * Fired when the trigger state has changed
  92513. */
  92514. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92515. /**
  92516. * Fired when the main button state has changed
  92517. */
  92518. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92519. /**
  92520. * Fired when the secondary button state has changed
  92521. */
  92522. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92523. /**
  92524. * Fired when the pad state has changed
  92525. */
  92526. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92527. /**
  92528. * Fired when controllers stick values have changed
  92529. */
  92530. onPadValuesChangedObservable: Observable<StickValues>;
  92531. /**
  92532. * Array of button availible on the controller
  92533. */
  92534. protected _buttons: Array<MutableGamepadButton>;
  92535. private _onButtonStateChange;
  92536. /**
  92537. * Fired when a controller button's state has changed
  92538. * @param callback the callback containing the button that was modified
  92539. */
  92540. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92541. /**
  92542. * X and Y axis corresponding to the controllers joystick
  92543. */
  92544. pad: StickValues;
  92545. /**
  92546. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92547. */
  92548. hand: string;
  92549. /**
  92550. * The default controller model for the controller
  92551. */
  92552. get defaultModel(): Nullable<AbstractMesh>;
  92553. /**
  92554. * Creates a new WebVRController from a gamepad
  92555. * @param vrGamepad the gamepad that the WebVRController should be created from
  92556. */
  92557. constructor(vrGamepad: any);
  92558. /**
  92559. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92560. */
  92561. update(): void;
  92562. /**
  92563. * Function to be called when a button is modified
  92564. */
  92565. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92566. /**
  92567. * Loads a mesh and attaches it to the controller
  92568. * @param scene the scene the mesh should be added to
  92569. * @param meshLoaded callback for when the mesh has been loaded
  92570. */
  92571. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92572. private _setButtonValue;
  92573. private _changes;
  92574. private _checkChanges;
  92575. /**
  92576. * Disposes of th webVRCOntroller
  92577. */
  92578. dispose(): void;
  92579. }
  92580. }
  92581. declare module BABYLON {
  92582. /**
  92583. * The HemisphericLight simulates the ambient environment light,
  92584. * so the passed direction is the light reflection direction, not the incoming direction.
  92585. */
  92586. export class HemisphericLight extends Light {
  92587. /**
  92588. * The groundColor is the light in the opposite direction to the one specified during creation.
  92589. * 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.
  92590. */
  92591. groundColor: Color3;
  92592. /**
  92593. * The light reflection direction, not the incoming direction.
  92594. */
  92595. direction: Vector3;
  92596. /**
  92597. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92598. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92599. * The HemisphericLight can't cast shadows.
  92600. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92601. * @param name The friendly name of the light
  92602. * @param direction The direction of the light reflection
  92603. * @param scene The scene the light belongs to
  92604. */
  92605. constructor(name: string, direction: Vector3, scene: Scene);
  92606. protected _buildUniformLayout(): void;
  92607. /**
  92608. * Returns the string "HemisphericLight".
  92609. * @return The class name
  92610. */
  92611. getClassName(): string;
  92612. /**
  92613. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92614. * Returns the updated direction.
  92615. * @param target The target the direction should point to
  92616. * @return The computed direction
  92617. */
  92618. setDirectionToTarget(target: Vector3): Vector3;
  92619. /**
  92620. * Returns the shadow generator associated to the light.
  92621. * @returns Always null for hemispheric lights because it does not support shadows.
  92622. */
  92623. getShadowGenerator(): Nullable<IShadowGenerator>;
  92624. /**
  92625. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92626. * @param effect The effect to update
  92627. * @param lightIndex The index of the light in the effect to update
  92628. * @returns The hemispheric light
  92629. */
  92630. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92631. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92632. /**
  92633. * Computes the world matrix of the node
  92634. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92635. * @param useWasUpdatedFlag defines a reserved property
  92636. * @returns the world matrix
  92637. */
  92638. computeWorldMatrix(): Matrix;
  92639. /**
  92640. * Returns the integer 3.
  92641. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92642. */
  92643. getTypeID(): number;
  92644. /**
  92645. * Prepares the list of defines specific to the light type.
  92646. * @param defines the list of defines
  92647. * @param lightIndex defines the index of the light for the effect
  92648. */
  92649. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92650. }
  92651. }
  92652. declare module BABYLON {
  92653. /** @hidden */
  92654. export var vrMultiviewToSingleviewPixelShader: {
  92655. name: string;
  92656. shader: string;
  92657. };
  92658. }
  92659. declare module BABYLON {
  92660. /**
  92661. * Renders to multiple views with a single draw call
  92662. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92663. */
  92664. export class MultiviewRenderTarget extends RenderTargetTexture {
  92665. /**
  92666. * Creates a multiview render target
  92667. * @param scene scene used with the render target
  92668. * @param size the size of the render target (used for each view)
  92669. */
  92670. constructor(scene: Scene, size?: number | {
  92671. width: number;
  92672. height: number;
  92673. } | {
  92674. ratio: number;
  92675. });
  92676. /**
  92677. * @hidden
  92678. * @param faceIndex the face index, if its a cube texture
  92679. */
  92680. _bindFrameBuffer(faceIndex?: number): void;
  92681. /**
  92682. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92683. * @returns the view count
  92684. */
  92685. getViewCount(): number;
  92686. }
  92687. }
  92688. declare module BABYLON {
  92689. /**
  92690. * Represents a camera frustum
  92691. */
  92692. export class Frustum {
  92693. /**
  92694. * Gets the planes representing the frustum
  92695. * @param transform matrix to be applied to the returned planes
  92696. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92697. */
  92698. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92699. /**
  92700. * Gets the near frustum plane transformed by the transform matrix
  92701. * @param transform transformation matrix to be applied to the resulting frustum plane
  92702. * @param frustumPlane the resuling frustum plane
  92703. */
  92704. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92705. /**
  92706. * Gets the far frustum plane transformed by the transform matrix
  92707. * @param transform transformation matrix to be applied to the resulting frustum plane
  92708. * @param frustumPlane the resuling frustum plane
  92709. */
  92710. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92711. /**
  92712. * Gets the left frustum plane transformed by the transform matrix
  92713. * @param transform transformation matrix to be applied to the resulting frustum plane
  92714. * @param frustumPlane the resuling frustum plane
  92715. */
  92716. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92717. /**
  92718. * Gets the right frustum plane transformed by the transform matrix
  92719. * @param transform transformation matrix to be applied to the resulting frustum plane
  92720. * @param frustumPlane the resuling frustum plane
  92721. */
  92722. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92723. /**
  92724. * Gets the top frustum plane transformed by the transform matrix
  92725. * @param transform transformation matrix to be applied to the resulting frustum plane
  92726. * @param frustumPlane the resuling frustum plane
  92727. */
  92728. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92729. /**
  92730. * Gets the bottom frustum plane transformed by the transform matrix
  92731. * @param transform transformation matrix to be applied to the resulting frustum plane
  92732. * @param frustumPlane the resuling frustum plane
  92733. */
  92734. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92735. /**
  92736. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92737. * @param transform transformation matrix to be applied to the resulting frustum planes
  92738. * @param frustumPlanes the resuling frustum planes
  92739. */
  92740. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92741. }
  92742. }
  92743. declare module BABYLON {
  92744. interface Engine {
  92745. /**
  92746. * Creates a new multiview render target
  92747. * @param width defines the width of the texture
  92748. * @param height defines the height of the texture
  92749. * @returns the created multiview texture
  92750. */
  92751. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92752. /**
  92753. * Binds a multiview framebuffer to be drawn to
  92754. * @param multiviewTexture texture to bind
  92755. */
  92756. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92757. }
  92758. interface Camera {
  92759. /**
  92760. * @hidden
  92761. * 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)
  92762. */
  92763. _useMultiviewToSingleView: boolean;
  92764. /**
  92765. * @hidden
  92766. * 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)
  92767. */
  92768. _multiviewTexture: Nullable<RenderTargetTexture>;
  92769. /**
  92770. * @hidden
  92771. * ensures the multiview texture of the camera exists and has the specified width/height
  92772. * @param width height to set on the multiview texture
  92773. * @param height width to set on the multiview texture
  92774. */
  92775. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92776. }
  92777. interface Scene {
  92778. /** @hidden */
  92779. _transformMatrixR: Matrix;
  92780. /** @hidden */
  92781. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92782. /** @hidden */
  92783. _createMultiviewUbo(): void;
  92784. /** @hidden */
  92785. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92786. /** @hidden */
  92787. _renderMultiviewToSingleView(camera: Camera): void;
  92788. }
  92789. }
  92790. declare module BABYLON {
  92791. /**
  92792. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92793. * This will not be used for webXR as it supports displaying texture arrays directly
  92794. */
  92795. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92796. /**
  92797. * Initializes a VRMultiviewToSingleview
  92798. * @param name name of the post process
  92799. * @param camera camera to be applied to
  92800. * @param scaleFactor scaling factor to the size of the output texture
  92801. */
  92802. constructor(name: string, camera: Camera, scaleFactor: number);
  92803. }
  92804. }
  92805. declare module BABYLON {
  92806. /**
  92807. * Interface used to define additional presentation attributes
  92808. */
  92809. export interface IVRPresentationAttributes {
  92810. /**
  92811. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92812. */
  92813. highRefreshRate: boolean;
  92814. /**
  92815. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92816. */
  92817. foveationLevel: number;
  92818. }
  92819. interface Engine {
  92820. /** @hidden */
  92821. _vrDisplay: any;
  92822. /** @hidden */
  92823. _vrSupported: boolean;
  92824. /** @hidden */
  92825. _oldSize: Size;
  92826. /** @hidden */
  92827. _oldHardwareScaleFactor: number;
  92828. /** @hidden */
  92829. _vrExclusivePointerMode: boolean;
  92830. /** @hidden */
  92831. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92832. /** @hidden */
  92833. _onVRDisplayPointerRestricted: () => void;
  92834. /** @hidden */
  92835. _onVRDisplayPointerUnrestricted: () => void;
  92836. /** @hidden */
  92837. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92838. /** @hidden */
  92839. _onVrDisplayDisconnect: Nullable<() => void>;
  92840. /** @hidden */
  92841. _onVrDisplayPresentChange: Nullable<() => void>;
  92842. /**
  92843. * Observable signaled when VR display mode changes
  92844. */
  92845. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92846. /**
  92847. * Observable signaled when VR request present is complete
  92848. */
  92849. onVRRequestPresentComplete: Observable<boolean>;
  92850. /**
  92851. * Observable signaled when VR request present starts
  92852. */
  92853. onVRRequestPresentStart: Observable<Engine>;
  92854. /**
  92855. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92856. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92857. */
  92858. isInVRExclusivePointerMode: boolean;
  92859. /**
  92860. * Gets a boolean indicating if a webVR device was detected
  92861. * @returns true if a webVR device was detected
  92862. */
  92863. isVRDevicePresent(): boolean;
  92864. /**
  92865. * Gets the current webVR device
  92866. * @returns the current webVR device (or null)
  92867. */
  92868. getVRDevice(): any;
  92869. /**
  92870. * Initializes a webVR display and starts listening to display change events
  92871. * The onVRDisplayChangedObservable will be notified upon these changes
  92872. * @returns A promise containing a VRDisplay and if vr is supported
  92873. */
  92874. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92875. /** @hidden */
  92876. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92877. /**
  92878. * Gets or sets the presentation attributes used to configure VR rendering
  92879. */
  92880. vrPresentationAttributes?: IVRPresentationAttributes;
  92881. /**
  92882. * Call this function to switch to webVR mode
  92883. * Will do nothing if webVR is not supported or if there is no webVR device
  92884. * @param options the webvr options provided to the camera. mainly used for multiview
  92885. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92886. */
  92887. enableVR(options: WebVROptions): void;
  92888. /** @hidden */
  92889. _onVRFullScreenTriggered(): void;
  92890. }
  92891. }
  92892. declare module BABYLON {
  92893. /**
  92894. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92895. * IMPORTANT!! The data is right-hand data.
  92896. * @export
  92897. * @interface DevicePose
  92898. */
  92899. export interface DevicePose {
  92900. /**
  92901. * The position of the device, values in array are [x,y,z].
  92902. */
  92903. readonly position: Nullable<Float32Array>;
  92904. /**
  92905. * The linearVelocity of the device, values in array are [x,y,z].
  92906. */
  92907. readonly linearVelocity: Nullable<Float32Array>;
  92908. /**
  92909. * The linearAcceleration of the device, values in array are [x,y,z].
  92910. */
  92911. readonly linearAcceleration: Nullable<Float32Array>;
  92912. /**
  92913. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92914. */
  92915. readonly orientation: Nullable<Float32Array>;
  92916. /**
  92917. * The angularVelocity of the device, values in array are [x,y,z].
  92918. */
  92919. readonly angularVelocity: Nullable<Float32Array>;
  92920. /**
  92921. * The angularAcceleration of the device, values in array are [x,y,z].
  92922. */
  92923. readonly angularAcceleration: Nullable<Float32Array>;
  92924. }
  92925. /**
  92926. * Interface representing a pose controlled object in Babylon.
  92927. * A pose controlled object has both regular pose values as well as pose values
  92928. * from an external device such as a VR head mounted display
  92929. */
  92930. export interface PoseControlled {
  92931. /**
  92932. * The position of the object in babylon space.
  92933. */
  92934. position: Vector3;
  92935. /**
  92936. * The rotation quaternion of the object in babylon space.
  92937. */
  92938. rotationQuaternion: Quaternion;
  92939. /**
  92940. * The position of the device in babylon space.
  92941. */
  92942. devicePosition?: Vector3;
  92943. /**
  92944. * The rotation quaternion of the device in babylon space.
  92945. */
  92946. deviceRotationQuaternion: Quaternion;
  92947. /**
  92948. * The raw pose coming from the device.
  92949. */
  92950. rawPose: Nullable<DevicePose>;
  92951. /**
  92952. * The scale of the device to be used when translating from device space to babylon space.
  92953. */
  92954. deviceScaleFactor: number;
  92955. /**
  92956. * Updates the poseControlled values based on the input device pose.
  92957. * @param poseData the pose data to update the object with
  92958. */
  92959. updateFromDevice(poseData: DevicePose): void;
  92960. }
  92961. /**
  92962. * Set of options to customize the webVRCamera
  92963. */
  92964. export interface WebVROptions {
  92965. /**
  92966. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92967. */
  92968. trackPosition?: boolean;
  92969. /**
  92970. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92971. */
  92972. positionScale?: number;
  92973. /**
  92974. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92975. */
  92976. displayName?: string;
  92977. /**
  92978. * Should the native controller meshes be initialized. (default: true)
  92979. */
  92980. controllerMeshes?: boolean;
  92981. /**
  92982. * Creating a default HemiLight only on controllers. (default: true)
  92983. */
  92984. defaultLightingOnControllers?: boolean;
  92985. /**
  92986. * If you don't want to use the default VR button of the helper. (default: false)
  92987. */
  92988. useCustomVRButton?: boolean;
  92989. /**
  92990. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92991. */
  92992. customVRButton?: HTMLButtonElement;
  92993. /**
  92994. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92995. */
  92996. rayLength?: number;
  92997. /**
  92998. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92999. */
  93000. defaultHeight?: number;
  93001. /**
  93002. * If multiview should be used if availible (default: false)
  93003. */
  93004. useMultiview?: boolean;
  93005. }
  93006. /**
  93007. * This represents a WebVR camera.
  93008. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93009. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93010. */
  93011. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93012. private webVROptions;
  93013. /**
  93014. * @hidden
  93015. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93016. */
  93017. _vrDevice: any;
  93018. /**
  93019. * The rawPose of the vrDevice.
  93020. */
  93021. rawPose: Nullable<DevicePose>;
  93022. private _onVREnabled;
  93023. private _specsVersion;
  93024. private _attached;
  93025. private _frameData;
  93026. protected _descendants: Array<Node>;
  93027. private _deviceRoomPosition;
  93028. /** @hidden */
  93029. _deviceRoomRotationQuaternion: Quaternion;
  93030. private _standingMatrix;
  93031. /**
  93032. * Represents device position in babylon space.
  93033. */
  93034. devicePosition: Vector3;
  93035. /**
  93036. * Represents device rotation in babylon space.
  93037. */
  93038. deviceRotationQuaternion: Quaternion;
  93039. /**
  93040. * The scale of the device to be used when translating from device space to babylon space.
  93041. */
  93042. deviceScaleFactor: number;
  93043. private _deviceToWorld;
  93044. private _worldToDevice;
  93045. /**
  93046. * References to the webVR controllers for the vrDevice.
  93047. */
  93048. controllers: Array<WebVRController>;
  93049. /**
  93050. * Emits an event when a controller is attached.
  93051. */
  93052. onControllersAttachedObservable: Observable<WebVRController[]>;
  93053. /**
  93054. * Emits an event when a controller's mesh has been loaded;
  93055. */
  93056. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93057. /**
  93058. * Emits an event when the HMD's pose has been updated.
  93059. */
  93060. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93061. private _poseSet;
  93062. /**
  93063. * If the rig cameras be used as parent instead of this camera.
  93064. */
  93065. rigParenting: boolean;
  93066. private _lightOnControllers;
  93067. private _defaultHeight?;
  93068. /**
  93069. * Instantiates a WebVRFreeCamera.
  93070. * @param name The name of the WebVRFreeCamera
  93071. * @param position The starting anchor position for the camera
  93072. * @param scene The scene the camera belongs to
  93073. * @param webVROptions a set of customizable options for the webVRCamera
  93074. */
  93075. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93076. /**
  93077. * Gets the device distance from the ground in meters.
  93078. * @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.
  93079. */
  93080. deviceDistanceToRoomGround(): number;
  93081. /**
  93082. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93083. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93084. */
  93085. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93086. /**
  93087. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93088. * @returns A promise with a boolean set to if the standing matrix is supported.
  93089. */
  93090. useStandingMatrixAsync(): Promise<boolean>;
  93091. /**
  93092. * Disposes the camera
  93093. */
  93094. dispose(): void;
  93095. /**
  93096. * Gets a vrController by name.
  93097. * @param name The name of the controller to retreive
  93098. * @returns the controller matching the name specified or null if not found
  93099. */
  93100. getControllerByName(name: string): Nullable<WebVRController>;
  93101. private _leftController;
  93102. /**
  93103. * The controller corresponding to the users left hand.
  93104. */
  93105. get leftController(): Nullable<WebVRController>;
  93106. private _rightController;
  93107. /**
  93108. * The controller corresponding to the users right hand.
  93109. */
  93110. get rightController(): Nullable<WebVRController>;
  93111. /**
  93112. * Casts a ray forward from the vrCamera's gaze.
  93113. * @param length Length of the ray (default: 100)
  93114. * @returns the ray corresponding to the gaze
  93115. */
  93116. getForwardRay(length?: number): Ray;
  93117. /**
  93118. * @hidden
  93119. * Updates the camera based on device's frame data
  93120. */
  93121. _checkInputs(): void;
  93122. /**
  93123. * Updates the poseControlled values based on the input device pose.
  93124. * @param poseData Pose coming from the device
  93125. */
  93126. updateFromDevice(poseData: DevicePose): void;
  93127. private _htmlElementAttached;
  93128. private _detachIfAttached;
  93129. /**
  93130. * WebVR's attach control will start broadcasting frames to the device.
  93131. * Note that in certain browsers (chrome for example) this function must be called
  93132. * within a user-interaction callback. Example:
  93133. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93134. *
  93135. * @param element html element to attach the vrDevice to
  93136. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93137. */
  93138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93139. /**
  93140. * Detaches the camera from the html element and disables VR
  93141. *
  93142. * @param element html element to detach from
  93143. */
  93144. detachControl(element: HTMLElement): void;
  93145. /**
  93146. * @returns the name of this class
  93147. */
  93148. getClassName(): string;
  93149. /**
  93150. * Calls resetPose on the vrDisplay
  93151. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93152. */
  93153. resetToCurrentRotation(): void;
  93154. /**
  93155. * @hidden
  93156. * Updates the rig cameras (left and right eye)
  93157. */
  93158. _updateRigCameras(): void;
  93159. private _workingVector;
  93160. private _oneVector;
  93161. private _workingMatrix;
  93162. private updateCacheCalled;
  93163. private _correctPositionIfNotTrackPosition;
  93164. /**
  93165. * @hidden
  93166. * Updates the cached values of the camera
  93167. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93168. */
  93169. _updateCache(ignoreParentClass?: boolean): void;
  93170. /**
  93171. * @hidden
  93172. * Get current device position in babylon world
  93173. */
  93174. _computeDevicePosition(): void;
  93175. /**
  93176. * Updates the current device position and rotation in the babylon world
  93177. */
  93178. update(): void;
  93179. /**
  93180. * @hidden
  93181. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93182. * @returns an identity matrix
  93183. */
  93184. _getViewMatrix(): Matrix;
  93185. private _tmpMatrix;
  93186. /**
  93187. * This function is called by the two RIG cameras.
  93188. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93189. * @hidden
  93190. */
  93191. _getWebVRViewMatrix(): Matrix;
  93192. /** @hidden */
  93193. _getWebVRProjectionMatrix(): Matrix;
  93194. private _onGamepadConnectedObserver;
  93195. private _onGamepadDisconnectedObserver;
  93196. private _updateCacheWhenTrackingDisabledObserver;
  93197. /**
  93198. * Initializes the controllers and their meshes
  93199. */
  93200. initControllers(): void;
  93201. }
  93202. }
  93203. declare module BABYLON {
  93204. /**
  93205. * Size options for a post process
  93206. */
  93207. export type PostProcessOptions = {
  93208. width: number;
  93209. height: number;
  93210. };
  93211. /**
  93212. * PostProcess can be used to apply a shader to a texture after it has been rendered
  93213. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93214. */
  93215. export class PostProcess {
  93216. /** Name of the PostProcess. */
  93217. name: string;
  93218. /**
  93219. * Gets or sets the unique id of the post process
  93220. */
  93221. uniqueId: number;
  93222. /**
  93223. * Width of the texture to apply the post process on
  93224. */
  93225. width: number;
  93226. /**
  93227. * Height of the texture to apply the post process on
  93228. */
  93229. height: number;
  93230. /**
  93231. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93232. * @hidden
  93233. */
  93234. _outputTexture: Nullable<InternalTexture>;
  93235. /**
  93236. * Sampling mode used by the shader
  93237. * See https://doc.babylonjs.com/classes/3.1/texture
  93238. */
  93239. renderTargetSamplingMode: number;
  93240. /**
  93241. * Clear color to use when screen clearing
  93242. */
  93243. clearColor: Color4;
  93244. /**
  93245. * If the buffer needs to be cleared before applying the post process. (default: true)
  93246. * Should be set to false if shader will overwrite all previous pixels.
  93247. */
  93248. autoClear: boolean;
  93249. /**
  93250. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93251. */
  93252. alphaMode: number;
  93253. /**
  93254. * Sets the setAlphaBlendConstants of the babylon engine
  93255. */
  93256. alphaConstants: Color4;
  93257. /**
  93258. * Animations to be used for the post processing
  93259. */
  93260. animations: Animation[];
  93261. /**
  93262. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93263. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93264. */
  93265. enablePixelPerfectMode: boolean;
  93266. /**
  93267. * Force the postprocess to be applied without taking in account viewport
  93268. */
  93269. forceFullscreenViewport: boolean;
  93270. /**
  93271. * List of inspectable custom properties (used by the Inspector)
  93272. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93273. */
  93274. inspectableCustomProperties: IInspectable[];
  93275. /**
  93276. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93277. *
  93278. * | Value | Type | Description |
  93279. * | ----- | ----------------------------------- | ----------- |
  93280. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93281. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93282. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93283. *
  93284. */
  93285. scaleMode: number;
  93286. /**
  93287. * Force textures to be a power of two (default: false)
  93288. */
  93289. alwaysForcePOT: boolean;
  93290. private _samples;
  93291. /**
  93292. * Number of sample textures (default: 1)
  93293. */
  93294. get samples(): number;
  93295. set samples(n: number);
  93296. /**
  93297. * Modify the scale of the post process to be the same as the viewport (default: false)
  93298. */
  93299. adaptScaleToCurrentViewport: boolean;
  93300. private _camera;
  93301. private _scene;
  93302. private _engine;
  93303. private _options;
  93304. private _reusable;
  93305. private _textureType;
  93306. private _textureFormat;
  93307. /**
  93308. * Smart array of input and output textures for the post process.
  93309. * @hidden
  93310. */
  93311. _textures: SmartArray<InternalTexture>;
  93312. /**
  93313. * The index in _textures that corresponds to the output texture.
  93314. * @hidden
  93315. */
  93316. _currentRenderTextureInd: number;
  93317. private _effect;
  93318. private _samplers;
  93319. private _fragmentUrl;
  93320. private _vertexUrl;
  93321. private _parameters;
  93322. private _scaleRatio;
  93323. protected _indexParameters: any;
  93324. private _shareOutputWithPostProcess;
  93325. private _texelSize;
  93326. private _forcedOutputTexture;
  93327. /**
  93328. * Returns the fragment url or shader name used in the post process.
  93329. * @returns the fragment url or name in the shader store.
  93330. */
  93331. getEffectName(): string;
  93332. /**
  93333. * An event triggered when the postprocess is activated.
  93334. */
  93335. onActivateObservable: Observable<Camera>;
  93336. private _onActivateObserver;
  93337. /**
  93338. * A function that is added to the onActivateObservable
  93339. */
  93340. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93341. /**
  93342. * An event triggered when the postprocess changes its size.
  93343. */
  93344. onSizeChangedObservable: Observable<PostProcess>;
  93345. private _onSizeChangedObserver;
  93346. /**
  93347. * A function that is added to the onSizeChangedObservable
  93348. */
  93349. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93350. /**
  93351. * An event triggered when the postprocess applies its effect.
  93352. */
  93353. onApplyObservable: Observable<Effect>;
  93354. private _onApplyObserver;
  93355. /**
  93356. * A function that is added to the onApplyObservable
  93357. */
  93358. set onApply(callback: (effect: Effect) => void);
  93359. /**
  93360. * An event triggered before rendering the postprocess
  93361. */
  93362. onBeforeRenderObservable: Observable<Effect>;
  93363. private _onBeforeRenderObserver;
  93364. /**
  93365. * A function that is added to the onBeforeRenderObservable
  93366. */
  93367. set onBeforeRender(callback: (effect: Effect) => void);
  93368. /**
  93369. * An event triggered after rendering the postprocess
  93370. */
  93371. onAfterRenderObservable: Observable<Effect>;
  93372. private _onAfterRenderObserver;
  93373. /**
  93374. * A function that is added to the onAfterRenderObservable
  93375. */
  93376. set onAfterRender(callback: (efect: Effect) => void);
  93377. /**
  93378. * 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
  93379. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93380. */
  93381. get inputTexture(): InternalTexture;
  93382. set inputTexture(value: InternalTexture);
  93383. /**
  93384. * Gets the camera which post process is applied to.
  93385. * @returns The camera the post process is applied to.
  93386. */
  93387. getCamera(): Camera;
  93388. /**
  93389. * Gets the texel size of the postprocess.
  93390. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93391. */
  93392. get texelSize(): Vector2;
  93393. /**
  93394. * Creates a new instance PostProcess
  93395. * @param name The name of the PostProcess.
  93396. * @param fragmentUrl The url of the fragment shader to be used.
  93397. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93398. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93399. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93400. * @param camera The camera to apply the render pass to.
  93401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93402. * @param engine The engine which the post process will be applied. (default: current engine)
  93403. * @param reusable If the post process can be reused on the same frame. (default: false)
  93404. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93405. * @param textureType Type of textures used when performing the post process. (default: 0)
  93406. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93407. * @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
  93408. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93409. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93410. */
  93411. constructor(
  93412. /** Name of the PostProcess. */
  93413. 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);
  93414. /**
  93415. * Gets a string idenfifying the name of the class
  93416. * @returns "PostProcess" string
  93417. */
  93418. getClassName(): string;
  93419. /**
  93420. * Gets the engine which this post process belongs to.
  93421. * @returns The engine the post process was enabled with.
  93422. */
  93423. getEngine(): Engine;
  93424. /**
  93425. * The effect that is created when initializing the post process.
  93426. * @returns The created effect corresponding the the postprocess.
  93427. */
  93428. getEffect(): Effect;
  93429. /**
  93430. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93431. * @param postProcess The post process to share the output with.
  93432. * @returns This post process.
  93433. */
  93434. shareOutputWith(postProcess: PostProcess): PostProcess;
  93435. /**
  93436. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93437. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93438. */
  93439. useOwnOutput(): void;
  93440. /**
  93441. * Updates the effect with the current post process compile time values and recompiles the shader.
  93442. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93443. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93444. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93445. * @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
  93446. * @param onCompiled Called when the shader has been compiled.
  93447. * @param onError Called if there is an error when compiling a shader.
  93448. */
  93449. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93450. /**
  93451. * The post process is reusable if it can be used multiple times within one frame.
  93452. * @returns If the post process is reusable
  93453. */
  93454. isReusable(): boolean;
  93455. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93456. markTextureDirty(): void;
  93457. /**
  93458. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93459. * 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.
  93460. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93461. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93462. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93463. * @returns The target texture that was bound to be written to.
  93464. */
  93465. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93466. /**
  93467. * If the post process is supported.
  93468. */
  93469. get isSupported(): boolean;
  93470. /**
  93471. * The aspect ratio of the output texture.
  93472. */
  93473. get aspectRatio(): number;
  93474. /**
  93475. * Get a value indicating if the post-process is ready to be used
  93476. * @returns true if the post-process is ready (shader is compiled)
  93477. */
  93478. isReady(): boolean;
  93479. /**
  93480. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93481. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93482. */
  93483. apply(): Nullable<Effect>;
  93484. private _disposeTextures;
  93485. /**
  93486. * Disposes the post process.
  93487. * @param camera The camera to dispose the post process on.
  93488. */
  93489. dispose(camera?: Camera): void;
  93490. }
  93491. }
  93492. declare module BABYLON {
  93493. /** @hidden */
  93494. export var kernelBlurVaryingDeclaration: {
  93495. name: string;
  93496. shader: string;
  93497. };
  93498. }
  93499. declare module BABYLON {
  93500. /** @hidden */
  93501. export var kernelBlurFragment: {
  93502. name: string;
  93503. shader: string;
  93504. };
  93505. }
  93506. declare module BABYLON {
  93507. /** @hidden */
  93508. export var kernelBlurFragment2: {
  93509. name: string;
  93510. shader: string;
  93511. };
  93512. }
  93513. declare module BABYLON {
  93514. /** @hidden */
  93515. export var kernelBlurPixelShader: {
  93516. name: string;
  93517. shader: string;
  93518. };
  93519. }
  93520. declare module BABYLON {
  93521. /** @hidden */
  93522. export var kernelBlurVertex: {
  93523. name: string;
  93524. shader: string;
  93525. };
  93526. }
  93527. declare module BABYLON {
  93528. /** @hidden */
  93529. export var kernelBlurVertexShader: {
  93530. name: string;
  93531. shader: string;
  93532. };
  93533. }
  93534. declare module BABYLON {
  93535. /**
  93536. * The Blur Post Process which blurs an image based on a kernel and direction.
  93537. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93538. */
  93539. export class BlurPostProcess extends PostProcess {
  93540. /** The direction in which to blur the image. */
  93541. direction: Vector2;
  93542. private blockCompilation;
  93543. protected _kernel: number;
  93544. protected _idealKernel: number;
  93545. protected _packedFloat: boolean;
  93546. private _staticDefines;
  93547. /**
  93548. * Sets the length in pixels of the blur sample region
  93549. */
  93550. set kernel(v: number);
  93551. /**
  93552. * Gets the length in pixels of the blur sample region
  93553. */
  93554. get kernel(): number;
  93555. /**
  93556. * Sets wether or not the blur needs to unpack/repack floats
  93557. */
  93558. set packedFloat(v: boolean);
  93559. /**
  93560. * Gets wether or not the blur is unpacking/repacking floats
  93561. */
  93562. get packedFloat(): boolean;
  93563. /**
  93564. * Creates a new instance BlurPostProcess
  93565. * @param name The name of the effect.
  93566. * @param direction The direction in which to blur the image.
  93567. * @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.
  93568. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93569. * @param camera The camera to apply the render pass to.
  93570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93571. * @param engine The engine which the post process will be applied. (default: current engine)
  93572. * @param reusable If the post process can be reused on the same frame. (default: false)
  93573. * @param textureType Type of textures used when performing the post process. (default: 0)
  93574. * @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)
  93575. */
  93576. constructor(name: string,
  93577. /** The direction in which to blur the image. */
  93578. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93579. /**
  93580. * Updates the effect with the current post process compile time values and recompiles the shader.
  93581. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93582. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93583. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93584. * @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
  93585. * @param onCompiled Called when the shader has been compiled.
  93586. * @param onError Called if there is an error when compiling a shader.
  93587. */
  93588. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93589. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93590. /**
  93591. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93592. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93593. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93594. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93595. * The gaps between physical kernels are compensated for in the weighting of the samples
  93596. * @param idealKernel Ideal blur kernel.
  93597. * @return Nearest best kernel.
  93598. */
  93599. protected _nearestBestKernel(idealKernel: number): number;
  93600. /**
  93601. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93602. * @param x The point on the Gaussian distribution to sample.
  93603. * @return the value of the Gaussian function at x.
  93604. */
  93605. protected _gaussianWeight(x: number): number;
  93606. /**
  93607. * Generates a string that can be used as a floating point number in GLSL.
  93608. * @param x Value to print.
  93609. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93610. * @return GLSL float string.
  93611. */
  93612. protected _glslFloat(x: number, decimalFigures?: number): string;
  93613. }
  93614. }
  93615. declare module BABYLON {
  93616. /**
  93617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93619. * You can then easily use it as a reflectionTexture on a flat surface.
  93620. * In case the surface is not a plane, please consider relying on reflection probes.
  93621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93622. */
  93623. export class MirrorTexture extends RenderTargetTexture {
  93624. private scene;
  93625. /**
  93626. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93627. * 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.
  93628. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93629. */
  93630. mirrorPlane: Plane;
  93631. /**
  93632. * Define the blur ratio used to blur the reflection if needed.
  93633. */
  93634. set blurRatio(value: number);
  93635. get blurRatio(): number;
  93636. /**
  93637. * Define the adaptive blur kernel used to blur the reflection if needed.
  93638. * This will autocompute the closest best match for the `blurKernel`
  93639. */
  93640. set adaptiveBlurKernel(value: number);
  93641. /**
  93642. * Define the blur kernel used to blur the reflection if needed.
  93643. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93644. */
  93645. set blurKernel(value: number);
  93646. /**
  93647. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93648. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93649. */
  93650. set blurKernelX(value: number);
  93651. get blurKernelX(): number;
  93652. /**
  93653. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93654. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93655. */
  93656. set blurKernelY(value: number);
  93657. get blurKernelY(): number;
  93658. private _autoComputeBlurKernel;
  93659. protected _onRatioRescale(): void;
  93660. private _updateGammaSpace;
  93661. private _imageProcessingConfigChangeObserver;
  93662. private _transformMatrix;
  93663. private _mirrorMatrix;
  93664. private _savedViewMatrix;
  93665. private _blurX;
  93666. private _blurY;
  93667. private _adaptiveBlurKernel;
  93668. private _blurKernelX;
  93669. private _blurKernelY;
  93670. private _blurRatio;
  93671. /**
  93672. * Instantiates a Mirror Texture.
  93673. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93674. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93675. * You can then easily use it as a reflectionTexture on a flat surface.
  93676. * In case the surface is not a plane, please consider relying on reflection probes.
  93677. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93678. * @param name
  93679. * @param size
  93680. * @param scene
  93681. * @param generateMipMaps
  93682. * @param type
  93683. * @param samplingMode
  93684. * @param generateDepthBuffer
  93685. */
  93686. constructor(name: string, size: number | {
  93687. width: number;
  93688. height: number;
  93689. } | {
  93690. ratio: number;
  93691. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93692. private _preparePostProcesses;
  93693. /**
  93694. * Clone the mirror texture.
  93695. * @returns the cloned texture
  93696. */
  93697. clone(): MirrorTexture;
  93698. /**
  93699. * Serialize the texture to a JSON representation you could use in Parse later on
  93700. * @returns the serialized JSON representation
  93701. */
  93702. serialize(): any;
  93703. /**
  93704. * Dispose the texture and release its associated resources.
  93705. */
  93706. dispose(): void;
  93707. }
  93708. }
  93709. declare module BABYLON {
  93710. /**
  93711. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93712. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93713. */
  93714. export class Texture extends BaseTexture {
  93715. /**
  93716. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93717. */
  93718. static SerializeBuffers: boolean;
  93719. /** @hidden */
  93720. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93721. /** @hidden */
  93722. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93723. /** @hidden */
  93724. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93725. /** nearest is mag = nearest and min = nearest and mip = linear */
  93726. static readonly NEAREST_SAMPLINGMODE: number;
  93727. /** nearest is mag = nearest and min = nearest and mip = linear */
  93728. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93729. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93730. static readonly BILINEAR_SAMPLINGMODE: number;
  93731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93732. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93733. /** Trilinear is mag = linear and min = linear and mip = linear */
  93734. static readonly TRILINEAR_SAMPLINGMODE: number;
  93735. /** Trilinear is mag = linear and min = linear and mip = linear */
  93736. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93737. /** mag = nearest and min = nearest and mip = nearest */
  93738. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93739. /** mag = nearest and min = linear and mip = nearest */
  93740. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93741. /** mag = nearest and min = linear and mip = linear */
  93742. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93743. /** mag = nearest and min = linear and mip = none */
  93744. static readonly NEAREST_LINEAR: number;
  93745. /** mag = nearest and min = nearest and mip = none */
  93746. static readonly NEAREST_NEAREST: number;
  93747. /** mag = linear and min = nearest and mip = nearest */
  93748. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93749. /** mag = linear and min = nearest and mip = linear */
  93750. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93751. /** mag = linear and min = linear and mip = none */
  93752. static readonly LINEAR_LINEAR: number;
  93753. /** mag = linear and min = nearest and mip = none */
  93754. static readonly LINEAR_NEAREST: number;
  93755. /** Explicit coordinates mode */
  93756. static readonly EXPLICIT_MODE: number;
  93757. /** Spherical coordinates mode */
  93758. static readonly SPHERICAL_MODE: number;
  93759. /** Planar coordinates mode */
  93760. static readonly PLANAR_MODE: number;
  93761. /** Cubic coordinates mode */
  93762. static readonly CUBIC_MODE: number;
  93763. /** Projection coordinates mode */
  93764. static readonly PROJECTION_MODE: number;
  93765. /** Inverse Cubic coordinates mode */
  93766. static readonly SKYBOX_MODE: number;
  93767. /** Inverse Cubic coordinates mode */
  93768. static readonly INVCUBIC_MODE: number;
  93769. /** Equirectangular coordinates mode */
  93770. static readonly EQUIRECTANGULAR_MODE: number;
  93771. /** Equirectangular Fixed coordinates mode */
  93772. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93773. /** Equirectangular Fixed Mirrored coordinates mode */
  93774. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93775. /** Texture is not repeating outside of 0..1 UVs */
  93776. static readonly CLAMP_ADDRESSMODE: number;
  93777. /** Texture is repeating outside of 0..1 UVs */
  93778. static readonly WRAP_ADDRESSMODE: number;
  93779. /** Texture is repeating and mirrored */
  93780. static readonly MIRROR_ADDRESSMODE: number;
  93781. /**
  93782. * 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
  93783. */
  93784. static UseSerializedUrlIfAny: boolean;
  93785. /**
  93786. * Define the url of the texture.
  93787. */
  93788. url: Nullable<string>;
  93789. /**
  93790. * Define an offset on the texture to offset the u coordinates of the UVs
  93791. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93792. */
  93793. uOffset: number;
  93794. /**
  93795. * Define an offset on the texture to offset the v coordinates of the UVs
  93796. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93797. */
  93798. vOffset: number;
  93799. /**
  93800. * Define an offset on the texture to scale the u coordinates of the UVs
  93801. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93802. */
  93803. uScale: number;
  93804. /**
  93805. * Define an offset on the texture to scale the v coordinates of the UVs
  93806. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93807. */
  93808. vScale: number;
  93809. /**
  93810. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93811. * @see http://doc.babylonjs.com/how_to/more_materials
  93812. */
  93813. uAng: number;
  93814. /**
  93815. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93816. * @see http://doc.babylonjs.com/how_to/more_materials
  93817. */
  93818. vAng: number;
  93819. /**
  93820. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93821. * @see http://doc.babylonjs.com/how_to/more_materials
  93822. */
  93823. wAng: number;
  93824. /**
  93825. * Defines the center of rotation (U)
  93826. */
  93827. uRotationCenter: number;
  93828. /**
  93829. * Defines the center of rotation (V)
  93830. */
  93831. vRotationCenter: number;
  93832. /**
  93833. * Defines the center of rotation (W)
  93834. */
  93835. wRotationCenter: number;
  93836. /**
  93837. * Are mip maps generated for this texture or not.
  93838. */
  93839. get noMipmap(): boolean;
  93840. /**
  93841. * List of inspectable custom properties (used by the Inspector)
  93842. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93843. */
  93844. inspectableCustomProperties: Nullable<IInspectable[]>;
  93845. private _noMipmap;
  93846. /** @hidden */
  93847. _invertY: boolean;
  93848. private _rowGenerationMatrix;
  93849. private _cachedTextureMatrix;
  93850. private _projectionModeMatrix;
  93851. private _t0;
  93852. private _t1;
  93853. private _t2;
  93854. private _cachedUOffset;
  93855. private _cachedVOffset;
  93856. private _cachedUScale;
  93857. private _cachedVScale;
  93858. private _cachedUAng;
  93859. private _cachedVAng;
  93860. private _cachedWAng;
  93861. private _cachedProjectionMatrixId;
  93862. private _cachedCoordinatesMode;
  93863. /** @hidden */
  93864. protected _initialSamplingMode: number;
  93865. /** @hidden */
  93866. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93867. private _deleteBuffer;
  93868. protected _format: Nullable<number>;
  93869. private _delayedOnLoad;
  93870. private _delayedOnError;
  93871. private _mimeType?;
  93872. /**
  93873. * Observable triggered once the texture has been loaded.
  93874. */
  93875. onLoadObservable: Observable<Texture>;
  93876. protected _isBlocking: boolean;
  93877. /**
  93878. * Is the texture preventing material to render while loading.
  93879. * If false, a default texture will be used instead of the loading one during the preparation step.
  93880. */
  93881. set isBlocking(value: boolean);
  93882. get isBlocking(): boolean;
  93883. /**
  93884. * Get the current sampling mode associated with the texture.
  93885. */
  93886. get samplingMode(): number;
  93887. /**
  93888. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93889. */
  93890. get invertY(): boolean;
  93891. /**
  93892. * Instantiates a new texture.
  93893. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93894. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93895. * @param url defines the url of the picture to load as a texture
  93896. * @param scene defines the scene or engine the texture will belong to
  93897. * @param noMipmap defines if the texture will require mip maps or not
  93898. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93899. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93900. * @param onLoad defines a callback triggered when the texture has been loaded
  93901. * @param onError defines a callback triggered when an error occurred during the loading session
  93902. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93903. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93904. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93905. * @param mimeType defines an optional mime type information
  93906. */
  93907. 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);
  93908. /**
  93909. * Update the url (and optional buffer) of this texture if url was null during construction.
  93910. * @param url the url of the texture
  93911. * @param buffer the buffer of the texture (defaults to null)
  93912. * @param onLoad callback called when the texture is loaded (defaults to null)
  93913. */
  93914. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93915. /**
  93916. * Finish the loading sequence of a texture flagged as delayed load.
  93917. * @hidden
  93918. */
  93919. delayLoad(): void;
  93920. private _prepareRowForTextureGeneration;
  93921. /**
  93922. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93923. * @returns the transform matrix of the texture.
  93924. */
  93925. getTextureMatrix(uBase?: number): Matrix;
  93926. /**
  93927. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93928. * @returns The reflection texture transform
  93929. */
  93930. getReflectionTextureMatrix(): Matrix;
  93931. /**
  93932. * Clones the texture.
  93933. * @returns the cloned texture
  93934. */
  93935. clone(): Texture;
  93936. /**
  93937. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93938. * @returns The JSON representation of the texture
  93939. */
  93940. serialize(): any;
  93941. /**
  93942. * Get the current class name of the texture useful for serialization or dynamic coding.
  93943. * @returns "Texture"
  93944. */
  93945. getClassName(): string;
  93946. /**
  93947. * Dispose the texture and release its associated resources.
  93948. */
  93949. dispose(): void;
  93950. /**
  93951. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93952. * @param parsedTexture Define the JSON representation of the texture
  93953. * @param scene Define the scene the parsed texture should be instantiated in
  93954. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93955. * @returns The parsed texture if successful
  93956. */
  93957. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93958. /**
  93959. * Creates a texture from its base 64 representation.
  93960. * @param data Define the base64 payload without the data: prefix
  93961. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93962. * @param scene Define the scene the texture should belong to
  93963. * @param noMipmap Forces the texture to not create mip map information if true
  93964. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93965. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93966. * @param onLoad define a callback triggered when the texture has been loaded
  93967. * @param onError define a callback triggered when an error occurred during the loading session
  93968. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93969. * @returns the created texture
  93970. */
  93971. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93972. /**
  93973. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93974. * @param data Define the base64 payload without the data: prefix
  93975. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93976. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93977. * @param scene Define the scene the texture should belong to
  93978. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93979. * @param noMipmap Forces the texture to not create mip map information if true
  93980. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93981. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93982. * @param onLoad define a callback triggered when the texture has been loaded
  93983. * @param onError define a callback triggered when an error occurred during the loading session
  93984. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93985. * @returns the created texture
  93986. */
  93987. 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;
  93988. }
  93989. }
  93990. declare module BABYLON {
  93991. /**
  93992. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93993. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93994. */
  93995. export class PostProcessManager {
  93996. private _scene;
  93997. private _indexBuffer;
  93998. private _vertexBuffers;
  93999. /**
  94000. * Creates a new instance PostProcess
  94001. * @param scene The scene that the post process is associated with.
  94002. */
  94003. constructor(scene: Scene);
  94004. private _prepareBuffers;
  94005. private _buildIndexBuffer;
  94006. /**
  94007. * Rebuilds the vertex buffers of the manager.
  94008. * @hidden
  94009. */
  94010. _rebuild(): void;
  94011. /**
  94012. * Prepares a frame to be run through a post process.
  94013. * @param sourceTexture The input texture to the post procesess. (default: null)
  94014. * @param postProcesses An array of post processes to be run. (default: null)
  94015. * @returns True if the post processes were able to be run.
  94016. * @hidden
  94017. */
  94018. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94019. /**
  94020. * Manually render a set of post processes to a texture.
  94021. * @param postProcesses An array of post processes to be run.
  94022. * @param targetTexture The target texture to render to.
  94023. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94024. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94025. * @param lodLevel defines which lod of the texture to render to
  94026. */
  94027. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94028. /**
  94029. * Finalize the result of the output of the postprocesses.
  94030. * @param doNotPresent If true the result will not be displayed to the screen.
  94031. * @param targetTexture The target texture to render to.
  94032. * @param faceIndex The index of the face to bind the target texture to.
  94033. * @param postProcesses The array of post processes to render.
  94034. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94035. * @hidden
  94036. */
  94037. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94038. /**
  94039. * Disposes of the post process manager.
  94040. */
  94041. dispose(): void;
  94042. }
  94043. }
  94044. declare module BABYLON {
  94045. /**
  94046. * This Helps creating a texture that will be created from a camera in your scene.
  94047. * It is basically a dynamic texture that could be used to create special effects for instance.
  94048. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94049. */
  94050. export class RenderTargetTexture extends Texture {
  94051. isCube: boolean;
  94052. /**
  94053. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94054. */
  94055. static readonly REFRESHRATE_RENDER_ONCE: number;
  94056. /**
  94057. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94058. */
  94059. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94060. /**
  94061. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94062. * the central point of your effect and can save a lot of performances.
  94063. */
  94064. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94065. /**
  94066. * Use this predicate to dynamically define the list of mesh you want to render.
  94067. * If set, the renderList property will be overwritten.
  94068. */
  94069. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94070. private _renderList;
  94071. /**
  94072. * Use this list to define the list of mesh you want to render.
  94073. */
  94074. get renderList(): Nullable<Array<AbstractMesh>>;
  94075. set renderList(value: Nullable<Array<AbstractMesh>>);
  94076. /**
  94077. * Use this function to overload the renderList array at rendering time.
  94078. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94079. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94080. * the cube (if the RTT is a cube, else layerOrFace=0).
  94081. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94082. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94083. * hold dummy elements!
  94084. */
  94085. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94086. private _hookArray;
  94087. /**
  94088. * Define if particles should be rendered in your texture.
  94089. */
  94090. renderParticles: boolean;
  94091. /**
  94092. * Define if sprites should be rendered in your texture.
  94093. */
  94094. renderSprites: boolean;
  94095. /**
  94096. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94097. */
  94098. coordinatesMode: number;
  94099. /**
  94100. * Define the camera used to render the texture.
  94101. */
  94102. activeCamera: Nullable<Camera>;
  94103. /**
  94104. * Override the render function of the texture with your own one.
  94105. */
  94106. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94107. /**
  94108. * Define if camera post processes should be use while rendering the texture.
  94109. */
  94110. useCameraPostProcesses: boolean;
  94111. /**
  94112. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94113. */
  94114. ignoreCameraViewport: boolean;
  94115. private _postProcessManager;
  94116. private _postProcesses;
  94117. private _resizeObserver;
  94118. /**
  94119. * An event triggered when the texture is unbind.
  94120. */
  94121. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94122. /**
  94123. * An event triggered when the texture is unbind.
  94124. */
  94125. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94126. private _onAfterUnbindObserver;
  94127. /**
  94128. * Set a after unbind callback in the texture.
  94129. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94130. */
  94131. set onAfterUnbind(callback: () => void);
  94132. /**
  94133. * An event triggered before rendering the texture
  94134. */
  94135. onBeforeRenderObservable: Observable<number>;
  94136. private _onBeforeRenderObserver;
  94137. /**
  94138. * Set a before render callback in the texture.
  94139. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94140. */
  94141. set onBeforeRender(callback: (faceIndex: number) => void);
  94142. /**
  94143. * An event triggered after rendering the texture
  94144. */
  94145. onAfterRenderObservable: Observable<number>;
  94146. private _onAfterRenderObserver;
  94147. /**
  94148. * Set a after render callback in the texture.
  94149. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94150. */
  94151. set onAfterRender(callback: (faceIndex: number) => void);
  94152. /**
  94153. * An event triggered after the texture clear
  94154. */
  94155. onClearObservable: Observable<Engine>;
  94156. private _onClearObserver;
  94157. /**
  94158. * Set a clear callback in the texture.
  94159. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94160. */
  94161. set onClear(callback: (Engine: Engine) => void);
  94162. /**
  94163. * An event triggered when the texture is resized.
  94164. */
  94165. onResizeObservable: Observable<RenderTargetTexture>;
  94166. /**
  94167. * Define the clear color of the Render Target if it should be different from the scene.
  94168. */
  94169. clearColor: Color4;
  94170. protected _size: number | {
  94171. width: number;
  94172. height: number;
  94173. layers?: number;
  94174. };
  94175. protected _initialSizeParameter: number | {
  94176. width: number;
  94177. height: number;
  94178. } | {
  94179. ratio: number;
  94180. };
  94181. protected _sizeRatio: Nullable<number>;
  94182. /** @hidden */
  94183. _generateMipMaps: boolean;
  94184. protected _renderingManager: RenderingManager;
  94185. /** @hidden */
  94186. _waitingRenderList: string[];
  94187. protected _doNotChangeAspectRatio: boolean;
  94188. protected _currentRefreshId: number;
  94189. protected _refreshRate: number;
  94190. protected _textureMatrix: Matrix;
  94191. protected _samples: number;
  94192. protected _renderTargetOptions: RenderTargetCreationOptions;
  94193. /**
  94194. * Gets render target creation options that were used.
  94195. */
  94196. get renderTargetOptions(): RenderTargetCreationOptions;
  94197. protected _engine: Engine;
  94198. protected _onRatioRescale(): void;
  94199. /**
  94200. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  94201. * It must define where the camera used to render the texture is set
  94202. */
  94203. boundingBoxPosition: Vector3;
  94204. private _boundingBoxSize;
  94205. /**
  94206. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  94207. * When defined, the cubemap will switch to local mode
  94208. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  94209. * @example https://www.babylonjs-playground.com/#RNASML
  94210. */
  94211. set boundingBoxSize(value: Vector3);
  94212. get boundingBoxSize(): Vector3;
  94213. /**
  94214. * In case the RTT has been created with a depth texture, get the associated
  94215. * depth texture.
  94216. * Otherwise, return null.
  94217. */
  94218. get depthStencilTexture(): Nullable<InternalTexture>;
  94219. /**
  94220. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  94221. * or used a shadow, depth texture...
  94222. * @param name The friendly name of the texture
  94223. * @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)
  94224. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  94225. * @param generateMipMaps True if mip maps need to be generated after render.
  94226. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  94227. * @param type The type of the buffer in the RTT (int, half float, float...)
  94228. * @param isCube True if a cube texture needs to be created
  94229. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94230. * @param generateDepthBuffer True to generate a depth buffer
  94231. * @param generateStencilBuffer True to generate a stencil buffer
  94232. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94233. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94234. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94235. */
  94236. constructor(name: string, size: number | {
  94237. width: number;
  94238. height: number;
  94239. layers?: number;
  94240. } | {
  94241. ratio: number;
  94242. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94243. /**
  94244. * Creates a depth stencil texture.
  94245. * This is only available in WebGL 2 or with the depth texture extension available.
  94246. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94247. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94248. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94249. */
  94250. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94251. private _processSizeParameter;
  94252. /**
  94253. * Define the number of samples to use in case of MSAA.
  94254. * It defaults to one meaning no MSAA has been enabled.
  94255. */
  94256. get samples(): number;
  94257. set samples(value: number);
  94258. /**
  94259. * Resets the refresh counter of the texture and start bak from scratch.
  94260. * Could be useful to regenerate the texture if it is setup to render only once.
  94261. */
  94262. resetRefreshCounter(): void;
  94263. /**
  94264. * Define the refresh rate of the texture or the rendering frequency.
  94265. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94266. */
  94267. get refreshRate(): number;
  94268. set refreshRate(value: number);
  94269. /**
  94270. * Adds a post process to the render target rendering passes.
  94271. * @param postProcess define the post process to add
  94272. */
  94273. addPostProcess(postProcess: PostProcess): void;
  94274. /**
  94275. * Clear all the post processes attached to the render target
  94276. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94277. */
  94278. clearPostProcesses(dispose?: boolean): void;
  94279. /**
  94280. * Remove one of the post process from the list of attached post processes to the texture
  94281. * @param postProcess define the post process to remove from the list
  94282. */
  94283. removePostProcess(postProcess: PostProcess): void;
  94284. /** @hidden */
  94285. _shouldRender(): boolean;
  94286. /**
  94287. * Gets the actual render size of the texture.
  94288. * @returns the width of the render size
  94289. */
  94290. getRenderSize(): number;
  94291. /**
  94292. * Gets the actual render width of the texture.
  94293. * @returns the width of the render size
  94294. */
  94295. getRenderWidth(): number;
  94296. /**
  94297. * Gets the actual render height of the texture.
  94298. * @returns the height of the render size
  94299. */
  94300. getRenderHeight(): number;
  94301. /**
  94302. * Gets the actual number of layers of the texture.
  94303. * @returns the number of layers
  94304. */
  94305. getRenderLayers(): number;
  94306. /**
  94307. * Get if the texture can be rescaled or not.
  94308. */
  94309. get canRescale(): boolean;
  94310. /**
  94311. * Resize the texture using a ratio.
  94312. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94313. */
  94314. scale(ratio: number): void;
  94315. /**
  94316. * Get the texture reflection matrix used to rotate/transform the reflection.
  94317. * @returns the reflection matrix
  94318. */
  94319. getReflectionTextureMatrix(): Matrix;
  94320. /**
  94321. * Resize the texture to a new desired size.
  94322. * Be carrefull as it will recreate all the data in the new texture.
  94323. * @param size Define the new size. It can be:
  94324. * - a number for squared texture,
  94325. * - an object containing { width: number, height: number }
  94326. * - or an object containing a ratio { ratio: number }
  94327. */
  94328. resize(size: number | {
  94329. width: number;
  94330. height: number;
  94331. } | {
  94332. ratio: number;
  94333. }): void;
  94334. private _defaultRenderListPrepared;
  94335. /**
  94336. * Renders all the objects from the render list into the texture.
  94337. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94338. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94339. */
  94340. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94341. private _bestReflectionRenderTargetDimension;
  94342. private _prepareRenderingManager;
  94343. /**
  94344. * @hidden
  94345. * @param faceIndex face index to bind to if this is a cubetexture
  94346. * @param layer defines the index of the texture to bind in the array
  94347. */
  94348. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94349. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94350. private renderToTarget;
  94351. /**
  94352. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94353. * This allowed control for front to back rendering or reversly depending of the special needs.
  94354. *
  94355. * @param renderingGroupId The rendering group id corresponding to its index
  94356. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94357. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94358. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94359. */
  94360. 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;
  94361. /**
  94362. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94363. *
  94364. * @param renderingGroupId The rendering group id corresponding to its index
  94365. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94366. */
  94367. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94368. /**
  94369. * Clones the texture.
  94370. * @returns the cloned texture
  94371. */
  94372. clone(): RenderTargetTexture;
  94373. /**
  94374. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94375. * @returns The JSON representation of the texture
  94376. */
  94377. serialize(): any;
  94378. /**
  94379. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94380. */
  94381. disposeFramebufferObjects(): void;
  94382. /**
  94383. * Dispose the texture and release its associated resources.
  94384. */
  94385. dispose(): void;
  94386. /** @hidden */
  94387. _rebuild(): void;
  94388. /**
  94389. * Clear the info related to rendering groups preventing retention point in material dispose.
  94390. */
  94391. freeRenderingGroups(): void;
  94392. /**
  94393. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94394. * @returns the view count
  94395. */
  94396. getViewCount(): number;
  94397. }
  94398. }
  94399. declare module BABYLON {
  94400. /**
  94401. * Options for compiling materials.
  94402. */
  94403. export interface IMaterialCompilationOptions {
  94404. /**
  94405. * Defines whether clip planes are enabled.
  94406. */
  94407. clipPlane: boolean;
  94408. /**
  94409. * Defines whether instances are enabled.
  94410. */
  94411. useInstances: boolean;
  94412. }
  94413. /**
  94414. * Base class for the main features of a material in Babylon.js
  94415. */
  94416. export class Material implements IAnimatable {
  94417. /**
  94418. * Returns the triangle fill mode
  94419. */
  94420. static readonly TriangleFillMode: number;
  94421. /**
  94422. * Returns the wireframe mode
  94423. */
  94424. static readonly WireFrameFillMode: number;
  94425. /**
  94426. * Returns the point fill mode
  94427. */
  94428. static readonly PointFillMode: number;
  94429. /**
  94430. * Returns the point list draw mode
  94431. */
  94432. static readonly PointListDrawMode: number;
  94433. /**
  94434. * Returns the line list draw mode
  94435. */
  94436. static readonly LineListDrawMode: number;
  94437. /**
  94438. * Returns the line loop draw mode
  94439. */
  94440. static readonly LineLoopDrawMode: number;
  94441. /**
  94442. * Returns the line strip draw mode
  94443. */
  94444. static readonly LineStripDrawMode: number;
  94445. /**
  94446. * Returns the triangle strip draw mode
  94447. */
  94448. static readonly TriangleStripDrawMode: number;
  94449. /**
  94450. * Returns the triangle fan draw mode
  94451. */
  94452. static readonly TriangleFanDrawMode: number;
  94453. /**
  94454. * Stores the clock-wise side orientation
  94455. */
  94456. static readonly ClockWiseSideOrientation: number;
  94457. /**
  94458. * Stores the counter clock-wise side orientation
  94459. */
  94460. static readonly CounterClockWiseSideOrientation: number;
  94461. /**
  94462. * The dirty texture flag value
  94463. */
  94464. static readonly TextureDirtyFlag: number;
  94465. /**
  94466. * The dirty light flag value
  94467. */
  94468. static readonly LightDirtyFlag: number;
  94469. /**
  94470. * The dirty fresnel flag value
  94471. */
  94472. static readonly FresnelDirtyFlag: number;
  94473. /**
  94474. * The dirty attribute flag value
  94475. */
  94476. static readonly AttributesDirtyFlag: number;
  94477. /**
  94478. * The dirty misc flag value
  94479. */
  94480. static readonly MiscDirtyFlag: number;
  94481. /**
  94482. * The all dirty flag value
  94483. */
  94484. static readonly AllDirtyFlag: number;
  94485. /**
  94486. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  94487. */
  94488. static readonly MATERIAL_OPAQUE: number;
  94489. /**
  94490. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  94491. */
  94492. static readonly MATERIAL_ALPHATEST: number;
  94493. /**
  94494. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  94495. */
  94496. static readonly MATERIAL_ALPHABLEND: number;
  94497. /**
  94498. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  94499. * They are also discarded below the alpha cutoff threshold to improve performances.
  94500. */
  94501. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  94502. /**
  94503. * The ID of the material
  94504. */
  94505. id: string;
  94506. /**
  94507. * Gets or sets the unique id of the material
  94508. */
  94509. uniqueId: number;
  94510. /**
  94511. * The name of the material
  94512. */
  94513. name: string;
  94514. /**
  94515. * Gets or sets user defined metadata
  94516. */
  94517. metadata: any;
  94518. /**
  94519. * For internal use only. Please do not use.
  94520. */
  94521. reservedDataStore: any;
  94522. /**
  94523. * Specifies if the ready state should be checked on each call
  94524. */
  94525. checkReadyOnEveryCall: boolean;
  94526. /**
  94527. * Specifies if the ready state should be checked once
  94528. */
  94529. checkReadyOnlyOnce: boolean;
  94530. /**
  94531. * The state of the material
  94532. */
  94533. state: string;
  94534. /**
  94535. * The alpha value of the material
  94536. */
  94537. protected _alpha: number;
  94538. /**
  94539. * List of inspectable custom properties (used by the Inspector)
  94540. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94541. */
  94542. inspectableCustomProperties: IInspectable[];
  94543. /**
  94544. * Sets the alpha value of the material
  94545. */
  94546. set alpha(value: number);
  94547. /**
  94548. * Gets the alpha value of the material
  94549. */
  94550. get alpha(): number;
  94551. /**
  94552. * Specifies if back face culling is enabled
  94553. */
  94554. protected _backFaceCulling: boolean;
  94555. /**
  94556. * Sets the back-face culling state
  94557. */
  94558. set backFaceCulling(value: boolean);
  94559. /**
  94560. * Gets the back-face culling state
  94561. */
  94562. get backFaceCulling(): boolean;
  94563. /**
  94564. * Stores the value for side orientation
  94565. */
  94566. sideOrientation: number;
  94567. /**
  94568. * Callback triggered when the material is compiled
  94569. */
  94570. onCompiled: Nullable<(effect: Effect) => void>;
  94571. /**
  94572. * Callback triggered when an error occurs
  94573. */
  94574. onError: Nullable<(effect: Effect, errors: string) => void>;
  94575. /**
  94576. * Callback triggered to get the render target textures
  94577. */
  94578. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94579. /**
  94580. * Gets a boolean indicating that current material needs to register RTT
  94581. */
  94582. get hasRenderTargetTextures(): boolean;
  94583. /**
  94584. * Specifies if the material should be serialized
  94585. */
  94586. doNotSerialize: boolean;
  94587. /**
  94588. * @hidden
  94589. */
  94590. _storeEffectOnSubMeshes: boolean;
  94591. /**
  94592. * Stores the animations for the material
  94593. */
  94594. animations: Nullable<Array<Animation>>;
  94595. /**
  94596. * An event triggered when the material is disposed
  94597. */
  94598. onDisposeObservable: Observable<Material>;
  94599. /**
  94600. * An observer which watches for dispose events
  94601. */
  94602. private _onDisposeObserver;
  94603. private _onUnBindObservable;
  94604. /**
  94605. * Called during a dispose event
  94606. */
  94607. set onDispose(callback: () => void);
  94608. private _onBindObservable;
  94609. /**
  94610. * An event triggered when the material is bound
  94611. */
  94612. get onBindObservable(): Observable<AbstractMesh>;
  94613. /**
  94614. * An observer which watches for bind events
  94615. */
  94616. private _onBindObserver;
  94617. /**
  94618. * Called during a bind event
  94619. */
  94620. set onBind(callback: (Mesh: AbstractMesh) => void);
  94621. /**
  94622. * An event triggered when the material is unbound
  94623. */
  94624. get onUnBindObservable(): Observable<Material>;
  94625. /**
  94626. * Stores the value of the alpha mode
  94627. */
  94628. private _alphaMode;
  94629. /**
  94630. * Sets the value of the alpha mode.
  94631. *
  94632. * | Value | Type | Description |
  94633. * | --- | --- | --- |
  94634. * | 0 | ALPHA_DISABLE | |
  94635. * | 1 | ALPHA_ADD | |
  94636. * | 2 | ALPHA_COMBINE | |
  94637. * | 3 | ALPHA_SUBTRACT | |
  94638. * | 4 | ALPHA_MULTIPLY | |
  94639. * | 5 | ALPHA_MAXIMIZED | |
  94640. * | 6 | ALPHA_ONEONE | |
  94641. * | 7 | ALPHA_PREMULTIPLIED | |
  94642. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94643. * | 9 | ALPHA_INTERPOLATE | |
  94644. * | 10 | ALPHA_SCREENMODE | |
  94645. *
  94646. */
  94647. set alphaMode(value: number);
  94648. /**
  94649. * Gets the value of the alpha mode
  94650. */
  94651. get alphaMode(): number;
  94652. /**
  94653. * Stores the state of the need depth pre-pass value
  94654. */
  94655. private _needDepthPrePass;
  94656. /**
  94657. * Sets the need depth pre-pass value
  94658. */
  94659. set needDepthPrePass(value: boolean);
  94660. /**
  94661. * Gets the depth pre-pass value
  94662. */
  94663. get needDepthPrePass(): boolean;
  94664. /**
  94665. * Specifies if depth writing should be disabled
  94666. */
  94667. disableDepthWrite: boolean;
  94668. /**
  94669. * Specifies if depth writing should be forced
  94670. */
  94671. forceDepthWrite: boolean;
  94672. /**
  94673. * Specifies the depth function that should be used. 0 means the default engine function
  94674. */
  94675. depthFunction: number;
  94676. /**
  94677. * Specifies if there should be a separate pass for culling
  94678. */
  94679. separateCullingPass: boolean;
  94680. /**
  94681. * Stores the state specifing if fog should be enabled
  94682. */
  94683. private _fogEnabled;
  94684. /**
  94685. * Sets the state for enabling fog
  94686. */
  94687. set fogEnabled(value: boolean);
  94688. /**
  94689. * Gets the value of the fog enabled state
  94690. */
  94691. get fogEnabled(): boolean;
  94692. /**
  94693. * Stores the size of points
  94694. */
  94695. pointSize: number;
  94696. /**
  94697. * Stores the z offset value
  94698. */
  94699. zOffset: number;
  94700. /**
  94701. * Gets a value specifying if wireframe mode is enabled
  94702. */
  94703. get wireframe(): boolean;
  94704. /**
  94705. * Sets the state of wireframe mode
  94706. */
  94707. set wireframe(value: boolean);
  94708. /**
  94709. * Gets the value specifying if point clouds are enabled
  94710. */
  94711. get pointsCloud(): boolean;
  94712. /**
  94713. * Sets the state of point cloud mode
  94714. */
  94715. set pointsCloud(value: boolean);
  94716. /**
  94717. * Gets the material fill mode
  94718. */
  94719. get fillMode(): number;
  94720. /**
  94721. * Sets the material fill mode
  94722. */
  94723. set fillMode(value: number);
  94724. /**
  94725. * @hidden
  94726. * Stores the effects for the material
  94727. */
  94728. _effect: Nullable<Effect>;
  94729. /**
  94730. * Specifies if uniform buffers should be used
  94731. */
  94732. private _useUBO;
  94733. /**
  94734. * Stores a reference to the scene
  94735. */
  94736. private _scene;
  94737. /**
  94738. * Stores the fill mode state
  94739. */
  94740. private _fillMode;
  94741. /**
  94742. * Specifies if the depth write state should be cached
  94743. */
  94744. private _cachedDepthWriteState;
  94745. /**
  94746. * Specifies if the depth function state should be cached
  94747. */
  94748. private _cachedDepthFunctionState;
  94749. /**
  94750. * Stores the uniform buffer
  94751. */
  94752. protected _uniformBuffer: UniformBuffer;
  94753. /** @hidden */
  94754. _indexInSceneMaterialArray: number;
  94755. /** @hidden */
  94756. meshMap: Nullable<{
  94757. [id: string]: AbstractMesh | undefined;
  94758. }>;
  94759. /**
  94760. * Creates a material instance
  94761. * @param name defines the name of the material
  94762. * @param scene defines the scene to reference
  94763. * @param doNotAdd specifies if the material should be added to the scene
  94764. */
  94765. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94766. /**
  94767. * Returns a string representation of the current material
  94768. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94769. * @returns a string with material information
  94770. */
  94771. toString(fullDetails?: boolean): string;
  94772. /**
  94773. * Gets the class name of the material
  94774. * @returns a string with the class name of the material
  94775. */
  94776. getClassName(): string;
  94777. /**
  94778. * Specifies if updates for the material been locked
  94779. */
  94780. get isFrozen(): boolean;
  94781. /**
  94782. * Locks updates for the material
  94783. */
  94784. freeze(): void;
  94785. /**
  94786. * Unlocks updates for the material
  94787. */
  94788. unfreeze(): void;
  94789. /**
  94790. * Specifies if the material is ready to be used
  94791. * @param mesh defines the mesh to check
  94792. * @param useInstances specifies if instances should be used
  94793. * @returns a boolean indicating if the material is ready to be used
  94794. */
  94795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94796. /**
  94797. * Specifies that the submesh is ready to be used
  94798. * @param mesh defines the mesh to check
  94799. * @param subMesh defines which submesh to check
  94800. * @param useInstances specifies that instances should be used
  94801. * @returns a boolean indicating that the submesh is ready or not
  94802. */
  94803. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94804. /**
  94805. * Returns the material effect
  94806. * @returns the effect associated with the material
  94807. */
  94808. getEffect(): Nullable<Effect>;
  94809. /**
  94810. * Returns the current scene
  94811. * @returns a Scene
  94812. */
  94813. getScene(): Scene;
  94814. /**
  94815. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  94816. */
  94817. protected _forceAlphaTest: boolean;
  94818. /**
  94819. * The transparency mode of the material.
  94820. */
  94821. protected _transparencyMode: Nullable<number>;
  94822. /**
  94823. * Gets the current transparency mode.
  94824. */
  94825. get transparencyMode(): Nullable<number>;
  94826. /**
  94827. * Sets the transparency mode of the material.
  94828. *
  94829. * | Value | Type | Description |
  94830. * | ----- | ----------------------------------- | ----------- |
  94831. * | 0 | OPAQUE | |
  94832. * | 1 | ALPHATEST | |
  94833. * | 2 | ALPHABLEND | |
  94834. * | 3 | ALPHATESTANDBLEND | |
  94835. *
  94836. */
  94837. set transparencyMode(value: Nullable<number>);
  94838. /**
  94839. * Returns true if alpha blending should be disabled.
  94840. */
  94841. protected get _disableAlphaBlending(): boolean;
  94842. /**
  94843. * Specifies whether or not this material should be rendered in alpha blend mode.
  94844. * @returns a boolean specifying if alpha blending is needed
  94845. */
  94846. needAlphaBlending(): boolean;
  94847. /**
  94848. * Specifies if the mesh will require alpha blending
  94849. * @param mesh defines the mesh to check
  94850. * @returns a boolean specifying if alpha blending is needed for the mesh
  94851. */
  94852. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94853. /**
  94854. * Specifies whether or not this material should be rendered in alpha test mode.
  94855. * @returns a boolean specifying if an alpha test is needed.
  94856. */
  94857. needAlphaTesting(): boolean;
  94858. /**
  94859. * Specifies if material alpha testing should be turned on for the mesh
  94860. * @param mesh defines the mesh to check
  94861. */
  94862. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94863. /**
  94864. * Gets the texture used for the alpha test
  94865. * @returns the texture to use for alpha testing
  94866. */
  94867. getAlphaTestTexture(): Nullable<BaseTexture>;
  94868. /**
  94869. * Marks the material to indicate that it needs to be re-calculated
  94870. */
  94871. markDirty(): void;
  94872. /** @hidden */
  94873. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94874. /**
  94875. * Binds the material to the mesh
  94876. * @param world defines the world transformation matrix
  94877. * @param mesh defines the mesh to bind the material to
  94878. */
  94879. bind(world: Matrix, mesh?: Mesh): void;
  94880. /**
  94881. * Binds the submesh to the material
  94882. * @param world defines the world transformation matrix
  94883. * @param mesh defines the mesh containing the submesh
  94884. * @param subMesh defines the submesh to bind the material to
  94885. */
  94886. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94887. /**
  94888. * Binds the world matrix to the material
  94889. * @param world defines the world transformation matrix
  94890. */
  94891. bindOnlyWorldMatrix(world: Matrix): void;
  94892. /**
  94893. * Binds the scene's uniform buffer to the effect.
  94894. * @param effect defines the effect to bind to the scene uniform buffer
  94895. * @param sceneUbo defines the uniform buffer storing scene data
  94896. */
  94897. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94898. /**
  94899. * Binds the view matrix to the effect
  94900. * @param effect defines the effect to bind the view matrix to
  94901. */
  94902. bindView(effect: Effect): void;
  94903. /**
  94904. * Binds the view projection matrix to the effect
  94905. * @param effect defines the effect to bind the view projection matrix to
  94906. */
  94907. bindViewProjection(effect: Effect): void;
  94908. /**
  94909. * Processes to execute after binding the material to a mesh
  94910. * @param mesh defines the rendered mesh
  94911. */
  94912. protected _afterBind(mesh?: Mesh): void;
  94913. /**
  94914. * Unbinds the material from the mesh
  94915. */
  94916. unbind(): void;
  94917. /**
  94918. * Gets the active textures from the material
  94919. * @returns an array of textures
  94920. */
  94921. getActiveTextures(): BaseTexture[];
  94922. /**
  94923. * Specifies if the material uses a texture
  94924. * @param texture defines the texture to check against the material
  94925. * @returns a boolean specifying if the material uses the texture
  94926. */
  94927. hasTexture(texture: BaseTexture): boolean;
  94928. /**
  94929. * Makes a duplicate of the material, and gives it a new name
  94930. * @param name defines the new name for the duplicated material
  94931. * @returns the cloned material
  94932. */
  94933. clone(name: string): Nullable<Material>;
  94934. /**
  94935. * Gets the meshes bound to the material
  94936. * @returns an array of meshes bound to the material
  94937. */
  94938. getBindedMeshes(): AbstractMesh[];
  94939. /**
  94940. * Force shader compilation
  94941. * @param mesh defines the mesh associated with this material
  94942. * @param onCompiled defines a function to execute once the material is compiled
  94943. * @param options defines the options to configure the compilation
  94944. * @param onError defines a function to execute if the material fails compiling
  94945. */
  94946. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94947. /**
  94948. * Force shader compilation
  94949. * @param mesh defines the mesh that will use this material
  94950. * @param options defines additional options for compiling the shaders
  94951. * @returns a promise that resolves when the compilation completes
  94952. */
  94953. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94954. private static readonly _AllDirtyCallBack;
  94955. private static readonly _ImageProcessingDirtyCallBack;
  94956. private static readonly _TextureDirtyCallBack;
  94957. private static readonly _FresnelDirtyCallBack;
  94958. private static readonly _MiscDirtyCallBack;
  94959. private static readonly _LightsDirtyCallBack;
  94960. private static readonly _AttributeDirtyCallBack;
  94961. private static _FresnelAndMiscDirtyCallBack;
  94962. private static _TextureAndMiscDirtyCallBack;
  94963. private static readonly _DirtyCallbackArray;
  94964. private static readonly _RunDirtyCallBacks;
  94965. /**
  94966. * Marks a define in the material to indicate that it needs to be re-computed
  94967. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94968. */
  94969. markAsDirty(flag: number): void;
  94970. /**
  94971. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94972. * @param func defines a function which checks material defines against the submeshes
  94973. */
  94974. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94975. /**
  94976. * Indicates that we need to re-calculated for all submeshes
  94977. */
  94978. protected _markAllSubMeshesAsAllDirty(): void;
  94979. /**
  94980. * Indicates that image processing needs to be re-calculated for all submeshes
  94981. */
  94982. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94983. /**
  94984. * Indicates that textures need to be re-calculated for all submeshes
  94985. */
  94986. protected _markAllSubMeshesAsTexturesDirty(): void;
  94987. /**
  94988. * Indicates that fresnel needs to be re-calculated for all submeshes
  94989. */
  94990. protected _markAllSubMeshesAsFresnelDirty(): void;
  94991. /**
  94992. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94993. */
  94994. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94995. /**
  94996. * Indicates that lights need to be re-calculated for all submeshes
  94997. */
  94998. protected _markAllSubMeshesAsLightsDirty(): void;
  94999. /**
  95000. * Indicates that attributes need to be re-calculated for all submeshes
  95001. */
  95002. protected _markAllSubMeshesAsAttributesDirty(): void;
  95003. /**
  95004. * Indicates that misc needs to be re-calculated for all submeshes
  95005. */
  95006. protected _markAllSubMeshesAsMiscDirty(): void;
  95007. /**
  95008. * Indicates that textures and misc need to be re-calculated for all submeshes
  95009. */
  95010. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95011. /**
  95012. * Disposes the material
  95013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95015. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95016. */
  95017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95018. /** @hidden */
  95019. private releaseVertexArrayObject;
  95020. /**
  95021. * Serializes this material
  95022. * @returns the serialized material object
  95023. */
  95024. serialize(): any;
  95025. /**
  95026. * Creates a material from parsed material data
  95027. * @param parsedMaterial defines parsed material data
  95028. * @param scene defines the hosting scene
  95029. * @param rootUrl defines the root URL to use to load textures
  95030. * @returns a new material
  95031. */
  95032. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95033. }
  95034. }
  95035. declare module BABYLON {
  95036. /**
  95037. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95038. * separate meshes. This can be use to improve performances.
  95039. * @see http://doc.babylonjs.com/how_to/multi_materials
  95040. */
  95041. export class MultiMaterial extends Material {
  95042. private _subMaterials;
  95043. /**
  95044. * Gets or Sets the list of Materials used within the multi material.
  95045. * They need to be ordered according to the submeshes order in the associated mesh
  95046. */
  95047. get subMaterials(): Nullable<Material>[];
  95048. set subMaterials(value: Nullable<Material>[]);
  95049. /**
  95050. * Function used to align with Node.getChildren()
  95051. * @returns the list of Materials used within the multi material
  95052. */
  95053. getChildren(): Nullable<Material>[];
  95054. /**
  95055. * Instantiates a new Multi Material
  95056. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95057. * separate meshes. This can be use to improve performances.
  95058. * @see http://doc.babylonjs.com/how_to/multi_materials
  95059. * @param name Define the name in the scene
  95060. * @param scene Define the scene the material belongs to
  95061. */
  95062. constructor(name: string, scene: Scene);
  95063. private _hookArray;
  95064. /**
  95065. * Get one of the submaterial by its index in the submaterials array
  95066. * @param index The index to look the sub material at
  95067. * @returns The Material if the index has been defined
  95068. */
  95069. getSubMaterial(index: number): Nullable<Material>;
  95070. /**
  95071. * Get the list of active textures for the whole sub materials list.
  95072. * @returns All the textures that will be used during the rendering
  95073. */
  95074. getActiveTextures(): BaseTexture[];
  95075. /**
  95076. * Gets the current class name of the material e.g. "MultiMaterial"
  95077. * Mainly use in serialization.
  95078. * @returns the class name
  95079. */
  95080. getClassName(): string;
  95081. /**
  95082. * Checks if the material is ready to render the requested sub mesh
  95083. * @param mesh Define the mesh the submesh belongs to
  95084. * @param subMesh Define the sub mesh to look readyness for
  95085. * @param useInstances Define whether or not the material is used with instances
  95086. * @returns true if ready, otherwise false
  95087. */
  95088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95089. /**
  95090. * Clones the current material and its related sub materials
  95091. * @param name Define the name of the newly cloned material
  95092. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95093. * @returns the cloned material
  95094. */
  95095. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95096. /**
  95097. * Serializes the materials into a JSON representation.
  95098. * @returns the JSON representation
  95099. */
  95100. serialize(): any;
  95101. /**
  95102. * Dispose the material and release its associated resources
  95103. * @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)
  95104. * @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)
  95105. * @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)
  95106. */
  95107. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95108. /**
  95109. * Creates a MultiMaterial from parsed MultiMaterial data.
  95110. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95111. * @param scene defines the hosting scene
  95112. * @returns a new MultiMaterial
  95113. */
  95114. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95115. }
  95116. }
  95117. declare module BABYLON {
  95118. /**
  95119. * Base class for submeshes
  95120. */
  95121. export class BaseSubMesh {
  95122. /** @hidden */
  95123. _materialDefines: Nullable<MaterialDefines>;
  95124. /** @hidden */
  95125. _materialEffect: Nullable<Effect>;
  95126. /**
  95127. * Gets material defines used by the effect associated to the sub mesh
  95128. */
  95129. get materialDefines(): Nullable<MaterialDefines>;
  95130. /**
  95131. * Sets material defines used by the effect associated to the sub mesh
  95132. */
  95133. set materialDefines(defines: Nullable<MaterialDefines>);
  95134. /**
  95135. * Gets associated effect
  95136. */
  95137. get effect(): Nullable<Effect>;
  95138. /**
  95139. * Sets associated effect (effect used to render this submesh)
  95140. * @param effect defines the effect to associate with
  95141. * @param defines defines the set of defines used to compile this effect
  95142. */
  95143. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95144. }
  95145. /**
  95146. * Defines a subdivision inside a mesh
  95147. */
  95148. export class SubMesh extends BaseSubMesh implements ICullable {
  95149. /** the material index to use */
  95150. materialIndex: number;
  95151. /** vertex index start */
  95152. verticesStart: number;
  95153. /** vertices count */
  95154. verticesCount: number;
  95155. /** index start */
  95156. indexStart: number;
  95157. /** indices count */
  95158. indexCount: number;
  95159. /** @hidden */
  95160. _linesIndexCount: number;
  95161. private _mesh;
  95162. private _renderingMesh;
  95163. private _boundingInfo;
  95164. private _linesIndexBuffer;
  95165. /** @hidden */
  95166. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95167. /** @hidden */
  95168. _trianglePlanes: Plane[];
  95169. /** @hidden */
  95170. _lastColliderTransformMatrix: Nullable<Matrix>;
  95171. /** @hidden */
  95172. _renderId: number;
  95173. /** @hidden */
  95174. _alphaIndex: number;
  95175. /** @hidden */
  95176. _distanceToCamera: number;
  95177. /** @hidden */
  95178. _id: number;
  95179. private _currentMaterial;
  95180. /**
  95181. * Add a new submesh to a mesh
  95182. * @param materialIndex defines the material index to use
  95183. * @param verticesStart defines vertex index start
  95184. * @param verticesCount defines vertices count
  95185. * @param indexStart defines index start
  95186. * @param indexCount defines indices count
  95187. * @param mesh defines the parent mesh
  95188. * @param renderingMesh defines an optional rendering mesh
  95189. * @param createBoundingBox defines if bounding box should be created for this submesh
  95190. * @returns the new submesh
  95191. */
  95192. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  95193. /**
  95194. * Creates a new submesh
  95195. * @param materialIndex defines the material index to use
  95196. * @param verticesStart defines vertex index start
  95197. * @param verticesCount defines vertices count
  95198. * @param indexStart defines index start
  95199. * @param indexCount defines indices count
  95200. * @param mesh defines the parent mesh
  95201. * @param renderingMesh defines an optional rendering mesh
  95202. * @param createBoundingBox defines if bounding box should be created for this submesh
  95203. */
  95204. constructor(
  95205. /** the material index to use */
  95206. materialIndex: number,
  95207. /** vertex index start */
  95208. verticesStart: number,
  95209. /** vertices count */
  95210. verticesCount: number,
  95211. /** index start */
  95212. indexStart: number,
  95213. /** indices count */
  95214. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  95215. /**
  95216. * Returns true if this submesh covers the entire parent mesh
  95217. * @ignorenaming
  95218. */
  95219. get IsGlobal(): boolean;
  95220. /**
  95221. * Returns the submesh BoudingInfo object
  95222. * @returns current bounding info (or mesh's one if the submesh is global)
  95223. */
  95224. getBoundingInfo(): BoundingInfo;
  95225. /**
  95226. * Sets the submesh BoundingInfo
  95227. * @param boundingInfo defines the new bounding info to use
  95228. * @returns the SubMesh
  95229. */
  95230. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  95231. /**
  95232. * Returns the mesh of the current submesh
  95233. * @return the parent mesh
  95234. */
  95235. getMesh(): AbstractMesh;
  95236. /**
  95237. * Returns the rendering mesh of the submesh
  95238. * @returns the rendering mesh (could be different from parent mesh)
  95239. */
  95240. getRenderingMesh(): Mesh;
  95241. /**
  95242. * Returns the submesh material
  95243. * @returns null or the current material
  95244. */
  95245. getMaterial(): Nullable<Material>;
  95246. /**
  95247. * Sets a new updated BoundingInfo object to the submesh
  95248. * @param data defines an optional position array to use to determine the bounding info
  95249. * @returns the SubMesh
  95250. */
  95251. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  95252. /** @hidden */
  95253. _checkCollision(collider: Collider): boolean;
  95254. /**
  95255. * Updates the submesh BoundingInfo
  95256. * @param world defines the world matrix to use to update the bounding info
  95257. * @returns the submesh
  95258. */
  95259. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  95260. /**
  95261. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  95262. * @param frustumPlanes defines the frustum planes
  95263. * @returns true if the submesh is intersecting with the frustum
  95264. */
  95265. isInFrustum(frustumPlanes: Plane[]): boolean;
  95266. /**
  95267. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95268. * @param frustumPlanes defines the frustum planes
  95269. * @returns true if the submesh is inside the frustum
  95270. */
  95271. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95272. /**
  95273. * Renders the submesh
  95274. * @param enableAlphaMode defines if alpha needs to be used
  95275. * @returns the submesh
  95276. */
  95277. render(enableAlphaMode: boolean): SubMesh;
  95278. /**
  95279. * @hidden
  95280. */
  95281. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95282. /**
  95283. * Checks if the submesh intersects with a ray
  95284. * @param ray defines the ray to test
  95285. * @returns true is the passed ray intersects the submesh bounding box
  95286. */
  95287. canIntersects(ray: Ray): boolean;
  95288. /**
  95289. * Intersects current submesh with a ray
  95290. * @param ray defines the ray to test
  95291. * @param positions defines mesh's positions array
  95292. * @param indices defines mesh's indices array
  95293. * @param fastCheck defines if only bounding info should be used
  95294. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95295. * @returns intersection info or null if no intersection
  95296. */
  95297. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95298. /** @hidden */
  95299. private _intersectLines;
  95300. /** @hidden */
  95301. private _intersectUnIndexedLines;
  95302. /** @hidden */
  95303. private _intersectTriangles;
  95304. /** @hidden */
  95305. private _intersectUnIndexedTriangles;
  95306. /** @hidden */
  95307. _rebuild(): void;
  95308. /**
  95309. * Creates a new submesh from the passed mesh
  95310. * @param newMesh defines the new hosting mesh
  95311. * @param newRenderingMesh defines an optional rendering mesh
  95312. * @returns the new submesh
  95313. */
  95314. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95315. /**
  95316. * Release associated resources
  95317. */
  95318. dispose(): void;
  95319. /**
  95320. * Gets the class name
  95321. * @returns the string "SubMesh".
  95322. */
  95323. getClassName(): string;
  95324. /**
  95325. * Creates a new submesh from indices data
  95326. * @param materialIndex the index of the main mesh material
  95327. * @param startIndex the index where to start the copy in the mesh indices array
  95328. * @param indexCount the number of indices to copy then from the startIndex
  95329. * @param mesh the main mesh to create the submesh from
  95330. * @param renderingMesh the optional rendering mesh
  95331. * @returns a new submesh
  95332. */
  95333. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95334. }
  95335. }
  95336. declare module BABYLON {
  95337. /**
  95338. * Class used to represent data loading progression
  95339. */
  95340. export class SceneLoaderFlags {
  95341. private static _ForceFullSceneLoadingForIncremental;
  95342. private static _ShowLoadingScreen;
  95343. private static _CleanBoneMatrixWeights;
  95344. private static _loggingLevel;
  95345. /**
  95346. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95347. */
  95348. static get ForceFullSceneLoadingForIncremental(): boolean;
  95349. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95350. /**
  95351. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95352. */
  95353. static get ShowLoadingScreen(): boolean;
  95354. static set ShowLoadingScreen(value: boolean);
  95355. /**
  95356. * Defines the current logging level (while loading the scene)
  95357. * @ignorenaming
  95358. */
  95359. static get loggingLevel(): number;
  95360. static set loggingLevel(value: number);
  95361. /**
  95362. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95363. */
  95364. static get CleanBoneMatrixWeights(): boolean;
  95365. static set CleanBoneMatrixWeights(value: boolean);
  95366. }
  95367. }
  95368. declare module BABYLON {
  95369. /**
  95370. * Class used to store geometry data (vertex buffers + index buffer)
  95371. */
  95372. export class Geometry implements IGetSetVerticesData {
  95373. /**
  95374. * Gets or sets the ID of the geometry
  95375. */
  95376. id: string;
  95377. /**
  95378. * Gets or sets the unique ID of the geometry
  95379. */
  95380. uniqueId: number;
  95381. /**
  95382. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95383. */
  95384. delayLoadState: number;
  95385. /**
  95386. * Gets the file containing the data to load when running in delay load state
  95387. */
  95388. delayLoadingFile: Nullable<string>;
  95389. /**
  95390. * Callback called when the geometry is updated
  95391. */
  95392. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95393. private _scene;
  95394. private _engine;
  95395. private _meshes;
  95396. private _totalVertices;
  95397. /** @hidden */
  95398. _indices: IndicesArray;
  95399. /** @hidden */
  95400. _vertexBuffers: {
  95401. [key: string]: VertexBuffer;
  95402. };
  95403. private _isDisposed;
  95404. private _extend;
  95405. private _boundingBias;
  95406. /** @hidden */
  95407. _delayInfo: Array<string>;
  95408. private _indexBuffer;
  95409. private _indexBufferIsUpdatable;
  95410. /** @hidden */
  95411. _boundingInfo: Nullable<BoundingInfo>;
  95412. /** @hidden */
  95413. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95414. /** @hidden */
  95415. _softwareSkinningFrameId: number;
  95416. private _vertexArrayObjects;
  95417. private _updatable;
  95418. /** @hidden */
  95419. _positions: Nullable<Vector3[]>;
  95420. /**
  95421. * 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
  95422. */
  95423. get boundingBias(): Vector2;
  95424. /**
  95425. * 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
  95426. */
  95427. set boundingBias(value: Vector2);
  95428. /**
  95429. * Static function used to attach a new empty geometry to a mesh
  95430. * @param mesh defines the mesh to attach the geometry to
  95431. * @returns the new Geometry
  95432. */
  95433. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95434. /**
  95435. * Creates a new geometry
  95436. * @param id defines the unique ID
  95437. * @param scene defines the hosting scene
  95438. * @param vertexData defines the VertexData used to get geometry data
  95439. * @param updatable defines if geometry must be updatable (false by default)
  95440. * @param mesh defines the mesh that will be associated with the geometry
  95441. */
  95442. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95443. /**
  95444. * Gets the current extend of the geometry
  95445. */
  95446. get extend(): {
  95447. minimum: Vector3;
  95448. maximum: Vector3;
  95449. };
  95450. /**
  95451. * Gets the hosting scene
  95452. * @returns the hosting Scene
  95453. */
  95454. getScene(): Scene;
  95455. /**
  95456. * Gets the hosting engine
  95457. * @returns the hosting Engine
  95458. */
  95459. getEngine(): Engine;
  95460. /**
  95461. * Defines if the geometry is ready to use
  95462. * @returns true if the geometry is ready to be used
  95463. */
  95464. isReady(): boolean;
  95465. /**
  95466. * Gets a value indicating that the geometry should not be serialized
  95467. */
  95468. get doNotSerialize(): boolean;
  95469. /** @hidden */
  95470. _rebuild(): void;
  95471. /**
  95472. * Affects all geometry data in one call
  95473. * @param vertexData defines the geometry data
  95474. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95475. */
  95476. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95477. /**
  95478. * Set specific vertex data
  95479. * @param kind defines the data kind (Position, normal, etc...)
  95480. * @param data defines the vertex data to use
  95481. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95482. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95483. */
  95484. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95485. /**
  95486. * Removes a specific vertex data
  95487. * @param kind defines the data kind (Position, normal, etc...)
  95488. */
  95489. removeVerticesData(kind: string): void;
  95490. /**
  95491. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95492. * @param buffer defines the vertex buffer to use
  95493. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95494. */
  95495. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95496. /**
  95497. * Update a specific vertex buffer
  95498. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95499. * It will do nothing if the buffer is not updatable
  95500. * @param kind defines the data kind (Position, normal, etc...)
  95501. * @param data defines the data to use
  95502. * @param offset defines the offset in the target buffer where to store the data
  95503. * @param useBytes set to true if the offset is in bytes
  95504. */
  95505. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95506. /**
  95507. * Update a specific vertex buffer
  95508. * This function will create a new buffer if the current one is not updatable
  95509. * @param kind defines the data kind (Position, normal, etc...)
  95510. * @param data defines the data to use
  95511. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95512. */
  95513. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95514. private _updateBoundingInfo;
  95515. /** @hidden */
  95516. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95517. /**
  95518. * Gets total number of vertices
  95519. * @returns the total number of vertices
  95520. */
  95521. getTotalVertices(): number;
  95522. /**
  95523. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95524. * @param kind defines the data kind (Position, normal, etc...)
  95525. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95526. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95527. * @returns a float array containing vertex data
  95528. */
  95529. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95530. /**
  95531. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95532. * @param kind defines the data kind (Position, normal, etc...)
  95533. * @returns true if the vertex buffer with the specified kind is updatable
  95534. */
  95535. isVertexBufferUpdatable(kind: string): boolean;
  95536. /**
  95537. * Gets a specific vertex buffer
  95538. * @param kind defines the data kind (Position, normal, etc...)
  95539. * @returns a VertexBuffer
  95540. */
  95541. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95542. /**
  95543. * Returns all vertex buffers
  95544. * @return an object holding all vertex buffers indexed by kind
  95545. */
  95546. getVertexBuffers(): Nullable<{
  95547. [key: string]: VertexBuffer;
  95548. }>;
  95549. /**
  95550. * Gets a boolean indicating if specific vertex buffer is present
  95551. * @param kind defines the data kind (Position, normal, etc...)
  95552. * @returns true if data is present
  95553. */
  95554. isVerticesDataPresent(kind: string): boolean;
  95555. /**
  95556. * Gets a list of all attached data kinds (Position, normal, etc...)
  95557. * @returns a list of string containing all kinds
  95558. */
  95559. getVerticesDataKinds(): string[];
  95560. /**
  95561. * Update index buffer
  95562. * @param indices defines the indices to store in the index buffer
  95563. * @param offset defines the offset in the target buffer where to store the data
  95564. * @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)
  95565. */
  95566. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95567. /**
  95568. * Creates a new index buffer
  95569. * @param indices defines the indices to store in the index buffer
  95570. * @param totalVertices defines the total number of vertices (could be null)
  95571. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95572. */
  95573. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95574. /**
  95575. * Return the total number of indices
  95576. * @returns the total number of indices
  95577. */
  95578. getTotalIndices(): number;
  95579. /**
  95580. * Gets the index buffer array
  95581. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95582. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95583. * @returns the index buffer array
  95584. */
  95585. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95586. /**
  95587. * Gets the index buffer
  95588. * @return the index buffer
  95589. */
  95590. getIndexBuffer(): Nullable<DataBuffer>;
  95591. /** @hidden */
  95592. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95593. /**
  95594. * Release the associated resources for a specific mesh
  95595. * @param mesh defines the source mesh
  95596. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95597. */
  95598. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95599. /**
  95600. * Apply current geometry to a given mesh
  95601. * @param mesh defines the mesh to apply geometry to
  95602. */
  95603. applyToMesh(mesh: Mesh): void;
  95604. private _updateExtend;
  95605. private _applyToMesh;
  95606. private notifyUpdate;
  95607. /**
  95608. * Load the geometry if it was flagged as delay loaded
  95609. * @param scene defines the hosting scene
  95610. * @param onLoaded defines a callback called when the geometry is loaded
  95611. */
  95612. load(scene: Scene, onLoaded?: () => void): void;
  95613. private _queueLoad;
  95614. /**
  95615. * Invert the geometry to move from a right handed system to a left handed one.
  95616. */
  95617. toLeftHanded(): void;
  95618. /** @hidden */
  95619. _resetPointsArrayCache(): void;
  95620. /** @hidden */
  95621. _generatePointsArray(): boolean;
  95622. /**
  95623. * Gets a value indicating if the geometry is disposed
  95624. * @returns true if the geometry was disposed
  95625. */
  95626. isDisposed(): boolean;
  95627. private _disposeVertexArrayObjects;
  95628. /**
  95629. * Free all associated resources
  95630. */
  95631. dispose(): void;
  95632. /**
  95633. * Clone the current geometry into a new geometry
  95634. * @param id defines the unique ID of the new geometry
  95635. * @returns a new geometry object
  95636. */
  95637. copy(id: string): Geometry;
  95638. /**
  95639. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95640. * @return a JSON representation of the current geometry data (without the vertices data)
  95641. */
  95642. serialize(): any;
  95643. private toNumberArray;
  95644. /**
  95645. * Serialize all vertices data into a JSON oject
  95646. * @returns a JSON representation of the current geometry data
  95647. */
  95648. serializeVerticeData(): any;
  95649. /**
  95650. * Extracts a clone of a mesh geometry
  95651. * @param mesh defines the source mesh
  95652. * @param id defines the unique ID of the new geometry object
  95653. * @returns the new geometry object
  95654. */
  95655. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95656. /**
  95657. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95658. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95659. * Be aware Math.random() could cause collisions, but:
  95660. * "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"
  95661. * @returns a string containing a new GUID
  95662. */
  95663. static RandomId(): string;
  95664. /** @hidden */
  95665. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95666. private static _CleanMatricesWeights;
  95667. /**
  95668. * Create a new geometry from persisted data (Using .babylon file format)
  95669. * @param parsedVertexData defines the persisted data
  95670. * @param scene defines the hosting scene
  95671. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95672. * @returns the new geometry object
  95673. */
  95674. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95675. }
  95676. }
  95677. declare module BABYLON {
  95678. /**
  95679. * Define an interface for all classes that will get and set the data on vertices
  95680. */
  95681. export interface IGetSetVerticesData {
  95682. /**
  95683. * Gets a boolean indicating if specific vertex data is present
  95684. * @param kind defines the vertex data kind to use
  95685. * @returns true is data kind is present
  95686. */
  95687. isVerticesDataPresent(kind: string): boolean;
  95688. /**
  95689. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95690. * @param kind defines the data kind (Position, normal, etc...)
  95691. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95692. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95693. * @returns a float array containing vertex data
  95694. */
  95695. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95696. /**
  95697. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95698. * @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.
  95699. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95700. * @returns the indices array or an empty array if the mesh has no geometry
  95701. */
  95702. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95703. /**
  95704. * Set specific vertex data
  95705. * @param kind defines the data kind (Position, normal, etc...)
  95706. * @param data defines the vertex data to use
  95707. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95708. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95709. */
  95710. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95711. /**
  95712. * Update a specific associated vertex buffer
  95713. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95714. * - VertexBuffer.PositionKind
  95715. * - VertexBuffer.UVKind
  95716. * - VertexBuffer.UV2Kind
  95717. * - VertexBuffer.UV3Kind
  95718. * - VertexBuffer.UV4Kind
  95719. * - VertexBuffer.UV5Kind
  95720. * - VertexBuffer.UV6Kind
  95721. * - VertexBuffer.ColorKind
  95722. * - VertexBuffer.MatricesIndicesKind
  95723. * - VertexBuffer.MatricesIndicesExtraKind
  95724. * - VertexBuffer.MatricesWeightsKind
  95725. * - VertexBuffer.MatricesWeightsExtraKind
  95726. * @param data defines the data source
  95727. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95728. * @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)
  95729. */
  95730. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95731. /**
  95732. * Creates a new index buffer
  95733. * @param indices defines the indices to store in the index buffer
  95734. * @param totalVertices defines the total number of vertices (could be null)
  95735. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95736. */
  95737. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95738. }
  95739. /**
  95740. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95741. */
  95742. export class VertexData {
  95743. /**
  95744. * Mesh side orientation : usually the external or front surface
  95745. */
  95746. static readonly FRONTSIDE: number;
  95747. /**
  95748. * Mesh side orientation : usually the internal or back surface
  95749. */
  95750. static readonly BACKSIDE: number;
  95751. /**
  95752. * Mesh side orientation : both internal and external or front and back surfaces
  95753. */
  95754. static readonly DOUBLESIDE: number;
  95755. /**
  95756. * Mesh side orientation : by default, `FRONTSIDE`
  95757. */
  95758. static readonly DEFAULTSIDE: number;
  95759. /**
  95760. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95761. */
  95762. positions: Nullable<FloatArray>;
  95763. /**
  95764. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95765. */
  95766. normals: Nullable<FloatArray>;
  95767. /**
  95768. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95769. */
  95770. tangents: Nullable<FloatArray>;
  95771. /**
  95772. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95773. */
  95774. uvs: Nullable<FloatArray>;
  95775. /**
  95776. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95777. */
  95778. uvs2: Nullable<FloatArray>;
  95779. /**
  95780. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95781. */
  95782. uvs3: Nullable<FloatArray>;
  95783. /**
  95784. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95785. */
  95786. uvs4: Nullable<FloatArray>;
  95787. /**
  95788. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95789. */
  95790. uvs5: Nullable<FloatArray>;
  95791. /**
  95792. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95793. */
  95794. uvs6: Nullable<FloatArray>;
  95795. /**
  95796. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95797. */
  95798. colors: Nullable<FloatArray>;
  95799. /**
  95800. * 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).
  95801. */
  95802. matricesIndices: Nullable<FloatArray>;
  95803. /**
  95804. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95805. */
  95806. matricesWeights: Nullable<FloatArray>;
  95807. /**
  95808. * An array extending the number of possible indices
  95809. */
  95810. matricesIndicesExtra: Nullable<FloatArray>;
  95811. /**
  95812. * An array extending the number of possible weights when the number of indices is extended
  95813. */
  95814. matricesWeightsExtra: Nullable<FloatArray>;
  95815. /**
  95816. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95817. */
  95818. indices: Nullable<IndicesArray>;
  95819. /**
  95820. * Uses the passed data array to set the set the values for the specified kind of data
  95821. * @param data a linear array of floating numbers
  95822. * @param kind the type of data that is being set, eg positions, colors etc
  95823. */
  95824. set(data: FloatArray, kind: string): void;
  95825. /**
  95826. * Associates the vertexData to the passed Mesh.
  95827. * Sets it as updatable or not (default `false`)
  95828. * @param mesh the mesh the vertexData is applied to
  95829. * @param updatable when used and having the value true allows new data to update the vertexData
  95830. * @returns the VertexData
  95831. */
  95832. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95833. /**
  95834. * Associates the vertexData to the passed Geometry.
  95835. * Sets it as updatable or not (default `false`)
  95836. * @param geometry the geometry the vertexData is applied to
  95837. * @param updatable when used and having the value true allows new data to update the vertexData
  95838. * @returns VertexData
  95839. */
  95840. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95841. /**
  95842. * Updates the associated mesh
  95843. * @param mesh the mesh to be updated
  95844. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95845. * @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
  95846. * @returns VertexData
  95847. */
  95848. updateMesh(mesh: Mesh): VertexData;
  95849. /**
  95850. * Updates the associated geometry
  95851. * @param geometry the geometry to be updated
  95852. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95853. * @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
  95854. * @returns VertexData.
  95855. */
  95856. updateGeometry(geometry: Geometry): VertexData;
  95857. private _applyTo;
  95858. private _update;
  95859. /**
  95860. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95861. * @param matrix the transforming matrix
  95862. * @returns the VertexData
  95863. */
  95864. transform(matrix: Matrix): VertexData;
  95865. /**
  95866. * Merges the passed VertexData into the current one
  95867. * @param other the VertexData to be merged into the current one
  95868. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95869. * @returns the modified VertexData
  95870. */
  95871. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95872. private _mergeElement;
  95873. private _validate;
  95874. /**
  95875. * Serializes the VertexData
  95876. * @returns a serialized object
  95877. */
  95878. serialize(): any;
  95879. /**
  95880. * Extracts the vertexData from a mesh
  95881. * @param mesh the mesh from which to extract the VertexData
  95882. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95883. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95884. * @returns the object VertexData associated to the passed mesh
  95885. */
  95886. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95887. /**
  95888. * Extracts the vertexData from the geometry
  95889. * @param geometry the geometry from which to extract the VertexData
  95890. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95891. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95892. * @returns the object VertexData associated to the passed mesh
  95893. */
  95894. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95895. private static _ExtractFrom;
  95896. /**
  95897. * Creates the VertexData for a Ribbon
  95898. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95899. * * pathArray array of paths, each of which an array of successive Vector3
  95900. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95901. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95902. * * 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
  95903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95904. * * 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)
  95905. * * 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)
  95906. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95907. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95908. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95909. * @returns the VertexData of the ribbon
  95910. */
  95911. static CreateRibbon(options: {
  95912. pathArray: Vector3[][];
  95913. closeArray?: boolean;
  95914. closePath?: boolean;
  95915. offset?: number;
  95916. sideOrientation?: number;
  95917. frontUVs?: Vector4;
  95918. backUVs?: Vector4;
  95919. invertUV?: boolean;
  95920. uvs?: Vector2[];
  95921. colors?: Color4[];
  95922. }): VertexData;
  95923. /**
  95924. * Creates the VertexData for a box
  95925. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95926. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95927. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95928. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95929. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95930. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95931. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95932. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95933. * * 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)
  95934. * * 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)
  95935. * @returns the VertexData of the box
  95936. */
  95937. static CreateBox(options: {
  95938. size?: number;
  95939. width?: number;
  95940. height?: number;
  95941. depth?: number;
  95942. faceUV?: Vector4[];
  95943. faceColors?: Color4[];
  95944. sideOrientation?: number;
  95945. frontUVs?: Vector4;
  95946. backUVs?: Vector4;
  95947. }): VertexData;
  95948. /**
  95949. * Creates the VertexData for a tiled box
  95950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95951. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95952. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95953. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95955. * @returns the VertexData of the box
  95956. */
  95957. static CreateTiledBox(options: {
  95958. pattern?: number;
  95959. width?: number;
  95960. height?: number;
  95961. depth?: number;
  95962. tileSize?: number;
  95963. tileWidth?: number;
  95964. tileHeight?: number;
  95965. alignHorizontal?: number;
  95966. alignVertical?: number;
  95967. faceUV?: Vector4[];
  95968. faceColors?: Color4[];
  95969. sideOrientation?: number;
  95970. }): VertexData;
  95971. /**
  95972. * Creates the VertexData for a tiled plane
  95973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95974. * * pattern a limited pattern arrangement depending on the number
  95975. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95976. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95977. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95979. * * 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)
  95980. * * 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)
  95981. * @returns the VertexData of the tiled plane
  95982. */
  95983. static CreateTiledPlane(options: {
  95984. pattern?: number;
  95985. tileSize?: number;
  95986. tileWidth?: number;
  95987. tileHeight?: number;
  95988. size?: number;
  95989. width?: number;
  95990. height?: number;
  95991. alignHorizontal?: number;
  95992. alignVertical?: number;
  95993. sideOrientation?: number;
  95994. frontUVs?: Vector4;
  95995. backUVs?: Vector4;
  95996. }): VertexData;
  95997. /**
  95998. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95999. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96000. * * segments sets the number of horizontal strips optional, default 32
  96001. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96002. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96003. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96004. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96005. * * 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
  96006. * * 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
  96007. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96008. * * 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)
  96009. * * 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)
  96010. * @returns the VertexData of the ellipsoid
  96011. */
  96012. static CreateSphere(options: {
  96013. segments?: number;
  96014. diameter?: number;
  96015. diameterX?: number;
  96016. diameterY?: number;
  96017. diameterZ?: number;
  96018. arc?: number;
  96019. slice?: number;
  96020. sideOrientation?: number;
  96021. frontUVs?: Vector4;
  96022. backUVs?: Vector4;
  96023. }): VertexData;
  96024. /**
  96025. * Creates the VertexData for a cylinder, cone or prism
  96026. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96027. * * height sets the height (y direction) of the cylinder, optional, default 2
  96028. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96029. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96030. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96031. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96032. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96033. * * 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
  96034. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96035. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96036. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96037. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96038. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96039. * * 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)
  96040. * * 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)
  96041. * @returns the VertexData of the cylinder, cone or prism
  96042. */
  96043. static CreateCylinder(options: {
  96044. height?: number;
  96045. diameterTop?: number;
  96046. diameterBottom?: number;
  96047. diameter?: number;
  96048. tessellation?: number;
  96049. subdivisions?: number;
  96050. arc?: number;
  96051. faceColors?: Color4[];
  96052. faceUV?: Vector4[];
  96053. hasRings?: boolean;
  96054. enclose?: boolean;
  96055. sideOrientation?: number;
  96056. frontUVs?: Vector4;
  96057. backUVs?: Vector4;
  96058. }): VertexData;
  96059. /**
  96060. * Creates the VertexData for a torus
  96061. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96062. * * diameter the diameter of the torus, optional default 1
  96063. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96064. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96065. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96066. * * 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)
  96067. * * 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)
  96068. * @returns the VertexData of the torus
  96069. */
  96070. static CreateTorus(options: {
  96071. diameter?: number;
  96072. thickness?: number;
  96073. tessellation?: number;
  96074. sideOrientation?: number;
  96075. frontUVs?: Vector4;
  96076. backUVs?: Vector4;
  96077. }): VertexData;
  96078. /**
  96079. * Creates the VertexData of the LineSystem
  96080. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96081. * - lines an array of lines, each line being an array of successive Vector3
  96082. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96083. * @returns the VertexData of the LineSystem
  96084. */
  96085. static CreateLineSystem(options: {
  96086. lines: Vector3[][];
  96087. colors?: Nullable<Color4[][]>;
  96088. }): VertexData;
  96089. /**
  96090. * Create the VertexData for a DashedLines
  96091. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96092. * - points an array successive Vector3
  96093. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96094. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96095. * - dashNb the intended total number of dashes, optional, default 200
  96096. * @returns the VertexData for the DashedLines
  96097. */
  96098. static CreateDashedLines(options: {
  96099. points: Vector3[];
  96100. dashSize?: number;
  96101. gapSize?: number;
  96102. dashNb?: number;
  96103. }): VertexData;
  96104. /**
  96105. * Creates the VertexData for a Ground
  96106. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96107. * - width the width (x direction) of the ground, optional, default 1
  96108. * - height the height (z direction) of the ground, optional, default 1
  96109. * - subdivisions the number of subdivisions per side, optional, default 1
  96110. * @returns the VertexData of the Ground
  96111. */
  96112. static CreateGround(options: {
  96113. width?: number;
  96114. height?: number;
  96115. subdivisions?: number;
  96116. subdivisionsX?: number;
  96117. subdivisionsY?: number;
  96118. }): VertexData;
  96119. /**
  96120. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96121. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96122. * * xmin the ground minimum X coordinate, optional, default -1
  96123. * * zmin the ground minimum Z coordinate, optional, default -1
  96124. * * xmax the ground maximum X coordinate, optional, default 1
  96125. * * zmax the ground maximum Z coordinate, optional, default 1
  96126. * * 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}
  96127. * * 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}
  96128. * @returns the VertexData of the TiledGround
  96129. */
  96130. static CreateTiledGround(options: {
  96131. xmin: number;
  96132. zmin: number;
  96133. xmax: number;
  96134. zmax: number;
  96135. subdivisions?: {
  96136. w: number;
  96137. h: number;
  96138. };
  96139. precision?: {
  96140. w: number;
  96141. h: number;
  96142. };
  96143. }): VertexData;
  96144. /**
  96145. * Creates the VertexData of the Ground designed from a heightmap
  96146. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96147. * * width the width (x direction) of the ground
  96148. * * height the height (z direction) of the ground
  96149. * * subdivisions the number of subdivisions per side
  96150. * * minHeight the minimum altitude on the ground, optional, default 0
  96151. * * maxHeight the maximum altitude on the ground, optional default 1
  96152. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96153. * * buffer the array holding the image color data
  96154. * * bufferWidth the width of image
  96155. * * bufferHeight the height of image
  96156. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96157. * @returns the VertexData of the Ground designed from a heightmap
  96158. */
  96159. static CreateGroundFromHeightMap(options: {
  96160. width: number;
  96161. height: number;
  96162. subdivisions: number;
  96163. minHeight: number;
  96164. maxHeight: number;
  96165. colorFilter: Color3;
  96166. buffer: Uint8Array;
  96167. bufferWidth: number;
  96168. bufferHeight: number;
  96169. alphaFilter: number;
  96170. }): VertexData;
  96171. /**
  96172. * Creates the VertexData for a Plane
  96173. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  96174. * * size sets the width and height of the plane to the value of size, optional default 1
  96175. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  96176. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  96177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96178. * * 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)
  96179. * * 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)
  96180. * @returns the VertexData of the box
  96181. */
  96182. static CreatePlane(options: {
  96183. size?: number;
  96184. width?: number;
  96185. height?: number;
  96186. sideOrientation?: number;
  96187. frontUVs?: Vector4;
  96188. backUVs?: Vector4;
  96189. }): VertexData;
  96190. /**
  96191. * Creates the VertexData of the Disc or regular Polygon
  96192. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  96193. * * radius the radius of the disc, optional default 0.5
  96194. * * tessellation the number of polygon sides, optional, default 64
  96195. * * 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
  96196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96197. * * 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)
  96198. * * 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)
  96199. * @returns the VertexData of the box
  96200. */
  96201. static CreateDisc(options: {
  96202. radius?: number;
  96203. tessellation?: number;
  96204. arc?: number;
  96205. sideOrientation?: number;
  96206. frontUVs?: Vector4;
  96207. backUVs?: Vector4;
  96208. }): VertexData;
  96209. /**
  96210. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  96211. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  96212. * @param polygon a mesh built from polygonTriangulation.build()
  96213. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96214. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96215. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96216. * @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)
  96217. * @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)
  96218. * @returns the VertexData of the Polygon
  96219. */
  96220. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  96221. /**
  96222. * Creates the VertexData of the IcoSphere
  96223. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  96224. * * radius the radius of the IcoSphere, optional default 1
  96225. * * radiusX allows stretching in the x direction, optional, default radius
  96226. * * radiusY allows stretching in the y direction, optional, default radius
  96227. * * radiusZ allows stretching in the z direction, optional, default radius
  96228. * * flat when true creates a flat shaded mesh, optional, default true
  96229. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96231. * * 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)
  96232. * * 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)
  96233. * @returns the VertexData of the IcoSphere
  96234. */
  96235. static CreateIcoSphere(options: {
  96236. radius?: number;
  96237. radiusX?: number;
  96238. radiusY?: number;
  96239. radiusZ?: number;
  96240. flat?: boolean;
  96241. subdivisions?: number;
  96242. sideOrientation?: number;
  96243. frontUVs?: Vector4;
  96244. backUVs?: Vector4;
  96245. }): VertexData;
  96246. /**
  96247. * Creates the VertexData for a Polyhedron
  96248. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  96249. * * type provided types are:
  96250. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  96251. * * 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)
  96252. * * size the size of the IcoSphere, optional default 1
  96253. * * sizeX allows stretching in the x direction, optional, default size
  96254. * * sizeY allows stretching in the y direction, optional, default size
  96255. * * sizeZ allows stretching in the z direction, optional, default size
  96256. * * 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
  96257. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96258. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96259. * * flat when true creates a flat shaded mesh, optional, default true
  96260. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96262. * * 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)
  96263. * * 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)
  96264. * @returns the VertexData of the Polyhedron
  96265. */
  96266. static CreatePolyhedron(options: {
  96267. type?: number;
  96268. size?: number;
  96269. sizeX?: number;
  96270. sizeY?: number;
  96271. sizeZ?: number;
  96272. custom?: any;
  96273. faceUV?: Vector4[];
  96274. faceColors?: Color4[];
  96275. flat?: boolean;
  96276. sideOrientation?: number;
  96277. frontUVs?: Vector4;
  96278. backUVs?: Vector4;
  96279. }): VertexData;
  96280. /**
  96281. * Creates the VertexData for a TorusKnot
  96282. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96283. * * radius the radius of the torus knot, optional, default 2
  96284. * * tube the thickness of the tube, optional, default 0.5
  96285. * * radialSegments the number of sides on each tube segments, optional, default 32
  96286. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96287. * * p the number of windings around the z axis, optional, default 2
  96288. * * q the number of windings around the x axis, optional, default 3
  96289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96290. * * 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)
  96291. * * 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)
  96292. * @returns the VertexData of the Torus Knot
  96293. */
  96294. static CreateTorusKnot(options: {
  96295. radius?: number;
  96296. tube?: number;
  96297. radialSegments?: number;
  96298. tubularSegments?: number;
  96299. p?: number;
  96300. q?: number;
  96301. sideOrientation?: number;
  96302. frontUVs?: Vector4;
  96303. backUVs?: Vector4;
  96304. }): VertexData;
  96305. /**
  96306. * Compute normals for given positions and indices
  96307. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96308. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96309. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96310. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96311. * * facetNormals : optional array of facet normals (vector3)
  96312. * * facetPositions : optional array of facet positions (vector3)
  96313. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96314. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96315. * * bInfo : optional bounding info, required for facetPartitioning computation
  96316. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96317. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96318. * * useRightHandedSystem: optional boolean to for right handed system computation
  96319. * * depthSort : optional boolean to enable the facet depth sort computation
  96320. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96321. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96322. */
  96323. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96324. facetNormals?: any;
  96325. facetPositions?: any;
  96326. facetPartitioning?: any;
  96327. ratio?: number;
  96328. bInfo?: any;
  96329. bbSize?: Vector3;
  96330. subDiv?: any;
  96331. useRightHandedSystem?: boolean;
  96332. depthSort?: boolean;
  96333. distanceTo?: Vector3;
  96334. depthSortedFacets?: any;
  96335. }): void;
  96336. /** @hidden */
  96337. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96338. /**
  96339. * Applies VertexData created from the imported parameters to the geometry
  96340. * @param parsedVertexData the parsed data from an imported file
  96341. * @param geometry the geometry to apply the VertexData to
  96342. */
  96343. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96344. }
  96345. }
  96346. declare module BABYLON {
  96347. /**
  96348. * Defines a target to use with MorphTargetManager
  96349. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96350. */
  96351. export class MorphTarget implements IAnimatable {
  96352. /** defines the name of the target */
  96353. name: string;
  96354. /**
  96355. * Gets or sets the list of animations
  96356. */
  96357. animations: Animation[];
  96358. private _scene;
  96359. private _positions;
  96360. private _normals;
  96361. private _tangents;
  96362. private _uvs;
  96363. private _influence;
  96364. private _uniqueId;
  96365. /**
  96366. * Observable raised when the influence changes
  96367. */
  96368. onInfluenceChanged: Observable<boolean>;
  96369. /** @hidden */
  96370. _onDataLayoutChanged: Observable<void>;
  96371. /**
  96372. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96373. */
  96374. get influence(): number;
  96375. set influence(influence: number);
  96376. /**
  96377. * Gets or sets the id of the morph Target
  96378. */
  96379. id: string;
  96380. private _animationPropertiesOverride;
  96381. /**
  96382. * Gets or sets the animation properties override
  96383. */
  96384. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96385. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96386. /**
  96387. * Creates a new MorphTarget
  96388. * @param name defines the name of the target
  96389. * @param influence defines the influence to use
  96390. * @param scene defines the scene the morphtarget belongs to
  96391. */
  96392. constructor(
  96393. /** defines the name of the target */
  96394. name: string, influence?: number, scene?: Nullable<Scene>);
  96395. /**
  96396. * Gets the unique ID of this manager
  96397. */
  96398. get uniqueId(): number;
  96399. /**
  96400. * Gets a boolean defining if the target contains position data
  96401. */
  96402. get hasPositions(): boolean;
  96403. /**
  96404. * Gets a boolean defining if the target contains normal data
  96405. */
  96406. get hasNormals(): boolean;
  96407. /**
  96408. * Gets a boolean defining if the target contains tangent data
  96409. */
  96410. get hasTangents(): boolean;
  96411. /**
  96412. * Gets a boolean defining if the target contains texture coordinates data
  96413. */
  96414. get hasUVs(): boolean;
  96415. /**
  96416. * Affects position data to this target
  96417. * @param data defines the position data to use
  96418. */
  96419. setPositions(data: Nullable<FloatArray>): void;
  96420. /**
  96421. * Gets the position data stored in this target
  96422. * @returns a FloatArray containing the position data (or null if not present)
  96423. */
  96424. getPositions(): Nullable<FloatArray>;
  96425. /**
  96426. * Affects normal data to this target
  96427. * @param data defines the normal data to use
  96428. */
  96429. setNormals(data: Nullable<FloatArray>): void;
  96430. /**
  96431. * Gets the normal data stored in this target
  96432. * @returns a FloatArray containing the normal data (or null if not present)
  96433. */
  96434. getNormals(): Nullable<FloatArray>;
  96435. /**
  96436. * Affects tangent data to this target
  96437. * @param data defines the tangent data to use
  96438. */
  96439. setTangents(data: Nullable<FloatArray>): void;
  96440. /**
  96441. * Gets the tangent data stored in this target
  96442. * @returns a FloatArray containing the tangent data (or null if not present)
  96443. */
  96444. getTangents(): Nullable<FloatArray>;
  96445. /**
  96446. * Affects texture coordinates data to this target
  96447. * @param data defines the texture coordinates data to use
  96448. */
  96449. setUVs(data: Nullable<FloatArray>): void;
  96450. /**
  96451. * Gets the texture coordinates data stored in this target
  96452. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96453. */
  96454. getUVs(): Nullable<FloatArray>;
  96455. /**
  96456. * Clone the current target
  96457. * @returns a new MorphTarget
  96458. */
  96459. clone(): MorphTarget;
  96460. /**
  96461. * Serializes the current target into a Serialization object
  96462. * @returns the serialized object
  96463. */
  96464. serialize(): any;
  96465. /**
  96466. * Returns the string "MorphTarget"
  96467. * @returns "MorphTarget"
  96468. */
  96469. getClassName(): string;
  96470. /**
  96471. * Creates a new target from serialized data
  96472. * @param serializationObject defines the serialized data to use
  96473. * @returns a new MorphTarget
  96474. */
  96475. static Parse(serializationObject: any): MorphTarget;
  96476. /**
  96477. * Creates a MorphTarget from mesh data
  96478. * @param mesh defines the source mesh
  96479. * @param name defines the name to use for the new target
  96480. * @param influence defines the influence to attach to the target
  96481. * @returns a new MorphTarget
  96482. */
  96483. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96484. }
  96485. }
  96486. declare module BABYLON {
  96487. /**
  96488. * This class is used to deform meshes using morphing between different targets
  96489. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96490. */
  96491. export class MorphTargetManager {
  96492. private _targets;
  96493. private _targetInfluenceChangedObservers;
  96494. private _targetDataLayoutChangedObservers;
  96495. private _activeTargets;
  96496. private _scene;
  96497. private _influences;
  96498. private _supportsNormals;
  96499. private _supportsTangents;
  96500. private _supportsUVs;
  96501. private _vertexCount;
  96502. private _uniqueId;
  96503. private _tempInfluences;
  96504. /**
  96505. * Gets or sets a boolean indicating if normals must be morphed
  96506. */
  96507. enableNormalMorphing: boolean;
  96508. /**
  96509. * Gets or sets a boolean indicating if tangents must be morphed
  96510. */
  96511. enableTangentMorphing: boolean;
  96512. /**
  96513. * Gets or sets a boolean indicating if UV must be morphed
  96514. */
  96515. enableUVMorphing: boolean;
  96516. /**
  96517. * Creates a new MorphTargetManager
  96518. * @param scene defines the current scene
  96519. */
  96520. constructor(scene?: Nullable<Scene>);
  96521. /**
  96522. * Gets the unique ID of this manager
  96523. */
  96524. get uniqueId(): number;
  96525. /**
  96526. * Gets the number of vertices handled by this manager
  96527. */
  96528. get vertexCount(): number;
  96529. /**
  96530. * Gets a boolean indicating if this manager supports morphing of normals
  96531. */
  96532. get supportsNormals(): boolean;
  96533. /**
  96534. * Gets a boolean indicating if this manager supports morphing of tangents
  96535. */
  96536. get supportsTangents(): boolean;
  96537. /**
  96538. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96539. */
  96540. get supportsUVs(): boolean;
  96541. /**
  96542. * Gets the number of targets stored in this manager
  96543. */
  96544. get numTargets(): number;
  96545. /**
  96546. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96547. */
  96548. get numInfluencers(): number;
  96549. /**
  96550. * Gets the list of influences (one per target)
  96551. */
  96552. get influences(): Float32Array;
  96553. /**
  96554. * Gets the active target at specified index. An active target is a target with an influence > 0
  96555. * @param index defines the index to check
  96556. * @returns the requested target
  96557. */
  96558. getActiveTarget(index: number): MorphTarget;
  96559. /**
  96560. * Gets the target at specified index
  96561. * @param index defines the index to check
  96562. * @returns the requested target
  96563. */
  96564. getTarget(index: number): MorphTarget;
  96565. /**
  96566. * Add a new target to this manager
  96567. * @param target defines the target to add
  96568. */
  96569. addTarget(target: MorphTarget): void;
  96570. /**
  96571. * Removes a target from the manager
  96572. * @param target defines the target to remove
  96573. */
  96574. removeTarget(target: MorphTarget): void;
  96575. /**
  96576. * Clone the current manager
  96577. * @returns a new MorphTargetManager
  96578. */
  96579. clone(): MorphTargetManager;
  96580. /**
  96581. * Serializes the current manager into a Serialization object
  96582. * @returns the serialized object
  96583. */
  96584. serialize(): any;
  96585. private _syncActiveTargets;
  96586. /**
  96587. * Syncrhonize the targets with all the meshes using this morph target manager
  96588. */
  96589. synchronize(): void;
  96590. /**
  96591. * Creates a new MorphTargetManager from serialized data
  96592. * @param serializationObject defines the serialized data
  96593. * @param scene defines the hosting scene
  96594. * @returns the new MorphTargetManager
  96595. */
  96596. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96597. }
  96598. }
  96599. declare module BABYLON {
  96600. /**
  96601. * Class used to represent a specific level of detail of a mesh
  96602. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96603. */
  96604. export class MeshLODLevel {
  96605. /** Defines the distance where this level should start being displayed */
  96606. distance: number;
  96607. /** Defines the mesh to use to render this level */
  96608. mesh: Nullable<Mesh>;
  96609. /**
  96610. * Creates a new LOD level
  96611. * @param distance defines the distance where this level should star being displayed
  96612. * @param mesh defines the mesh to use to render this level
  96613. */
  96614. constructor(
  96615. /** Defines the distance where this level should start being displayed */
  96616. distance: number,
  96617. /** Defines the mesh to use to render this level */
  96618. mesh: Nullable<Mesh>);
  96619. }
  96620. }
  96621. declare module BABYLON {
  96622. /**
  96623. * Mesh representing the gorund
  96624. */
  96625. export class GroundMesh extends Mesh {
  96626. /** If octree should be generated */
  96627. generateOctree: boolean;
  96628. private _heightQuads;
  96629. /** @hidden */
  96630. _subdivisionsX: number;
  96631. /** @hidden */
  96632. _subdivisionsY: number;
  96633. /** @hidden */
  96634. _width: number;
  96635. /** @hidden */
  96636. _height: number;
  96637. /** @hidden */
  96638. _minX: number;
  96639. /** @hidden */
  96640. _maxX: number;
  96641. /** @hidden */
  96642. _minZ: number;
  96643. /** @hidden */
  96644. _maxZ: number;
  96645. constructor(name: string, scene: Scene);
  96646. /**
  96647. * "GroundMesh"
  96648. * @returns "GroundMesh"
  96649. */
  96650. getClassName(): string;
  96651. /**
  96652. * The minimum of x and y subdivisions
  96653. */
  96654. get subdivisions(): number;
  96655. /**
  96656. * X subdivisions
  96657. */
  96658. get subdivisionsX(): number;
  96659. /**
  96660. * Y subdivisions
  96661. */
  96662. get subdivisionsY(): number;
  96663. /**
  96664. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96665. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96666. * @param chunksCount the number of subdivisions for x and y
  96667. * @param octreeBlocksSize (Default: 32)
  96668. */
  96669. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96670. /**
  96671. * Returns a height (y) value in the Worl system :
  96672. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96673. * @param x x coordinate
  96674. * @param z z coordinate
  96675. * @returns the ground y position if (x, z) are outside the ground surface.
  96676. */
  96677. getHeightAtCoordinates(x: number, z: number): number;
  96678. /**
  96679. * Returns a normalized vector (Vector3) orthogonal to the ground
  96680. * at the ground coordinates (x, z) expressed in the World system.
  96681. * @param x x coordinate
  96682. * @param z z coordinate
  96683. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96684. */
  96685. getNormalAtCoordinates(x: number, z: number): Vector3;
  96686. /**
  96687. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96688. * at the ground coordinates (x, z) expressed in the World system.
  96689. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96690. * @param x x coordinate
  96691. * @param z z coordinate
  96692. * @param ref vector to store the result
  96693. * @returns the GroundMesh.
  96694. */
  96695. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96696. /**
  96697. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96698. * if the ground has been updated.
  96699. * This can be used in the render loop.
  96700. * @returns the GroundMesh.
  96701. */
  96702. updateCoordinateHeights(): GroundMesh;
  96703. private _getFacetAt;
  96704. private _initHeightQuads;
  96705. private _computeHeightQuads;
  96706. /**
  96707. * Serializes this ground mesh
  96708. * @param serializationObject object to write serialization to
  96709. */
  96710. serialize(serializationObject: any): void;
  96711. /**
  96712. * Parses a serialized ground mesh
  96713. * @param parsedMesh the serialized mesh
  96714. * @param scene the scene to create the ground mesh in
  96715. * @returns the created ground mesh
  96716. */
  96717. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96718. }
  96719. }
  96720. declare module BABYLON {
  96721. /**
  96722. * Interface for Physics-Joint data
  96723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96724. */
  96725. export interface PhysicsJointData {
  96726. /**
  96727. * The main pivot of the joint
  96728. */
  96729. mainPivot?: Vector3;
  96730. /**
  96731. * The connected pivot of the joint
  96732. */
  96733. connectedPivot?: Vector3;
  96734. /**
  96735. * The main axis of the joint
  96736. */
  96737. mainAxis?: Vector3;
  96738. /**
  96739. * The connected axis of the joint
  96740. */
  96741. connectedAxis?: Vector3;
  96742. /**
  96743. * The collision of the joint
  96744. */
  96745. collision?: boolean;
  96746. /**
  96747. * Native Oimo/Cannon/Energy data
  96748. */
  96749. nativeParams?: any;
  96750. }
  96751. /**
  96752. * This is a holder class for the physics joint created by the physics plugin
  96753. * It holds a set of functions to control the underlying joint
  96754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96755. */
  96756. export class PhysicsJoint {
  96757. /**
  96758. * The type of the physics joint
  96759. */
  96760. type: number;
  96761. /**
  96762. * The data for the physics joint
  96763. */
  96764. jointData: PhysicsJointData;
  96765. private _physicsJoint;
  96766. protected _physicsPlugin: IPhysicsEnginePlugin;
  96767. /**
  96768. * Initializes the physics joint
  96769. * @param type The type of the physics joint
  96770. * @param jointData The data for the physics joint
  96771. */
  96772. constructor(
  96773. /**
  96774. * The type of the physics joint
  96775. */
  96776. type: number,
  96777. /**
  96778. * The data for the physics joint
  96779. */
  96780. jointData: PhysicsJointData);
  96781. /**
  96782. * Gets the physics joint
  96783. */
  96784. get physicsJoint(): any;
  96785. /**
  96786. * Sets the physics joint
  96787. */
  96788. set physicsJoint(newJoint: any);
  96789. /**
  96790. * Sets the physics plugin
  96791. */
  96792. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96793. /**
  96794. * Execute a function that is physics-plugin specific.
  96795. * @param {Function} func the function that will be executed.
  96796. * It accepts two parameters: the physics world and the physics joint
  96797. */
  96798. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96799. /**
  96800. * Distance-Joint type
  96801. */
  96802. static DistanceJoint: number;
  96803. /**
  96804. * Hinge-Joint type
  96805. */
  96806. static HingeJoint: number;
  96807. /**
  96808. * Ball-and-Socket joint type
  96809. */
  96810. static BallAndSocketJoint: number;
  96811. /**
  96812. * Wheel-Joint type
  96813. */
  96814. static WheelJoint: number;
  96815. /**
  96816. * Slider-Joint type
  96817. */
  96818. static SliderJoint: number;
  96819. /**
  96820. * Prismatic-Joint type
  96821. */
  96822. static PrismaticJoint: number;
  96823. /**
  96824. * Universal-Joint type
  96825. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96826. */
  96827. static UniversalJoint: number;
  96828. /**
  96829. * Hinge-Joint 2 type
  96830. */
  96831. static Hinge2Joint: number;
  96832. /**
  96833. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96834. */
  96835. static PointToPointJoint: number;
  96836. /**
  96837. * Spring-Joint type
  96838. */
  96839. static SpringJoint: number;
  96840. /**
  96841. * Lock-Joint type
  96842. */
  96843. static LockJoint: number;
  96844. }
  96845. /**
  96846. * A class representing a physics distance joint
  96847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96848. */
  96849. export class DistanceJoint extends PhysicsJoint {
  96850. /**
  96851. *
  96852. * @param jointData The data for the Distance-Joint
  96853. */
  96854. constructor(jointData: DistanceJointData);
  96855. /**
  96856. * Update the predefined distance.
  96857. * @param maxDistance The maximum preferred distance
  96858. * @param minDistance The minimum preferred distance
  96859. */
  96860. updateDistance(maxDistance: number, minDistance?: number): void;
  96861. }
  96862. /**
  96863. * Represents a Motor-Enabled Joint
  96864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96865. */
  96866. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96867. /**
  96868. * Initializes the Motor-Enabled Joint
  96869. * @param type The type of the joint
  96870. * @param jointData The physica joint data for the joint
  96871. */
  96872. constructor(type: number, jointData: PhysicsJointData);
  96873. /**
  96874. * Set the motor values.
  96875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96876. * @param force the force to apply
  96877. * @param maxForce max force for this motor.
  96878. */
  96879. setMotor(force?: number, maxForce?: number): void;
  96880. /**
  96881. * Set the motor's limits.
  96882. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96883. * @param upperLimit The upper limit of the motor
  96884. * @param lowerLimit The lower limit of the motor
  96885. */
  96886. setLimit(upperLimit: number, lowerLimit?: number): void;
  96887. }
  96888. /**
  96889. * This class represents a single physics Hinge-Joint
  96890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96891. */
  96892. export class HingeJoint extends MotorEnabledJoint {
  96893. /**
  96894. * Initializes the Hinge-Joint
  96895. * @param jointData The joint data for the Hinge-Joint
  96896. */
  96897. constructor(jointData: PhysicsJointData);
  96898. /**
  96899. * Set the motor values.
  96900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96901. * @param {number} force the force to apply
  96902. * @param {number} maxForce max force for this motor.
  96903. */
  96904. setMotor(force?: number, maxForce?: number): void;
  96905. /**
  96906. * Set the motor's limits.
  96907. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96908. * @param upperLimit The upper limit of the motor
  96909. * @param lowerLimit The lower limit of the motor
  96910. */
  96911. setLimit(upperLimit: number, lowerLimit?: number): void;
  96912. }
  96913. /**
  96914. * This class represents a dual hinge physics joint (same as wheel joint)
  96915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96916. */
  96917. export class Hinge2Joint extends MotorEnabledJoint {
  96918. /**
  96919. * Initializes the Hinge2-Joint
  96920. * @param jointData The joint data for the Hinge2-Joint
  96921. */
  96922. constructor(jointData: PhysicsJointData);
  96923. /**
  96924. * Set the motor values.
  96925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96926. * @param {number} targetSpeed the speed the motor is to reach
  96927. * @param {number} maxForce max force for this motor.
  96928. * @param {motorIndex} the motor's index, 0 or 1.
  96929. */
  96930. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96931. /**
  96932. * Set the motor limits.
  96933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96934. * @param {number} upperLimit the upper limit
  96935. * @param {number} lowerLimit lower limit
  96936. * @param {motorIndex} the motor's index, 0 or 1.
  96937. */
  96938. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96939. }
  96940. /**
  96941. * Interface for a motor enabled joint
  96942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96943. */
  96944. export interface IMotorEnabledJoint {
  96945. /**
  96946. * Physics joint
  96947. */
  96948. physicsJoint: any;
  96949. /**
  96950. * Sets the motor of the motor-enabled joint
  96951. * @param force The force of the motor
  96952. * @param maxForce The maximum force of the motor
  96953. * @param motorIndex The index of the motor
  96954. */
  96955. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96956. /**
  96957. * Sets the limit of the motor
  96958. * @param upperLimit The upper limit of the motor
  96959. * @param lowerLimit The lower limit of the motor
  96960. * @param motorIndex The index of the motor
  96961. */
  96962. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96963. }
  96964. /**
  96965. * Joint data for a Distance-Joint
  96966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96967. */
  96968. export interface DistanceJointData extends PhysicsJointData {
  96969. /**
  96970. * Max distance the 2 joint objects can be apart
  96971. */
  96972. maxDistance: number;
  96973. }
  96974. /**
  96975. * Joint data from a spring joint
  96976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96977. */
  96978. export interface SpringJointData extends PhysicsJointData {
  96979. /**
  96980. * Length of the spring
  96981. */
  96982. length: number;
  96983. /**
  96984. * Stiffness of the spring
  96985. */
  96986. stiffness: number;
  96987. /**
  96988. * Damping of the spring
  96989. */
  96990. damping: number;
  96991. /** this callback will be called when applying the force to the impostors. */
  96992. forceApplicationCallback: () => void;
  96993. }
  96994. }
  96995. declare module BABYLON {
  96996. /**
  96997. * Holds the data for the raycast result
  96998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96999. */
  97000. export class PhysicsRaycastResult {
  97001. private _hasHit;
  97002. private _hitDistance;
  97003. private _hitNormalWorld;
  97004. private _hitPointWorld;
  97005. private _rayFromWorld;
  97006. private _rayToWorld;
  97007. /**
  97008. * Gets if there was a hit
  97009. */
  97010. get hasHit(): boolean;
  97011. /**
  97012. * Gets the distance from the hit
  97013. */
  97014. get hitDistance(): number;
  97015. /**
  97016. * Gets the hit normal/direction in the world
  97017. */
  97018. get hitNormalWorld(): Vector3;
  97019. /**
  97020. * Gets the hit point in the world
  97021. */
  97022. get hitPointWorld(): Vector3;
  97023. /**
  97024. * Gets the ray "start point" of the ray in the world
  97025. */
  97026. get rayFromWorld(): Vector3;
  97027. /**
  97028. * Gets the ray "end point" of the ray in the world
  97029. */
  97030. get rayToWorld(): Vector3;
  97031. /**
  97032. * Sets the hit data (normal & point in world space)
  97033. * @param hitNormalWorld defines the normal in world space
  97034. * @param hitPointWorld defines the point in world space
  97035. */
  97036. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97037. /**
  97038. * Sets the distance from the start point to the hit point
  97039. * @param distance
  97040. */
  97041. setHitDistance(distance: number): void;
  97042. /**
  97043. * Calculates the distance manually
  97044. */
  97045. calculateHitDistance(): void;
  97046. /**
  97047. * Resets all the values to default
  97048. * @param from The from point on world space
  97049. * @param to The to point on world space
  97050. */
  97051. reset(from?: Vector3, to?: Vector3): void;
  97052. }
  97053. /**
  97054. * Interface for the size containing width and height
  97055. */
  97056. interface IXYZ {
  97057. /**
  97058. * X
  97059. */
  97060. x: number;
  97061. /**
  97062. * Y
  97063. */
  97064. y: number;
  97065. /**
  97066. * Z
  97067. */
  97068. z: number;
  97069. }
  97070. }
  97071. declare module BABYLON {
  97072. /**
  97073. * Interface used to describe a physics joint
  97074. */
  97075. export interface PhysicsImpostorJoint {
  97076. /** Defines the main impostor to which the joint is linked */
  97077. mainImpostor: PhysicsImpostor;
  97078. /** Defines the impostor that is connected to the main impostor using this joint */
  97079. connectedImpostor: PhysicsImpostor;
  97080. /** Defines the joint itself */
  97081. joint: PhysicsJoint;
  97082. }
  97083. /** @hidden */
  97084. export interface IPhysicsEnginePlugin {
  97085. world: any;
  97086. name: string;
  97087. setGravity(gravity: Vector3): void;
  97088. setTimeStep(timeStep: number): void;
  97089. getTimeStep(): number;
  97090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97092. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97093. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97094. removePhysicsBody(impostor: PhysicsImpostor): void;
  97095. generateJoint(joint: PhysicsImpostorJoint): void;
  97096. removeJoint(joint: PhysicsImpostorJoint): void;
  97097. isSupported(): boolean;
  97098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97099. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97100. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97101. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97102. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97103. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97104. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97105. getBodyMass(impostor: PhysicsImpostor): number;
  97106. getBodyFriction(impostor: PhysicsImpostor): number;
  97107. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97108. getBodyRestitution(impostor: PhysicsImpostor): number;
  97109. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97110. getBodyPressure?(impostor: PhysicsImpostor): number;
  97111. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97112. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97113. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97114. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97115. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97116. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97117. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97118. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97119. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97120. sleepBody(impostor: PhysicsImpostor): void;
  97121. wakeUpBody(impostor: PhysicsImpostor): void;
  97122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97123. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97124. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97125. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97126. getRadius(impostor: PhysicsImpostor): number;
  97127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97129. dispose(): void;
  97130. }
  97131. /**
  97132. * Interface used to define a physics engine
  97133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97134. */
  97135. export interface IPhysicsEngine {
  97136. /**
  97137. * Gets the gravity vector used by the simulation
  97138. */
  97139. gravity: Vector3;
  97140. /**
  97141. * Sets the gravity vector used by the simulation
  97142. * @param gravity defines the gravity vector to use
  97143. */
  97144. setGravity(gravity: Vector3): void;
  97145. /**
  97146. * Set the time step of the physics engine.
  97147. * Default is 1/60.
  97148. * To slow it down, enter 1/600 for example.
  97149. * To speed it up, 1/30
  97150. * @param newTimeStep the new timestep to apply to this world.
  97151. */
  97152. setTimeStep(newTimeStep: number): void;
  97153. /**
  97154. * Get the time step of the physics engine.
  97155. * @returns the current time step
  97156. */
  97157. getTimeStep(): number;
  97158. /**
  97159. * Set the sub time step of the physics engine.
  97160. * Default is 0 meaning there is no sub steps
  97161. * To increase physics resolution precision, set a small value (like 1 ms)
  97162. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97163. */
  97164. setSubTimeStep(subTimeStep: number): void;
  97165. /**
  97166. * Get the sub time step of the physics engine.
  97167. * @returns the current sub time step
  97168. */
  97169. getSubTimeStep(): number;
  97170. /**
  97171. * Release all resources
  97172. */
  97173. dispose(): void;
  97174. /**
  97175. * Gets the name of the current physics plugin
  97176. * @returns the name of the plugin
  97177. */
  97178. getPhysicsPluginName(): string;
  97179. /**
  97180. * Adding a new impostor for the impostor tracking.
  97181. * This will be done by the impostor itself.
  97182. * @param impostor the impostor to add
  97183. */
  97184. addImpostor(impostor: PhysicsImpostor): void;
  97185. /**
  97186. * Remove an impostor from the engine.
  97187. * This impostor and its mesh will not longer be updated by the physics engine.
  97188. * @param impostor the impostor to remove
  97189. */
  97190. removeImpostor(impostor: PhysicsImpostor): void;
  97191. /**
  97192. * Add a joint to the physics engine
  97193. * @param mainImpostor defines the main impostor to which the joint is added.
  97194. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  97195. * @param joint defines the joint that will connect both impostors.
  97196. */
  97197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97198. /**
  97199. * Removes a joint from the simulation
  97200. * @param mainImpostor defines the impostor used with the joint
  97201. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  97202. * @param joint defines the joint to remove
  97203. */
  97204. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97205. /**
  97206. * Gets the current plugin used to run the simulation
  97207. * @returns current plugin
  97208. */
  97209. getPhysicsPlugin(): IPhysicsEnginePlugin;
  97210. /**
  97211. * Gets the list of physic impostors
  97212. * @returns an array of PhysicsImpostor
  97213. */
  97214. getImpostors(): Array<PhysicsImpostor>;
  97215. /**
  97216. * Gets the impostor for a physics enabled object
  97217. * @param object defines the object impersonated by the impostor
  97218. * @returns the PhysicsImpostor or null if not found
  97219. */
  97220. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97221. /**
  97222. * Gets the impostor for a physics body object
  97223. * @param body defines physics body used by the impostor
  97224. * @returns the PhysicsImpostor or null if not found
  97225. */
  97226. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  97227. /**
  97228. * Does a raycast in the physics world
  97229. * @param from when should the ray start?
  97230. * @param to when should the ray end?
  97231. * @returns PhysicsRaycastResult
  97232. */
  97233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97234. /**
  97235. * Called by the scene. No need to call it.
  97236. * @param delta defines the timespam between frames
  97237. */
  97238. _step(delta: number): void;
  97239. }
  97240. }
  97241. declare module BABYLON {
  97242. /**
  97243. * The interface for the physics imposter parameters
  97244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97245. */
  97246. export interface PhysicsImpostorParameters {
  97247. /**
  97248. * The mass of the physics imposter
  97249. */
  97250. mass: number;
  97251. /**
  97252. * The friction of the physics imposter
  97253. */
  97254. friction?: number;
  97255. /**
  97256. * The coefficient of restitution of the physics imposter
  97257. */
  97258. restitution?: number;
  97259. /**
  97260. * The native options of the physics imposter
  97261. */
  97262. nativeOptions?: any;
  97263. /**
  97264. * Specifies if the parent should be ignored
  97265. */
  97266. ignoreParent?: boolean;
  97267. /**
  97268. * Specifies if bi-directional transformations should be disabled
  97269. */
  97270. disableBidirectionalTransformation?: boolean;
  97271. /**
  97272. * The pressure inside the physics imposter, soft object only
  97273. */
  97274. pressure?: number;
  97275. /**
  97276. * The stiffness the physics imposter, soft object only
  97277. */
  97278. stiffness?: number;
  97279. /**
  97280. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97281. */
  97282. velocityIterations?: number;
  97283. /**
  97284. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97285. */
  97286. positionIterations?: number;
  97287. /**
  97288. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97289. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97290. * Add to fix multiple points
  97291. */
  97292. fixedPoints?: number;
  97293. /**
  97294. * The collision margin around a soft object
  97295. */
  97296. margin?: number;
  97297. /**
  97298. * The collision margin around a soft object
  97299. */
  97300. damping?: number;
  97301. /**
  97302. * The path for a rope based on an extrusion
  97303. */
  97304. path?: any;
  97305. /**
  97306. * The shape of an extrusion used for a rope based on an extrusion
  97307. */
  97308. shape?: any;
  97309. }
  97310. /**
  97311. * Interface for a physics-enabled object
  97312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97313. */
  97314. export interface IPhysicsEnabledObject {
  97315. /**
  97316. * The position of the physics-enabled object
  97317. */
  97318. position: Vector3;
  97319. /**
  97320. * The rotation of the physics-enabled object
  97321. */
  97322. rotationQuaternion: Nullable<Quaternion>;
  97323. /**
  97324. * The scale of the physics-enabled object
  97325. */
  97326. scaling: Vector3;
  97327. /**
  97328. * The rotation of the physics-enabled object
  97329. */
  97330. rotation?: Vector3;
  97331. /**
  97332. * The parent of the physics-enabled object
  97333. */
  97334. parent?: any;
  97335. /**
  97336. * The bounding info of the physics-enabled object
  97337. * @returns The bounding info of the physics-enabled object
  97338. */
  97339. getBoundingInfo(): BoundingInfo;
  97340. /**
  97341. * Computes the world matrix
  97342. * @param force Specifies if the world matrix should be computed by force
  97343. * @returns A world matrix
  97344. */
  97345. computeWorldMatrix(force: boolean): Matrix;
  97346. /**
  97347. * Gets the world matrix
  97348. * @returns A world matrix
  97349. */
  97350. getWorldMatrix?(): Matrix;
  97351. /**
  97352. * Gets the child meshes
  97353. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97354. * @returns An array of abstract meshes
  97355. */
  97356. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97357. /**
  97358. * Gets the vertex data
  97359. * @param kind The type of vertex data
  97360. * @returns A nullable array of numbers, or a float32 array
  97361. */
  97362. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97363. /**
  97364. * Gets the indices from the mesh
  97365. * @returns A nullable array of index arrays
  97366. */
  97367. getIndices?(): Nullable<IndicesArray>;
  97368. /**
  97369. * Gets the scene from the mesh
  97370. * @returns the indices array or null
  97371. */
  97372. getScene?(): Scene;
  97373. /**
  97374. * Gets the absolute position from the mesh
  97375. * @returns the absolute position
  97376. */
  97377. getAbsolutePosition(): Vector3;
  97378. /**
  97379. * Gets the absolute pivot point from the mesh
  97380. * @returns the absolute pivot point
  97381. */
  97382. getAbsolutePivotPoint(): Vector3;
  97383. /**
  97384. * Rotates the mesh
  97385. * @param axis The axis of rotation
  97386. * @param amount The amount of rotation
  97387. * @param space The space of the rotation
  97388. * @returns The rotation transform node
  97389. */
  97390. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97391. /**
  97392. * Translates the mesh
  97393. * @param axis The axis of translation
  97394. * @param distance The distance of translation
  97395. * @param space The space of the translation
  97396. * @returns The transform node
  97397. */
  97398. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97399. /**
  97400. * Sets the absolute position of the mesh
  97401. * @param absolutePosition The absolute position of the mesh
  97402. * @returns The transform node
  97403. */
  97404. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97405. /**
  97406. * Gets the class name of the mesh
  97407. * @returns The class name
  97408. */
  97409. getClassName(): string;
  97410. }
  97411. /**
  97412. * Represents a physics imposter
  97413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97414. */
  97415. export class PhysicsImpostor {
  97416. /**
  97417. * The physics-enabled object used as the physics imposter
  97418. */
  97419. object: IPhysicsEnabledObject;
  97420. /**
  97421. * The type of the physics imposter
  97422. */
  97423. type: number;
  97424. private _options;
  97425. private _scene?;
  97426. /**
  97427. * The default object size of the imposter
  97428. */
  97429. static DEFAULT_OBJECT_SIZE: Vector3;
  97430. /**
  97431. * The identity quaternion of the imposter
  97432. */
  97433. static IDENTITY_QUATERNION: Quaternion;
  97434. /** @hidden */
  97435. _pluginData: any;
  97436. private _physicsEngine;
  97437. private _physicsBody;
  97438. private _bodyUpdateRequired;
  97439. private _onBeforePhysicsStepCallbacks;
  97440. private _onAfterPhysicsStepCallbacks;
  97441. /** @hidden */
  97442. _onPhysicsCollideCallbacks: Array<{
  97443. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97444. otherImpostors: Array<PhysicsImpostor>;
  97445. }>;
  97446. private _deltaPosition;
  97447. private _deltaRotation;
  97448. private _deltaRotationConjugated;
  97449. /** @hidden */
  97450. _isFromLine: boolean;
  97451. private _parent;
  97452. private _isDisposed;
  97453. private static _tmpVecs;
  97454. private static _tmpQuat;
  97455. /**
  97456. * Specifies if the physics imposter is disposed
  97457. */
  97458. get isDisposed(): boolean;
  97459. /**
  97460. * Gets the mass of the physics imposter
  97461. */
  97462. get mass(): number;
  97463. set mass(value: number);
  97464. /**
  97465. * Gets the coefficient of friction
  97466. */
  97467. get friction(): number;
  97468. /**
  97469. * Sets the coefficient of friction
  97470. */
  97471. set friction(value: number);
  97472. /**
  97473. * Gets the coefficient of restitution
  97474. */
  97475. get restitution(): number;
  97476. /**
  97477. * Sets the coefficient of restitution
  97478. */
  97479. set restitution(value: number);
  97480. /**
  97481. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97482. */
  97483. get pressure(): number;
  97484. /**
  97485. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97486. */
  97487. set pressure(value: number);
  97488. /**
  97489. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97490. */
  97491. get stiffness(): number;
  97492. /**
  97493. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97494. */
  97495. set stiffness(value: number);
  97496. /**
  97497. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97498. */
  97499. get velocityIterations(): number;
  97500. /**
  97501. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97502. */
  97503. set velocityIterations(value: number);
  97504. /**
  97505. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97506. */
  97507. get positionIterations(): number;
  97508. /**
  97509. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97510. */
  97511. set positionIterations(value: number);
  97512. /**
  97513. * The unique id of the physics imposter
  97514. * set by the physics engine when adding this impostor to the array
  97515. */
  97516. uniqueId: number;
  97517. /**
  97518. * @hidden
  97519. */
  97520. soft: boolean;
  97521. /**
  97522. * @hidden
  97523. */
  97524. segments: number;
  97525. private _joints;
  97526. /**
  97527. * Initializes the physics imposter
  97528. * @param object The physics-enabled object used as the physics imposter
  97529. * @param type The type of the physics imposter
  97530. * @param _options The options for the physics imposter
  97531. * @param _scene The Babylon scene
  97532. */
  97533. constructor(
  97534. /**
  97535. * The physics-enabled object used as the physics imposter
  97536. */
  97537. object: IPhysicsEnabledObject,
  97538. /**
  97539. * The type of the physics imposter
  97540. */
  97541. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97542. /**
  97543. * This function will completly initialize this impostor.
  97544. * It will create a new body - but only if this mesh has no parent.
  97545. * If it has, this impostor will not be used other than to define the impostor
  97546. * of the child mesh.
  97547. * @hidden
  97548. */
  97549. _init(): void;
  97550. private _getPhysicsParent;
  97551. /**
  97552. * Should a new body be generated.
  97553. * @returns boolean specifying if body initialization is required
  97554. */
  97555. isBodyInitRequired(): boolean;
  97556. /**
  97557. * Sets the updated scaling
  97558. * @param updated Specifies if the scaling is updated
  97559. */
  97560. setScalingUpdated(): void;
  97561. /**
  97562. * Force a regeneration of this or the parent's impostor's body.
  97563. * Use under cautious - This will remove all joints already implemented.
  97564. */
  97565. forceUpdate(): void;
  97566. /**
  97567. * Gets the body that holds this impostor. Either its own, or its parent.
  97568. */
  97569. get physicsBody(): any;
  97570. /**
  97571. * Get the parent of the physics imposter
  97572. * @returns Physics imposter or null
  97573. */
  97574. get parent(): Nullable<PhysicsImpostor>;
  97575. /**
  97576. * Sets the parent of the physics imposter
  97577. */
  97578. set parent(value: Nullable<PhysicsImpostor>);
  97579. /**
  97580. * Set the physics body. Used mainly by the physics engine/plugin
  97581. */
  97582. set physicsBody(physicsBody: any);
  97583. /**
  97584. * Resets the update flags
  97585. */
  97586. resetUpdateFlags(): void;
  97587. /**
  97588. * Gets the object extend size
  97589. * @returns the object extend size
  97590. */
  97591. getObjectExtendSize(): Vector3;
  97592. /**
  97593. * Gets the object center
  97594. * @returns The object center
  97595. */
  97596. getObjectCenter(): Vector3;
  97597. /**
  97598. * Get a specific parameter from the options parameters
  97599. * @param paramName The object parameter name
  97600. * @returns The object parameter
  97601. */
  97602. getParam(paramName: string): any;
  97603. /**
  97604. * Sets a specific parameter in the options given to the physics plugin
  97605. * @param paramName The parameter name
  97606. * @param value The value of the parameter
  97607. */
  97608. setParam(paramName: string, value: number): void;
  97609. /**
  97610. * Specifically change the body's mass option. Won't recreate the physics body object
  97611. * @param mass The mass of the physics imposter
  97612. */
  97613. setMass(mass: number): void;
  97614. /**
  97615. * Gets the linear velocity
  97616. * @returns linear velocity or null
  97617. */
  97618. getLinearVelocity(): Nullable<Vector3>;
  97619. /**
  97620. * Sets the linear velocity
  97621. * @param velocity linear velocity or null
  97622. */
  97623. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97624. /**
  97625. * Gets the angular velocity
  97626. * @returns angular velocity or null
  97627. */
  97628. getAngularVelocity(): Nullable<Vector3>;
  97629. /**
  97630. * Sets the angular velocity
  97631. * @param velocity The velocity or null
  97632. */
  97633. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97634. /**
  97635. * Execute a function with the physics plugin native code
  97636. * Provide a function the will have two variables - the world object and the physics body object
  97637. * @param func The function to execute with the physics plugin native code
  97638. */
  97639. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97640. /**
  97641. * Register a function that will be executed before the physics world is stepping forward
  97642. * @param func The function to execute before the physics world is stepped forward
  97643. */
  97644. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97645. /**
  97646. * Unregister a function that will be executed before the physics world is stepping forward
  97647. * @param func The function to execute before the physics world is stepped forward
  97648. */
  97649. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97650. /**
  97651. * Register a function that will be executed after the physics step
  97652. * @param func The function to execute after physics step
  97653. */
  97654. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97655. /**
  97656. * Unregisters a function that will be executed after the physics step
  97657. * @param func The function to execute after physics step
  97658. */
  97659. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97660. /**
  97661. * register a function that will be executed when this impostor collides against a different body
  97662. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97663. * @param func Callback that is executed on collision
  97664. */
  97665. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97666. /**
  97667. * Unregisters the physics imposter on contact
  97668. * @param collideAgainst The physics object to collide against
  97669. * @param func Callback to execute on collision
  97670. */
  97671. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97672. private _tmpQuat;
  97673. private _tmpQuat2;
  97674. /**
  97675. * Get the parent rotation
  97676. * @returns The parent rotation
  97677. */
  97678. getParentsRotation(): Quaternion;
  97679. /**
  97680. * this function is executed by the physics engine.
  97681. */
  97682. beforeStep: () => void;
  97683. /**
  97684. * this function is executed by the physics engine
  97685. */
  97686. afterStep: () => void;
  97687. /**
  97688. * Legacy collision detection event support
  97689. */
  97690. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97691. /**
  97692. * event and body object due to cannon's event-based architecture.
  97693. */
  97694. onCollide: (e: {
  97695. body: any;
  97696. }) => void;
  97697. /**
  97698. * Apply a force
  97699. * @param force The force to apply
  97700. * @param contactPoint The contact point for the force
  97701. * @returns The physics imposter
  97702. */
  97703. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97704. /**
  97705. * Apply an impulse
  97706. * @param force The impulse force
  97707. * @param contactPoint The contact point for the impulse force
  97708. * @returns The physics imposter
  97709. */
  97710. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97711. /**
  97712. * A help function to create a joint
  97713. * @param otherImpostor A physics imposter used to create a joint
  97714. * @param jointType The type of joint
  97715. * @param jointData The data for the joint
  97716. * @returns The physics imposter
  97717. */
  97718. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97719. /**
  97720. * Add a joint to this impostor with a different impostor
  97721. * @param otherImpostor A physics imposter used to add a joint
  97722. * @param joint The joint to add
  97723. * @returns The physics imposter
  97724. */
  97725. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97726. /**
  97727. * Add an anchor to a cloth impostor
  97728. * @param otherImpostor rigid impostor to anchor to
  97729. * @param width ratio across width from 0 to 1
  97730. * @param height ratio up height from 0 to 1
  97731. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97732. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97733. * @returns impostor the soft imposter
  97734. */
  97735. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97736. /**
  97737. * Add a hook to a rope impostor
  97738. * @param otherImpostor rigid impostor to anchor to
  97739. * @param length ratio across rope from 0 to 1
  97740. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97741. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97742. * @returns impostor the rope imposter
  97743. */
  97744. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97745. /**
  97746. * Will keep this body still, in a sleep mode.
  97747. * @returns the physics imposter
  97748. */
  97749. sleep(): PhysicsImpostor;
  97750. /**
  97751. * Wake the body up.
  97752. * @returns The physics imposter
  97753. */
  97754. wakeUp(): PhysicsImpostor;
  97755. /**
  97756. * Clones the physics imposter
  97757. * @param newObject The physics imposter clones to this physics-enabled object
  97758. * @returns A nullable physics imposter
  97759. */
  97760. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97761. /**
  97762. * Disposes the physics imposter
  97763. */
  97764. dispose(): void;
  97765. /**
  97766. * Sets the delta position
  97767. * @param position The delta position amount
  97768. */
  97769. setDeltaPosition(position: Vector3): void;
  97770. /**
  97771. * Sets the delta rotation
  97772. * @param rotation The delta rotation amount
  97773. */
  97774. setDeltaRotation(rotation: Quaternion): void;
  97775. /**
  97776. * Gets the box size of the physics imposter and stores the result in the input parameter
  97777. * @param result Stores the box size
  97778. * @returns The physics imposter
  97779. */
  97780. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97781. /**
  97782. * Gets the radius of the physics imposter
  97783. * @returns Radius of the physics imposter
  97784. */
  97785. getRadius(): number;
  97786. /**
  97787. * Sync a bone with this impostor
  97788. * @param bone The bone to sync to the impostor.
  97789. * @param boneMesh The mesh that the bone is influencing.
  97790. * @param jointPivot The pivot of the joint / bone in local space.
  97791. * @param distToJoint Optional distance from the impostor to the joint.
  97792. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97793. */
  97794. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97795. /**
  97796. * Sync impostor to a bone
  97797. * @param bone The bone that the impostor will be synced to.
  97798. * @param boneMesh The mesh that the bone is influencing.
  97799. * @param jointPivot The pivot of the joint / bone in local space.
  97800. * @param distToJoint Optional distance from the impostor to the joint.
  97801. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97802. * @param boneAxis Optional vector3 axis the bone is aligned with
  97803. */
  97804. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97805. /**
  97806. * No-Imposter type
  97807. */
  97808. static NoImpostor: number;
  97809. /**
  97810. * Sphere-Imposter type
  97811. */
  97812. static SphereImpostor: number;
  97813. /**
  97814. * Box-Imposter type
  97815. */
  97816. static BoxImpostor: number;
  97817. /**
  97818. * Plane-Imposter type
  97819. */
  97820. static PlaneImpostor: number;
  97821. /**
  97822. * Mesh-imposter type
  97823. */
  97824. static MeshImpostor: number;
  97825. /**
  97826. * Capsule-Impostor type (Ammo.js plugin only)
  97827. */
  97828. static CapsuleImpostor: number;
  97829. /**
  97830. * Cylinder-Imposter type
  97831. */
  97832. static CylinderImpostor: number;
  97833. /**
  97834. * Particle-Imposter type
  97835. */
  97836. static ParticleImpostor: number;
  97837. /**
  97838. * Heightmap-Imposter type
  97839. */
  97840. static HeightmapImpostor: number;
  97841. /**
  97842. * ConvexHull-Impostor type (Ammo.js plugin only)
  97843. */
  97844. static ConvexHullImpostor: number;
  97845. /**
  97846. * Custom-Imposter type (Ammo.js plugin only)
  97847. */
  97848. static CustomImpostor: number;
  97849. /**
  97850. * Rope-Imposter type
  97851. */
  97852. static RopeImpostor: number;
  97853. /**
  97854. * Cloth-Imposter type
  97855. */
  97856. static ClothImpostor: number;
  97857. /**
  97858. * Softbody-Imposter type
  97859. */
  97860. static SoftbodyImpostor: number;
  97861. }
  97862. }
  97863. declare module BABYLON {
  97864. /**
  97865. * @hidden
  97866. **/
  97867. export class _CreationDataStorage {
  97868. closePath?: boolean;
  97869. closeArray?: boolean;
  97870. idx: number[];
  97871. dashSize: number;
  97872. gapSize: number;
  97873. path3D: Path3D;
  97874. pathArray: Vector3[][];
  97875. arc: number;
  97876. radius: number;
  97877. cap: number;
  97878. tessellation: number;
  97879. }
  97880. /**
  97881. * @hidden
  97882. **/
  97883. class _InstanceDataStorage {
  97884. visibleInstances: any;
  97885. batchCache: _InstancesBatch;
  97886. instancesBufferSize: number;
  97887. instancesBuffer: Nullable<Buffer>;
  97888. instancesData: Float32Array;
  97889. overridenInstanceCount: number;
  97890. isFrozen: boolean;
  97891. previousBatch: Nullable<_InstancesBatch>;
  97892. hardwareInstancedRendering: boolean;
  97893. sideOrientation: number;
  97894. manualUpdate: boolean;
  97895. }
  97896. /**
  97897. * @hidden
  97898. **/
  97899. export class _InstancesBatch {
  97900. mustReturn: boolean;
  97901. visibleInstances: Nullable<InstancedMesh[]>[];
  97902. renderSelf: boolean[];
  97903. hardwareInstancedRendering: boolean[];
  97904. }
  97905. /**
  97906. * Class used to represent renderable models
  97907. */
  97908. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97909. /**
  97910. * Mesh side orientation : usually the external or front surface
  97911. */
  97912. static readonly FRONTSIDE: number;
  97913. /**
  97914. * Mesh side orientation : usually the internal or back surface
  97915. */
  97916. static readonly BACKSIDE: number;
  97917. /**
  97918. * Mesh side orientation : both internal and external or front and back surfaces
  97919. */
  97920. static readonly DOUBLESIDE: number;
  97921. /**
  97922. * Mesh side orientation : by default, `FRONTSIDE`
  97923. */
  97924. static readonly DEFAULTSIDE: number;
  97925. /**
  97926. * Mesh cap setting : no cap
  97927. */
  97928. static readonly NO_CAP: number;
  97929. /**
  97930. * Mesh cap setting : one cap at the beginning of the mesh
  97931. */
  97932. static readonly CAP_START: number;
  97933. /**
  97934. * Mesh cap setting : one cap at the end of the mesh
  97935. */
  97936. static readonly CAP_END: number;
  97937. /**
  97938. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97939. */
  97940. static readonly CAP_ALL: number;
  97941. /**
  97942. * Mesh pattern setting : no flip or rotate
  97943. */
  97944. static readonly NO_FLIP: number;
  97945. /**
  97946. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97947. */
  97948. static readonly FLIP_TILE: number;
  97949. /**
  97950. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97951. */
  97952. static readonly ROTATE_TILE: number;
  97953. /**
  97954. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97955. */
  97956. static readonly FLIP_ROW: number;
  97957. /**
  97958. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97959. */
  97960. static readonly ROTATE_ROW: number;
  97961. /**
  97962. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97963. */
  97964. static readonly FLIP_N_ROTATE_TILE: number;
  97965. /**
  97966. * Mesh pattern setting : rotate pattern and rotate
  97967. */
  97968. static readonly FLIP_N_ROTATE_ROW: number;
  97969. /**
  97970. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97971. */
  97972. static readonly CENTER: number;
  97973. /**
  97974. * Mesh tile positioning : part tiles on left
  97975. */
  97976. static readonly LEFT: number;
  97977. /**
  97978. * Mesh tile positioning : part tiles on right
  97979. */
  97980. static readonly RIGHT: number;
  97981. /**
  97982. * Mesh tile positioning : part tiles on top
  97983. */
  97984. static readonly TOP: number;
  97985. /**
  97986. * Mesh tile positioning : part tiles on bottom
  97987. */
  97988. static readonly BOTTOM: number;
  97989. /**
  97990. * Gets the default side orientation.
  97991. * @param orientation the orientation to value to attempt to get
  97992. * @returns the default orientation
  97993. * @hidden
  97994. */
  97995. static _GetDefaultSideOrientation(orientation?: number): number;
  97996. private _internalMeshDataInfo;
  97997. /**
  97998. * An event triggered before rendering the mesh
  97999. */
  98000. get onBeforeRenderObservable(): Observable<Mesh>;
  98001. /**
  98002. * An event triggered before binding the mesh
  98003. */
  98004. get onBeforeBindObservable(): Observable<Mesh>;
  98005. /**
  98006. * An event triggered after rendering the mesh
  98007. */
  98008. get onAfterRenderObservable(): Observable<Mesh>;
  98009. /**
  98010. * An event triggered before drawing the mesh
  98011. */
  98012. get onBeforeDrawObservable(): Observable<Mesh>;
  98013. private _onBeforeDrawObserver;
  98014. /**
  98015. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98016. */
  98017. set onBeforeDraw(callback: () => void);
  98018. get hasInstances(): boolean;
  98019. /**
  98020. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98021. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98022. */
  98023. delayLoadState: number;
  98024. /**
  98025. * Gets the list of instances created from this mesh
  98026. * it is not supposed to be modified manually.
  98027. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98028. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98029. */
  98030. instances: InstancedMesh[];
  98031. /**
  98032. * Gets the file containing delay loading data for this mesh
  98033. */
  98034. delayLoadingFile: string;
  98035. /** @hidden */
  98036. _binaryInfo: any;
  98037. /**
  98038. * User defined function used to change how LOD level selection is done
  98039. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98040. */
  98041. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98042. /**
  98043. * Gets or sets the morph target manager
  98044. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98045. */
  98046. get morphTargetManager(): Nullable<MorphTargetManager>;
  98047. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98048. /** @hidden */
  98049. _creationDataStorage: Nullable<_CreationDataStorage>;
  98050. /** @hidden */
  98051. _geometry: Nullable<Geometry>;
  98052. /** @hidden */
  98053. _delayInfo: Array<string>;
  98054. /** @hidden */
  98055. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98056. /** @hidden */
  98057. _instanceDataStorage: _InstanceDataStorage;
  98058. private _effectiveMaterial;
  98059. /** @hidden */
  98060. _shouldGenerateFlatShading: boolean;
  98061. /** @hidden */
  98062. _originalBuilderSideOrientation: number;
  98063. /**
  98064. * Use this property to change the original side orientation defined at construction time
  98065. */
  98066. overrideMaterialSideOrientation: Nullable<number>;
  98067. /**
  98068. * Gets the source mesh (the one used to clone this one from)
  98069. */
  98070. get source(): Nullable<Mesh>;
  98071. /**
  98072. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98073. */
  98074. get isUnIndexed(): boolean;
  98075. set isUnIndexed(value: boolean);
  98076. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98077. get worldMatrixInstancedBuffer(): Float32Array;
  98078. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98079. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98080. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98081. /**
  98082. * @constructor
  98083. * @param name The value used by scene.getMeshByName() to do a lookup.
  98084. * @param scene The scene to add this mesh to.
  98085. * @param parent The parent of this mesh, if it has one
  98086. * @param source An optional Mesh from which geometry is shared, cloned.
  98087. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98088. * When false, achieved by calling a clone(), also passing False.
  98089. * This will make creation of children, recursive.
  98090. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98091. */
  98092. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98093. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98094. doNotInstantiate: boolean;
  98095. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98096. /**
  98097. * Gets the class name
  98098. * @returns the string "Mesh".
  98099. */
  98100. getClassName(): string;
  98101. /** @hidden */
  98102. get _isMesh(): boolean;
  98103. /**
  98104. * Returns a description of this mesh
  98105. * @param fullDetails define if full details about this mesh must be used
  98106. * @returns a descriptive string representing this mesh
  98107. */
  98108. toString(fullDetails?: boolean): string;
  98109. /** @hidden */
  98110. _unBindEffect(): void;
  98111. /**
  98112. * Gets a boolean indicating if this mesh has LOD
  98113. */
  98114. get hasLODLevels(): boolean;
  98115. /**
  98116. * Gets the list of MeshLODLevel associated with the current mesh
  98117. * @returns an array of MeshLODLevel
  98118. */
  98119. getLODLevels(): MeshLODLevel[];
  98120. private _sortLODLevels;
  98121. /**
  98122. * Add a mesh as LOD level triggered at the given distance.
  98123. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98124. * @param distance The distance from the center of the object to show this level
  98125. * @param mesh The mesh to be added as LOD level (can be null)
  98126. * @return This mesh (for chaining)
  98127. */
  98128. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98129. /**
  98130. * Returns the LOD level mesh at the passed distance or null if not found.
  98131. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98132. * @param distance The distance from the center of the object to show this level
  98133. * @returns a Mesh or `null`
  98134. */
  98135. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98136. /**
  98137. * Remove a mesh from the LOD array
  98138. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98139. * @param mesh defines the mesh to be removed
  98140. * @return This mesh (for chaining)
  98141. */
  98142. removeLODLevel(mesh: Mesh): Mesh;
  98143. /**
  98144. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98145. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98146. * @param camera defines the camera to use to compute distance
  98147. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98148. * @return This mesh (for chaining)
  98149. */
  98150. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98151. /**
  98152. * Gets the mesh internal Geometry object
  98153. */
  98154. get geometry(): Nullable<Geometry>;
  98155. /**
  98156. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98157. * @returns the total number of vertices
  98158. */
  98159. getTotalVertices(): number;
  98160. /**
  98161. * Returns the content of an associated vertex buffer
  98162. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98163. * - VertexBuffer.PositionKind
  98164. * - VertexBuffer.UVKind
  98165. * - VertexBuffer.UV2Kind
  98166. * - VertexBuffer.UV3Kind
  98167. * - VertexBuffer.UV4Kind
  98168. * - VertexBuffer.UV5Kind
  98169. * - VertexBuffer.UV6Kind
  98170. * - VertexBuffer.ColorKind
  98171. * - VertexBuffer.MatricesIndicesKind
  98172. * - VertexBuffer.MatricesIndicesExtraKind
  98173. * - VertexBuffer.MatricesWeightsKind
  98174. * - VertexBuffer.MatricesWeightsExtraKind
  98175. * @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
  98176. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  98177. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  98178. */
  98179. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98180. /**
  98181. * Returns the mesh VertexBuffer object from the requested `kind`
  98182. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98183. * - VertexBuffer.PositionKind
  98184. * - VertexBuffer.NormalKind
  98185. * - VertexBuffer.UVKind
  98186. * - VertexBuffer.UV2Kind
  98187. * - VertexBuffer.UV3Kind
  98188. * - VertexBuffer.UV4Kind
  98189. * - VertexBuffer.UV5Kind
  98190. * - VertexBuffer.UV6Kind
  98191. * - VertexBuffer.ColorKind
  98192. * - VertexBuffer.MatricesIndicesKind
  98193. * - VertexBuffer.MatricesIndicesExtraKind
  98194. * - VertexBuffer.MatricesWeightsKind
  98195. * - VertexBuffer.MatricesWeightsExtraKind
  98196. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  98197. */
  98198. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98199. /**
  98200. * Tests if a specific vertex buffer is associated with this mesh
  98201. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98202. * - VertexBuffer.PositionKind
  98203. * - VertexBuffer.NormalKind
  98204. * - VertexBuffer.UVKind
  98205. * - VertexBuffer.UV2Kind
  98206. * - VertexBuffer.UV3Kind
  98207. * - VertexBuffer.UV4Kind
  98208. * - VertexBuffer.UV5Kind
  98209. * - VertexBuffer.UV6Kind
  98210. * - VertexBuffer.ColorKind
  98211. * - VertexBuffer.MatricesIndicesKind
  98212. * - VertexBuffer.MatricesIndicesExtraKind
  98213. * - VertexBuffer.MatricesWeightsKind
  98214. * - VertexBuffer.MatricesWeightsExtraKind
  98215. * @returns a boolean
  98216. */
  98217. isVerticesDataPresent(kind: string): boolean;
  98218. /**
  98219. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  98220. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98221. * - VertexBuffer.PositionKind
  98222. * - VertexBuffer.UVKind
  98223. * - VertexBuffer.UV2Kind
  98224. * - VertexBuffer.UV3Kind
  98225. * - VertexBuffer.UV4Kind
  98226. * - VertexBuffer.UV5Kind
  98227. * - VertexBuffer.UV6Kind
  98228. * - VertexBuffer.ColorKind
  98229. * - VertexBuffer.MatricesIndicesKind
  98230. * - VertexBuffer.MatricesIndicesExtraKind
  98231. * - VertexBuffer.MatricesWeightsKind
  98232. * - VertexBuffer.MatricesWeightsExtraKind
  98233. * @returns a boolean
  98234. */
  98235. isVertexBufferUpdatable(kind: string): boolean;
  98236. /**
  98237. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  98238. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98239. * - VertexBuffer.PositionKind
  98240. * - VertexBuffer.NormalKind
  98241. * - VertexBuffer.UVKind
  98242. * - VertexBuffer.UV2Kind
  98243. * - VertexBuffer.UV3Kind
  98244. * - VertexBuffer.UV4Kind
  98245. * - VertexBuffer.UV5Kind
  98246. * - VertexBuffer.UV6Kind
  98247. * - VertexBuffer.ColorKind
  98248. * - VertexBuffer.MatricesIndicesKind
  98249. * - VertexBuffer.MatricesIndicesExtraKind
  98250. * - VertexBuffer.MatricesWeightsKind
  98251. * - VertexBuffer.MatricesWeightsExtraKind
  98252. * @returns an array of strings
  98253. */
  98254. getVerticesDataKinds(): string[];
  98255. /**
  98256. * Returns a positive integer : the total number of indices in this mesh geometry.
  98257. * @returns the numner of indices or zero if the mesh has no geometry.
  98258. */
  98259. getTotalIndices(): number;
  98260. /**
  98261. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98262. * @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.
  98263. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98264. * @returns the indices array or an empty array if the mesh has no geometry
  98265. */
  98266. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98267. get isBlocked(): boolean;
  98268. /**
  98269. * Determine if the current mesh is ready to be rendered
  98270. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98271. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98272. * @returns true if all associated assets are ready (material, textures, shaders)
  98273. */
  98274. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98275. /**
  98276. * 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.
  98277. */
  98278. get areNormalsFrozen(): boolean;
  98279. /**
  98280. * 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.
  98281. * @returns the current mesh
  98282. */
  98283. freezeNormals(): Mesh;
  98284. /**
  98285. * 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
  98286. * @returns the current mesh
  98287. */
  98288. unfreezeNormals(): Mesh;
  98289. /**
  98290. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98291. */
  98292. set overridenInstanceCount(count: number);
  98293. /** @hidden */
  98294. _preActivate(): Mesh;
  98295. /** @hidden */
  98296. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98297. /** @hidden */
  98298. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98299. /**
  98300. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98301. * This means the mesh underlying bounding box and sphere are recomputed.
  98302. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98303. * @returns the current mesh
  98304. */
  98305. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98306. /** @hidden */
  98307. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98308. /**
  98309. * This function will subdivide the mesh into multiple submeshes
  98310. * @param count defines the expected number of submeshes
  98311. */
  98312. subdivide(count: number): void;
  98313. /**
  98314. * Copy a FloatArray into a specific associated vertex buffer
  98315. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98316. * - VertexBuffer.PositionKind
  98317. * - VertexBuffer.UVKind
  98318. * - VertexBuffer.UV2Kind
  98319. * - VertexBuffer.UV3Kind
  98320. * - VertexBuffer.UV4Kind
  98321. * - VertexBuffer.UV5Kind
  98322. * - VertexBuffer.UV6Kind
  98323. * - VertexBuffer.ColorKind
  98324. * - VertexBuffer.MatricesIndicesKind
  98325. * - VertexBuffer.MatricesIndicesExtraKind
  98326. * - VertexBuffer.MatricesWeightsKind
  98327. * - VertexBuffer.MatricesWeightsExtraKind
  98328. * @param data defines the data source
  98329. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98330. * @param stride defines the data stride size (can be null)
  98331. * @returns the current mesh
  98332. */
  98333. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98334. /**
  98335. * Delete a vertex buffer associated with this mesh
  98336. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98337. * - VertexBuffer.PositionKind
  98338. * - VertexBuffer.UVKind
  98339. * - VertexBuffer.UV2Kind
  98340. * - VertexBuffer.UV3Kind
  98341. * - VertexBuffer.UV4Kind
  98342. * - VertexBuffer.UV5Kind
  98343. * - VertexBuffer.UV6Kind
  98344. * - VertexBuffer.ColorKind
  98345. * - VertexBuffer.MatricesIndicesKind
  98346. * - VertexBuffer.MatricesIndicesExtraKind
  98347. * - VertexBuffer.MatricesWeightsKind
  98348. * - VertexBuffer.MatricesWeightsExtraKind
  98349. */
  98350. removeVerticesData(kind: string): void;
  98351. /**
  98352. * Flags an associated vertex buffer as updatable
  98353. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98354. * - VertexBuffer.PositionKind
  98355. * - VertexBuffer.UVKind
  98356. * - VertexBuffer.UV2Kind
  98357. * - VertexBuffer.UV3Kind
  98358. * - VertexBuffer.UV4Kind
  98359. * - VertexBuffer.UV5Kind
  98360. * - VertexBuffer.UV6Kind
  98361. * - VertexBuffer.ColorKind
  98362. * - VertexBuffer.MatricesIndicesKind
  98363. * - VertexBuffer.MatricesIndicesExtraKind
  98364. * - VertexBuffer.MatricesWeightsKind
  98365. * - VertexBuffer.MatricesWeightsExtraKind
  98366. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98367. */
  98368. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98369. /**
  98370. * Sets the mesh global Vertex Buffer
  98371. * @param buffer defines the buffer to use
  98372. * @returns the current mesh
  98373. */
  98374. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98375. /**
  98376. * Update a specific associated vertex buffer
  98377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98378. * - VertexBuffer.PositionKind
  98379. * - VertexBuffer.UVKind
  98380. * - VertexBuffer.UV2Kind
  98381. * - VertexBuffer.UV3Kind
  98382. * - VertexBuffer.UV4Kind
  98383. * - VertexBuffer.UV5Kind
  98384. * - VertexBuffer.UV6Kind
  98385. * - VertexBuffer.ColorKind
  98386. * - VertexBuffer.MatricesIndicesKind
  98387. * - VertexBuffer.MatricesIndicesExtraKind
  98388. * - VertexBuffer.MatricesWeightsKind
  98389. * - VertexBuffer.MatricesWeightsExtraKind
  98390. * @param data defines the data source
  98391. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98392. * @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)
  98393. * @returns the current mesh
  98394. */
  98395. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98396. /**
  98397. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98398. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98399. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98400. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98401. * @returns the current mesh
  98402. */
  98403. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98404. /**
  98405. * Creates a un-shared specific occurence of the geometry for the mesh.
  98406. * @returns the current mesh
  98407. */
  98408. makeGeometryUnique(): Mesh;
  98409. /**
  98410. * Set the index buffer of this mesh
  98411. * @param indices defines the source data
  98412. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98413. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98414. * @returns the current mesh
  98415. */
  98416. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98417. /**
  98418. * Update the current index buffer
  98419. * @param indices defines the source data
  98420. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98421. * @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)
  98422. * @returns the current mesh
  98423. */
  98424. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98425. /**
  98426. * Invert the geometry to move from a right handed system to a left handed one.
  98427. * @returns the current mesh
  98428. */
  98429. toLeftHanded(): Mesh;
  98430. /** @hidden */
  98431. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98432. /** @hidden */
  98433. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98434. /**
  98435. * Registers for this mesh a javascript function called just before the rendering process
  98436. * @param func defines the function to call before rendering this mesh
  98437. * @returns the current mesh
  98438. */
  98439. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98440. /**
  98441. * Disposes a previously registered javascript function called before the rendering
  98442. * @param func defines the function to remove
  98443. * @returns the current mesh
  98444. */
  98445. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98446. /**
  98447. * Registers for this mesh a javascript function called just after the rendering is complete
  98448. * @param func defines the function to call after rendering this mesh
  98449. * @returns the current mesh
  98450. */
  98451. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98452. /**
  98453. * Disposes a previously registered javascript function called after the rendering.
  98454. * @param func defines the function to remove
  98455. * @returns the current mesh
  98456. */
  98457. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98458. /** @hidden */
  98459. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98460. /** @hidden */
  98461. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98462. /** @hidden */
  98463. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98464. /** @hidden */
  98465. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98466. /** @hidden */
  98467. _rebuild(): void;
  98468. /** @hidden */
  98469. _freeze(): void;
  98470. /** @hidden */
  98471. _unFreeze(): void;
  98472. /**
  98473. * 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
  98474. * @param subMesh defines the subMesh to render
  98475. * @param enableAlphaMode defines if alpha mode can be changed
  98476. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98477. * @returns the current mesh
  98478. */
  98479. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98480. private _onBeforeDraw;
  98481. /**
  98482. * Renormalize the mesh and patch it up if there are no weights
  98483. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98484. * However in the case of zero weights then we set just a single influence to 1.
  98485. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98486. */
  98487. cleanMatrixWeights(): void;
  98488. private normalizeSkinFourWeights;
  98489. private normalizeSkinWeightsAndExtra;
  98490. /**
  98491. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98492. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98493. * the user know there was an issue with importing the mesh
  98494. * @returns a validation object with skinned, valid and report string
  98495. */
  98496. validateSkinning(): {
  98497. skinned: boolean;
  98498. valid: boolean;
  98499. report: string;
  98500. };
  98501. /** @hidden */
  98502. _checkDelayState(): Mesh;
  98503. private _queueLoad;
  98504. /**
  98505. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98506. * A mesh is in the frustum if its bounding box intersects the frustum
  98507. * @param frustumPlanes defines the frustum to test
  98508. * @returns true if the mesh is in the frustum planes
  98509. */
  98510. isInFrustum(frustumPlanes: Plane[]): boolean;
  98511. /**
  98512. * Sets the mesh material by the material or multiMaterial `id` property
  98513. * @param id is a string identifying the material or the multiMaterial
  98514. * @returns the current mesh
  98515. */
  98516. setMaterialByID(id: string): Mesh;
  98517. /**
  98518. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98519. * @returns an array of IAnimatable
  98520. */
  98521. getAnimatables(): IAnimatable[];
  98522. /**
  98523. * Modifies the mesh geometry according to the passed transformation matrix.
  98524. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98525. * The mesh normals are modified using the same transformation.
  98526. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98527. * @param transform defines the transform matrix to use
  98528. * @see http://doc.babylonjs.com/resources/baking_transformations
  98529. * @returns the current mesh
  98530. */
  98531. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98532. /**
  98533. * Modifies the mesh geometry according to its own current World Matrix.
  98534. * The mesh World Matrix is then reset.
  98535. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98536. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98537. * @see http://doc.babylonjs.com/resources/baking_transformations
  98538. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98539. * @returns the current mesh
  98540. */
  98541. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98542. /** @hidden */
  98543. get _positions(): Nullable<Vector3[]>;
  98544. /** @hidden */
  98545. _resetPointsArrayCache(): Mesh;
  98546. /** @hidden */
  98547. _generatePointsArray(): boolean;
  98548. /**
  98549. * Returns a new Mesh object generated from the current mesh properties.
  98550. * This method must not get confused with createInstance()
  98551. * @param name is a string, the name given to the new mesh
  98552. * @param newParent can be any Node object (default `null`)
  98553. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98554. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98555. * @returns a new mesh
  98556. */
  98557. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98558. /**
  98559. * Releases resources associated with this mesh.
  98560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98562. */
  98563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98564. /** @hidden */
  98565. _disposeInstanceSpecificData(): void;
  98566. /**
  98567. * Modifies the mesh geometry according to a displacement map.
  98568. * 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.
  98569. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98570. * @param url is a string, the URL from the image file is to be downloaded.
  98571. * @param minHeight is the lower limit of the displacement.
  98572. * @param maxHeight is the upper limit of the displacement.
  98573. * @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.
  98574. * @param uvOffset is an optional vector2 used to offset UV.
  98575. * @param uvScale is an optional vector2 used to scale UV.
  98576. * @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.
  98577. * @returns the Mesh.
  98578. */
  98579. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98580. /**
  98581. * Modifies the mesh geometry according to a displacementMap buffer.
  98582. * 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.
  98583. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98584. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98585. * @param heightMapWidth is the width of the buffer image.
  98586. * @param heightMapHeight is the height of the buffer image.
  98587. * @param minHeight is the lower limit of the displacement.
  98588. * @param maxHeight is the upper limit of the displacement.
  98589. * @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.
  98590. * @param uvOffset is an optional vector2 used to offset UV.
  98591. * @param uvScale is an optional vector2 used to scale UV.
  98592. * @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.
  98593. * @returns the Mesh.
  98594. */
  98595. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98596. /**
  98597. * Modify the mesh to get a flat shading rendering.
  98598. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98599. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98600. * @returns current mesh
  98601. */
  98602. convertToFlatShadedMesh(): Mesh;
  98603. /**
  98604. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98605. * In other words, more vertices, no more indices and a single bigger VBO.
  98606. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98607. * @returns current mesh
  98608. */
  98609. convertToUnIndexedMesh(): Mesh;
  98610. /**
  98611. * Inverses facet orientations.
  98612. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98613. * @param flipNormals will also inverts the normals
  98614. * @returns current mesh
  98615. */
  98616. flipFaces(flipNormals?: boolean): Mesh;
  98617. /**
  98618. * Increase the number of facets and hence vertices in a mesh
  98619. * Vertex normals are interpolated from existing vertex normals
  98620. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98621. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98622. */
  98623. increaseVertices(numberPerEdge: number): void;
  98624. /**
  98625. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98626. * This will undo any application of covertToFlatShadedMesh
  98627. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98628. */
  98629. forceSharedVertices(): void;
  98630. /** @hidden */
  98631. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98632. /** @hidden */
  98633. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98634. /**
  98635. * Creates a new InstancedMesh object from the mesh model.
  98636. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98637. * @param name defines the name of the new instance
  98638. * @returns a new InstancedMesh
  98639. */
  98640. createInstance(name: string): InstancedMesh;
  98641. /**
  98642. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98643. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98644. * @returns the current mesh
  98645. */
  98646. synchronizeInstances(): Mesh;
  98647. /**
  98648. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98649. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98650. * This should be used together with the simplification to avoid disappearing triangles.
  98651. * @param successCallback an optional success callback to be called after the optimization finished.
  98652. * @returns the current mesh
  98653. */
  98654. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98655. /**
  98656. * Serialize current mesh
  98657. * @param serializationObject defines the object which will receive the serialization data
  98658. */
  98659. serialize(serializationObject: any): void;
  98660. /** @hidden */
  98661. _syncGeometryWithMorphTargetManager(): void;
  98662. /** @hidden */
  98663. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98664. /**
  98665. * Returns a new Mesh object parsed from the source provided.
  98666. * @param parsedMesh is the source
  98667. * @param scene defines the hosting scene
  98668. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98669. * @returns a new Mesh
  98670. */
  98671. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98672. /**
  98673. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98674. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98675. * @param name defines the name of the mesh to create
  98676. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98677. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98678. * @param closePath creates a seam between the first and the last points of each path of the path array
  98679. * @param offset is taken in account only if the `pathArray` is containing a single path
  98680. * @param scene defines the hosting scene
  98681. * @param updatable defines if the mesh must be flagged as updatable
  98682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98683. * @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)
  98684. * @returns a new Mesh
  98685. */
  98686. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98687. /**
  98688. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98689. * @param name defines the name of the mesh to create
  98690. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98691. * @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
  98692. * @param scene defines the hosting scene
  98693. * @param updatable defines if the mesh must be flagged as updatable
  98694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98695. * @returns a new Mesh
  98696. */
  98697. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98698. /**
  98699. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98700. * @param name defines the name of the mesh to create
  98701. * @param size sets the size (float) of each box side (default 1)
  98702. * @param scene defines the hosting scene
  98703. * @param updatable defines if the mesh must be flagged as updatable
  98704. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98705. * @returns a new Mesh
  98706. */
  98707. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98708. /**
  98709. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98710. * @param name defines the name of the mesh to create
  98711. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98712. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98713. * @param scene defines the hosting scene
  98714. * @param updatable defines if the mesh must be flagged as updatable
  98715. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98716. * @returns a new Mesh
  98717. */
  98718. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98719. /**
  98720. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98721. * @param name defines the name of the mesh to create
  98722. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98723. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98724. * @param scene defines the hosting scene
  98725. * @returns a new Mesh
  98726. */
  98727. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98728. /**
  98729. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98730. * @param name defines the name of the mesh to create
  98731. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98732. * @param diameterTop set the top cap diameter (floats, default 1)
  98733. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98734. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98735. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98736. * @param scene defines the hosting scene
  98737. * @param updatable defines if the mesh must be flagged as updatable
  98738. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98739. * @returns a new Mesh
  98740. */
  98741. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98742. /**
  98743. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98744. * @param name defines the name of the mesh to create
  98745. * @param diameter sets the diameter size (float) of the torus (default 1)
  98746. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98747. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98748. * @param scene defines the hosting scene
  98749. * @param updatable defines if the mesh must be flagged as updatable
  98750. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98751. * @returns a new Mesh
  98752. */
  98753. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98754. /**
  98755. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98756. * @param name defines the name of the mesh to create
  98757. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98758. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98759. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98760. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98761. * @param p the number of windings on X axis (positive integers, default 2)
  98762. * @param q the number of windings on Y axis (positive integers, default 3)
  98763. * @param scene defines the hosting scene
  98764. * @param updatable defines if the mesh must be flagged as updatable
  98765. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98766. * @returns a new Mesh
  98767. */
  98768. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98769. /**
  98770. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98771. * @param name defines the name of the mesh to create
  98772. * @param points is an array successive Vector3
  98773. * @param scene defines the hosting scene
  98774. * @param updatable defines if the mesh must be flagged as updatable
  98775. * @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).
  98776. * @returns a new Mesh
  98777. */
  98778. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98779. /**
  98780. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98781. * @param name defines the name of the mesh to create
  98782. * @param points is an array successive Vector3
  98783. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98784. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98785. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98786. * @param scene defines the hosting scene
  98787. * @param updatable defines if the mesh must be flagged as updatable
  98788. * @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)
  98789. * @returns a new Mesh
  98790. */
  98791. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98792. /**
  98793. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98794. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98795. * 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.
  98796. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98797. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98798. * Remember you can only change the shape positions, not their number when updating a polygon.
  98799. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98800. * @param name defines the name of the mesh to create
  98801. * @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
  98802. * @param scene defines the hosting scene
  98803. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98804. * @param updatable defines if the mesh must be flagged as updatable
  98805. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98806. * @param earcutInjection can be used to inject your own earcut reference
  98807. * @returns a new Mesh
  98808. */
  98809. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98810. /**
  98811. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98812. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98813. * @param name defines the name of the mesh to create
  98814. * @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
  98815. * @param depth defines the height of extrusion
  98816. * @param scene defines the hosting scene
  98817. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98818. * @param updatable defines if the mesh must be flagged as updatable
  98819. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98820. * @param earcutInjection can be used to inject your own earcut reference
  98821. * @returns a new Mesh
  98822. */
  98823. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98824. /**
  98825. * Creates an extruded shape mesh.
  98826. * 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
  98827. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98828. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98829. * @param name defines the name of the mesh to create
  98830. * @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
  98831. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98832. * @param scale is the value to scale the shape
  98833. * @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
  98834. * @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
  98835. * @param scene defines the hosting scene
  98836. * @param updatable defines if the mesh must be flagged as updatable
  98837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98838. * @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)
  98839. * @returns a new Mesh
  98840. */
  98841. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98842. /**
  98843. * Creates an custom extruded shape mesh.
  98844. * The custom extrusion is a parametric shape.
  98845. * It has no predefined shape. Its final shape will depend on the input parameters.
  98846. * Please consider using the same method from the MeshBuilder class instead
  98847. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98848. * @param name defines the name of the mesh to create
  98849. * @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
  98850. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98851. * @param scaleFunction is a custom Javascript function called on each path point
  98852. * @param rotationFunction is a custom Javascript function called on each path point
  98853. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98854. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98855. * @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
  98856. * @param scene defines the hosting scene
  98857. * @param updatable defines if the mesh must be flagged as updatable
  98858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98859. * @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)
  98860. * @returns a new Mesh
  98861. */
  98862. 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;
  98863. /**
  98864. * Creates lathe mesh.
  98865. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98866. * Please consider using the same method from the MeshBuilder class instead
  98867. * @param name defines the name of the mesh to create
  98868. * @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
  98869. * @param radius is the radius value of the lathe
  98870. * @param tessellation is the side number of the lathe.
  98871. * @param scene defines the hosting scene
  98872. * @param updatable defines if the mesh must be flagged as updatable
  98873. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98874. * @returns a new Mesh
  98875. */
  98876. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98877. /**
  98878. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98879. * @param name defines the name of the mesh to create
  98880. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98881. * @param scene defines the hosting scene
  98882. * @param updatable defines if the mesh must be flagged as updatable
  98883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98884. * @returns a new Mesh
  98885. */
  98886. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98887. /**
  98888. * Creates a ground mesh.
  98889. * Please consider using the same method from the MeshBuilder class instead
  98890. * @param name defines the name of the mesh to create
  98891. * @param width set the width of the ground
  98892. * @param height set the height of the ground
  98893. * @param subdivisions sets the number of subdivisions per side
  98894. * @param scene defines the hosting scene
  98895. * @param updatable defines if the mesh must be flagged as updatable
  98896. * @returns a new Mesh
  98897. */
  98898. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98899. /**
  98900. * Creates a tiled ground mesh.
  98901. * Please consider using the same method from the MeshBuilder class instead
  98902. * @param name defines the name of the mesh to create
  98903. * @param xmin set the ground minimum X coordinate
  98904. * @param zmin set the ground minimum Y coordinate
  98905. * @param xmax set the ground maximum X coordinate
  98906. * @param zmax set the ground maximum Z coordinate
  98907. * @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
  98908. * @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
  98909. * @param scene defines the hosting scene
  98910. * @param updatable defines if the mesh must be flagged as updatable
  98911. * @returns a new Mesh
  98912. */
  98913. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98914. w: number;
  98915. h: number;
  98916. }, precision: {
  98917. w: number;
  98918. h: number;
  98919. }, scene: Scene, updatable?: boolean): Mesh;
  98920. /**
  98921. * Creates a ground mesh from a height map.
  98922. * Please consider using the same method from the MeshBuilder class instead
  98923. * @see http://doc.babylonjs.com/babylon101/height_map
  98924. * @param name defines the name of the mesh to create
  98925. * @param url sets the URL of the height map image resource
  98926. * @param width set the ground width size
  98927. * @param height set the ground height size
  98928. * @param subdivisions sets the number of subdivision per side
  98929. * @param minHeight is the minimum altitude on the ground
  98930. * @param maxHeight is the maximum altitude on the ground
  98931. * @param scene defines the hosting scene
  98932. * @param updatable defines if the mesh must be flagged as updatable
  98933. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98934. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98935. * @returns a new Mesh
  98936. */
  98937. 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;
  98938. /**
  98939. * Creates a tube mesh.
  98940. * The tube is a parametric shape.
  98941. * It has no predefined shape. Its final shape will depend on the input parameters.
  98942. * Please consider using the same method from the MeshBuilder class instead
  98943. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98944. * @param name defines the name of the mesh to create
  98945. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98946. * @param radius sets the tube radius size
  98947. * @param tessellation is the number of sides on the tubular surface
  98948. * @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
  98949. * @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
  98950. * @param scene defines the hosting scene
  98951. * @param updatable defines if the mesh must be flagged as updatable
  98952. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98953. * @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)
  98954. * @returns a new Mesh
  98955. */
  98956. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98957. (i: number, distance: number): number;
  98958. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98959. /**
  98960. * Creates a polyhedron mesh.
  98961. * Please consider using the same method from the MeshBuilder class instead.
  98962. * * 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
  98963. * * The parameter `size` (positive float, default 1) sets the polygon size
  98964. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98965. * * 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`
  98966. * * 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
  98967. * * 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)`)
  98968. * * 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
  98969. * * 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
  98970. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98971. * * If you create a double-sided mesh, you can choose what parts of 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
  98972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98973. * @param name defines the name of the mesh to create
  98974. * @param options defines the options used to create the mesh
  98975. * @param scene defines the hosting scene
  98976. * @returns a new Mesh
  98977. */
  98978. static CreatePolyhedron(name: string, options: {
  98979. type?: number;
  98980. size?: number;
  98981. sizeX?: number;
  98982. sizeY?: number;
  98983. sizeZ?: number;
  98984. custom?: any;
  98985. faceUV?: Vector4[];
  98986. faceColors?: Color4[];
  98987. updatable?: boolean;
  98988. sideOrientation?: number;
  98989. }, scene: Scene): Mesh;
  98990. /**
  98991. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98992. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98993. * * 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`)
  98994. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98995. * * 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
  98996. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98997. * * If you create a double-sided mesh, you can choose what parts of 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
  98998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98999. * @param name defines the name of the mesh
  99000. * @param options defines the options used to create the mesh
  99001. * @param scene defines the hosting scene
  99002. * @returns a new Mesh
  99003. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99004. */
  99005. static CreateIcoSphere(name: string, options: {
  99006. radius?: number;
  99007. flat?: boolean;
  99008. subdivisions?: number;
  99009. sideOrientation?: number;
  99010. updatable?: boolean;
  99011. }, scene: Scene): Mesh;
  99012. /**
  99013. * Creates a decal mesh.
  99014. * Please consider using the same method from the MeshBuilder class instead.
  99015. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99016. * @param name defines the name of the mesh
  99017. * @param sourceMesh defines the mesh receiving the decal
  99018. * @param position sets the position of the decal in world coordinates
  99019. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99020. * @param size sets the decal scaling
  99021. * @param angle sets the angle to rotate the decal
  99022. * @returns a new Mesh
  99023. */
  99024. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99025. /**
  99026. * Prepare internal position array for software CPU skinning
  99027. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99028. */
  99029. setPositionsForCPUSkinning(): Float32Array;
  99030. /**
  99031. * Prepare internal normal array for software CPU skinning
  99032. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99033. */
  99034. setNormalsForCPUSkinning(): Float32Array;
  99035. /**
  99036. * Updates the vertex buffer by applying transformation from the bones
  99037. * @param skeleton defines the skeleton to apply to current mesh
  99038. * @returns the current mesh
  99039. */
  99040. applySkeleton(skeleton: Skeleton): Mesh;
  99041. /**
  99042. * 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
  99043. * @param meshes defines the list of meshes to scan
  99044. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99045. */
  99046. static MinMax(meshes: AbstractMesh[]): {
  99047. min: Vector3;
  99048. max: Vector3;
  99049. };
  99050. /**
  99051. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99052. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99053. * @returns a vector3
  99054. */
  99055. static Center(meshesOrMinMaxVector: {
  99056. min: Vector3;
  99057. max: Vector3;
  99058. } | AbstractMesh[]): Vector3;
  99059. /**
  99060. * Merge the array of meshes into a single mesh for performance reasons.
  99061. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99062. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99063. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99064. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99065. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99066. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99067. * @returns a new mesh
  99068. */
  99069. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99070. /** @hidden */
  99071. addInstance(instance: InstancedMesh): void;
  99072. /** @hidden */
  99073. removeInstance(instance: InstancedMesh): void;
  99074. }
  99075. }
  99076. declare module BABYLON {
  99077. /**
  99078. * This is the base class of all the camera used in the application.
  99079. * @see http://doc.babylonjs.com/features/cameras
  99080. */
  99081. export class Camera extends Node {
  99082. /** @hidden */
  99083. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99084. /**
  99085. * This is the default projection mode used by the cameras.
  99086. * It helps recreating a feeling of perspective and better appreciate depth.
  99087. * This is the best way to simulate real life cameras.
  99088. */
  99089. static readonly PERSPECTIVE_CAMERA: number;
  99090. /**
  99091. * This helps creating camera with an orthographic mode.
  99092. * 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.
  99093. */
  99094. static readonly ORTHOGRAPHIC_CAMERA: number;
  99095. /**
  99096. * This is the default FOV mode for perspective cameras.
  99097. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99098. */
  99099. static readonly FOVMODE_VERTICAL_FIXED: number;
  99100. /**
  99101. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99102. */
  99103. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99104. /**
  99105. * This specifies ther is no need for a camera rig.
  99106. * Basically only one eye is rendered corresponding to the camera.
  99107. */
  99108. static readonly RIG_MODE_NONE: number;
  99109. /**
  99110. * Simulates a camera Rig with one blue eye and one red eye.
  99111. * This can be use with 3d blue and red glasses.
  99112. */
  99113. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99114. /**
  99115. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99116. */
  99117. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99118. /**
  99119. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99120. */
  99121. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99122. /**
  99123. * Defines that both eyes of the camera will be rendered over under each other.
  99124. */
  99125. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99126. /**
  99127. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99128. */
  99129. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99130. /**
  99131. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99132. */
  99133. static readonly RIG_MODE_VR: number;
  99134. /**
  99135. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99136. */
  99137. static readonly RIG_MODE_WEBVR: number;
  99138. /**
  99139. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99140. */
  99141. static readonly RIG_MODE_CUSTOM: number;
  99142. /**
  99143. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99144. */
  99145. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99146. /**
  99147. * Define the input manager associated with the camera.
  99148. */
  99149. inputs: CameraInputsManager<Camera>;
  99150. /** @hidden */
  99151. _position: Vector3;
  99152. /**
  99153. * Define the current local position of the camera in the scene
  99154. */
  99155. get position(): Vector3;
  99156. set position(newPosition: Vector3);
  99157. /**
  99158. * The vector the camera should consider as up.
  99159. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99160. */
  99161. upVector: Vector3;
  99162. /**
  99163. * Define the current limit on the left side for an orthographic camera
  99164. * In scene unit
  99165. */
  99166. orthoLeft: Nullable<number>;
  99167. /**
  99168. * Define the current limit on the right side for an orthographic camera
  99169. * In scene unit
  99170. */
  99171. orthoRight: Nullable<number>;
  99172. /**
  99173. * Define the current limit on the bottom side for an orthographic camera
  99174. * In scene unit
  99175. */
  99176. orthoBottom: Nullable<number>;
  99177. /**
  99178. * Define the current limit on the top side for an orthographic camera
  99179. * In scene unit
  99180. */
  99181. orthoTop: Nullable<number>;
  99182. /**
  99183. * Field Of View is set in Radians. (default is 0.8)
  99184. */
  99185. fov: number;
  99186. /**
  99187. * Define the minimum distance the camera can see from.
  99188. * This is important to note that the depth buffer are not infinite and the closer it starts
  99189. * the more your scene might encounter depth fighting issue.
  99190. */
  99191. minZ: number;
  99192. /**
  99193. * Define the maximum distance the camera can see to.
  99194. * This is important to note that the depth buffer are not infinite and the further it end
  99195. * the more your scene might encounter depth fighting issue.
  99196. */
  99197. maxZ: number;
  99198. /**
  99199. * Define the default inertia of the camera.
  99200. * This helps giving a smooth feeling to the camera movement.
  99201. */
  99202. inertia: number;
  99203. /**
  99204. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  99205. */
  99206. mode: number;
  99207. /**
  99208. * Define whether the camera is intermediate.
  99209. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  99210. */
  99211. isIntermediate: boolean;
  99212. /**
  99213. * Define the viewport of the camera.
  99214. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  99215. */
  99216. viewport: Viewport;
  99217. /**
  99218. * Restricts the camera to viewing objects with the same layerMask.
  99219. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  99220. */
  99221. layerMask: number;
  99222. /**
  99223. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  99224. */
  99225. fovMode: number;
  99226. /**
  99227. * Rig mode of the camera.
  99228. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  99229. * This is normally controlled byt the camera themselves as internal use.
  99230. */
  99231. cameraRigMode: number;
  99232. /**
  99233. * Defines the distance between both "eyes" in case of a RIG
  99234. */
  99235. interaxialDistance: number;
  99236. /**
  99237. * Defines if stereoscopic rendering is done side by side or over under.
  99238. */
  99239. isStereoscopicSideBySide: boolean;
  99240. /**
  99241. * 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
  99242. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  99243. * else in the scene. (Eg. security camera)
  99244. *
  99245. * 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)
  99246. */
  99247. customRenderTargets: RenderTargetTexture[];
  99248. /**
  99249. * When set, the camera will render to this render target instead of the default canvas
  99250. *
  99251. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  99252. */
  99253. outputRenderTarget: Nullable<RenderTargetTexture>;
  99254. /**
  99255. * Observable triggered when the camera view matrix has changed.
  99256. */
  99257. onViewMatrixChangedObservable: Observable<Camera>;
  99258. /**
  99259. * Observable triggered when the camera Projection matrix has changed.
  99260. */
  99261. onProjectionMatrixChangedObservable: Observable<Camera>;
  99262. /**
  99263. * Observable triggered when the inputs have been processed.
  99264. */
  99265. onAfterCheckInputsObservable: Observable<Camera>;
  99266. /**
  99267. * Observable triggered when reset has been called and applied to the camera.
  99268. */
  99269. onRestoreStateObservable: Observable<Camera>;
  99270. /**
  99271. * Is this camera a part of a rig system?
  99272. */
  99273. isRigCamera: boolean;
  99274. /**
  99275. * If isRigCamera set to true this will be set with the parent camera.
  99276. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99277. */
  99278. rigParent?: Camera;
  99279. /** @hidden */
  99280. _cameraRigParams: any;
  99281. /** @hidden */
  99282. _rigCameras: Camera[];
  99283. /** @hidden */
  99284. _rigPostProcess: Nullable<PostProcess>;
  99285. protected _webvrViewMatrix: Matrix;
  99286. /** @hidden */
  99287. _skipRendering: boolean;
  99288. /** @hidden */
  99289. _projectionMatrix: Matrix;
  99290. /** @hidden */
  99291. _postProcesses: Nullable<PostProcess>[];
  99292. /** @hidden */
  99293. _activeMeshes: SmartArray<AbstractMesh>;
  99294. protected _globalPosition: Vector3;
  99295. /** @hidden */
  99296. _computedViewMatrix: Matrix;
  99297. private _doNotComputeProjectionMatrix;
  99298. private _transformMatrix;
  99299. private _frustumPlanes;
  99300. private _refreshFrustumPlanes;
  99301. private _storedFov;
  99302. private _stateStored;
  99303. /**
  99304. * Instantiates a new camera object.
  99305. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99306. * @see http://doc.babylonjs.com/features/cameras
  99307. * @param name Defines the name of the camera in the scene
  99308. * @param position Defines the position of the camera
  99309. * @param scene Defines the scene the camera belongs too
  99310. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99311. */
  99312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99313. /**
  99314. * Store current camera state (fov, position, etc..)
  99315. * @returns the camera
  99316. */
  99317. storeState(): Camera;
  99318. /**
  99319. * Restores the camera state values if it has been stored. You must call storeState() first
  99320. */
  99321. protected _restoreStateValues(): boolean;
  99322. /**
  99323. * Restored camera state. You must call storeState() first.
  99324. * @returns true if restored and false otherwise
  99325. */
  99326. restoreState(): boolean;
  99327. /**
  99328. * Gets the class name of the camera.
  99329. * @returns the class name
  99330. */
  99331. getClassName(): string;
  99332. /** @hidden */
  99333. readonly _isCamera: boolean;
  99334. /**
  99335. * Gets a string representation of the camera useful for debug purpose.
  99336. * @param fullDetails Defines that a more verboe level of logging is required
  99337. * @returns the string representation
  99338. */
  99339. toString(fullDetails?: boolean): string;
  99340. /**
  99341. * Gets the current world space position of the camera.
  99342. */
  99343. get globalPosition(): Vector3;
  99344. /**
  99345. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99346. * @returns the active meshe list
  99347. */
  99348. getActiveMeshes(): SmartArray<AbstractMesh>;
  99349. /**
  99350. * Check whether a mesh is part of the current active mesh list of the camera
  99351. * @param mesh Defines the mesh to check
  99352. * @returns true if active, false otherwise
  99353. */
  99354. isActiveMesh(mesh: Mesh): boolean;
  99355. /**
  99356. * Is this camera ready to be used/rendered
  99357. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99358. * @return true if the camera is ready
  99359. */
  99360. isReady(completeCheck?: boolean): boolean;
  99361. /** @hidden */
  99362. _initCache(): void;
  99363. /** @hidden */
  99364. _updateCache(ignoreParentClass?: boolean): void;
  99365. /** @hidden */
  99366. _isSynchronized(): boolean;
  99367. /** @hidden */
  99368. _isSynchronizedViewMatrix(): boolean;
  99369. /** @hidden */
  99370. _isSynchronizedProjectionMatrix(): boolean;
  99371. /**
  99372. * Attach the input controls to a specific dom element to get the input from.
  99373. * @param element Defines the element the controls should be listened from
  99374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99375. */
  99376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99377. /**
  99378. * Detach the current controls from the specified dom element.
  99379. * @param element Defines the element to stop listening the inputs from
  99380. */
  99381. detachControl(element: HTMLElement): void;
  99382. /**
  99383. * Update the camera state according to the different inputs gathered during the frame.
  99384. */
  99385. update(): void;
  99386. /** @hidden */
  99387. _checkInputs(): void;
  99388. /** @hidden */
  99389. get rigCameras(): Camera[];
  99390. /**
  99391. * Gets the post process used by the rig cameras
  99392. */
  99393. get rigPostProcess(): Nullable<PostProcess>;
  99394. /**
  99395. * Internal, gets the first post proces.
  99396. * @returns the first post process to be run on this camera.
  99397. */
  99398. _getFirstPostProcess(): Nullable<PostProcess>;
  99399. private _cascadePostProcessesToRigCams;
  99400. /**
  99401. * Attach a post process to the camera.
  99402. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99403. * @param postProcess The post process to attach to the camera
  99404. * @param insertAt The position of the post process in case several of them are in use in the scene
  99405. * @returns the position the post process has been inserted at
  99406. */
  99407. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99408. /**
  99409. * Detach a post process to the camera.
  99410. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99411. * @param postProcess The post process to detach from the camera
  99412. */
  99413. detachPostProcess(postProcess: PostProcess): void;
  99414. /**
  99415. * Gets the current world matrix of the camera
  99416. */
  99417. getWorldMatrix(): Matrix;
  99418. /** @hidden */
  99419. _getViewMatrix(): Matrix;
  99420. /**
  99421. * Gets the current view matrix of the camera.
  99422. * @param force forces the camera to recompute the matrix without looking at the cached state
  99423. * @returns the view matrix
  99424. */
  99425. getViewMatrix(force?: boolean): Matrix;
  99426. /**
  99427. * Freeze the projection matrix.
  99428. * It will prevent the cache check of the camera projection compute and can speed up perf
  99429. * if no parameter of the camera are meant to change
  99430. * @param projection Defines manually a projection if necessary
  99431. */
  99432. freezeProjectionMatrix(projection?: Matrix): void;
  99433. /**
  99434. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99435. */
  99436. unfreezeProjectionMatrix(): void;
  99437. /**
  99438. * Gets the current projection matrix of the camera.
  99439. * @param force forces the camera to recompute the matrix without looking at the cached state
  99440. * @returns the projection matrix
  99441. */
  99442. getProjectionMatrix(force?: boolean): Matrix;
  99443. /**
  99444. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99445. * @returns a Matrix
  99446. */
  99447. getTransformationMatrix(): Matrix;
  99448. private _updateFrustumPlanes;
  99449. /**
  99450. * Checks if a cullable object (mesh...) is in the camera frustum
  99451. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99452. * @param target The object to check
  99453. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99454. * @returns true if the object is in frustum otherwise false
  99455. */
  99456. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99457. /**
  99458. * Checks if a cullable object (mesh...) is in the camera frustum
  99459. * Unlike isInFrustum this cheks the full bounding box
  99460. * @param target The object to check
  99461. * @returns true if the object is in frustum otherwise false
  99462. */
  99463. isCompletelyInFrustum(target: ICullable): boolean;
  99464. /**
  99465. * Gets a ray in the forward direction from the camera.
  99466. * @param length Defines the length of the ray to create
  99467. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99468. * @param origin Defines the start point of the ray which defaults to the camera position
  99469. * @returns the forward ray
  99470. */
  99471. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99472. /**
  99473. * Releases resources associated with this node.
  99474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99476. */
  99477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99478. /** @hidden */
  99479. _isLeftCamera: boolean;
  99480. /**
  99481. * Gets the left camera of a rig setup in case of Rigged Camera
  99482. */
  99483. get isLeftCamera(): boolean;
  99484. /** @hidden */
  99485. _isRightCamera: boolean;
  99486. /**
  99487. * Gets the right camera of a rig setup in case of Rigged Camera
  99488. */
  99489. get isRightCamera(): boolean;
  99490. /**
  99491. * Gets the left camera of a rig setup in case of Rigged Camera
  99492. */
  99493. get leftCamera(): Nullable<FreeCamera>;
  99494. /**
  99495. * Gets the right camera of a rig setup in case of Rigged Camera
  99496. */
  99497. get rightCamera(): Nullable<FreeCamera>;
  99498. /**
  99499. * Gets the left camera target of a rig setup in case of Rigged Camera
  99500. * @returns the target position
  99501. */
  99502. getLeftTarget(): Nullable<Vector3>;
  99503. /**
  99504. * Gets the right camera target of a rig setup in case of Rigged Camera
  99505. * @returns the target position
  99506. */
  99507. getRightTarget(): Nullable<Vector3>;
  99508. /**
  99509. * @hidden
  99510. */
  99511. setCameraRigMode(mode: number, rigParams: any): void;
  99512. /** @hidden */
  99513. static _setStereoscopicRigMode(camera: Camera): void;
  99514. /** @hidden */
  99515. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99516. /** @hidden */
  99517. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99518. /** @hidden */
  99519. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99520. /** @hidden */
  99521. _getVRProjectionMatrix(): Matrix;
  99522. protected _updateCameraRotationMatrix(): void;
  99523. protected _updateWebVRCameraRotationMatrix(): void;
  99524. /**
  99525. * This function MUST be overwritten by the different WebVR cameras available.
  99526. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99527. * @hidden
  99528. */
  99529. _getWebVRProjectionMatrix(): Matrix;
  99530. /**
  99531. * This function MUST be overwritten by the different WebVR cameras available.
  99532. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99533. * @hidden
  99534. */
  99535. _getWebVRViewMatrix(): Matrix;
  99536. /** @hidden */
  99537. setCameraRigParameter(name: string, value: any): void;
  99538. /**
  99539. * needs to be overridden by children so sub has required properties to be copied
  99540. * @hidden
  99541. */
  99542. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99543. /**
  99544. * May need to be overridden by children
  99545. * @hidden
  99546. */
  99547. _updateRigCameras(): void;
  99548. /** @hidden */
  99549. _setupInputs(): void;
  99550. /**
  99551. * Serialiaze the camera setup to a json represention
  99552. * @returns the JSON representation
  99553. */
  99554. serialize(): any;
  99555. /**
  99556. * Clones the current camera.
  99557. * @param name The cloned camera name
  99558. * @returns the cloned camera
  99559. */
  99560. clone(name: string): Camera;
  99561. /**
  99562. * Gets the direction of the camera relative to a given local axis.
  99563. * @param localAxis Defines the reference axis to provide a relative direction.
  99564. * @return the direction
  99565. */
  99566. getDirection(localAxis: Vector3): Vector3;
  99567. /**
  99568. * Returns the current camera absolute rotation
  99569. */
  99570. get absoluteRotation(): Quaternion;
  99571. /**
  99572. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99573. * @param localAxis Defines the reference axis to provide a relative direction.
  99574. * @param result Defines the vector to store the result in
  99575. */
  99576. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99577. /**
  99578. * Gets a camera constructor for a given camera type
  99579. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99580. * @param name The name of the camera the result will be able to instantiate
  99581. * @param scene The scene the result will construct the camera in
  99582. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99583. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99584. * @returns a factory method to construc the camera
  99585. */
  99586. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99587. /**
  99588. * Compute the world matrix of the camera.
  99589. * @returns the camera world matrix
  99590. */
  99591. computeWorldMatrix(): Matrix;
  99592. /**
  99593. * Parse a JSON and creates the camera from the parsed information
  99594. * @param parsedCamera The JSON to parse
  99595. * @param scene The scene to instantiate the camera in
  99596. * @returns the newly constructed camera
  99597. */
  99598. static Parse(parsedCamera: any, scene: Scene): Camera;
  99599. }
  99600. }
  99601. declare module BABYLON {
  99602. /**
  99603. * Class containing static functions to help procedurally build meshes
  99604. */
  99605. export class DiscBuilder {
  99606. /**
  99607. * Creates a plane polygonal mesh. By default, this is a disc
  99608. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99609. * * 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
  99610. * * 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
  99611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99614. * @param name defines the name of the mesh
  99615. * @param options defines the options used to create the mesh
  99616. * @param scene defines the hosting scene
  99617. * @returns the plane polygonal mesh
  99618. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99619. */
  99620. static CreateDisc(name: string, options: {
  99621. radius?: number;
  99622. tessellation?: number;
  99623. arc?: number;
  99624. updatable?: boolean;
  99625. sideOrientation?: number;
  99626. frontUVs?: Vector4;
  99627. backUVs?: Vector4;
  99628. }, scene?: Nullable<Scene>): Mesh;
  99629. }
  99630. }
  99631. declare module BABYLON {
  99632. /**
  99633. * This represents all the required information to add a fresnel effect on a material:
  99634. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99635. */
  99636. export class FresnelParameters {
  99637. private _isEnabled;
  99638. /**
  99639. * Define if the fresnel effect is enable or not.
  99640. */
  99641. get isEnabled(): boolean;
  99642. set isEnabled(value: boolean);
  99643. /**
  99644. * Define the color used on edges (grazing angle)
  99645. */
  99646. leftColor: Color3;
  99647. /**
  99648. * Define the color used on center
  99649. */
  99650. rightColor: Color3;
  99651. /**
  99652. * Define bias applied to computed fresnel term
  99653. */
  99654. bias: number;
  99655. /**
  99656. * Defined the power exponent applied to fresnel term
  99657. */
  99658. power: number;
  99659. /**
  99660. * Clones the current fresnel and its valuues
  99661. * @returns a clone fresnel configuration
  99662. */
  99663. clone(): FresnelParameters;
  99664. /**
  99665. * Serializes the current fresnel parameters to a JSON representation.
  99666. * @return the JSON serialization
  99667. */
  99668. serialize(): any;
  99669. /**
  99670. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99671. * @param parsedFresnelParameters Define the JSON representation
  99672. * @returns the parsed parameters
  99673. */
  99674. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99675. }
  99676. }
  99677. declare module BABYLON {
  99678. /**
  99679. * Base class of materials working in push mode in babylon JS
  99680. * @hidden
  99681. */
  99682. export class PushMaterial extends Material {
  99683. protected _activeEffect: Effect;
  99684. protected _normalMatrix: Matrix;
  99685. /**
  99686. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99687. * This means that the material can keep using a previous shader while a new one is being compiled.
  99688. * This is mostly used when shader parallel compilation is supported (true by default)
  99689. */
  99690. allowShaderHotSwapping: boolean;
  99691. constructor(name: string, scene: Scene);
  99692. getEffect(): Effect;
  99693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99694. /**
  99695. * Binds the given world matrix to the active effect
  99696. *
  99697. * @param world the matrix to bind
  99698. */
  99699. bindOnlyWorldMatrix(world: Matrix): void;
  99700. /**
  99701. * Binds the given normal matrix to the active effect
  99702. *
  99703. * @param normalMatrix the matrix to bind
  99704. */
  99705. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99706. bind(world: Matrix, mesh?: Mesh): void;
  99707. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99708. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99709. }
  99710. }
  99711. declare module BABYLON {
  99712. /**
  99713. * This groups all the flags used to control the materials channel.
  99714. */
  99715. export class MaterialFlags {
  99716. private static _DiffuseTextureEnabled;
  99717. /**
  99718. * Are diffuse textures enabled in the application.
  99719. */
  99720. static get DiffuseTextureEnabled(): boolean;
  99721. static set DiffuseTextureEnabled(value: boolean);
  99722. private static _AmbientTextureEnabled;
  99723. /**
  99724. * Are ambient textures enabled in the application.
  99725. */
  99726. static get AmbientTextureEnabled(): boolean;
  99727. static set AmbientTextureEnabled(value: boolean);
  99728. private static _OpacityTextureEnabled;
  99729. /**
  99730. * Are opacity textures enabled in the application.
  99731. */
  99732. static get OpacityTextureEnabled(): boolean;
  99733. static set OpacityTextureEnabled(value: boolean);
  99734. private static _ReflectionTextureEnabled;
  99735. /**
  99736. * Are reflection textures enabled in the application.
  99737. */
  99738. static get ReflectionTextureEnabled(): boolean;
  99739. static set ReflectionTextureEnabled(value: boolean);
  99740. private static _EmissiveTextureEnabled;
  99741. /**
  99742. * Are emissive textures enabled in the application.
  99743. */
  99744. static get EmissiveTextureEnabled(): boolean;
  99745. static set EmissiveTextureEnabled(value: boolean);
  99746. private static _SpecularTextureEnabled;
  99747. /**
  99748. * Are specular textures enabled in the application.
  99749. */
  99750. static get SpecularTextureEnabled(): boolean;
  99751. static set SpecularTextureEnabled(value: boolean);
  99752. private static _BumpTextureEnabled;
  99753. /**
  99754. * Are bump textures enabled in the application.
  99755. */
  99756. static get BumpTextureEnabled(): boolean;
  99757. static set BumpTextureEnabled(value: boolean);
  99758. private static _LightmapTextureEnabled;
  99759. /**
  99760. * Are lightmap textures enabled in the application.
  99761. */
  99762. static get LightmapTextureEnabled(): boolean;
  99763. static set LightmapTextureEnabled(value: boolean);
  99764. private static _RefractionTextureEnabled;
  99765. /**
  99766. * Are refraction textures enabled in the application.
  99767. */
  99768. static get RefractionTextureEnabled(): boolean;
  99769. static set RefractionTextureEnabled(value: boolean);
  99770. private static _ColorGradingTextureEnabled;
  99771. /**
  99772. * Are color grading textures enabled in the application.
  99773. */
  99774. static get ColorGradingTextureEnabled(): boolean;
  99775. static set ColorGradingTextureEnabled(value: boolean);
  99776. private static _FresnelEnabled;
  99777. /**
  99778. * Are fresnels enabled in the application.
  99779. */
  99780. static get FresnelEnabled(): boolean;
  99781. static set FresnelEnabled(value: boolean);
  99782. private static _ClearCoatTextureEnabled;
  99783. /**
  99784. * Are clear coat textures enabled in the application.
  99785. */
  99786. static get ClearCoatTextureEnabled(): boolean;
  99787. static set ClearCoatTextureEnabled(value: boolean);
  99788. private static _ClearCoatBumpTextureEnabled;
  99789. /**
  99790. * Are clear coat bump textures enabled in the application.
  99791. */
  99792. static get ClearCoatBumpTextureEnabled(): boolean;
  99793. static set ClearCoatBumpTextureEnabled(value: boolean);
  99794. private static _ClearCoatTintTextureEnabled;
  99795. /**
  99796. * Are clear coat tint textures enabled in the application.
  99797. */
  99798. static get ClearCoatTintTextureEnabled(): boolean;
  99799. static set ClearCoatTintTextureEnabled(value: boolean);
  99800. private static _SheenTextureEnabled;
  99801. /**
  99802. * Are sheen textures enabled in the application.
  99803. */
  99804. static get SheenTextureEnabled(): boolean;
  99805. static set SheenTextureEnabled(value: boolean);
  99806. private static _AnisotropicTextureEnabled;
  99807. /**
  99808. * Are anisotropic textures enabled in the application.
  99809. */
  99810. static get AnisotropicTextureEnabled(): boolean;
  99811. static set AnisotropicTextureEnabled(value: boolean);
  99812. private static _ThicknessTextureEnabled;
  99813. /**
  99814. * Are thickness textures enabled in the application.
  99815. */
  99816. static get ThicknessTextureEnabled(): boolean;
  99817. static set ThicknessTextureEnabled(value: boolean);
  99818. }
  99819. }
  99820. declare module BABYLON {
  99821. /** @hidden */
  99822. export var defaultFragmentDeclaration: {
  99823. name: string;
  99824. shader: string;
  99825. };
  99826. }
  99827. declare module BABYLON {
  99828. /** @hidden */
  99829. export var defaultUboDeclaration: {
  99830. name: string;
  99831. shader: string;
  99832. };
  99833. }
  99834. declare module BABYLON {
  99835. /** @hidden */
  99836. export var lightFragmentDeclaration: {
  99837. name: string;
  99838. shader: string;
  99839. };
  99840. }
  99841. declare module BABYLON {
  99842. /** @hidden */
  99843. export var lightUboDeclaration: {
  99844. name: string;
  99845. shader: string;
  99846. };
  99847. }
  99848. declare module BABYLON {
  99849. /** @hidden */
  99850. export var lightsFragmentFunctions: {
  99851. name: string;
  99852. shader: string;
  99853. };
  99854. }
  99855. declare module BABYLON {
  99856. /** @hidden */
  99857. export var shadowsFragmentFunctions: {
  99858. name: string;
  99859. shader: string;
  99860. };
  99861. }
  99862. declare module BABYLON {
  99863. /** @hidden */
  99864. export var fresnelFunction: {
  99865. name: string;
  99866. shader: string;
  99867. };
  99868. }
  99869. declare module BABYLON {
  99870. /** @hidden */
  99871. export var reflectionFunction: {
  99872. name: string;
  99873. shader: string;
  99874. };
  99875. }
  99876. declare module BABYLON {
  99877. /** @hidden */
  99878. export var bumpFragmentFunctions: {
  99879. name: string;
  99880. shader: string;
  99881. };
  99882. }
  99883. declare module BABYLON {
  99884. /** @hidden */
  99885. export var logDepthDeclaration: {
  99886. name: string;
  99887. shader: string;
  99888. };
  99889. }
  99890. declare module BABYLON {
  99891. /** @hidden */
  99892. export var bumpFragment: {
  99893. name: string;
  99894. shader: string;
  99895. };
  99896. }
  99897. declare module BABYLON {
  99898. /** @hidden */
  99899. export var depthPrePass: {
  99900. name: string;
  99901. shader: string;
  99902. };
  99903. }
  99904. declare module BABYLON {
  99905. /** @hidden */
  99906. export var lightFragment: {
  99907. name: string;
  99908. shader: string;
  99909. };
  99910. }
  99911. declare module BABYLON {
  99912. /** @hidden */
  99913. export var logDepthFragment: {
  99914. name: string;
  99915. shader: string;
  99916. };
  99917. }
  99918. declare module BABYLON {
  99919. /** @hidden */
  99920. export var defaultPixelShader: {
  99921. name: string;
  99922. shader: string;
  99923. };
  99924. }
  99925. declare module BABYLON {
  99926. /** @hidden */
  99927. export var defaultVertexDeclaration: {
  99928. name: string;
  99929. shader: string;
  99930. };
  99931. }
  99932. declare module BABYLON {
  99933. /** @hidden */
  99934. export var bumpVertexDeclaration: {
  99935. name: string;
  99936. shader: string;
  99937. };
  99938. }
  99939. declare module BABYLON {
  99940. /** @hidden */
  99941. export var bumpVertex: {
  99942. name: string;
  99943. shader: string;
  99944. };
  99945. }
  99946. declare module BABYLON {
  99947. /** @hidden */
  99948. export var fogVertex: {
  99949. name: string;
  99950. shader: string;
  99951. };
  99952. }
  99953. declare module BABYLON {
  99954. /** @hidden */
  99955. export var shadowsVertex: {
  99956. name: string;
  99957. shader: string;
  99958. };
  99959. }
  99960. declare module BABYLON {
  99961. /** @hidden */
  99962. export var pointCloudVertex: {
  99963. name: string;
  99964. shader: string;
  99965. };
  99966. }
  99967. declare module BABYLON {
  99968. /** @hidden */
  99969. export var logDepthVertex: {
  99970. name: string;
  99971. shader: string;
  99972. };
  99973. }
  99974. declare module BABYLON {
  99975. /** @hidden */
  99976. export var defaultVertexShader: {
  99977. name: string;
  99978. shader: string;
  99979. };
  99980. }
  99981. declare module BABYLON {
  99982. /** @hidden */
  99983. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99984. MAINUV1: boolean;
  99985. MAINUV2: boolean;
  99986. DIFFUSE: boolean;
  99987. DIFFUSEDIRECTUV: number;
  99988. AMBIENT: boolean;
  99989. AMBIENTDIRECTUV: number;
  99990. OPACITY: boolean;
  99991. OPACITYDIRECTUV: number;
  99992. OPACITYRGB: boolean;
  99993. REFLECTION: boolean;
  99994. EMISSIVE: boolean;
  99995. EMISSIVEDIRECTUV: number;
  99996. SPECULAR: boolean;
  99997. SPECULARDIRECTUV: number;
  99998. BUMP: boolean;
  99999. BUMPDIRECTUV: number;
  100000. PARALLAX: boolean;
  100001. PARALLAXOCCLUSION: boolean;
  100002. SPECULAROVERALPHA: boolean;
  100003. CLIPPLANE: boolean;
  100004. CLIPPLANE2: boolean;
  100005. CLIPPLANE3: boolean;
  100006. CLIPPLANE4: boolean;
  100007. CLIPPLANE5: boolean;
  100008. CLIPPLANE6: boolean;
  100009. ALPHATEST: boolean;
  100010. DEPTHPREPASS: boolean;
  100011. ALPHAFROMDIFFUSE: boolean;
  100012. POINTSIZE: boolean;
  100013. FOG: boolean;
  100014. SPECULARTERM: boolean;
  100015. DIFFUSEFRESNEL: boolean;
  100016. OPACITYFRESNEL: boolean;
  100017. REFLECTIONFRESNEL: boolean;
  100018. REFRACTIONFRESNEL: boolean;
  100019. EMISSIVEFRESNEL: boolean;
  100020. FRESNEL: boolean;
  100021. NORMAL: boolean;
  100022. UV1: boolean;
  100023. UV2: boolean;
  100024. VERTEXCOLOR: boolean;
  100025. VERTEXALPHA: boolean;
  100026. NUM_BONE_INFLUENCERS: number;
  100027. BonesPerMesh: number;
  100028. BONETEXTURE: boolean;
  100029. INSTANCES: boolean;
  100030. GLOSSINESS: boolean;
  100031. ROUGHNESS: boolean;
  100032. EMISSIVEASILLUMINATION: boolean;
  100033. LINKEMISSIVEWITHDIFFUSE: boolean;
  100034. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100035. LIGHTMAP: boolean;
  100036. LIGHTMAPDIRECTUV: number;
  100037. OBJECTSPACE_NORMALMAP: boolean;
  100038. USELIGHTMAPASSHADOWMAP: boolean;
  100039. REFLECTIONMAP_3D: boolean;
  100040. REFLECTIONMAP_SPHERICAL: boolean;
  100041. REFLECTIONMAP_PLANAR: boolean;
  100042. REFLECTIONMAP_CUBIC: boolean;
  100043. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100044. REFLECTIONMAP_PROJECTION: boolean;
  100045. REFLECTIONMAP_SKYBOX: boolean;
  100046. REFLECTIONMAP_EXPLICIT: boolean;
  100047. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100048. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100049. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100050. INVERTCUBICMAP: boolean;
  100051. LOGARITHMICDEPTH: boolean;
  100052. REFRACTION: boolean;
  100053. REFRACTIONMAP_3D: boolean;
  100054. REFLECTIONOVERALPHA: boolean;
  100055. TWOSIDEDLIGHTING: boolean;
  100056. SHADOWFLOAT: boolean;
  100057. MORPHTARGETS: boolean;
  100058. MORPHTARGETS_NORMAL: boolean;
  100059. MORPHTARGETS_TANGENT: boolean;
  100060. MORPHTARGETS_UV: boolean;
  100061. NUM_MORPH_INFLUENCERS: number;
  100062. NONUNIFORMSCALING: boolean;
  100063. PREMULTIPLYALPHA: boolean;
  100064. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100065. ALPHABLEND: boolean;
  100066. IMAGEPROCESSING: boolean;
  100067. VIGNETTE: boolean;
  100068. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100069. VIGNETTEBLENDMODEOPAQUE: boolean;
  100070. TONEMAPPING: boolean;
  100071. TONEMAPPING_ACES: boolean;
  100072. CONTRAST: boolean;
  100073. COLORCURVES: boolean;
  100074. COLORGRADING: boolean;
  100075. COLORGRADING3D: boolean;
  100076. SAMPLER3DGREENDEPTH: boolean;
  100077. SAMPLER3DBGRMAP: boolean;
  100078. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100079. MULTIVIEW: boolean;
  100080. /**
  100081. * If the reflection texture on this material is in linear color space
  100082. * @hidden
  100083. */
  100084. IS_REFLECTION_LINEAR: boolean;
  100085. /**
  100086. * If the refraction texture on this material is in linear color space
  100087. * @hidden
  100088. */
  100089. IS_REFRACTION_LINEAR: boolean;
  100090. EXPOSURE: boolean;
  100091. constructor();
  100092. setReflectionMode(modeToEnable: string): void;
  100093. }
  100094. /**
  100095. * This is the default material used in Babylon. It is the best trade off between quality
  100096. * and performances.
  100097. * @see http://doc.babylonjs.com/babylon101/materials
  100098. */
  100099. export class StandardMaterial extends PushMaterial {
  100100. private _diffuseTexture;
  100101. /**
  100102. * The basic texture of the material as viewed under a light.
  100103. */
  100104. diffuseTexture: Nullable<BaseTexture>;
  100105. private _ambientTexture;
  100106. /**
  100107. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100108. */
  100109. ambientTexture: Nullable<BaseTexture>;
  100110. private _opacityTexture;
  100111. /**
  100112. * Define the transparency of the material from a texture.
  100113. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100114. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100115. */
  100116. opacityTexture: Nullable<BaseTexture>;
  100117. private _reflectionTexture;
  100118. /**
  100119. * Define the texture used to display the reflection.
  100120. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100121. */
  100122. reflectionTexture: Nullable<BaseTexture>;
  100123. private _emissiveTexture;
  100124. /**
  100125. * Define texture of the material as if self lit.
  100126. * This will be mixed in the final result even in the absence of light.
  100127. */
  100128. emissiveTexture: Nullable<BaseTexture>;
  100129. private _specularTexture;
  100130. /**
  100131. * Define how the color and intensity of the highlight given by the light in the material.
  100132. */
  100133. specularTexture: Nullable<BaseTexture>;
  100134. private _bumpTexture;
  100135. /**
  100136. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100137. * 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.
  100138. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  100139. */
  100140. bumpTexture: Nullable<BaseTexture>;
  100141. private _lightmapTexture;
  100142. /**
  100143. * Complex lighting can be computationally expensive to compute at runtime.
  100144. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100145. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  100146. */
  100147. lightmapTexture: Nullable<BaseTexture>;
  100148. private _refractionTexture;
  100149. /**
  100150. * Define the texture used to display the refraction.
  100151. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100152. */
  100153. refractionTexture: Nullable<BaseTexture>;
  100154. /**
  100155. * The color of the material lit by the environmental background lighting.
  100156. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100157. */
  100158. ambientColor: Color3;
  100159. /**
  100160. * The basic color of the material as viewed under a light.
  100161. */
  100162. diffuseColor: Color3;
  100163. /**
  100164. * Define how the color and intensity of the highlight given by the light in the material.
  100165. */
  100166. specularColor: Color3;
  100167. /**
  100168. * Define the color of the material as if self lit.
  100169. * This will be mixed in the final result even in the absence of light.
  100170. */
  100171. emissiveColor: Color3;
  100172. /**
  100173. * Defines how sharp are the highlights in the material.
  100174. * The bigger the value the sharper giving a more glossy feeling to the result.
  100175. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100176. */
  100177. specularPower: number;
  100178. private _useAlphaFromDiffuseTexture;
  100179. /**
  100180. * Does the transparency come from the diffuse texture alpha channel.
  100181. */
  100182. useAlphaFromDiffuseTexture: boolean;
  100183. private _useEmissiveAsIllumination;
  100184. /**
  100185. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100186. */
  100187. useEmissiveAsIllumination: boolean;
  100188. private _linkEmissiveWithDiffuse;
  100189. /**
  100190. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100191. * the emissive level when the final color is close to one.
  100192. */
  100193. linkEmissiveWithDiffuse: boolean;
  100194. private _useSpecularOverAlpha;
  100195. /**
  100196. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100197. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100198. */
  100199. useSpecularOverAlpha: boolean;
  100200. private _useReflectionOverAlpha;
  100201. /**
  100202. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100203. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100204. */
  100205. useReflectionOverAlpha: boolean;
  100206. private _disableLighting;
  100207. /**
  100208. * Does lights from the scene impacts this material.
  100209. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100210. */
  100211. disableLighting: boolean;
  100212. private _useObjectSpaceNormalMap;
  100213. /**
  100214. * Allows using an object space normal map (instead of tangent space).
  100215. */
  100216. useObjectSpaceNormalMap: boolean;
  100217. private _useParallax;
  100218. /**
  100219. * Is parallax enabled or not.
  100220. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100221. */
  100222. useParallax: boolean;
  100223. private _useParallaxOcclusion;
  100224. /**
  100225. * Is parallax occlusion enabled or not.
  100226. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100227. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100228. */
  100229. useParallaxOcclusion: boolean;
  100230. /**
  100231. * 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.
  100232. */
  100233. parallaxScaleBias: number;
  100234. private _roughness;
  100235. /**
  100236. * Helps to define how blurry the reflections should appears in the material.
  100237. */
  100238. roughness: number;
  100239. /**
  100240. * In case of refraction, define the value of the index of refraction.
  100241. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100242. */
  100243. indexOfRefraction: number;
  100244. /**
  100245. * Invert the refraction texture alongside the y axis.
  100246. * It can be useful with procedural textures or probe for instance.
  100247. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100248. */
  100249. invertRefractionY: boolean;
  100250. /**
  100251. * Defines the alpha limits in alpha test mode.
  100252. */
  100253. alphaCutOff: number;
  100254. private _useLightmapAsShadowmap;
  100255. /**
  100256. * In case of light mapping, define whether the map contains light or shadow informations.
  100257. */
  100258. useLightmapAsShadowmap: boolean;
  100259. private _diffuseFresnelParameters;
  100260. /**
  100261. * Define the diffuse fresnel parameters of the material.
  100262. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100263. */
  100264. diffuseFresnelParameters: FresnelParameters;
  100265. private _opacityFresnelParameters;
  100266. /**
  100267. * Define the opacity fresnel parameters of the material.
  100268. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100269. */
  100270. opacityFresnelParameters: FresnelParameters;
  100271. private _reflectionFresnelParameters;
  100272. /**
  100273. * Define the reflection fresnel parameters of the material.
  100274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100275. */
  100276. reflectionFresnelParameters: FresnelParameters;
  100277. private _refractionFresnelParameters;
  100278. /**
  100279. * Define the refraction fresnel parameters of the material.
  100280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100281. */
  100282. refractionFresnelParameters: FresnelParameters;
  100283. private _emissiveFresnelParameters;
  100284. /**
  100285. * Define the emissive fresnel parameters of the material.
  100286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100287. */
  100288. emissiveFresnelParameters: FresnelParameters;
  100289. private _useReflectionFresnelFromSpecular;
  100290. /**
  100291. * If true automatically deducts the fresnels values from the material specularity.
  100292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100293. */
  100294. useReflectionFresnelFromSpecular: boolean;
  100295. private _useGlossinessFromSpecularMapAlpha;
  100296. /**
  100297. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100298. */
  100299. useGlossinessFromSpecularMapAlpha: boolean;
  100300. private _maxSimultaneousLights;
  100301. /**
  100302. * Defines the maximum number of lights that can be used in the material
  100303. */
  100304. maxSimultaneousLights: number;
  100305. private _invertNormalMapX;
  100306. /**
  100307. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100308. */
  100309. invertNormalMapX: boolean;
  100310. private _invertNormalMapY;
  100311. /**
  100312. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100313. */
  100314. invertNormalMapY: boolean;
  100315. private _twoSidedLighting;
  100316. /**
  100317. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100318. */
  100319. twoSidedLighting: boolean;
  100320. /**
  100321. * Default configuration related to image processing available in the standard Material.
  100322. */
  100323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100324. /**
  100325. * Gets the image processing configuration used either in this material.
  100326. */
  100327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100328. /**
  100329. * Sets the Default image processing configuration used either in the this material.
  100330. *
  100331. * If sets to null, the scene one is in use.
  100332. */
  100333. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100334. /**
  100335. * Keep track of the image processing observer to allow dispose and replace.
  100336. */
  100337. private _imageProcessingObserver;
  100338. /**
  100339. * Attaches a new image processing configuration to the Standard Material.
  100340. * @param configuration
  100341. */
  100342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100343. /**
  100344. * Gets wether the color curves effect is enabled.
  100345. */
  100346. get cameraColorCurvesEnabled(): boolean;
  100347. /**
  100348. * Sets wether the color curves effect is enabled.
  100349. */
  100350. set cameraColorCurvesEnabled(value: boolean);
  100351. /**
  100352. * Gets wether the color grading effect is enabled.
  100353. */
  100354. get cameraColorGradingEnabled(): boolean;
  100355. /**
  100356. * Gets wether the color grading effect is enabled.
  100357. */
  100358. set cameraColorGradingEnabled(value: boolean);
  100359. /**
  100360. * Gets wether tonemapping is enabled or not.
  100361. */
  100362. get cameraToneMappingEnabled(): boolean;
  100363. /**
  100364. * Sets wether tonemapping is enabled or not
  100365. */
  100366. set cameraToneMappingEnabled(value: boolean);
  100367. /**
  100368. * The camera exposure used on this material.
  100369. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100370. * This corresponds to a photographic exposure.
  100371. */
  100372. get cameraExposure(): number;
  100373. /**
  100374. * The camera exposure used on this material.
  100375. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100376. * This corresponds to a photographic exposure.
  100377. */
  100378. set cameraExposure(value: number);
  100379. /**
  100380. * Gets The camera contrast used on this material.
  100381. */
  100382. get cameraContrast(): number;
  100383. /**
  100384. * Sets The camera contrast used on this material.
  100385. */
  100386. set cameraContrast(value: number);
  100387. /**
  100388. * Gets the Color Grading 2D Lookup Texture.
  100389. */
  100390. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100391. /**
  100392. * Sets the Color Grading 2D Lookup Texture.
  100393. */
  100394. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100395. /**
  100396. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100397. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100398. * 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;
  100399. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100400. */
  100401. get cameraColorCurves(): Nullable<ColorCurves>;
  100402. /**
  100403. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100404. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100405. * 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;
  100406. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100407. */
  100408. set cameraColorCurves(value: Nullable<ColorCurves>);
  100409. /**
  100410. * Custom callback helping to override the default shader used in the material.
  100411. */
  100412. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100413. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100414. protected _worldViewProjectionMatrix: Matrix;
  100415. protected _globalAmbientColor: Color3;
  100416. protected _useLogarithmicDepth: boolean;
  100417. protected _rebuildInParallel: boolean;
  100418. /**
  100419. * Instantiates a new standard material.
  100420. * This is the default material used in Babylon. It is the best trade off between quality
  100421. * and performances.
  100422. * @see http://doc.babylonjs.com/babylon101/materials
  100423. * @param name Define the name of the material in the scene
  100424. * @param scene Define the scene the material belong to
  100425. */
  100426. constructor(name: string, scene: Scene);
  100427. /**
  100428. * Gets a boolean indicating that current material needs to register RTT
  100429. */
  100430. get hasRenderTargetTextures(): boolean;
  100431. /**
  100432. * Gets the current class name of the material e.g. "StandardMaterial"
  100433. * Mainly use in serialization.
  100434. * @returns the class name
  100435. */
  100436. getClassName(): string;
  100437. /**
  100438. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100439. * You can try switching to logarithmic depth.
  100440. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100441. */
  100442. get useLogarithmicDepth(): boolean;
  100443. set useLogarithmicDepth(value: boolean);
  100444. /**
  100445. * Specifies if the material will require alpha blending
  100446. * @returns a boolean specifying if alpha blending is needed
  100447. */
  100448. needAlphaBlending(): boolean;
  100449. /**
  100450. * Specifies if this material should be rendered in alpha test mode
  100451. * @returns a boolean specifying if an alpha test is needed.
  100452. */
  100453. needAlphaTesting(): boolean;
  100454. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100455. /**
  100456. * Get the texture used for alpha test purpose.
  100457. * @returns the diffuse texture in case of the standard material.
  100458. */
  100459. getAlphaTestTexture(): Nullable<BaseTexture>;
  100460. /**
  100461. * Get if the submesh is ready to be used and all its information available.
  100462. * Child classes can use it to update shaders
  100463. * @param mesh defines the mesh to check
  100464. * @param subMesh defines which submesh to check
  100465. * @param useInstances specifies that instances should be used
  100466. * @returns a boolean indicating that the submesh is ready or not
  100467. */
  100468. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100469. /**
  100470. * Builds the material UBO layouts.
  100471. * Used internally during the effect preparation.
  100472. */
  100473. buildUniformLayout(): void;
  100474. /**
  100475. * Unbinds the material from the mesh
  100476. */
  100477. unbind(): void;
  100478. /**
  100479. * Binds the submesh to this material by preparing the effect and shader to draw
  100480. * @param world defines the world transformation matrix
  100481. * @param mesh defines the mesh containing the submesh
  100482. * @param subMesh defines the submesh to bind the material to
  100483. */
  100484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100485. /**
  100486. * Get the list of animatables in the material.
  100487. * @returns the list of animatables object used in the material
  100488. */
  100489. getAnimatables(): IAnimatable[];
  100490. /**
  100491. * Gets the active textures from the material
  100492. * @returns an array of textures
  100493. */
  100494. getActiveTextures(): BaseTexture[];
  100495. /**
  100496. * Specifies if the material uses a texture
  100497. * @param texture defines the texture to check against the material
  100498. * @returns a boolean specifying if the material uses the texture
  100499. */
  100500. hasTexture(texture: BaseTexture): boolean;
  100501. /**
  100502. * Disposes the material
  100503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100505. */
  100506. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100507. /**
  100508. * Makes a duplicate of the material, and gives it a new name
  100509. * @param name defines the new name for the duplicated material
  100510. * @returns the cloned material
  100511. */
  100512. clone(name: string): StandardMaterial;
  100513. /**
  100514. * Serializes this material in a JSON representation
  100515. * @returns the serialized material object
  100516. */
  100517. serialize(): any;
  100518. /**
  100519. * Creates a standard material from parsed material data
  100520. * @param source defines the JSON representation of the material
  100521. * @param scene defines the hosting scene
  100522. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100523. * @returns a new standard material
  100524. */
  100525. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100526. /**
  100527. * Are diffuse textures enabled in the application.
  100528. */
  100529. static get DiffuseTextureEnabled(): boolean;
  100530. static set DiffuseTextureEnabled(value: boolean);
  100531. /**
  100532. * Are ambient textures enabled in the application.
  100533. */
  100534. static get AmbientTextureEnabled(): boolean;
  100535. static set AmbientTextureEnabled(value: boolean);
  100536. /**
  100537. * Are opacity textures enabled in the application.
  100538. */
  100539. static get OpacityTextureEnabled(): boolean;
  100540. static set OpacityTextureEnabled(value: boolean);
  100541. /**
  100542. * Are reflection textures enabled in the application.
  100543. */
  100544. static get ReflectionTextureEnabled(): boolean;
  100545. static set ReflectionTextureEnabled(value: boolean);
  100546. /**
  100547. * Are emissive textures enabled in the application.
  100548. */
  100549. static get EmissiveTextureEnabled(): boolean;
  100550. static set EmissiveTextureEnabled(value: boolean);
  100551. /**
  100552. * Are specular textures enabled in the application.
  100553. */
  100554. static get SpecularTextureEnabled(): boolean;
  100555. static set SpecularTextureEnabled(value: boolean);
  100556. /**
  100557. * Are bump textures enabled in the application.
  100558. */
  100559. static get BumpTextureEnabled(): boolean;
  100560. static set BumpTextureEnabled(value: boolean);
  100561. /**
  100562. * Are lightmap textures enabled in the application.
  100563. */
  100564. static get LightmapTextureEnabled(): boolean;
  100565. static set LightmapTextureEnabled(value: boolean);
  100566. /**
  100567. * Are refraction textures enabled in the application.
  100568. */
  100569. static get RefractionTextureEnabled(): boolean;
  100570. static set RefractionTextureEnabled(value: boolean);
  100571. /**
  100572. * Are color grading textures enabled in the application.
  100573. */
  100574. static get ColorGradingTextureEnabled(): boolean;
  100575. static set ColorGradingTextureEnabled(value: boolean);
  100576. /**
  100577. * Are fresnels enabled in the application.
  100578. */
  100579. static get FresnelEnabled(): boolean;
  100580. static set FresnelEnabled(value: boolean);
  100581. }
  100582. }
  100583. declare module BABYLON {
  100584. /**
  100585. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100586. *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.
  100587. * The SPS is also a particle system. It provides some methods to manage the particles.
  100588. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100589. *
  100590. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100591. */
  100592. export class SolidParticleSystem implements IDisposable {
  100593. /**
  100594. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100595. * Example : var p = SPS.particles[i];
  100596. */
  100597. particles: SolidParticle[];
  100598. /**
  100599. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100600. */
  100601. nbParticles: number;
  100602. /**
  100603. * If the particles must ever face the camera (default false). Useful for planar particles.
  100604. */
  100605. billboard: boolean;
  100606. /**
  100607. * Recompute normals when adding a shape
  100608. */
  100609. recomputeNormals: boolean;
  100610. /**
  100611. * This a counter ofr your own usage. It's not set by any SPS functions.
  100612. */
  100613. counter: number;
  100614. /**
  100615. * The SPS name. This name is also given to the underlying mesh.
  100616. */
  100617. name: string;
  100618. /**
  100619. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100620. */
  100621. mesh: Mesh;
  100622. /**
  100623. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100624. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100625. */
  100626. vars: any;
  100627. /**
  100628. * This array is populated when the SPS is set as 'pickable'.
  100629. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100630. * Each element of this array is an object `{idx: int, faceId: int}`.
  100631. * `idx` is the picked particle index in the `SPS.particles` array
  100632. * `faceId` is the picked face index counted within this particle.
  100633. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  100634. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  100635. * Use the method SPS.pickedParticle(pickingInfo) instead.
  100636. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100637. */
  100638. pickedParticles: {
  100639. idx: number;
  100640. faceId: number;
  100641. }[];
  100642. /**
  100643. * This array is populated when the SPS is set as 'pickable'
  100644. * Each key of this array is a submesh index.
  100645. * Each element of this array is a second array defined like this :
  100646. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  100647. * Each element of this second array is an object `{idx: int, faceId: int}`.
  100648. * `idx` is the picked particle index in the `SPS.particles` array
  100649. * `faceId` is the picked face index counted within this particle.
  100650. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  100651. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100652. */
  100653. pickedBySubMesh: {
  100654. idx: number;
  100655. faceId: number;
  100656. }[][];
  100657. /**
  100658. * This array is populated when `enableDepthSort` is set to true.
  100659. * Each element of this array is an instance of the class DepthSortedParticle.
  100660. */
  100661. depthSortedParticles: DepthSortedParticle[];
  100662. /**
  100663. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100664. * @hidden
  100665. */
  100666. _bSphereOnly: boolean;
  100667. /**
  100668. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100669. * @hidden
  100670. */
  100671. _bSphereRadiusFactor: number;
  100672. private _scene;
  100673. private _positions;
  100674. private _indices;
  100675. private _normals;
  100676. private _colors;
  100677. private _uvs;
  100678. private _indices32;
  100679. private _positions32;
  100680. private _normals32;
  100681. private _fixedNormal32;
  100682. private _colors32;
  100683. private _uvs32;
  100684. private _index;
  100685. private _updatable;
  100686. private _pickable;
  100687. private _isVisibilityBoxLocked;
  100688. private _alwaysVisible;
  100689. private _depthSort;
  100690. private _expandable;
  100691. private _shapeCounter;
  100692. private _copy;
  100693. private _color;
  100694. private _computeParticleColor;
  100695. private _computeParticleTexture;
  100696. private _computeParticleRotation;
  100697. private _computeParticleVertex;
  100698. private _computeBoundingBox;
  100699. private _depthSortParticles;
  100700. private _camera;
  100701. private _mustUnrotateFixedNormals;
  100702. private _particlesIntersect;
  100703. private _needs32Bits;
  100704. private _isNotBuilt;
  100705. private _lastParticleId;
  100706. private _idxOfId;
  100707. private _multimaterialEnabled;
  100708. private _useModelMaterial;
  100709. private _indicesByMaterial;
  100710. private _materialIndexes;
  100711. private _depthSortFunction;
  100712. private _materialSortFunction;
  100713. private _materials;
  100714. private _multimaterial;
  100715. private _materialIndexesById;
  100716. private _defaultMaterial;
  100717. private _autoUpdateSubMeshes;
  100718. /**
  100719. * Creates a SPS (Solid Particle System) object.
  100720. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100721. * @param scene (Scene) is the scene in which the SPS is added.
  100722. * @param options defines the options of the sps e.g.
  100723. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100724. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100725. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100726. * * 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.
  100727. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100728. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100729. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100730. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100731. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100732. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100733. */
  100734. constructor(name: string, scene: Scene, options?: {
  100735. updatable?: boolean;
  100736. isPickable?: boolean;
  100737. enableDepthSort?: boolean;
  100738. particleIntersection?: boolean;
  100739. boundingSphereOnly?: boolean;
  100740. bSphereRadiusFactor?: number;
  100741. expandable?: boolean;
  100742. useModelMaterial?: boolean;
  100743. enableMultiMaterial?: boolean;
  100744. });
  100745. /**
  100746. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100747. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100748. * @returns the created mesh
  100749. */
  100750. buildMesh(): Mesh;
  100751. /**
  100752. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100753. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100754. * Thus the particles generated from `digest()` have their property `position` set yet.
  100755. * @param mesh ( Mesh ) is the mesh to be digested
  100756. * @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
  100757. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100758. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100759. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100760. * @returns the current SPS
  100761. */
  100762. digest(mesh: Mesh, options?: {
  100763. facetNb?: number;
  100764. number?: number;
  100765. delta?: number;
  100766. storage?: [];
  100767. }): SolidParticleSystem;
  100768. /**
  100769. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100770. * @hidden
  100771. */
  100772. private _unrotateFixedNormals;
  100773. /**
  100774. * Resets the temporary working copy particle
  100775. * @hidden
  100776. */
  100777. private _resetCopy;
  100778. /**
  100779. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100780. * @param p the current index in the positions array to be updated
  100781. * @param ind the current index in the indices array
  100782. * @param shape a Vector3 array, the shape geometry
  100783. * @param positions the positions array to be updated
  100784. * @param meshInd the shape indices array
  100785. * @param indices the indices array to be updated
  100786. * @param meshUV the shape uv array
  100787. * @param uvs the uv array to be updated
  100788. * @param meshCol the shape color array
  100789. * @param colors the color array to be updated
  100790. * @param meshNor the shape normals array
  100791. * @param normals the normals array to be updated
  100792. * @param idx the particle index
  100793. * @param idxInShape the particle index in its shape
  100794. * @param options the addShape() method passed options
  100795. * @model the particle model
  100796. * @hidden
  100797. */
  100798. private _meshBuilder;
  100799. /**
  100800. * Returns a shape Vector3 array from positions float array
  100801. * @param positions float array
  100802. * @returns a vector3 array
  100803. * @hidden
  100804. */
  100805. private _posToShape;
  100806. /**
  100807. * Returns a shapeUV array from a float uvs (array deep copy)
  100808. * @param uvs as a float array
  100809. * @returns a shapeUV array
  100810. * @hidden
  100811. */
  100812. private _uvsToShapeUV;
  100813. /**
  100814. * Adds a new particle object in the particles array
  100815. * @param idx particle index in particles array
  100816. * @param id particle id
  100817. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100818. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100819. * @param model particle ModelShape object
  100820. * @param shapeId model shape identifier
  100821. * @param idxInShape index of the particle in the current model
  100822. * @param bInfo model bounding info object
  100823. * @param storage target storage array, if any
  100824. * @hidden
  100825. */
  100826. private _addParticle;
  100827. /**
  100828. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100829. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100830. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100831. * @param nb (positive integer) the number of particles to be created from this model
  100832. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100833. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100834. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100835. * @returns the number of shapes in the system
  100836. */
  100837. addShape(mesh: Mesh, nb: number, options?: {
  100838. positionFunction?: any;
  100839. vertexFunction?: any;
  100840. storage?: [];
  100841. }): number;
  100842. /**
  100843. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100844. * @hidden
  100845. */
  100846. private _rebuildParticle;
  100847. /**
  100848. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100849. * @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.
  100850. * @returns the SPS.
  100851. */
  100852. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100853. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100854. * Returns an array with the removed particles.
  100855. * 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.
  100856. * The SPS can't be empty so at least one particle needs to remain in place.
  100857. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100858. * @param start index of the first particle to remove
  100859. * @param end index of the last particle to remove (included)
  100860. * @returns an array populated with the removed particles
  100861. */
  100862. removeParticles(start: number, end: number): SolidParticle[];
  100863. /**
  100864. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100865. * @param solidParticleArray an array populated with Solid Particles objects
  100866. * @returns the SPS
  100867. */
  100868. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100869. /**
  100870. * Creates a new particle and modifies the SPS mesh geometry :
  100871. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100872. * - calls _addParticle() to populate the particle array
  100873. * factorized code from addShape() and insertParticlesFromArray()
  100874. * @param idx particle index in the particles array
  100875. * @param i particle index in its shape
  100876. * @param modelShape particle ModelShape object
  100877. * @param shape shape vertex array
  100878. * @param meshInd shape indices array
  100879. * @param meshUV shape uv array
  100880. * @param meshCol shape color array
  100881. * @param meshNor shape normals array
  100882. * @param bbInfo shape bounding info
  100883. * @param storage target particle storage
  100884. * @options addShape() passed options
  100885. * @hidden
  100886. */
  100887. private _insertNewParticle;
  100888. /**
  100889. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100890. * This method calls `updateParticle()` for each particle of the SPS.
  100891. * For an animated SPS, it is usually called within the render loop.
  100892. * 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.
  100893. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100894. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100895. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100896. * @returns the SPS.
  100897. */
  100898. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100899. /**
  100900. * Disposes the SPS.
  100901. */
  100902. dispose(): void;
  100903. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  100904. * idx is the particle index in the SPS
  100905. * faceId is the picked face index counted within this particle.
  100906. * Returns null if the pickInfo can't identify a picked particle.
  100907. * @param pickingInfo (PickingInfo object)
  100908. * @returns {idx: number, faceId: number} or null
  100909. */
  100910. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  100911. idx: number;
  100912. faceId: number;
  100913. }>;
  100914. /**
  100915. * Returns a SolidParticle object from its identifier : particle.id
  100916. * @param id (integer) the particle Id
  100917. * @returns the searched particle or null if not found in the SPS.
  100918. */
  100919. getParticleById(id: number): Nullable<SolidParticle>;
  100920. /**
  100921. * Returns a new array populated with the particles having the passed shapeId.
  100922. * @param shapeId (integer) the shape identifier
  100923. * @returns a new solid particle array
  100924. */
  100925. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100926. /**
  100927. * Populates the passed array "ref" with the particles having the passed shapeId.
  100928. * @param shapeId the shape identifier
  100929. * @returns the SPS
  100930. * @param ref
  100931. */
  100932. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100933. /**
  100934. * Computes the required SubMeshes according the materials assigned to the particles.
  100935. * @returns the solid particle system.
  100936. * Does nothing if called before the SPS mesh is built.
  100937. */
  100938. computeSubMeshes(): SolidParticleSystem;
  100939. /**
  100940. * Sorts the solid particles by material when MultiMaterial is enabled.
  100941. * Updates the indices32 array.
  100942. * Updates the indicesByMaterial array.
  100943. * Updates the mesh indices array.
  100944. * @returns the SPS
  100945. * @hidden
  100946. */
  100947. private _sortParticlesByMaterial;
  100948. /**
  100949. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100950. * @hidden
  100951. */
  100952. private _setMaterialIndexesById;
  100953. /**
  100954. * Returns an array with unique values of Materials from the passed array
  100955. * @param array the material array to be checked and filtered
  100956. * @hidden
  100957. */
  100958. private _filterUniqueMaterialId;
  100959. /**
  100960. * Sets a new Standard Material as _defaultMaterial if not already set.
  100961. * @hidden
  100962. */
  100963. private _setDefaultMaterial;
  100964. /**
  100965. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100966. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100967. * @returns the SPS.
  100968. */
  100969. refreshVisibleSize(): SolidParticleSystem;
  100970. /**
  100971. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100972. * @param size the size (float) of the visibility box
  100973. * note : this doesn't lock the SPS mesh bounding box.
  100974. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100975. */
  100976. setVisibilityBox(size: number): void;
  100977. /**
  100978. * Gets whether the SPS as always visible or not
  100979. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100980. */
  100981. get isAlwaysVisible(): boolean;
  100982. /**
  100983. * Sets the SPS as always visible or not
  100984. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100985. */
  100986. set isAlwaysVisible(val: boolean);
  100987. /**
  100988. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100989. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100990. */
  100991. set isVisibilityBoxLocked(val: boolean);
  100992. /**
  100993. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100994. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100995. */
  100996. get isVisibilityBoxLocked(): boolean;
  100997. /**
  100998. * Tells to `setParticles()` to compute the particle rotations or not.
  100999. * Default value : true. The SPS is faster when it's set to false.
  101000. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101001. */
  101002. set computeParticleRotation(val: boolean);
  101003. /**
  101004. * Tells to `setParticles()` to compute the particle colors or not.
  101005. * Default value : true. The SPS is faster when it's set to false.
  101006. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101007. */
  101008. set computeParticleColor(val: boolean);
  101009. set computeParticleTexture(val: boolean);
  101010. /**
  101011. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101012. * Default value : false. The SPS is faster when it's set to false.
  101013. * Note : the particle custom vertex positions aren't stored values.
  101014. */
  101015. set computeParticleVertex(val: boolean);
  101016. /**
  101017. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101018. */
  101019. set computeBoundingBox(val: boolean);
  101020. /**
  101021. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101022. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101023. * Default : `true`
  101024. */
  101025. set depthSortParticles(val: boolean);
  101026. /**
  101027. * Gets if `setParticles()` computes the particle rotations or not.
  101028. * Default value : true. The SPS is faster when it's set to false.
  101029. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101030. */
  101031. get computeParticleRotation(): boolean;
  101032. /**
  101033. * Gets if `setParticles()` computes the particle colors or not.
  101034. * Default value : true. The SPS is faster when it's set to false.
  101035. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101036. */
  101037. get computeParticleColor(): boolean;
  101038. /**
  101039. * Gets if `setParticles()` computes the particle textures or not.
  101040. * Default value : true. The SPS is faster when it's set to false.
  101041. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101042. */
  101043. get computeParticleTexture(): boolean;
  101044. /**
  101045. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101046. * Default value : false. The SPS is faster when it's set to false.
  101047. * Note : the particle custom vertex positions aren't stored values.
  101048. */
  101049. get computeParticleVertex(): boolean;
  101050. /**
  101051. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101052. */
  101053. get computeBoundingBox(): boolean;
  101054. /**
  101055. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101056. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101057. * Default : `true`
  101058. */
  101059. get depthSortParticles(): boolean;
  101060. /**
  101061. * Gets if the SPS is created as expandable at construction time.
  101062. * Default : `false`
  101063. */
  101064. get expandable(): boolean;
  101065. /**
  101066. * Gets if the SPS supports the Multi Materials
  101067. */
  101068. get multimaterialEnabled(): boolean;
  101069. /**
  101070. * Gets if the SPS uses the model materials for its own multimaterial.
  101071. */
  101072. get useModelMaterial(): boolean;
  101073. /**
  101074. * The SPS used material array.
  101075. */
  101076. get materials(): Material[];
  101077. /**
  101078. * Sets the SPS MultiMaterial from the passed materials.
  101079. * Note : the passed array is internally copied and not used then by reference.
  101080. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101081. */
  101082. setMultiMaterial(materials: Material[]): void;
  101083. /**
  101084. * The SPS computed multimaterial object
  101085. */
  101086. get multimaterial(): MultiMaterial;
  101087. set multimaterial(mm: MultiMaterial);
  101088. /**
  101089. * If the subMeshes must be updated on the next call to setParticles()
  101090. */
  101091. get autoUpdateSubMeshes(): boolean;
  101092. set autoUpdateSubMeshes(val: boolean);
  101093. /**
  101094. * This function does nothing. It may be overwritten to set all the particle first values.
  101095. * The SPS doesn't call this function, you may have to call it by your own.
  101096. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101097. */
  101098. initParticles(): void;
  101099. /**
  101100. * This function does nothing. It may be overwritten to recycle a particle.
  101101. * The SPS doesn't call this function, you may have to call it by your own.
  101102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101103. * @param particle The particle to recycle
  101104. * @returns the recycled particle
  101105. */
  101106. recycleParticle(particle: SolidParticle): SolidParticle;
  101107. /**
  101108. * Updates a particle : this function should be overwritten by the user.
  101109. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  101110. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101111. * @example : just set a particle position or velocity and recycle conditions
  101112. * @param particle The particle to update
  101113. * @returns the updated particle
  101114. */
  101115. updateParticle(particle: SolidParticle): SolidParticle;
  101116. /**
  101117. * Updates a vertex of a particle : it can be overwritten by the user.
  101118. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  101119. * @param particle the current particle
  101120. * @param vertex the current index of the current particle
  101121. * @param pt the index of the current vertex in the particle shape
  101122. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  101123. * @example : just set a vertex particle position
  101124. * @returns the updated vertex
  101125. */
  101126. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  101127. /**
  101128. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  101129. * This does nothing and may be overwritten by the user.
  101130. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101131. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101132. * @param update the boolean update value actually passed to setParticles()
  101133. */
  101134. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101135. /**
  101136. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  101137. * This will be passed three parameters.
  101138. * This does nothing and may be overwritten by the user.
  101139. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101140. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101141. * @param update the boolean update value actually passed to setParticles()
  101142. */
  101143. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101144. }
  101145. }
  101146. declare module BABYLON {
  101147. /**
  101148. * Represents one particle of a solid particle system.
  101149. */
  101150. export class SolidParticle {
  101151. /**
  101152. * particle global index
  101153. */
  101154. idx: number;
  101155. /**
  101156. * particle identifier
  101157. */
  101158. id: number;
  101159. /**
  101160. * The color of the particle
  101161. */
  101162. color: Nullable<Color4>;
  101163. /**
  101164. * The world space position of the particle.
  101165. */
  101166. position: Vector3;
  101167. /**
  101168. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  101169. */
  101170. rotation: Vector3;
  101171. /**
  101172. * The world space rotation quaternion of the particle.
  101173. */
  101174. rotationQuaternion: Nullable<Quaternion>;
  101175. /**
  101176. * The scaling of the particle.
  101177. */
  101178. scaling: Vector3;
  101179. /**
  101180. * The uvs of the particle.
  101181. */
  101182. uvs: Vector4;
  101183. /**
  101184. * The current speed of the particle.
  101185. */
  101186. velocity: Vector3;
  101187. /**
  101188. * The pivot point in the particle local space.
  101189. */
  101190. pivot: Vector3;
  101191. /**
  101192. * Must the particle be translated from its pivot point in its local space ?
  101193. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  101194. * Default : false
  101195. */
  101196. translateFromPivot: boolean;
  101197. /**
  101198. * Is the particle active or not ?
  101199. */
  101200. alive: boolean;
  101201. /**
  101202. * Is the particle visible or not ?
  101203. */
  101204. isVisible: boolean;
  101205. /**
  101206. * Index of this particle in the global "positions" array (Internal use)
  101207. * @hidden
  101208. */
  101209. _pos: number;
  101210. /**
  101211. * @hidden Index of this particle in the global "indices" array (Internal use)
  101212. */
  101213. _ind: number;
  101214. /**
  101215. * @hidden ModelShape of this particle (Internal use)
  101216. */
  101217. _model: ModelShape;
  101218. /**
  101219. * ModelShape id of this particle
  101220. */
  101221. shapeId: number;
  101222. /**
  101223. * Index of the particle in its shape id
  101224. */
  101225. idxInShape: number;
  101226. /**
  101227. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  101228. */
  101229. _modelBoundingInfo: BoundingInfo;
  101230. /**
  101231. * @hidden Particle BoundingInfo object (Internal use)
  101232. */
  101233. _boundingInfo: BoundingInfo;
  101234. /**
  101235. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  101236. */
  101237. _sps: SolidParticleSystem;
  101238. /**
  101239. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  101240. */
  101241. _stillInvisible: boolean;
  101242. /**
  101243. * @hidden Last computed particle rotation matrix
  101244. */
  101245. _rotationMatrix: number[];
  101246. /**
  101247. * Parent particle Id, if any.
  101248. * Default null.
  101249. */
  101250. parentId: Nullable<number>;
  101251. /**
  101252. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  101253. */
  101254. materialIndex: Nullable<number>;
  101255. /**
  101256. * Custom object or properties.
  101257. */
  101258. props: Nullable<any>;
  101259. /**
  101260. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  101261. * The possible values are :
  101262. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101263. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101264. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101265. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101266. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101267. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  101268. * */
  101269. cullingStrategy: number;
  101270. /**
  101271. * @hidden Internal global position in the SPS.
  101272. */
  101273. _globalPosition: Vector3;
  101274. /**
  101275. * Creates a Solid Particle object.
  101276. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  101277. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  101278. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  101279. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  101280. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  101281. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  101282. * @param shapeId (integer) is the model shape identifier in the SPS.
  101283. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  101284. * @param sps defines the sps it is associated to
  101285. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  101286. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  101287. */
  101288. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  101289. /**
  101290. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  101291. * @param target the particle target
  101292. * @returns the current particle
  101293. */
  101294. copyToRef(target: SolidParticle): SolidParticle;
  101295. /**
  101296. * Legacy support, changed scale to scaling
  101297. */
  101298. get scale(): Vector3;
  101299. /**
  101300. * Legacy support, changed scale to scaling
  101301. */
  101302. set scale(scale: Vector3);
  101303. /**
  101304. * Legacy support, changed quaternion to rotationQuaternion
  101305. */
  101306. get quaternion(): Nullable<Quaternion>;
  101307. /**
  101308. * Legacy support, changed quaternion to rotationQuaternion
  101309. */
  101310. set quaternion(q: Nullable<Quaternion>);
  101311. /**
  101312. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101313. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101314. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101315. * @returns true if it intersects
  101316. */
  101317. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101318. /**
  101319. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101320. * A particle is in the frustum if its bounding box intersects the frustum
  101321. * @param frustumPlanes defines the frustum to test
  101322. * @returns true if the particle is in the frustum planes
  101323. */
  101324. isInFrustum(frustumPlanes: Plane[]): boolean;
  101325. /**
  101326. * get the rotation matrix of the particle
  101327. * @hidden
  101328. */
  101329. getRotationMatrix(m: Matrix): void;
  101330. }
  101331. /**
  101332. * Represents the shape of the model used by one particle of a solid particle system.
  101333. * SPS internal tool, don't use it manually.
  101334. */
  101335. export class ModelShape {
  101336. /**
  101337. * The shape id
  101338. * @hidden
  101339. */
  101340. shapeID: number;
  101341. /**
  101342. * flat array of model positions (internal use)
  101343. * @hidden
  101344. */
  101345. _shape: Vector3[];
  101346. /**
  101347. * flat array of model UVs (internal use)
  101348. * @hidden
  101349. */
  101350. _shapeUV: number[];
  101351. /**
  101352. * color array of the model
  101353. * @hidden
  101354. */
  101355. _shapeColors: number[];
  101356. /**
  101357. * indices array of the model
  101358. * @hidden
  101359. */
  101360. _indices: number[];
  101361. /**
  101362. * normals array of the model
  101363. * @hidden
  101364. */
  101365. _normals: number[];
  101366. /**
  101367. * length of the shape in the model indices array (internal use)
  101368. * @hidden
  101369. */
  101370. _indicesLength: number;
  101371. /**
  101372. * Custom position function (internal use)
  101373. * @hidden
  101374. */
  101375. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  101376. /**
  101377. * Custom vertex function (internal use)
  101378. * @hidden
  101379. */
  101380. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  101381. /**
  101382. * Model material (internal use)
  101383. * @hidden
  101384. */
  101385. _material: Nullable<Material>;
  101386. /**
  101387. * 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.
  101388. * SPS internal tool, don't use it manually.
  101389. * @hidden
  101390. */
  101391. 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>);
  101392. }
  101393. /**
  101394. * Represents a Depth Sorted Particle in the solid particle system.
  101395. * @hidden
  101396. */
  101397. export class DepthSortedParticle {
  101398. /**
  101399. * Particle index
  101400. */
  101401. idx: number;
  101402. /**
  101403. * Index of the particle in the "indices" array
  101404. */
  101405. ind: number;
  101406. /**
  101407. * Length of the particle shape in the "indices" array
  101408. */
  101409. indicesLength: number;
  101410. /**
  101411. * Squared distance from the particle to the camera
  101412. */
  101413. sqDistance: number;
  101414. /**
  101415. * Material index when used with MultiMaterials
  101416. */
  101417. materialIndex: number;
  101418. /**
  101419. * Creates a new sorted particle
  101420. * @param materialIndex
  101421. */
  101422. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  101423. }
  101424. }
  101425. declare module BABYLON {
  101426. /**
  101427. * @hidden
  101428. */
  101429. export class _MeshCollisionData {
  101430. _checkCollisions: boolean;
  101431. _collisionMask: number;
  101432. _collisionGroup: number;
  101433. _collider: Nullable<Collider>;
  101434. _oldPositionForCollisions: Vector3;
  101435. _diffPositionForCollisions: Vector3;
  101436. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101437. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101438. }
  101439. }
  101440. declare module BABYLON {
  101441. /** @hidden */
  101442. class _FacetDataStorage {
  101443. facetPositions: Vector3[];
  101444. facetNormals: Vector3[];
  101445. facetPartitioning: number[][];
  101446. facetNb: number;
  101447. partitioningSubdivisions: number;
  101448. partitioningBBoxRatio: number;
  101449. facetDataEnabled: boolean;
  101450. facetParameters: any;
  101451. bbSize: Vector3;
  101452. subDiv: {
  101453. max: number;
  101454. X: number;
  101455. Y: number;
  101456. Z: number;
  101457. };
  101458. facetDepthSort: boolean;
  101459. facetDepthSortEnabled: boolean;
  101460. depthSortedIndices: IndicesArray;
  101461. depthSortedFacets: {
  101462. ind: number;
  101463. sqDistance: number;
  101464. }[];
  101465. facetDepthSortFunction: (f1: {
  101466. ind: number;
  101467. sqDistance: number;
  101468. }, f2: {
  101469. ind: number;
  101470. sqDistance: number;
  101471. }) => number;
  101472. facetDepthSortFrom: Vector3;
  101473. facetDepthSortOrigin: Vector3;
  101474. invertedMatrix: Matrix;
  101475. }
  101476. /**
  101477. * @hidden
  101478. **/
  101479. class _InternalAbstractMeshDataInfo {
  101480. _hasVertexAlpha: boolean;
  101481. _useVertexColors: boolean;
  101482. _numBoneInfluencers: number;
  101483. _applyFog: boolean;
  101484. _receiveShadows: boolean;
  101485. _facetData: _FacetDataStorage;
  101486. _visibility: number;
  101487. _skeleton: Nullable<Skeleton>;
  101488. _layerMask: number;
  101489. _computeBonesUsingShaders: boolean;
  101490. _isActive: boolean;
  101491. _onlyForInstances: boolean;
  101492. _isActiveIntermediate: boolean;
  101493. _onlyForInstancesIntermediate: boolean;
  101494. _actAsRegularMesh: boolean;
  101495. }
  101496. /**
  101497. * Class used to store all common mesh properties
  101498. */
  101499. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101500. /** No occlusion */
  101501. static OCCLUSION_TYPE_NONE: number;
  101502. /** Occlusion set to optimisitic */
  101503. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101504. /** Occlusion set to strict */
  101505. static OCCLUSION_TYPE_STRICT: number;
  101506. /** Use an accurante occlusion algorithm */
  101507. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101508. /** Use a conservative occlusion algorithm */
  101509. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101510. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101511. * Test order :
  101512. * Is the bounding sphere outside the frustum ?
  101513. * If not, are the bounding box vertices outside the frustum ?
  101514. * It not, then the cullable object is in the frustum.
  101515. */
  101516. static readonly CULLINGSTRATEGY_STANDARD: number;
  101517. /** Culling strategy : Bounding Sphere Only.
  101518. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101519. * It's also less accurate than the standard because some not visible objects can still be selected.
  101520. * Test : is the bounding sphere outside the frustum ?
  101521. * If not, then the cullable object is in the frustum.
  101522. */
  101523. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101524. /** Culling strategy : Optimistic Inclusion.
  101525. * This in an inclusion test first, then the standard exclusion test.
  101526. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101527. * 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.
  101528. * Anyway, it's as accurate as the standard strategy.
  101529. * Test :
  101530. * Is the cullable object bounding sphere center in the frustum ?
  101531. * If not, apply the default culling strategy.
  101532. */
  101533. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101534. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101535. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101536. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101537. * 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.
  101538. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101539. * Test :
  101540. * Is the cullable object bounding sphere center in the frustum ?
  101541. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101542. */
  101543. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101544. /**
  101545. * No billboard
  101546. */
  101547. static get BILLBOARDMODE_NONE(): number;
  101548. /** Billboard on X axis */
  101549. static get BILLBOARDMODE_X(): number;
  101550. /** Billboard on Y axis */
  101551. static get BILLBOARDMODE_Y(): number;
  101552. /** Billboard on Z axis */
  101553. static get BILLBOARDMODE_Z(): number;
  101554. /** Billboard on all axes */
  101555. static get BILLBOARDMODE_ALL(): number;
  101556. /** Billboard on using position instead of orientation */
  101557. static get BILLBOARDMODE_USE_POSITION(): number;
  101558. /** @hidden */
  101559. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101560. /**
  101561. * The culling strategy to use to check whether the mesh must be rendered or not.
  101562. * This value can be changed at any time and will be used on the next render mesh selection.
  101563. * The possible values are :
  101564. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101565. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101566. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101567. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101568. * Please read each static variable documentation to get details about the culling process.
  101569. * */
  101570. cullingStrategy: number;
  101571. /**
  101572. * Gets the number of facets in the mesh
  101573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101574. */
  101575. get facetNb(): number;
  101576. /**
  101577. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101579. */
  101580. get partitioningSubdivisions(): number;
  101581. set partitioningSubdivisions(nb: number);
  101582. /**
  101583. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101584. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101586. */
  101587. get partitioningBBoxRatio(): number;
  101588. set partitioningBBoxRatio(ratio: number);
  101589. /**
  101590. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101591. * Works only for updatable meshes.
  101592. * Doesn't work with multi-materials
  101593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101594. */
  101595. get mustDepthSortFacets(): boolean;
  101596. set mustDepthSortFacets(sort: boolean);
  101597. /**
  101598. * The location (Vector3) where the facet depth sort must be computed from.
  101599. * By default, the active camera position.
  101600. * Used only when facet depth sort is enabled
  101601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101602. */
  101603. get facetDepthSortFrom(): Vector3;
  101604. set facetDepthSortFrom(location: Vector3);
  101605. /**
  101606. * gets a boolean indicating if facetData is enabled
  101607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101608. */
  101609. get isFacetDataEnabled(): boolean;
  101610. /** @hidden */
  101611. _updateNonUniformScalingState(value: boolean): boolean;
  101612. /**
  101613. * An event triggered when this mesh collides with another one
  101614. */
  101615. onCollideObservable: Observable<AbstractMesh>;
  101616. /** Set a function to call when this mesh collides with another one */
  101617. set onCollide(callback: () => void);
  101618. /**
  101619. * An event triggered when the collision's position changes
  101620. */
  101621. onCollisionPositionChangeObservable: Observable<Vector3>;
  101622. /** Set a function to call when the collision's position changes */
  101623. set onCollisionPositionChange(callback: () => void);
  101624. /**
  101625. * An event triggered when material is changed
  101626. */
  101627. onMaterialChangedObservable: Observable<AbstractMesh>;
  101628. /**
  101629. * Gets or sets the orientation for POV movement & rotation
  101630. */
  101631. definedFacingForward: boolean;
  101632. /** @hidden */
  101633. _occlusionQuery: Nullable<WebGLQuery>;
  101634. /** @hidden */
  101635. _renderingGroup: Nullable<RenderingGroup>;
  101636. /**
  101637. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101638. */
  101639. get visibility(): number;
  101640. /**
  101641. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101642. */
  101643. set visibility(value: number);
  101644. /** Gets or sets the alpha index used to sort transparent meshes
  101645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101646. */
  101647. alphaIndex: number;
  101648. /**
  101649. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101650. */
  101651. isVisible: boolean;
  101652. /**
  101653. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101654. */
  101655. isPickable: boolean;
  101656. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101657. showSubMeshesBoundingBox: boolean;
  101658. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101659. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101660. */
  101661. isBlocker: boolean;
  101662. /**
  101663. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101664. */
  101665. enablePointerMoveEvents: boolean;
  101666. /**
  101667. * Specifies the rendering group id for this mesh (0 by default)
  101668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101669. */
  101670. renderingGroupId: number;
  101671. private _material;
  101672. /** Gets or sets current material */
  101673. get material(): Nullable<Material>;
  101674. set material(value: Nullable<Material>);
  101675. /**
  101676. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101677. * @see http://doc.babylonjs.com/babylon101/shadows
  101678. */
  101679. get receiveShadows(): boolean;
  101680. set receiveShadows(value: boolean);
  101681. /** Defines color to use when rendering outline */
  101682. outlineColor: Color3;
  101683. /** Define width to use when rendering outline */
  101684. outlineWidth: number;
  101685. /** Defines color to use when rendering overlay */
  101686. overlayColor: Color3;
  101687. /** Defines alpha to use when rendering overlay */
  101688. overlayAlpha: number;
  101689. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101690. get hasVertexAlpha(): boolean;
  101691. set hasVertexAlpha(value: boolean);
  101692. /** 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) */
  101693. get useVertexColors(): boolean;
  101694. set useVertexColors(value: boolean);
  101695. /**
  101696. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101697. */
  101698. get computeBonesUsingShaders(): boolean;
  101699. set computeBonesUsingShaders(value: boolean);
  101700. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101701. get numBoneInfluencers(): number;
  101702. set numBoneInfluencers(value: number);
  101703. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101704. get applyFog(): boolean;
  101705. set applyFog(value: boolean);
  101706. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101707. useOctreeForRenderingSelection: boolean;
  101708. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101709. useOctreeForPicking: boolean;
  101710. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101711. useOctreeForCollisions: boolean;
  101712. /**
  101713. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101714. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101715. */
  101716. get layerMask(): number;
  101717. set layerMask(value: number);
  101718. /**
  101719. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101720. */
  101721. alwaysSelectAsActiveMesh: boolean;
  101722. /**
  101723. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101724. */
  101725. doNotSyncBoundingInfo: boolean;
  101726. /**
  101727. * Gets or sets the current action manager
  101728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101729. */
  101730. actionManager: Nullable<AbstractActionManager>;
  101731. private _meshCollisionData;
  101732. /**
  101733. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101735. */
  101736. ellipsoid: Vector3;
  101737. /**
  101738. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101740. */
  101741. ellipsoidOffset: Vector3;
  101742. /**
  101743. * Gets or sets a collision mask used to mask collisions (default is -1).
  101744. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101745. */
  101746. get collisionMask(): number;
  101747. set collisionMask(mask: number);
  101748. /**
  101749. * Gets or sets the current collision group mask (-1 by default).
  101750. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101751. */
  101752. get collisionGroup(): number;
  101753. set collisionGroup(mask: number);
  101754. /**
  101755. * Defines edge width used when edgesRenderer is enabled
  101756. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101757. */
  101758. edgesWidth: number;
  101759. /**
  101760. * Defines edge color used when edgesRenderer is enabled
  101761. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101762. */
  101763. edgesColor: Color4;
  101764. /** @hidden */
  101765. _edgesRenderer: Nullable<IEdgesRenderer>;
  101766. /** @hidden */
  101767. _masterMesh: Nullable<AbstractMesh>;
  101768. /** @hidden */
  101769. _boundingInfo: Nullable<BoundingInfo>;
  101770. /** @hidden */
  101771. _renderId: number;
  101772. /**
  101773. * Gets or sets the list of subMeshes
  101774. * @see http://doc.babylonjs.com/how_to/multi_materials
  101775. */
  101776. subMeshes: SubMesh[];
  101777. /** @hidden */
  101778. _intersectionsInProgress: AbstractMesh[];
  101779. /** @hidden */
  101780. _unIndexed: boolean;
  101781. /** @hidden */
  101782. _lightSources: Light[];
  101783. /** Gets the list of lights affecting that mesh */
  101784. get lightSources(): Light[];
  101785. /** @hidden */
  101786. get _positions(): Nullable<Vector3[]>;
  101787. /** @hidden */
  101788. _waitingData: {
  101789. lods: Nullable<any>;
  101790. actions: Nullable<any>;
  101791. freezeWorldMatrix: Nullable<boolean>;
  101792. };
  101793. /** @hidden */
  101794. _bonesTransformMatrices: Nullable<Float32Array>;
  101795. /** @hidden */
  101796. _transformMatrixTexture: Nullable<RawTexture>;
  101797. /**
  101798. * Gets or sets a skeleton to apply skining transformations
  101799. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101800. */
  101801. set skeleton(value: Nullable<Skeleton>);
  101802. get skeleton(): Nullable<Skeleton>;
  101803. /**
  101804. * An event triggered when the mesh is rebuilt.
  101805. */
  101806. onRebuildObservable: Observable<AbstractMesh>;
  101807. /**
  101808. * Creates a new AbstractMesh
  101809. * @param name defines the name of the mesh
  101810. * @param scene defines the hosting scene
  101811. */
  101812. constructor(name: string, scene?: Nullable<Scene>);
  101813. /**
  101814. * Returns the string "AbstractMesh"
  101815. * @returns "AbstractMesh"
  101816. */
  101817. getClassName(): string;
  101818. /**
  101819. * Gets a string representation of the current mesh
  101820. * @param fullDetails defines a boolean indicating if full details must be included
  101821. * @returns a string representation of the current mesh
  101822. */
  101823. toString(fullDetails?: boolean): string;
  101824. /**
  101825. * @hidden
  101826. */
  101827. protected _getEffectiveParent(): Nullable<Node>;
  101828. /** @hidden */
  101829. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101830. /** @hidden */
  101831. _rebuild(): void;
  101832. /** @hidden */
  101833. _resyncLightSources(): void;
  101834. /** @hidden */
  101835. _resyncLightSource(light: Light): void;
  101836. /** @hidden */
  101837. _unBindEffect(): void;
  101838. /** @hidden */
  101839. _removeLightSource(light: Light, dispose: boolean): void;
  101840. private _markSubMeshesAsDirty;
  101841. /** @hidden */
  101842. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101843. /** @hidden */
  101844. _markSubMeshesAsAttributesDirty(): void;
  101845. /** @hidden */
  101846. _markSubMeshesAsMiscDirty(): void;
  101847. /**
  101848. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101849. */
  101850. get scaling(): Vector3;
  101851. set scaling(newScaling: Vector3);
  101852. /**
  101853. * Returns true if the mesh is blocked. Implemented by child classes
  101854. */
  101855. get isBlocked(): boolean;
  101856. /**
  101857. * Returns the mesh itself by default. Implemented by child classes
  101858. * @param camera defines the camera to use to pick the right LOD level
  101859. * @returns the currentAbstractMesh
  101860. */
  101861. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101862. /**
  101863. * Returns 0 by default. Implemented by child classes
  101864. * @returns an integer
  101865. */
  101866. getTotalVertices(): number;
  101867. /**
  101868. * Returns a positive integer : the total number of indices in this mesh geometry.
  101869. * @returns the numner of indices or zero if the mesh has no geometry.
  101870. */
  101871. getTotalIndices(): number;
  101872. /**
  101873. * Returns null by default. Implemented by child classes
  101874. * @returns null
  101875. */
  101876. getIndices(): Nullable<IndicesArray>;
  101877. /**
  101878. * Returns the array of the requested vertex data kind. Implemented by child classes
  101879. * @param kind defines the vertex data kind to use
  101880. * @returns null
  101881. */
  101882. getVerticesData(kind: string): Nullable<FloatArray>;
  101883. /**
  101884. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101885. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101886. * Note that a new underlying VertexBuffer object is created each call.
  101887. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101888. * @param kind defines vertex data kind:
  101889. * * VertexBuffer.PositionKind
  101890. * * VertexBuffer.UVKind
  101891. * * VertexBuffer.UV2Kind
  101892. * * VertexBuffer.UV3Kind
  101893. * * VertexBuffer.UV4Kind
  101894. * * VertexBuffer.UV5Kind
  101895. * * VertexBuffer.UV6Kind
  101896. * * VertexBuffer.ColorKind
  101897. * * VertexBuffer.MatricesIndicesKind
  101898. * * VertexBuffer.MatricesIndicesExtraKind
  101899. * * VertexBuffer.MatricesWeightsKind
  101900. * * VertexBuffer.MatricesWeightsExtraKind
  101901. * @param data defines the data source
  101902. * @param updatable defines if the data must be flagged as updatable (or static)
  101903. * @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
  101904. * @returns the current mesh
  101905. */
  101906. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101907. /**
  101908. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101909. * If the mesh has no geometry, it is simply returned as it is.
  101910. * @param kind defines vertex data kind:
  101911. * * VertexBuffer.PositionKind
  101912. * * VertexBuffer.UVKind
  101913. * * VertexBuffer.UV2Kind
  101914. * * VertexBuffer.UV3Kind
  101915. * * VertexBuffer.UV4Kind
  101916. * * VertexBuffer.UV5Kind
  101917. * * VertexBuffer.UV6Kind
  101918. * * VertexBuffer.ColorKind
  101919. * * VertexBuffer.MatricesIndicesKind
  101920. * * VertexBuffer.MatricesIndicesExtraKind
  101921. * * VertexBuffer.MatricesWeightsKind
  101922. * * VertexBuffer.MatricesWeightsExtraKind
  101923. * @param data defines the data source
  101924. * @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
  101925. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101926. * @returns the current mesh
  101927. */
  101928. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101929. /**
  101930. * Sets the mesh indices,
  101931. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101932. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101933. * @param totalVertices Defines the total number of vertices
  101934. * @returns the current mesh
  101935. */
  101936. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101937. /**
  101938. * Gets a boolean indicating if specific vertex data is present
  101939. * @param kind defines the vertex data kind to use
  101940. * @returns true is data kind is present
  101941. */
  101942. isVerticesDataPresent(kind: string): boolean;
  101943. /**
  101944. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101945. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101946. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101947. * @returns a BoundingInfo
  101948. */
  101949. getBoundingInfo(): BoundingInfo;
  101950. /**
  101951. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101952. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101953. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101954. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101955. * @returns the current mesh
  101956. */
  101957. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101958. /**
  101959. * Overwrite the current bounding info
  101960. * @param boundingInfo defines the new bounding info
  101961. * @returns the current mesh
  101962. */
  101963. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101964. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101965. get useBones(): boolean;
  101966. /** @hidden */
  101967. _preActivate(): void;
  101968. /** @hidden */
  101969. _preActivateForIntermediateRendering(renderId: number): void;
  101970. /** @hidden */
  101971. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101972. /** @hidden */
  101973. _postActivate(): void;
  101974. /** @hidden */
  101975. _freeze(): void;
  101976. /** @hidden */
  101977. _unFreeze(): void;
  101978. /**
  101979. * Gets the current world matrix
  101980. * @returns a Matrix
  101981. */
  101982. getWorldMatrix(): Matrix;
  101983. /** @hidden */
  101984. _getWorldMatrixDeterminant(): number;
  101985. /**
  101986. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101987. */
  101988. get isAnInstance(): boolean;
  101989. /**
  101990. * Gets a boolean indicating if this mesh has instances
  101991. */
  101992. get hasInstances(): boolean;
  101993. /**
  101994. * Perform relative position change from the point of view of behind the front of the mesh.
  101995. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101996. * Supports definition of mesh facing forward or backward
  101997. * @param amountRight defines the distance on the right axis
  101998. * @param amountUp defines the distance on the up axis
  101999. * @param amountForward defines the distance on the forward axis
  102000. * @returns the current mesh
  102001. */
  102002. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102003. /**
  102004. * Calculate relative position change from the point of view of behind the front of the mesh.
  102005. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102006. * Supports definition of mesh facing forward or backward
  102007. * @param amountRight defines the distance on the right axis
  102008. * @param amountUp defines the distance on the up axis
  102009. * @param amountForward defines the distance on the forward axis
  102010. * @returns the new displacement vector
  102011. */
  102012. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102013. /**
  102014. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102015. * Supports definition of mesh facing forward or backward
  102016. * @param flipBack defines the flip
  102017. * @param twirlClockwise defines the twirl
  102018. * @param tiltRight defines the tilt
  102019. * @returns the current mesh
  102020. */
  102021. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102022. /**
  102023. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102024. * Supports definition of mesh facing forward or backward.
  102025. * @param flipBack defines the flip
  102026. * @param twirlClockwise defines the twirl
  102027. * @param tiltRight defines the tilt
  102028. * @returns the new rotation vector
  102029. */
  102030. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102031. /**
  102032. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102033. * This means the mesh underlying bounding box and sphere are recomputed.
  102034. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102035. * @returns the current mesh
  102036. */
  102037. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102038. /** @hidden */
  102039. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102040. /** @hidden */
  102041. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102042. /** @hidden */
  102043. _updateBoundingInfo(): AbstractMesh;
  102044. /** @hidden */
  102045. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102046. /** @hidden */
  102047. protected _afterComputeWorldMatrix(): void;
  102048. /** @hidden */
  102049. get _effectiveMesh(): AbstractMesh;
  102050. /**
  102051. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102052. * A mesh is in the frustum if its bounding box intersects the frustum
  102053. * @param frustumPlanes defines the frustum to test
  102054. * @returns true if the mesh is in the frustum planes
  102055. */
  102056. isInFrustum(frustumPlanes: Plane[]): boolean;
  102057. /**
  102058. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102059. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102060. * @param frustumPlanes defines the frustum to test
  102061. * @returns true if the mesh is completely in the frustum planes
  102062. */
  102063. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102064. /**
  102065. * True if the mesh intersects another mesh or a SolidParticle object
  102066. * @param mesh defines a target mesh or SolidParticle to test
  102067. * @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)
  102068. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102069. * @returns true if there is an intersection
  102070. */
  102071. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102072. /**
  102073. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102074. * @param point defines the point to test
  102075. * @returns true if there is an intersection
  102076. */
  102077. intersectsPoint(point: Vector3): boolean;
  102078. /**
  102079. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102081. */
  102082. get checkCollisions(): boolean;
  102083. set checkCollisions(collisionEnabled: boolean);
  102084. /**
  102085. * Gets Collider object used to compute collisions (not physics)
  102086. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102087. */
  102088. get collider(): Nullable<Collider>;
  102089. /**
  102090. * Move the mesh using collision engine
  102091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102092. * @param displacement defines the requested displacement vector
  102093. * @returns the current mesh
  102094. */
  102095. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102096. private _onCollisionPositionChange;
  102097. /** @hidden */
  102098. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  102099. /** @hidden */
  102100. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  102101. /** @hidden */
  102102. _checkCollision(collider: Collider): AbstractMesh;
  102103. /** @hidden */
  102104. _generatePointsArray(): boolean;
  102105. /**
  102106. * Checks if the passed Ray intersects with the mesh
  102107. * @param ray defines the ray to use
  102108. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  102109. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102110. * @returns the picking info
  102111. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  102112. */
  102113. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  102114. /**
  102115. * Clones the current mesh
  102116. * @param name defines the mesh name
  102117. * @param newParent defines the new mesh parent
  102118. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  102119. * @returns the new mesh
  102120. */
  102121. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  102122. /**
  102123. * Disposes all the submeshes of the current meshnp
  102124. * @returns the current mesh
  102125. */
  102126. releaseSubMeshes(): AbstractMesh;
  102127. /**
  102128. * Releases resources associated with this abstract mesh.
  102129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102131. */
  102132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102133. /**
  102134. * Adds the passed mesh as a child to the current mesh
  102135. * @param mesh defines the child mesh
  102136. * @returns the current mesh
  102137. */
  102138. addChild(mesh: AbstractMesh): AbstractMesh;
  102139. /**
  102140. * Removes the passed mesh from the current mesh children list
  102141. * @param mesh defines the child mesh
  102142. * @returns the current mesh
  102143. */
  102144. removeChild(mesh: AbstractMesh): AbstractMesh;
  102145. /** @hidden */
  102146. private _initFacetData;
  102147. /**
  102148. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  102149. * This method can be called within the render loop.
  102150. * 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
  102151. * @returns the current mesh
  102152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102153. */
  102154. updateFacetData(): AbstractMesh;
  102155. /**
  102156. * Returns the facetLocalNormals array.
  102157. * The normals are expressed in the mesh local spac
  102158. * @returns an array of Vector3
  102159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102160. */
  102161. getFacetLocalNormals(): Vector3[];
  102162. /**
  102163. * Returns the facetLocalPositions array.
  102164. * The facet positions are expressed in the mesh local space
  102165. * @returns an array of Vector3
  102166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102167. */
  102168. getFacetLocalPositions(): Vector3[];
  102169. /**
  102170. * Returns the facetLocalPartioning array
  102171. * @returns an array of array of numbers
  102172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102173. */
  102174. getFacetLocalPartitioning(): number[][];
  102175. /**
  102176. * Returns the i-th facet position in the world system.
  102177. * This method allocates a new Vector3 per call
  102178. * @param i defines the facet index
  102179. * @returns a new Vector3
  102180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102181. */
  102182. getFacetPosition(i: number): Vector3;
  102183. /**
  102184. * Sets the reference Vector3 with the i-th facet position in the world system
  102185. * @param i defines the facet index
  102186. * @param ref defines the target vector
  102187. * @returns the current mesh
  102188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102189. */
  102190. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  102191. /**
  102192. * Returns the i-th facet normal in the world system.
  102193. * This method allocates a new Vector3 per call
  102194. * @param i defines the facet index
  102195. * @returns a new Vector3
  102196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102197. */
  102198. getFacetNormal(i: number): Vector3;
  102199. /**
  102200. * Sets the reference Vector3 with the i-th facet normal in the world system
  102201. * @param i defines the facet index
  102202. * @param ref defines the target vector
  102203. * @returns the current mesh
  102204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102205. */
  102206. getFacetNormalToRef(i: number, ref: Vector3): this;
  102207. /**
  102208. * 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)
  102209. * @param x defines x coordinate
  102210. * @param y defines y coordinate
  102211. * @param z defines z coordinate
  102212. * @returns the array of facet indexes
  102213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102214. */
  102215. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  102216. /**
  102217. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  102218. * @param projected sets as the (x,y,z) world projection on the facet
  102219. * @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
  102220. * @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
  102221. * @param x defines x coordinate
  102222. * @param y defines y coordinate
  102223. * @param z defines z coordinate
  102224. * @returns the face index if found (or null instead)
  102225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102226. */
  102227. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102228. /**
  102229. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  102230. * @param projected sets as the (x,y,z) local projection on the facet
  102231. * @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
  102232. * @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
  102233. * @param x defines x coordinate
  102234. * @param y defines y coordinate
  102235. * @param z defines z coordinate
  102236. * @returns the face index if found (or null instead)
  102237. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102238. */
  102239. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102240. /**
  102241. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  102242. * @returns the parameters
  102243. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102244. */
  102245. getFacetDataParameters(): any;
  102246. /**
  102247. * Disables the feature FacetData and frees the related memory
  102248. * @returns the current mesh
  102249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102250. */
  102251. disableFacetData(): AbstractMesh;
  102252. /**
  102253. * Updates the AbstractMesh indices array
  102254. * @param indices defines the data source
  102255. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  102256. * @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)
  102257. * @returns the current mesh
  102258. */
  102259. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  102260. /**
  102261. * Creates new normals data for the mesh
  102262. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  102263. * @returns the current mesh
  102264. */
  102265. createNormals(updatable: boolean): AbstractMesh;
  102266. /**
  102267. * Align the mesh with a normal
  102268. * @param normal defines the normal to use
  102269. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  102270. * @returns the current mesh
  102271. */
  102272. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  102273. /** @hidden */
  102274. _checkOcclusionQuery(): boolean;
  102275. /**
  102276. * Disables the mesh edge rendering mode
  102277. * @returns the currentAbstractMesh
  102278. */
  102279. disableEdgesRendering(): AbstractMesh;
  102280. /**
  102281. * Enables the edge rendering mode on the mesh.
  102282. * This mode makes the mesh edges visible
  102283. * @param epsilon defines the maximal distance between two angles to detect a face
  102284. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  102285. * @returns the currentAbstractMesh
  102286. * @see https://www.babylonjs-playground.com/#19O9TU#0
  102287. */
  102288. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  102289. }
  102290. }
  102291. declare module BABYLON {
  102292. /**
  102293. * Interface used to define ActionEvent
  102294. */
  102295. export interface IActionEvent {
  102296. /** The mesh or sprite that triggered the action */
  102297. source: any;
  102298. /** The X mouse cursor position at the time of the event */
  102299. pointerX: number;
  102300. /** The Y mouse cursor position at the time of the event */
  102301. pointerY: number;
  102302. /** The mesh that is currently pointed at (can be null) */
  102303. meshUnderPointer: Nullable<AbstractMesh>;
  102304. /** the original (browser) event that triggered the ActionEvent */
  102305. sourceEvent?: any;
  102306. /** additional data for the event */
  102307. additionalData?: any;
  102308. }
  102309. /**
  102310. * ActionEvent is the event being sent when an action is triggered.
  102311. */
  102312. export class ActionEvent implements IActionEvent {
  102313. /** The mesh or sprite that triggered the action */
  102314. source: any;
  102315. /** The X mouse cursor position at the time of the event */
  102316. pointerX: number;
  102317. /** The Y mouse cursor position at the time of the event */
  102318. pointerY: number;
  102319. /** The mesh that is currently pointed at (can be null) */
  102320. meshUnderPointer: Nullable<AbstractMesh>;
  102321. /** the original (browser) event that triggered the ActionEvent */
  102322. sourceEvent?: any;
  102323. /** additional data for the event */
  102324. additionalData?: any;
  102325. /**
  102326. * Creates a new ActionEvent
  102327. * @param source The mesh or sprite that triggered the action
  102328. * @param pointerX The X mouse cursor position at the time of the event
  102329. * @param pointerY The Y mouse cursor position at the time of the event
  102330. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102331. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102332. * @param additionalData additional data for the event
  102333. */
  102334. constructor(
  102335. /** The mesh or sprite that triggered the action */
  102336. source: any,
  102337. /** The X mouse cursor position at the time of the event */
  102338. pointerX: number,
  102339. /** The Y mouse cursor position at the time of the event */
  102340. pointerY: number,
  102341. /** The mesh that is currently pointed at (can be null) */
  102342. meshUnderPointer: Nullable<AbstractMesh>,
  102343. /** the original (browser) event that triggered the ActionEvent */
  102344. sourceEvent?: any,
  102345. /** additional data for the event */
  102346. additionalData?: any);
  102347. /**
  102348. * Helper function to auto-create an ActionEvent from a source mesh.
  102349. * @param source The source mesh that triggered the event
  102350. * @param evt The original (browser) event
  102351. * @param additionalData additional data for the event
  102352. * @returns the new ActionEvent
  102353. */
  102354. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  102355. /**
  102356. * Helper function to auto-create an ActionEvent from a source sprite
  102357. * @param source The source sprite that triggered the event
  102358. * @param scene Scene associated with the sprite
  102359. * @param evt The original (browser) event
  102360. * @param additionalData additional data for the event
  102361. * @returns the new ActionEvent
  102362. */
  102363. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  102364. /**
  102365. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  102366. * @param scene the scene where the event occurred
  102367. * @param evt The original (browser) event
  102368. * @returns the new ActionEvent
  102369. */
  102370. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  102371. /**
  102372. * Helper function to auto-create an ActionEvent from a primitive
  102373. * @param prim defines the target primitive
  102374. * @param pointerPos defines the pointer position
  102375. * @param evt The original (browser) event
  102376. * @param additionalData additional data for the event
  102377. * @returns the new ActionEvent
  102378. */
  102379. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  102380. }
  102381. }
  102382. declare module BABYLON {
  102383. /**
  102384. * Abstract class used to decouple action Manager from scene and meshes.
  102385. * Do not instantiate.
  102386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102387. */
  102388. export abstract class AbstractActionManager implements IDisposable {
  102389. /** Gets the list of active triggers */
  102390. static Triggers: {
  102391. [key: string]: number;
  102392. };
  102393. /** Gets the cursor to use when hovering items */
  102394. hoverCursor: string;
  102395. /** Gets the list of actions */
  102396. actions: IAction[];
  102397. /**
  102398. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  102399. */
  102400. isRecursive: boolean;
  102401. /**
  102402. * Releases all associated resources
  102403. */
  102404. abstract dispose(): void;
  102405. /**
  102406. * Does this action manager has pointer triggers
  102407. */
  102408. abstract get hasPointerTriggers(): boolean;
  102409. /**
  102410. * Does this action manager has pick triggers
  102411. */
  102412. abstract get hasPickTriggers(): boolean;
  102413. /**
  102414. * Process a specific trigger
  102415. * @param trigger defines the trigger to process
  102416. * @param evt defines the event details to be processed
  102417. */
  102418. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102419. /**
  102420. * Does this action manager handles actions of any of the given triggers
  102421. * @param triggers defines the triggers to be tested
  102422. * @return a boolean indicating whether one (or more) of the triggers is handled
  102423. */
  102424. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102425. /**
  102426. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102427. * speed.
  102428. * @param triggerA defines the trigger to be tested
  102429. * @param triggerB defines the trigger to be tested
  102430. * @return a boolean indicating whether one (or more) of the triggers is handled
  102431. */
  102432. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102433. /**
  102434. * Does this action manager handles actions of a given trigger
  102435. * @param trigger defines the trigger to be tested
  102436. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102437. * @return whether the trigger is handled
  102438. */
  102439. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102440. /**
  102441. * Serialize this manager to a JSON object
  102442. * @param name defines the property name to store this manager
  102443. * @returns a JSON representation of this manager
  102444. */
  102445. abstract serialize(name: string): any;
  102446. /**
  102447. * Registers an action to this action manager
  102448. * @param action defines the action to be registered
  102449. * @return the action amended (prepared) after registration
  102450. */
  102451. abstract registerAction(action: IAction): Nullable<IAction>;
  102452. /**
  102453. * Unregisters an action to this action manager
  102454. * @param action defines the action to be unregistered
  102455. * @return a boolean indicating whether the action has been unregistered
  102456. */
  102457. abstract unregisterAction(action: IAction): Boolean;
  102458. /**
  102459. * Does exist one action manager with at least one trigger
  102460. **/
  102461. static get HasTriggers(): boolean;
  102462. /**
  102463. * Does exist one action manager with at least one pick trigger
  102464. **/
  102465. static get HasPickTriggers(): boolean;
  102466. /**
  102467. * Does exist one action manager that handles actions of a given trigger
  102468. * @param trigger defines the trigger to be tested
  102469. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102470. **/
  102471. static HasSpecificTrigger(trigger: number): boolean;
  102472. }
  102473. }
  102474. declare module BABYLON {
  102475. /**
  102476. * Defines how a node can be built from a string name.
  102477. */
  102478. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102479. /**
  102480. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102481. */
  102482. export class Node implements IBehaviorAware<Node> {
  102483. /** @hidden */
  102484. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102485. private static _NodeConstructors;
  102486. /**
  102487. * Add a new node constructor
  102488. * @param type defines the type name of the node to construct
  102489. * @param constructorFunc defines the constructor function
  102490. */
  102491. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102492. /**
  102493. * Returns a node constructor based on type name
  102494. * @param type defines the type name
  102495. * @param name defines the new node name
  102496. * @param scene defines the hosting scene
  102497. * @param options defines optional options to transmit to constructors
  102498. * @returns the new constructor or null
  102499. */
  102500. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102501. /**
  102502. * Gets or sets the name of the node
  102503. */
  102504. name: string;
  102505. /**
  102506. * Gets or sets the id of the node
  102507. */
  102508. id: string;
  102509. /**
  102510. * Gets or sets the unique id of the node
  102511. */
  102512. uniqueId: number;
  102513. /**
  102514. * Gets or sets a string used to store user defined state for the node
  102515. */
  102516. state: string;
  102517. /**
  102518. * Gets or sets an object used to store user defined information for the node
  102519. */
  102520. metadata: any;
  102521. /**
  102522. * For internal use only. Please do not use.
  102523. */
  102524. reservedDataStore: any;
  102525. /**
  102526. * List of inspectable custom properties (used by the Inspector)
  102527. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102528. */
  102529. inspectableCustomProperties: IInspectable[];
  102530. private _doNotSerialize;
  102531. /**
  102532. * Gets or sets a boolean used to define if the node must be serialized
  102533. */
  102534. get doNotSerialize(): boolean;
  102535. set doNotSerialize(value: boolean);
  102536. /** @hidden */
  102537. _isDisposed: boolean;
  102538. /**
  102539. * Gets a list of Animations associated with the node
  102540. */
  102541. animations: Animation[];
  102542. protected _ranges: {
  102543. [name: string]: Nullable<AnimationRange>;
  102544. };
  102545. /**
  102546. * Callback raised when the node is ready to be used
  102547. */
  102548. onReady: Nullable<(node: Node) => void>;
  102549. private _isEnabled;
  102550. private _isParentEnabled;
  102551. private _isReady;
  102552. /** @hidden */
  102553. _currentRenderId: number;
  102554. private _parentUpdateId;
  102555. /** @hidden */
  102556. _childUpdateId: number;
  102557. /** @hidden */
  102558. _waitingParentId: Nullable<string>;
  102559. /** @hidden */
  102560. _scene: Scene;
  102561. /** @hidden */
  102562. _cache: any;
  102563. private _parentNode;
  102564. private _children;
  102565. /** @hidden */
  102566. _worldMatrix: Matrix;
  102567. /** @hidden */
  102568. _worldMatrixDeterminant: number;
  102569. /** @hidden */
  102570. _worldMatrixDeterminantIsDirty: boolean;
  102571. /** @hidden */
  102572. private _sceneRootNodesIndex;
  102573. /**
  102574. * Gets a boolean indicating if the node has been disposed
  102575. * @returns true if the node was disposed
  102576. */
  102577. isDisposed(): boolean;
  102578. /**
  102579. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102580. * @see https://doc.babylonjs.com/how_to/parenting
  102581. */
  102582. set parent(parent: Nullable<Node>);
  102583. get parent(): Nullable<Node>;
  102584. /** @hidden */
  102585. _addToSceneRootNodes(): void;
  102586. /** @hidden */
  102587. _removeFromSceneRootNodes(): void;
  102588. private _animationPropertiesOverride;
  102589. /**
  102590. * Gets or sets the animation properties override
  102591. */
  102592. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102593. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102594. /**
  102595. * Gets a string idenfifying the name of the class
  102596. * @returns "Node" string
  102597. */
  102598. getClassName(): string;
  102599. /** @hidden */
  102600. readonly _isNode: boolean;
  102601. /**
  102602. * An event triggered when the mesh is disposed
  102603. */
  102604. onDisposeObservable: Observable<Node>;
  102605. private _onDisposeObserver;
  102606. /**
  102607. * Sets a callback that will be raised when the node will be disposed
  102608. */
  102609. set onDispose(callback: () => void);
  102610. /**
  102611. * Creates a new Node
  102612. * @param name the name and id to be given to this node
  102613. * @param scene the scene this node will be added to
  102614. */
  102615. constructor(name: string, scene?: Nullable<Scene>);
  102616. /**
  102617. * Gets the scene of the node
  102618. * @returns a scene
  102619. */
  102620. getScene(): Scene;
  102621. /**
  102622. * Gets the engine of the node
  102623. * @returns a Engine
  102624. */
  102625. getEngine(): Engine;
  102626. private _behaviors;
  102627. /**
  102628. * Attach a behavior to the node
  102629. * @see http://doc.babylonjs.com/features/behaviour
  102630. * @param behavior defines the behavior to attach
  102631. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102632. * @returns the current Node
  102633. */
  102634. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102635. /**
  102636. * Remove an attached behavior
  102637. * @see http://doc.babylonjs.com/features/behaviour
  102638. * @param behavior defines the behavior to attach
  102639. * @returns the current Node
  102640. */
  102641. removeBehavior(behavior: Behavior<Node>): Node;
  102642. /**
  102643. * Gets the list of attached behaviors
  102644. * @see http://doc.babylonjs.com/features/behaviour
  102645. */
  102646. get behaviors(): Behavior<Node>[];
  102647. /**
  102648. * Gets an attached behavior by name
  102649. * @param name defines the name of the behavior to look for
  102650. * @see http://doc.babylonjs.com/features/behaviour
  102651. * @returns null if behavior was not found else the requested behavior
  102652. */
  102653. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102654. /**
  102655. * Returns the latest update of the World matrix
  102656. * @returns a Matrix
  102657. */
  102658. getWorldMatrix(): Matrix;
  102659. /** @hidden */
  102660. _getWorldMatrixDeterminant(): number;
  102661. /**
  102662. * Returns directly the latest state of the mesh World matrix.
  102663. * A Matrix is returned.
  102664. */
  102665. get worldMatrixFromCache(): Matrix;
  102666. /** @hidden */
  102667. _initCache(): void;
  102668. /** @hidden */
  102669. updateCache(force?: boolean): void;
  102670. /** @hidden */
  102671. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102672. /** @hidden */
  102673. _updateCache(ignoreParentClass?: boolean): void;
  102674. /** @hidden */
  102675. _isSynchronized(): boolean;
  102676. /** @hidden */
  102677. _markSyncedWithParent(): void;
  102678. /** @hidden */
  102679. isSynchronizedWithParent(): boolean;
  102680. /** @hidden */
  102681. isSynchronized(): boolean;
  102682. /**
  102683. * Is this node ready to be used/rendered
  102684. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102685. * @return true if the node is ready
  102686. */
  102687. isReady(completeCheck?: boolean): boolean;
  102688. /**
  102689. * Is this node enabled?
  102690. * 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
  102691. * @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
  102692. * @return whether this node (and its parent) is enabled
  102693. */
  102694. isEnabled(checkAncestors?: boolean): boolean;
  102695. /** @hidden */
  102696. protected _syncParentEnabledState(): void;
  102697. /**
  102698. * Set the enabled state of this node
  102699. * @param value defines the new enabled state
  102700. */
  102701. setEnabled(value: boolean): void;
  102702. /**
  102703. * Is this node a descendant of the given node?
  102704. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102705. * @param ancestor defines the parent node to inspect
  102706. * @returns a boolean indicating if this node is a descendant of the given node
  102707. */
  102708. isDescendantOf(ancestor: Node): boolean;
  102709. /** @hidden */
  102710. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102711. /**
  102712. * Will return all nodes that have this node as ascendant
  102713. * @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
  102714. * @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
  102715. * @return all children nodes of all types
  102716. */
  102717. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102718. /**
  102719. * Get all child-meshes of this node
  102720. * @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)
  102721. * @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
  102722. * @returns an array of AbstractMesh
  102723. */
  102724. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102725. /**
  102726. * Get all direct children of this node
  102727. * @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
  102728. * @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)
  102729. * @returns an array of Node
  102730. */
  102731. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102732. /** @hidden */
  102733. _setReady(state: boolean): void;
  102734. /**
  102735. * Get an animation by name
  102736. * @param name defines the name of the animation to look for
  102737. * @returns null if not found else the requested animation
  102738. */
  102739. getAnimationByName(name: string): Nullable<Animation>;
  102740. /**
  102741. * Creates an animation range for this node
  102742. * @param name defines the name of the range
  102743. * @param from defines the starting key
  102744. * @param to defines the end key
  102745. */
  102746. createAnimationRange(name: string, from: number, to: number): void;
  102747. /**
  102748. * Delete a specific animation range
  102749. * @param name defines the name of the range to delete
  102750. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102751. */
  102752. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102753. /**
  102754. * Get an animation range by name
  102755. * @param name defines the name of the animation range to look for
  102756. * @returns null if not found else the requested animation range
  102757. */
  102758. getAnimationRange(name: string): Nullable<AnimationRange>;
  102759. /**
  102760. * Gets the list of all animation ranges defined on this node
  102761. * @returns an array
  102762. */
  102763. getAnimationRanges(): Nullable<AnimationRange>[];
  102764. /**
  102765. * Will start the animation sequence
  102766. * @param name defines the range frames for animation sequence
  102767. * @param loop defines if the animation should loop (false by default)
  102768. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102769. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102770. * @returns the object created for this animation. If range does not exist, it will return null
  102771. */
  102772. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102773. /**
  102774. * Serialize animation ranges into a JSON compatible object
  102775. * @returns serialization object
  102776. */
  102777. serializeAnimationRanges(): any;
  102778. /**
  102779. * Computes the world matrix of the node
  102780. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102781. * @returns the world matrix
  102782. */
  102783. computeWorldMatrix(force?: boolean): Matrix;
  102784. /**
  102785. * Releases resources associated with this node.
  102786. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102787. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102788. */
  102789. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102790. /**
  102791. * Parse animation range data from a serialization object and store them into a given node
  102792. * @param node defines where to store the animation ranges
  102793. * @param parsedNode defines the serialization object to read data from
  102794. * @param scene defines the hosting scene
  102795. */
  102796. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102797. /**
  102798. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102799. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102800. * @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
  102801. * @returns the new bounding vectors
  102802. */
  102803. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102804. min: Vector3;
  102805. max: Vector3;
  102806. };
  102807. }
  102808. }
  102809. declare module BABYLON {
  102810. /**
  102811. * @hidden
  102812. */
  102813. export class _IAnimationState {
  102814. key: number;
  102815. repeatCount: number;
  102816. workValue?: any;
  102817. loopMode?: number;
  102818. offsetValue?: any;
  102819. highLimitValue?: any;
  102820. }
  102821. /**
  102822. * Class used to store any kind of animation
  102823. */
  102824. export class Animation {
  102825. /**Name of the animation */
  102826. name: string;
  102827. /**Property to animate */
  102828. targetProperty: string;
  102829. /**The frames per second of the animation */
  102830. framePerSecond: number;
  102831. /**The data type of the animation */
  102832. dataType: number;
  102833. /**The loop mode of the animation */
  102834. loopMode?: number | undefined;
  102835. /**Specifies if blending should be enabled */
  102836. enableBlending?: boolean | undefined;
  102837. /**
  102838. * Use matrix interpolation instead of using direct key value when animating matrices
  102839. */
  102840. static AllowMatricesInterpolation: boolean;
  102841. /**
  102842. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102843. */
  102844. static AllowMatrixDecomposeForInterpolation: boolean;
  102845. /**
  102846. * Stores the key frames of the animation
  102847. */
  102848. private _keys;
  102849. /**
  102850. * Stores the easing function of the animation
  102851. */
  102852. private _easingFunction;
  102853. /**
  102854. * @hidden Internal use only
  102855. */
  102856. _runtimeAnimations: RuntimeAnimation[];
  102857. /**
  102858. * The set of event that will be linked to this animation
  102859. */
  102860. private _events;
  102861. /**
  102862. * Stores an array of target property paths
  102863. */
  102864. targetPropertyPath: string[];
  102865. /**
  102866. * Stores the blending speed of the animation
  102867. */
  102868. blendingSpeed: number;
  102869. /**
  102870. * Stores the animation ranges for the animation
  102871. */
  102872. private _ranges;
  102873. /**
  102874. * @hidden Internal use
  102875. */
  102876. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102877. /**
  102878. * Sets up an animation
  102879. * @param property The property to animate
  102880. * @param animationType The animation type to apply
  102881. * @param framePerSecond The frames per second of the animation
  102882. * @param easingFunction The easing function used in the animation
  102883. * @returns The created animation
  102884. */
  102885. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102886. /**
  102887. * Create and start an animation on a node
  102888. * @param name defines the name of the global animation that will be run on all nodes
  102889. * @param node defines the root node where the animation will take place
  102890. * @param targetProperty defines property to animate
  102891. * @param framePerSecond defines the number of frame per second yo use
  102892. * @param totalFrame defines the number of frames in total
  102893. * @param from defines the initial value
  102894. * @param to defines the final value
  102895. * @param loopMode defines which loop mode you want to use (off by default)
  102896. * @param easingFunction defines the easing function to use (linear by default)
  102897. * @param onAnimationEnd defines the callback to call when animation end
  102898. * @returns the animatable created for this animation
  102899. */
  102900. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102901. /**
  102902. * Create and start an animation on a node and its descendants
  102903. * @param name defines the name of the global animation that will be run on all nodes
  102904. * @param node defines the root node where the animation will take place
  102905. * @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
  102906. * @param targetProperty defines property to animate
  102907. * @param framePerSecond defines the number of frame per second to use
  102908. * @param totalFrame defines the number of frames in total
  102909. * @param from defines the initial value
  102910. * @param to defines the final value
  102911. * @param loopMode defines which loop mode you want to use (off by default)
  102912. * @param easingFunction defines the easing function to use (linear by default)
  102913. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102914. * @returns the list of animatables created for all nodes
  102915. * @example https://www.babylonjs-playground.com/#MH0VLI
  102916. */
  102917. 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[]>;
  102918. /**
  102919. * Creates a new animation, merges it with the existing animations and starts it
  102920. * @param name Name of the animation
  102921. * @param node Node which contains the scene that begins the animations
  102922. * @param targetProperty Specifies which property to animate
  102923. * @param framePerSecond The frames per second of the animation
  102924. * @param totalFrame The total number of frames
  102925. * @param from The frame at the beginning of the animation
  102926. * @param to The frame at the end of the animation
  102927. * @param loopMode Specifies the loop mode of the animation
  102928. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102929. * @param onAnimationEnd Callback to run once the animation is complete
  102930. * @returns Nullable animation
  102931. */
  102932. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102933. /**
  102934. * Transition property of an host to the target Value
  102935. * @param property The property to transition
  102936. * @param targetValue The target Value of the property
  102937. * @param host The object where the property to animate belongs
  102938. * @param scene Scene used to run the animation
  102939. * @param frameRate Framerate (in frame/s) to use
  102940. * @param transition The transition type we want to use
  102941. * @param duration The duration of the animation, in milliseconds
  102942. * @param onAnimationEnd Callback trigger at the end of the animation
  102943. * @returns Nullable animation
  102944. */
  102945. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102946. /**
  102947. * Return the array of runtime animations currently using this animation
  102948. */
  102949. get runtimeAnimations(): RuntimeAnimation[];
  102950. /**
  102951. * Specifies if any of the runtime animations are currently running
  102952. */
  102953. get hasRunningRuntimeAnimations(): boolean;
  102954. /**
  102955. * Initializes the animation
  102956. * @param name Name of the animation
  102957. * @param targetProperty Property to animate
  102958. * @param framePerSecond The frames per second of the animation
  102959. * @param dataType The data type of the animation
  102960. * @param loopMode The loop mode of the animation
  102961. * @param enableBlending Specifies if blending should be enabled
  102962. */
  102963. constructor(
  102964. /**Name of the animation */
  102965. name: string,
  102966. /**Property to animate */
  102967. targetProperty: string,
  102968. /**The frames per second of the animation */
  102969. framePerSecond: number,
  102970. /**The data type of the animation */
  102971. dataType: number,
  102972. /**The loop mode of the animation */
  102973. loopMode?: number | undefined,
  102974. /**Specifies if blending should be enabled */
  102975. enableBlending?: boolean | undefined);
  102976. /**
  102977. * Converts the animation to a string
  102978. * @param fullDetails support for multiple levels of logging within scene loading
  102979. * @returns String form of the animation
  102980. */
  102981. toString(fullDetails?: boolean): string;
  102982. /**
  102983. * Add an event to this animation
  102984. * @param event Event to add
  102985. */
  102986. addEvent(event: AnimationEvent): void;
  102987. /**
  102988. * Remove all events found at the given frame
  102989. * @param frame The frame to remove events from
  102990. */
  102991. removeEvents(frame: number): void;
  102992. /**
  102993. * Retrieves all the events from the animation
  102994. * @returns Events from the animation
  102995. */
  102996. getEvents(): AnimationEvent[];
  102997. /**
  102998. * Creates an animation range
  102999. * @param name Name of the animation range
  103000. * @param from Starting frame of the animation range
  103001. * @param to Ending frame of the animation
  103002. */
  103003. createRange(name: string, from: number, to: number): void;
  103004. /**
  103005. * Deletes an animation range by name
  103006. * @param name Name of the animation range to delete
  103007. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103008. */
  103009. deleteRange(name: string, deleteFrames?: boolean): void;
  103010. /**
  103011. * Gets the animation range by name, or null if not defined
  103012. * @param name Name of the animation range
  103013. * @returns Nullable animation range
  103014. */
  103015. getRange(name: string): Nullable<AnimationRange>;
  103016. /**
  103017. * Gets the key frames from the animation
  103018. * @returns The key frames of the animation
  103019. */
  103020. getKeys(): Array<IAnimationKey>;
  103021. /**
  103022. * Gets the highest frame rate of the animation
  103023. * @returns Highest frame rate of the animation
  103024. */
  103025. getHighestFrame(): number;
  103026. /**
  103027. * Gets the easing function of the animation
  103028. * @returns Easing function of the animation
  103029. */
  103030. getEasingFunction(): IEasingFunction;
  103031. /**
  103032. * Sets the easing function of the animation
  103033. * @param easingFunction A custom mathematical formula for animation
  103034. */
  103035. setEasingFunction(easingFunction: EasingFunction): void;
  103036. /**
  103037. * Interpolates a scalar linearly
  103038. * @param startValue Start value of the animation curve
  103039. * @param endValue End value of the animation curve
  103040. * @param gradient Scalar amount to interpolate
  103041. * @returns Interpolated scalar value
  103042. */
  103043. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103044. /**
  103045. * Interpolates a scalar cubically
  103046. * @param startValue Start value of the animation curve
  103047. * @param outTangent End tangent of the animation
  103048. * @param endValue End value of the animation curve
  103049. * @param inTangent Start tangent of the animation curve
  103050. * @param gradient Scalar amount to interpolate
  103051. * @returns Interpolated scalar value
  103052. */
  103053. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103054. /**
  103055. * Interpolates a quaternion using a spherical linear interpolation
  103056. * @param startValue Start value of the animation curve
  103057. * @param endValue End value of the animation curve
  103058. * @param gradient Scalar amount to interpolate
  103059. * @returns Interpolated quaternion value
  103060. */
  103061. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103062. /**
  103063. * Interpolates a quaternion cubically
  103064. * @param startValue Start value of the animation curve
  103065. * @param outTangent End tangent of the animation curve
  103066. * @param endValue End value of the animation curve
  103067. * @param inTangent Start tangent of the animation curve
  103068. * @param gradient Scalar amount to interpolate
  103069. * @returns Interpolated quaternion value
  103070. */
  103071. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103072. /**
  103073. * Interpolates a Vector3 linearl
  103074. * @param startValue Start value of the animation curve
  103075. * @param endValue End value of the animation curve
  103076. * @param gradient Scalar amount to interpolate
  103077. * @returns Interpolated scalar value
  103078. */
  103079. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103080. /**
  103081. * Interpolates a Vector3 cubically
  103082. * @param startValue Start value of the animation curve
  103083. * @param outTangent End tangent of the animation
  103084. * @param endValue End value of the animation curve
  103085. * @param inTangent Start tangent of the animation curve
  103086. * @param gradient Scalar amount to interpolate
  103087. * @returns InterpolatedVector3 value
  103088. */
  103089. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  103090. /**
  103091. * Interpolates a Vector2 linearly
  103092. * @param startValue Start value of the animation curve
  103093. * @param endValue End value of the animation curve
  103094. * @param gradient Scalar amount to interpolate
  103095. * @returns Interpolated Vector2 value
  103096. */
  103097. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  103098. /**
  103099. * Interpolates a Vector2 cubically
  103100. * @param startValue Start value of the animation curve
  103101. * @param outTangent End tangent of the animation
  103102. * @param endValue End value of the animation curve
  103103. * @param inTangent Start tangent of the animation curve
  103104. * @param gradient Scalar amount to interpolate
  103105. * @returns Interpolated Vector2 value
  103106. */
  103107. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  103108. /**
  103109. * Interpolates a size linearly
  103110. * @param startValue Start value of the animation curve
  103111. * @param endValue End value of the animation curve
  103112. * @param gradient Scalar amount to interpolate
  103113. * @returns Interpolated Size value
  103114. */
  103115. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  103116. /**
  103117. * Interpolates a Color3 linearly
  103118. * @param startValue Start value of the animation curve
  103119. * @param endValue End value of the animation curve
  103120. * @param gradient Scalar amount to interpolate
  103121. * @returns Interpolated Color3 value
  103122. */
  103123. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  103124. /**
  103125. * Interpolates a Color4 linearly
  103126. * @param startValue Start value of the animation curve
  103127. * @param endValue End value of the animation curve
  103128. * @param gradient Scalar amount to interpolate
  103129. * @returns Interpolated Color3 value
  103130. */
  103131. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  103132. /**
  103133. * @hidden Internal use only
  103134. */
  103135. _getKeyValue(value: any): any;
  103136. /**
  103137. * @hidden Internal use only
  103138. */
  103139. _interpolate(currentFrame: number, state: _IAnimationState): any;
  103140. /**
  103141. * Defines the function to use to interpolate matrices
  103142. * @param startValue defines the start matrix
  103143. * @param endValue defines the end matrix
  103144. * @param gradient defines the gradient between both matrices
  103145. * @param result defines an optional target matrix where to store the interpolation
  103146. * @returns the interpolated matrix
  103147. */
  103148. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  103149. /**
  103150. * Makes a copy of the animation
  103151. * @returns Cloned animation
  103152. */
  103153. clone(): Animation;
  103154. /**
  103155. * Sets the key frames of the animation
  103156. * @param values The animation key frames to set
  103157. */
  103158. setKeys(values: Array<IAnimationKey>): void;
  103159. /**
  103160. * Serializes the animation to an object
  103161. * @returns Serialized object
  103162. */
  103163. serialize(): any;
  103164. /**
  103165. * Float animation type
  103166. */
  103167. static readonly ANIMATIONTYPE_FLOAT: number;
  103168. /**
  103169. * Vector3 animation type
  103170. */
  103171. static readonly ANIMATIONTYPE_VECTOR3: number;
  103172. /**
  103173. * Quaternion animation type
  103174. */
  103175. static readonly ANIMATIONTYPE_QUATERNION: number;
  103176. /**
  103177. * Matrix animation type
  103178. */
  103179. static readonly ANIMATIONTYPE_MATRIX: number;
  103180. /**
  103181. * Color3 animation type
  103182. */
  103183. static readonly ANIMATIONTYPE_COLOR3: number;
  103184. /**
  103185. * Color3 animation type
  103186. */
  103187. static readonly ANIMATIONTYPE_COLOR4: number;
  103188. /**
  103189. * Vector2 animation type
  103190. */
  103191. static readonly ANIMATIONTYPE_VECTOR2: number;
  103192. /**
  103193. * Size animation type
  103194. */
  103195. static readonly ANIMATIONTYPE_SIZE: number;
  103196. /**
  103197. * Relative Loop Mode
  103198. */
  103199. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  103200. /**
  103201. * Cycle Loop Mode
  103202. */
  103203. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  103204. /**
  103205. * Constant Loop Mode
  103206. */
  103207. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  103208. /** @hidden */
  103209. static _UniversalLerp(left: any, right: any, amount: number): any;
  103210. /**
  103211. * Parses an animation object and creates an animation
  103212. * @param parsedAnimation Parsed animation object
  103213. * @returns Animation object
  103214. */
  103215. static Parse(parsedAnimation: any): Animation;
  103216. /**
  103217. * Appends the serialized animations from the source animations
  103218. * @param source Source containing the animations
  103219. * @param destination Target to store the animations
  103220. */
  103221. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103222. }
  103223. }
  103224. declare module BABYLON {
  103225. /**
  103226. * Interface containing an array of animations
  103227. */
  103228. export interface IAnimatable {
  103229. /**
  103230. * Array of animations
  103231. */
  103232. animations: Nullable<Array<Animation>>;
  103233. }
  103234. }
  103235. declare module BABYLON {
  103236. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  103237. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103238. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103239. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103240. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103241. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103242. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103243. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103244. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103245. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103246. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103247. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103248. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103249. /**
  103250. * Decorator used to define property that can be serialized as reference to a camera
  103251. * @param sourceName defines the name of the property to decorate
  103252. */
  103253. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103254. /**
  103255. * Class used to help serialization objects
  103256. */
  103257. export class SerializationHelper {
  103258. /** @hidden */
  103259. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  103260. /** @hidden */
  103261. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  103262. /** @hidden */
  103263. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  103264. /** @hidden */
  103265. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  103266. /**
  103267. * Appends the serialized animations from the source animations
  103268. * @param source Source containing the animations
  103269. * @param destination Target to store the animations
  103270. */
  103271. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103272. /**
  103273. * Static function used to serialized a specific entity
  103274. * @param entity defines the entity to serialize
  103275. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  103276. * @returns a JSON compatible object representing the serialization of the entity
  103277. */
  103278. static Serialize<T>(entity: T, serializationObject?: any): any;
  103279. /**
  103280. * Creates a new entity from a serialization data object
  103281. * @param creationFunction defines a function used to instanciated the new entity
  103282. * @param source defines the source serialization data
  103283. * @param scene defines the hosting scene
  103284. * @param rootUrl defines the root url for resources
  103285. * @returns a new entity
  103286. */
  103287. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  103288. /**
  103289. * Clones an object
  103290. * @param creationFunction defines the function used to instanciate the new object
  103291. * @param source defines the source object
  103292. * @returns the cloned object
  103293. */
  103294. static Clone<T>(creationFunction: () => T, source: T): T;
  103295. /**
  103296. * Instanciates a new object based on a source one (some data will be shared between both object)
  103297. * @param creationFunction defines the function used to instanciate the new object
  103298. * @param source defines the source object
  103299. * @returns the new object
  103300. */
  103301. static Instanciate<T>(creationFunction: () => T, source: T): T;
  103302. }
  103303. }
  103304. declare module BABYLON {
  103305. /**
  103306. * Class used to manipulate GUIDs
  103307. */
  103308. export class GUID {
  103309. /**
  103310. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103311. * Be aware Math.random() could cause collisions, but:
  103312. * "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"
  103313. * @returns a pseudo random id
  103314. */
  103315. static RandomId(): string;
  103316. }
  103317. }
  103318. declare module BABYLON {
  103319. /**
  103320. * Base class of all the textures in babylon.
  103321. * It groups all the common properties the materials, post process, lights... might need
  103322. * in order to make a correct use of the texture.
  103323. */
  103324. export class BaseTexture implements IAnimatable {
  103325. /**
  103326. * Default anisotropic filtering level for the application.
  103327. * It is set to 4 as a good tradeoff between perf and quality.
  103328. */
  103329. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  103330. /**
  103331. * Gets or sets the unique id of the texture
  103332. */
  103333. uniqueId: number;
  103334. /**
  103335. * Define the name of the texture.
  103336. */
  103337. name: string;
  103338. /**
  103339. * Gets or sets an object used to store user defined information.
  103340. */
  103341. metadata: any;
  103342. /**
  103343. * For internal use only. Please do not use.
  103344. */
  103345. reservedDataStore: any;
  103346. private _hasAlpha;
  103347. /**
  103348. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  103349. */
  103350. set hasAlpha(value: boolean);
  103351. get hasAlpha(): boolean;
  103352. /**
  103353. * Defines if the alpha value should be determined via the rgb values.
  103354. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  103355. */
  103356. getAlphaFromRGB: boolean;
  103357. /**
  103358. * Intensity or strength of the texture.
  103359. * It is commonly used by materials to fine tune the intensity of the texture
  103360. */
  103361. level: number;
  103362. /**
  103363. * Define the UV chanel to use starting from 0 and defaulting to 0.
  103364. * This is part of the texture as textures usually maps to one uv set.
  103365. */
  103366. coordinatesIndex: number;
  103367. private _coordinatesMode;
  103368. /**
  103369. * How a texture is mapped.
  103370. *
  103371. * | Value | Type | Description |
  103372. * | ----- | ----------------------------------- | ----------- |
  103373. * | 0 | EXPLICIT_MODE | |
  103374. * | 1 | SPHERICAL_MODE | |
  103375. * | 2 | PLANAR_MODE | |
  103376. * | 3 | CUBIC_MODE | |
  103377. * | 4 | PROJECTION_MODE | |
  103378. * | 5 | SKYBOX_MODE | |
  103379. * | 6 | INVCUBIC_MODE | |
  103380. * | 7 | EQUIRECTANGULAR_MODE | |
  103381. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  103382. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  103383. */
  103384. set coordinatesMode(value: number);
  103385. get coordinatesMode(): number;
  103386. /**
  103387. * | Value | Type | Description |
  103388. * | ----- | ------------------ | ----------- |
  103389. * | 0 | CLAMP_ADDRESSMODE | |
  103390. * | 1 | WRAP_ADDRESSMODE | |
  103391. * | 2 | MIRROR_ADDRESSMODE | |
  103392. */
  103393. wrapU: number;
  103394. /**
  103395. * | Value | Type | Description |
  103396. * | ----- | ------------------ | ----------- |
  103397. * | 0 | CLAMP_ADDRESSMODE | |
  103398. * | 1 | WRAP_ADDRESSMODE | |
  103399. * | 2 | MIRROR_ADDRESSMODE | |
  103400. */
  103401. wrapV: number;
  103402. /**
  103403. * | Value | Type | Description |
  103404. * | ----- | ------------------ | ----------- |
  103405. * | 0 | CLAMP_ADDRESSMODE | |
  103406. * | 1 | WRAP_ADDRESSMODE | |
  103407. * | 2 | MIRROR_ADDRESSMODE | |
  103408. */
  103409. wrapR: number;
  103410. /**
  103411. * With compliant hardware and browser (supporting anisotropic filtering)
  103412. * this defines the level of anisotropic filtering in the texture.
  103413. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103414. */
  103415. anisotropicFilteringLevel: number;
  103416. /**
  103417. * Define if the texture is a cube texture or if false a 2d texture.
  103418. */
  103419. get isCube(): boolean;
  103420. set isCube(value: boolean);
  103421. /**
  103422. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103423. */
  103424. get is3D(): boolean;
  103425. set is3D(value: boolean);
  103426. /**
  103427. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103428. */
  103429. get is2DArray(): boolean;
  103430. set is2DArray(value: boolean);
  103431. /**
  103432. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103433. * HDR texture are usually stored in linear space.
  103434. * This only impacts the PBR and Background materials
  103435. */
  103436. gammaSpace: boolean;
  103437. /**
  103438. * Gets or sets whether or not the texture contains RGBD data.
  103439. */
  103440. get isRGBD(): boolean;
  103441. set isRGBD(value: boolean);
  103442. /**
  103443. * Is Z inverted in the texture (useful in a cube texture).
  103444. */
  103445. invertZ: boolean;
  103446. /**
  103447. * Are mip maps generated for this texture or not.
  103448. */
  103449. get noMipmap(): boolean;
  103450. /**
  103451. * @hidden
  103452. */
  103453. lodLevelInAlpha: boolean;
  103454. /**
  103455. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103456. */
  103457. get lodGenerationOffset(): number;
  103458. set lodGenerationOffset(value: number);
  103459. /**
  103460. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103461. */
  103462. get lodGenerationScale(): number;
  103463. set lodGenerationScale(value: number);
  103464. /**
  103465. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103466. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103467. * average roughness values.
  103468. */
  103469. get linearSpecularLOD(): boolean;
  103470. set linearSpecularLOD(value: boolean);
  103471. /**
  103472. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103473. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103474. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103475. */
  103476. get irradianceTexture(): Nullable<BaseTexture>;
  103477. set irradianceTexture(value: Nullable<BaseTexture>);
  103478. /**
  103479. * Define if the texture is a render target.
  103480. */
  103481. isRenderTarget: boolean;
  103482. /**
  103483. * Define the unique id of the texture in the scene.
  103484. */
  103485. get uid(): string;
  103486. /**
  103487. * Return a string representation of the texture.
  103488. * @returns the texture as a string
  103489. */
  103490. toString(): string;
  103491. /**
  103492. * Get the class name of the texture.
  103493. * @returns "BaseTexture"
  103494. */
  103495. getClassName(): string;
  103496. /**
  103497. * Define the list of animation attached to the texture.
  103498. */
  103499. animations: Animation[];
  103500. /**
  103501. * An event triggered when the texture is disposed.
  103502. */
  103503. onDisposeObservable: Observable<BaseTexture>;
  103504. private _onDisposeObserver;
  103505. /**
  103506. * Callback triggered when the texture has been disposed.
  103507. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103508. */
  103509. set onDispose(callback: () => void);
  103510. /**
  103511. * Define the current state of the loading sequence when in delayed load mode.
  103512. */
  103513. delayLoadState: number;
  103514. private _scene;
  103515. /** @hidden */
  103516. _texture: Nullable<InternalTexture>;
  103517. private _uid;
  103518. /**
  103519. * Define if the texture is preventinga material to render or not.
  103520. * If not and the texture is not ready, the engine will use a default black texture instead.
  103521. */
  103522. get isBlocking(): boolean;
  103523. /**
  103524. * Instantiates a new BaseTexture.
  103525. * Base class of all the textures in babylon.
  103526. * It groups all the common properties the materials, post process, lights... might need
  103527. * in order to make a correct use of the texture.
  103528. * @param scene Define the scene the texture blongs to
  103529. */
  103530. constructor(scene: Nullable<Scene>);
  103531. /**
  103532. * Get the scene the texture belongs to.
  103533. * @returns the scene or null if undefined
  103534. */
  103535. getScene(): Nullable<Scene>;
  103536. /**
  103537. * Get the texture transform matrix used to offset tile the texture for istance.
  103538. * @returns the transformation matrix
  103539. */
  103540. getTextureMatrix(): Matrix;
  103541. /**
  103542. * Get the texture reflection matrix used to rotate/transform the reflection.
  103543. * @returns the reflection matrix
  103544. */
  103545. getReflectionTextureMatrix(): Matrix;
  103546. /**
  103547. * Get the underlying lower level texture from Babylon.
  103548. * @returns the insternal texture
  103549. */
  103550. getInternalTexture(): Nullable<InternalTexture>;
  103551. /**
  103552. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103553. * @returns true if ready or not blocking
  103554. */
  103555. isReadyOrNotBlocking(): boolean;
  103556. /**
  103557. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103558. * @returns true if fully ready
  103559. */
  103560. isReady(): boolean;
  103561. private _cachedSize;
  103562. /**
  103563. * Get the size of the texture.
  103564. * @returns the texture size.
  103565. */
  103566. getSize(): ISize;
  103567. /**
  103568. * Get the base size of the texture.
  103569. * It can be different from the size if the texture has been resized for POT for instance
  103570. * @returns the base size
  103571. */
  103572. getBaseSize(): ISize;
  103573. /**
  103574. * Update the sampling mode of the texture.
  103575. * Default is Trilinear mode.
  103576. *
  103577. * | Value | Type | Description |
  103578. * | ----- | ------------------ | ----------- |
  103579. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103580. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103581. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103582. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103583. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103584. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103585. * | 7 | NEAREST_LINEAR | |
  103586. * | 8 | NEAREST_NEAREST | |
  103587. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103588. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103589. * | 11 | LINEAR_LINEAR | |
  103590. * | 12 | LINEAR_NEAREST | |
  103591. *
  103592. * > _mag_: magnification filter (close to the viewer)
  103593. * > _min_: minification filter (far from the viewer)
  103594. * > _mip_: filter used between mip map levels
  103595. *@param samplingMode Define the new sampling mode of the texture
  103596. */
  103597. updateSamplingMode(samplingMode: number): void;
  103598. /**
  103599. * Scales the texture if is `canRescale()`
  103600. * @param ratio the resize factor we want to use to rescale
  103601. */
  103602. scale(ratio: number): void;
  103603. /**
  103604. * Get if the texture can rescale.
  103605. */
  103606. get canRescale(): boolean;
  103607. /** @hidden */
  103608. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103609. /** @hidden */
  103610. _rebuild(): void;
  103611. /**
  103612. * Triggers the load sequence in delayed load mode.
  103613. */
  103614. delayLoad(): void;
  103615. /**
  103616. * Clones the texture.
  103617. * @returns the cloned texture
  103618. */
  103619. clone(): Nullable<BaseTexture>;
  103620. /**
  103621. * Get the texture underlying type (INT, FLOAT...)
  103622. */
  103623. get textureType(): number;
  103624. /**
  103625. * Get the texture underlying format (RGB, RGBA...)
  103626. */
  103627. get textureFormat(): number;
  103628. /**
  103629. * Indicates that textures need to be re-calculated for all materials
  103630. */
  103631. protected _markAllSubMeshesAsTexturesDirty(): void;
  103632. /**
  103633. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103634. * This will returns an RGBA array buffer containing either in values (0-255) or
  103635. * float values (0-1) depending of the underlying buffer type.
  103636. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103637. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103638. * @param buffer defines a user defined buffer to fill with data (can be null)
  103639. * @returns The Array buffer containing the pixels data.
  103640. */
  103641. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103642. /**
  103643. * Release and destroy the underlying lower level texture aka internalTexture.
  103644. */
  103645. releaseInternalTexture(): void;
  103646. /** @hidden */
  103647. get _lodTextureHigh(): Nullable<BaseTexture>;
  103648. /** @hidden */
  103649. get _lodTextureMid(): Nullable<BaseTexture>;
  103650. /** @hidden */
  103651. get _lodTextureLow(): Nullable<BaseTexture>;
  103652. /**
  103653. * Dispose the texture and release its associated resources.
  103654. */
  103655. dispose(): void;
  103656. /**
  103657. * Serialize the texture into a JSON representation that can be parsed later on.
  103658. * @returns the JSON representation of the texture
  103659. */
  103660. serialize(): any;
  103661. /**
  103662. * Helper function to be called back once a list of texture contains only ready textures.
  103663. * @param textures Define the list of textures to wait for
  103664. * @param callback Define the callback triggered once the entire list will be ready
  103665. */
  103666. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103667. }
  103668. }
  103669. declare module BABYLON {
  103670. /**
  103671. * Options to be used when creating an effect.
  103672. */
  103673. export interface IEffectCreationOptions {
  103674. /**
  103675. * Atrributes that will be used in the shader.
  103676. */
  103677. attributes: string[];
  103678. /**
  103679. * Uniform varible names that will be set in the shader.
  103680. */
  103681. uniformsNames: string[];
  103682. /**
  103683. * Uniform buffer variable names that will be set in the shader.
  103684. */
  103685. uniformBuffersNames: string[];
  103686. /**
  103687. * Sampler texture variable names that will be set in the shader.
  103688. */
  103689. samplers: string[];
  103690. /**
  103691. * Define statements that will be set in the shader.
  103692. */
  103693. defines: any;
  103694. /**
  103695. * Possible fallbacks for this effect to improve performance when needed.
  103696. */
  103697. fallbacks: Nullable<IEffectFallbacks>;
  103698. /**
  103699. * Callback that will be called when the shader is compiled.
  103700. */
  103701. onCompiled: Nullable<(effect: Effect) => void>;
  103702. /**
  103703. * Callback that will be called if an error occurs during shader compilation.
  103704. */
  103705. onError: Nullable<(effect: Effect, errors: string) => void>;
  103706. /**
  103707. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103708. */
  103709. indexParameters?: any;
  103710. /**
  103711. * Max number of lights that can be used in the shader.
  103712. */
  103713. maxSimultaneousLights?: number;
  103714. /**
  103715. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103716. */
  103717. transformFeedbackVaryings?: Nullable<string[]>;
  103718. }
  103719. /**
  103720. * Effect containing vertex and fragment shader that can be executed on an object.
  103721. */
  103722. export class Effect implements IDisposable {
  103723. /**
  103724. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103725. */
  103726. static ShadersRepository: string;
  103727. /**
  103728. * Enable logging of the shader code when a compilation error occurs
  103729. */
  103730. static LogShaderCodeOnCompilationError: boolean;
  103731. /**
  103732. * Name of the effect.
  103733. */
  103734. name: any;
  103735. /**
  103736. * String container all the define statements that should be set on the shader.
  103737. */
  103738. defines: string;
  103739. /**
  103740. * Callback that will be called when the shader is compiled.
  103741. */
  103742. onCompiled: Nullable<(effect: Effect) => void>;
  103743. /**
  103744. * Callback that will be called if an error occurs during shader compilation.
  103745. */
  103746. onError: Nullable<(effect: Effect, errors: string) => void>;
  103747. /**
  103748. * Callback that will be called when effect is bound.
  103749. */
  103750. onBind: Nullable<(effect: Effect) => void>;
  103751. /**
  103752. * Unique ID of the effect.
  103753. */
  103754. uniqueId: number;
  103755. /**
  103756. * Observable that will be called when the shader is compiled.
  103757. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103758. */
  103759. onCompileObservable: Observable<Effect>;
  103760. /**
  103761. * Observable that will be called if an error occurs during shader compilation.
  103762. */
  103763. onErrorObservable: Observable<Effect>;
  103764. /** @hidden */
  103765. _onBindObservable: Nullable<Observable<Effect>>;
  103766. /**
  103767. * @hidden
  103768. * Specifies if the effect was previously ready
  103769. */
  103770. _wasPreviouslyReady: boolean;
  103771. /**
  103772. * Observable that will be called when effect is bound.
  103773. */
  103774. get onBindObservable(): Observable<Effect>;
  103775. /** @hidden */
  103776. _bonesComputationForcedToCPU: boolean;
  103777. private static _uniqueIdSeed;
  103778. private _engine;
  103779. private _uniformBuffersNames;
  103780. private _uniformsNames;
  103781. private _samplerList;
  103782. private _samplers;
  103783. private _isReady;
  103784. private _compilationError;
  103785. private _allFallbacksProcessed;
  103786. private _attributesNames;
  103787. private _attributes;
  103788. private _attributeLocationByName;
  103789. private _uniforms;
  103790. /**
  103791. * Key for the effect.
  103792. * @hidden
  103793. */
  103794. _key: string;
  103795. private _indexParameters;
  103796. private _fallbacks;
  103797. private _vertexSourceCode;
  103798. private _fragmentSourceCode;
  103799. private _vertexSourceCodeOverride;
  103800. private _fragmentSourceCodeOverride;
  103801. private _transformFeedbackVaryings;
  103802. /**
  103803. * Compiled shader to webGL program.
  103804. * @hidden
  103805. */
  103806. _pipelineContext: Nullable<IPipelineContext>;
  103807. private _valueCache;
  103808. private static _baseCache;
  103809. /**
  103810. * Instantiates an effect.
  103811. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103812. * @param baseName Name of the effect.
  103813. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103814. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103815. * @param samplers List of sampler variables that will be passed to the shader.
  103816. * @param engine Engine to be used to render the effect
  103817. * @param defines Define statements to be added to the shader.
  103818. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103819. * @param onCompiled Callback that will be called when the shader is compiled.
  103820. * @param onError Callback that will be called if an error occurs during shader compilation.
  103821. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103822. */
  103823. 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);
  103824. private _useFinalCode;
  103825. /**
  103826. * Unique key for this effect
  103827. */
  103828. get key(): string;
  103829. /**
  103830. * If the effect has been compiled and prepared.
  103831. * @returns if the effect is compiled and prepared.
  103832. */
  103833. isReady(): boolean;
  103834. private _isReadyInternal;
  103835. /**
  103836. * The engine the effect was initialized with.
  103837. * @returns the engine.
  103838. */
  103839. getEngine(): Engine;
  103840. /**
  103841. * The pipeline context for this effect
  103842. * @returns the associated pipeline context
  103843. */
  103844. getPipelineContext(): Nullable<IPipelineContext>;
  103845. /**
  103846. * The set of names of attribute variables for the shader.
  103847. * @returns An array of attribute names.
  103848. */
  103849. getAttributesNames(): string[];
  103850. /**
  103851. * Returns the attribute at the given index.
  103852. * @param index The index of the attribute.
  103853. * @returns The location of the attribute.
  103854. */
  103855. getAttributeLocation(index: number): number;
  103856. /**
  103857. * Returns the attribute based on the name of the variable.
  103858. * @param name of the attribute to look up.
  103859. * @returns the attribute location.
  103860. */
  103861. getAttributeLocationByName(name: string): number;
  103862. /**
  103863. * The number of attributes.
  103864. * @returns the numnber of attributes.
  103865. */
  103866. getAttributesCount(): number;
  103867. /**
  103868. * Gets the index of a uniform variable.
  103869. * @param uniformName of the uniform to look up.
  103870. * @returns the index.
  103871. */
  103872. getUniformIndex(uniformName: string): number;
  103873. /**
  103874. * Returns the attribute based on the name of the variable.
  103875. * @param uniformName of the uniform to look up.
  103876. * @returns the location of the uniform.
  103877. */
  103878. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103879. /**
  103880. * Returns an array of sampler variable names
  103881. * @returns The array of sampler variable neames.
  103882. */
  103883. getSamplers(): string[];
  103884. /**
  103885. * The error from the last compilation.
  103886. * @returns the error string.
  103887. */
  103888. getCompilationError(): string;
  103889. /**
  103890. * Gets a boolean indicating that all fallbacks were used during compilation
  103891. * @returns true if all fallbacks were used
  103892. */
  103893. allFallbacksProcessed(): boolean;
  103894. /**
  103895. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103896. * @param func The callback to be used.
  103897. */
  103898. executeWhenCompiled(func: (effect: Effect) => void): void;
  103899. private _checkIsReady;
  103900. private _loadShader;
  103901. /**
  103902. * Recompiles the webGL program
  103903. * @param vertexSourceCode The source code for the vertex shader.
  103904. * @param fragmentSourceCode The source code for the fragment shader.
  103905. * @param onCompiled Callback called when completed.
  103906. * @param onError Callback called on error.
  103907. * @hidden
  103908. */
  103909. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103910. /**
  103911. * Prepares the effect
  103912. * @hidden
  103913. */
  103914. _prepareEffect(): void;
  103915. private _getShaderCodeAndErrorLine;
  103916. private _processCompilationErrors;
  103917. /**
  103918. * Checks if the effect is supported. (Must be called after compilation)
  103919. */
  103920. get isSupported(): boolean;
  103921. /**
  103922. * Binds a texture to the engine to be used as output of the shader.
  103923. * @param channel Name of the output variable.
  103924. * @param texture Texture to bind.
  103925. * @hidden
  103926. */
  103927. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103928. /**
  103929. * Sets a texture on the engine to be used in the shader.
  103930. * @param channel Name of the sampler variable.
  103931. * @param texture Texture to set.
  103932. */
  103933. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103934. /**
  103935. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103936. * @param channel Name of the sampler variable.
  103937. * @param texture Texture to set.
  103938. */
  103939. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103940. /**
  103941. * Sets an array of textures on the engine to be used in the shader.
  103942. * @param channel Name of the variable.
  103943. * @param textures Textures to set.
  103944. */
  103945. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103946. /**
  103947. * 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)
  103948. * @param channel Name of the sampler variable.
  103949. * @param postProcess Post process to get the input texture from.
  103950. */
  103951. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103952. /**
  103953. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103954. * 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)
  103955. * @param channel Name of the sampler variable.
  103956. * @param postProcess Post process to get the output texture from.
  103957. */
  103958. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103959. /** @hidden */
  103960. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103961. /** @hidden */
  103962. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103963. /** @hidden */
  103964. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103965. /** @hidden */
  103966. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103967. /**
  103968. * Binds a buffer to a uniform.
  103969. * @param buffer Buffer to bind.
  103970. * @param name Name of the uniform variable to bind to.
  103971. */
  103972. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103973. /**
  103974. * Binds block to a uniform.
  103975. * @param blockName Name of the block to bind.
  103976. * @param index Index to bind.
  103977. */
  103978. bindUniformBlock(blockName: string, index: number): void;
  103979. /**
  103980. * Sets an interger value on a uniform variable.
  103981. * @param uniformName Name of the variable.
  103982. * @param value Value to be set.
  103983. * @returns this effect.
  103984. */
  103985. setInt(uniformName: string, value: number): Effect;
  103986. /**
  103987. * Sets an int array on a uniform variable.
  103988. * @param uniformName Name of the variable.
  103989. * @param array array to be set.
  103990. * @returns this effect.
  103991. */
  103992. setIntArray(uniformName: string, array: Int32Array): Effect;
  103993. /**
  103994. * 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)
  103995. * @param uniformName Name of the variable.
  103996. * @param array array to be set.
  103997. * @returns this effect.
  103998. */
  103999. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104000. /**
  104001. * 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)
  104002. * @param uniformName Name of the variable.
  104003. * @param array array to be set.
  104004. * @returns this effect.
  104005. */
  104006. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104007. /**
  104008. * 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)
  104009. * @param uniformName Name of the variable.
  104010. * @param array array to be set.
  104011. * @returns this effect.
  104012. */
  104013. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104014. /**
  104015. * Sets an float array on a uniform variable.
  104016. * @param uniformName Name of the variable.
  104017. * @param array array to be set.
  104018. * @returns this effect.
  104019. */
  104020. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104021. /**
  104022. * 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)
  104023. * @param uniformName Name of the variable.
  104024. * @param array array to be set.
  104025. * @returns this effect.
  104026. */
  104027. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104028. /**
  104029. * 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)
  104030. * @param uniformName Name of the variable.
  104031. * @param array array to be set.
  104032. * @returns this effect.
  104033. */
  104034. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104035. /**
  104036. * 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)
  104037. * @param uniformName Name of the variable.
  104038. * @param array array to be set.
  104039. * @returns this effect.
  104040. */
  104041. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104042. /**
  104043. * Sets an array on a uniform variable.
  104044. * @param uniformName Name of the variable.
  104045. * @param array array to be set.
  104046. * @returns this effect.
  104047. */
  104048. setArray(uniformName: string, array: number[]): Effect;
  104049. /**
  104050. * 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)
  104051. * @param uniformName Name of the variable.
  104052. * @param array array to be set.
  104053. * @returns this effect.
  104054. */
  104055. setArray2(uniformName: string, array: number[]): Effect;
  104056. /**
  104057. * 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)
  104058. * @param uniformName Name of the variable.
  104059. * @param array array to be set.
  104060. * @returns this effect.
  104061. */
  104062. setArray3(uniformName: string, array: number[]): Effect;
  104063. /**
  104064. * 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)
  104065. * @param uniformName Name of the variable.
  104066. * @param array array to be set.
  104067. * @returns this effect.
  104068. */
  104069. setArray4(uniformName: string, array: number[]): Effect;
  104070. /**
  104071. * Sets matrices on a uniform variable.
  104072. * @param uniformName Name of the variable.
  104073. * @param matrices matrices to be set.
  104074. * @returns this effect.
  104075. */
  104076. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104077. /**
  104078. * Sets matrix on a uniform variable.
  104079. * @param uniformName Name of the variable.
  104080. * @param matrix matrix to be set.
  104081. * @returns this effect.
  104082. */
  104083. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104084. /**
  104085. * 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)
  104086. * @param uniformName Name of the variable.
  104087. * @param matrix matrix to be set.
  104088. * @returns this effect.
  104089. */
  104090. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  104091. /**
  104092. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  104093. * @param uniformName Name of the variable.
  104094. * @param matrix matrix to be set.
  104095. * @returns this effect.
  104096. */
  104097. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  104098. /**
  104099. * Sets a float on a uniform variable.
  104100. * @param uniformName Name of the variable.
  104101. * @param value value to be set.
  104102. * @returns this effect.
  104103. */
  104104. setFloat(uniformName: string, value: number): Effect;
  104105. /**
  104106. * Sets a boolean on a uniform variable.
  104107. * @param uniformName Name of the variable.
  104108. * @param bool value to be set.
  104109. * @returns this effect.
  104110. */
  104111. setBool(uniformName: string, bool: boolean): Effect;
  104112. /**
  104113. * Sets a Vector2 on a uniform variable.
  104114. * @param uniformName Name of the variable.
  104115. * @param vector2 vector2 to be set.
  104116. * @returns this effect.
  104117. */
  104118. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  104119. /**
  104120. * Sets a float2 on a uniform variable.
  104121. * @param uniformName Name of the variable.
  104122. * @param x First float in float2.
  104123. * @param y Second float in float2.
  104124. * @returns this effect.
  104125. */
  104126. setFloat2(uniformName: string, x: number, y: number): Effect;
  104127. /**
  104128. * Sets a Vector3 on a uniform variable.
  104129. * @param uniformName Name of the variable.
  104130. * @param vector3 Value to be set.
  104131. * @returns this effect.
  104132. */
  104133. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  104134. /**
  104135. * Sets a float3 on a uniform variable.
  104136. * @param uniformName Name of the variable.
  104137. * @param x First float in float3.
  104138. * @param y Second float in float3.
  104139. * @param z Third float in float3.
  104140. * @returns this effect.
  104141. */
  104142. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  104143. /**
  104144. * Sets a Vector4 on a uniform variable.
  104145. * @param uniformName Name of the variable.
  104146. * @param vector4 Value to be set.
  104147. * @returns this effect.
  104148. */
  104149. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  104150. /**
  104151. * Sets a float4 on a uniform variable.
  104152. * @param uniformName Name of the variable.
  104153. * @param x First float in float4.
  104154. * @param y Second float in float4.
  104155. * @param z Third float in float4.
  104156. * @param w Fourth float in float4.
  104157. * @returns this effect.
  104158. */
  104159. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  104160. /**
  104161. * Sets a Color3 on a uniform variable.
  104162. * @param uniformName Name of the variable.
  104163. * @param color3 Value to be set.
  104164. * @returns this effect.
  104165. */
  104166. setColor3(uniformName: string, color3: IColor3Like): Effect;
  104167. /**
  104168. * Sets a Color4 on a uniform variable.
  104169. * @param uniformName Name of the variable.
  104170. * @param color3 Value to be set.
  104171. * @param alpha Alpha value to be set.
  104172. * @returns this effect.
  104173. */
  104174. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  104175. /**
  104176. * Sets a Color4 on a uniform variable
  104177. * @param uniformName defines the name of the variable
  104178. * @param color4 defines the value to be set
  104179. * @returns this effect.
  104180. */
  104181. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  104182. /** Release all associated resources */
  104183. dispose(): void;
  104184. /**
  104185. * This function will add a new shader to the shader store
  104186. * @param name the name of the shader
  104187. * @param pixelShader optional pixel shader content
  104188. * @param vertexShader optional vertex shader content
  104189. */
  104190. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  104191. /**
  104192. * Store of each shader (The can be looked up using effect.key)
  104193. */
  104194. static ShadersStore: {
  104195. [key: string]: string;
  104196. };
  104197. /**
  104198. * Store of each included file for a shader (The can be looked up using effect.key)
  104199. */
  104200. static IncludesShadersStore: {
  104201. [key: string]: string;
  104202. };
  104203. /**
  104204. * Resets the cache of effects.
  104205. */
  104206. static ResetCache(): void;
  104207. }
  104208. }
  104209. declare module BABYLON {
  104210. /**
  104211. * Interface used to describe the capabilities of the engine relatively to the current browser
  104212. */
  104213. export interface EngineCapabilities {
  104214. /** Maximum textures units per fragment shader */
  104215. maxTexturesImageUnits: number;
  104216. /** Maximum texture units per vertex shader */
  104217. maxVertexTextureImageUnits: number;
  104218. /** Maximum textures units in the entire pipeline */
  104219. maxCombinedTexturesImageUnits: number;
  104220. /** Maximum texture size */
  104221. maxTextureSize: number;
  104222. /** Maximum texture samples */
  104223. maxSamples?: number;
  104224. /** Maximum cube texture size */
  104225. maxCubemapTextureSize: number;
  104226. /** Maximum render texture size */
  104227. maxRenderTextureSize: number;
  104228. /** Maximum number of vertex attributes */
  104229. maxVertexAttribs: number;
  104230. /** Maximum number of varyings */
  104231. maxVaryingVectors: number;
  104232. /** Maximum number of uniforms per vertex shader */
  104233. maxVertexUniformVectors: number;
  104234. /** Maximum number of uniforms per fragment shader */
  104235. maxFragmentUniformVectors: number;
  104236. /** Defines if standard derivates (dx/dy) are supported */
  104237. standardDerivatives: boolean;
  104238. /** Defines if s3tc texture compression is supported */
  104239. s3tc?: WEBGL_compressed_texture_s3tc;
  104240. /** Defines if pvrtc texture compression is supported */
  104241. pvrtc: any;
  104242. /** Defines if etc1 texture compression is supported */
  104243. etc1: any;
  104244. /** Defines if etc2 texture compression is supported */
  104245. etc2: any;
  104246. /** Defines if astc texture compression is supported */
  104247. astc: any;
  104248. /** Defines if float textures are supported */
  104249. textureFloat: boolean;
  104250. /** Defines if vertex array objects are supported */
  104251. vertexArrayObject: boolean;
  104252. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  104253. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  104254. /** Gets the maximum level of anisotropy supported */
  104255. maxAnisotropy: number;
  104256. /** Defines if instancing is supported */
  104257. instancedArrays: boolean;
  104258. /** Defines if 32 bits indices are supported */
  104259. uintIndices: boolean;
  104260. /** Defines if high precision shaders are supported */
  104261. highPrecisionShaderSupported: boolean;
  104262. /** Defines if depth reading in the fragment shader is supported */
  104263. fragmentDepthSupported: boolean;
  104264. /** Defines if float texture linear filtering is supported*/
  104265. textureFloatLinearFiltering: boolean;
  104266. /** Defines if rendering to float textures is supported */
  104267. textureFloatRender: boolean;
  104268. /** Defines if half float textures are supported*/
  104269. textureHalfFloat: boolean;
  104270. /** Defines if half float texture linear filtering is supported*/
  104271. textureHalfFloatLinearFiltering: boolean;
  104272. /** Defines if rendering to half float textures is supported */
  104273. textureHalfFloatRender: boolean;
  104274. /** Defines if textureLOD shader command is supported */
  104275. textureLOD: boolean;
  104276. /** Defines if draw buffers extension is supported */
  104277. drawBuffersExtension: boolean;
  104278. /** Defines if depth textures are supported */
  104279. depthTextureExtension: boolean;
  104280. /** Defines if float color buffer are supported */
  104281. colorBufferFloat: boolean;
  104282. /** Gets disjoint timer query extension (null if not supported) */
  104283. timerQuery?: EXT_disjoint_timer_query;
  104284. /** Defines if timestamp can be used with timer query */
  104285. canUseTimestampForTimerQuery: boolean;
  104286. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  104287. multiview?: any;
  104288. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  104289. oculusMultiview?: any;
  104290. /** Function used to let the system compiles shaders in background */
  104291. parallelShaderCompile?: {
  104292. COMPLETION_STATUS_KHR: number;
  104293. };
  104294. /** Max number of texture samples for MSAA */
  104295. maxMSAASamples: number;
  104296. /** Defines if the blend min max extension is supported */
  104297. blendMinMax: boolean;
  104298. }
  104299. }
  104300. declare module BABYLON {
  104301. /**
  104302. * @hidden
  104303. **/
  104304. export class DepthCullingState {
  104305. private _isDepthTestDirty;
  104306. private _isDepthMaskDirty;
  104307. private _isDepthFuncDirty;
  104308. private _isCullFaceDirty;
  104309. private _isCullDirty;
  104310. private _isZOffsetDirty;
  104311. private _isFrontFaceDirty;
  104312. private _depthTest;
  104313. private _depthMask;
  104314. private _depthFunc;
  104315. private _cull;
  104316. private _cullFace;
  104317. private _zOffset;
  104318. private _frontFace;
  104319. /**
  104320. * Initializes the state.
  104321. */
  104322. constructor();
  104323. get isDirty(): boolean;
  104324. get zOffset(): number;
  104325. set zOffset(value: number);
  104326. get cullFace(): Nullable<number>;
  104327. set cullFace(value: Nullable<number>);
  104328. get cull(): Nullable<boolean>;
  104329. set cull(value: Nullable<boolean>);
  104330. get depthFunc(): Nullable<number>;
  104331. set depthFunc(value: Nullable<number>);
  104332. get depthMask(): boolean;
  104333. set depthMask(value: boolean);
  104334. get depthTest(): boolean;
  104335. set depthTest(value: boolean);
  104336. get frontFace(): Nullable<number>;
  104337. set frontFace(value: Nullable<number>);
  104338. reset(): void;
  104339. apply(gl: WebGLRenderingContext): void;
  104340. }
  104341. }
  104342. declare module BABYLON {
  104343. /**
  104344. * @hidden
  104345. **/
  104346. export class StencilState {
  104347. /** 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 */
  104348. static readonly ALWAYS: number;
  104349. /** Passed to stencilOperation to specify that stencil value must be kept */
  104350. static readonly KEEP: number;
  104351. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104352. static readonly REPLACE: number;
  104353. private _isStencilTestDirty;
  104354. private _isStencilMaskDirty;
  104355. private _isStencilFuncDirty;
  104356. private _isStencilOpDirty;
  104357. private _stencilTest;
  104358. private _stencilMask;
  104359. private _stencilFunc;
  104360. private _stencilFuncRef;
  104361. private _stencilFuncMask;
  104362. private _stencilOpStencilFail;
  104363. private _stencilOpDepthFail;
  104364. private _stencilOpStencilDepthPass;
  104365. get isDirty(): boolean;
  104366. get stencilFunc(): number;
  104367. set stencilFunc(value: number);
  104368. get stencilFuncRef(): number;
  104369. set stencilFuncRef(value: number);
  104370. get stencilFuncMask(): number;
  104371. set stencilFuncMask(value: number);
  104372. get stencilOpStencilFail(): number;
  104373. set stencilOpStencilFail(value: number);
  104374. get stencilOpDepthFail(): number;
  104375. set stencilOpDepthFail(value: number);
  104376. get stencilOpStencilDepthPass(): number;
  104377. set stencilOpStencilDepthPass(value: number);
  104378. get stencilMask(): number;
  104379. set stencilMask(value: number);
  104380. get stencilTest(): boolean;
  104381. set stencilTest(value: boolean);
  104382. constructor();
  104383. reset(): void;
  104384. apply(gl: WebGLRenderingContext): void;
  104385. }
  104386. }
  104387. declare module BABYLON {
  104388. /**
  104389. * @hidden
  104390. **/
  104391. export class AlphaState {
  104392. private _isAlphaBlendDirty;
  104393. private _isBlendFunctionParametersDirty;
  104394. private _isBlendEquationParametersDirty;
  104395. private _isBlendConstantsDirty;
  104396. private _alphaBlend;
  104397. private _blendFunctionParameters;
  104398. private _blendEquationParameters;
  104399. private _blendConstants;
  104400. /**
  104401. * Initializes the state.
  104402. */
  104403. constructor();
  104404. get isDirty(): boolean;
  104405. get alphaBlend(): boolean;
  104406. set alphaBlend(value: boolean);
  104407. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  104408. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  104409. setAlphaEquationParameters(rgb: number, alpha: number): void;
  104410. reset(): void;
  104411. apply(gl: WebGLRenderingContext): void;
  104412. }
  104413. }
  104414. declare module BABYLON {
  104415. /** @hidden */
  104416. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104417. attributeProcessor(attribute: string): string;
  104418. varyingProcessor(varying: string, isFragment: boolean): string;
  104419. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104420. }
  104421. }
  104422. declare module BABYLON {
  104423. /**
  104424. * Interface for attribute information associated with buffer instanciation
  104425. */
  104426. export interface InstancingAttributeInfo {
  104427. /**
  104428. * Name of the GLSL attribute
  104429. * if attribute index is not specified, this is used to retrieve the index from the effect
  104430. */
  104431. attributeName: string;
  104432. /**
  104433. * Index/offset of the attribute in the vertex shader
  104434. * if not specified, this will be computes from the name.
  104435. */
  104436. index?: number;
  104437. /**
  104438. * size of the attribute, 1, 2, 3 or 4
  104439. */
  104440. attributeSize: number;
  104441. /**
  104442. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104443. */
  104444. offset: number;
  104445. /**
  104446. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104447. * default to 1
  104448. */
  104449. divisor?: number;
  104450. /**
  104451. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104452. * default is FLOAT
  104453. */
  104454. attributeType?: number;
  104455. /**
  104456. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104457. */
  104458. normalized?: boolean;
  104459. }
  104460. }
  104461. declare module BABYLON {
  104462. interface ThinEngine {
  104463. /**
  104464. * Update a video texture
  104465. * @param texture defines the texture to update
  104466. * @param video defines the video element to use
  104467. * @param invertY defines if data must be stored with Y axis inverted
  104468. */
  104469. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104470. }
  104471. }
  104472. declare module BABYLON {
  104473. /**
  104474. * Settings for finer control over video usage
  104475. */
  104476. export interface VideoTextureSettings {
  104477. /**
  104478. * Applies `autoplay` to video, if specified
  104479. */
  104480. autoPlay?: boolean;
  104481. /**
  104482. * Applies `loop` to video, if specified
  104483. */
  104484. loop?: boolean;
  104485. /**
  104486. * Automatically updates internal texture from video at every frame in the render loop
  104487. */
  104488. autoUpdateTexture: boolean;
  104489. /**
  104490. * Image src displayed during the video loading or until the user interacts with the video.
  104491. */
  104492. poster?: string;
  104493. }
  104494. /**
  104495. * If you want to display a video in your scene, this is the special texture for that.
  104496. * This special texture works similar to other textures, with the exception of a few parameters.
  104497. * @see https://doc.babylonjs.com/how_to/video_texture
  104498. */
  104499. export class VideoTexture extends Texture {
  104500. /**
  104501. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104502. */
  104503. readonly autoUpdateTexture: boolean;
  104504. /**
  104505. * The video instance used by the texture internally
  104506. */
  104507. readonly video: HTMLVideoElement;
  104508. private _onUserActionRequestedObservable;
  104509. /**
  104510. * Event triggerd when a dom action is required by the user to play the video.
  104511. * This happens due to recent changes in browser policies preventing video to auto start.
  104512. */
  104513. get onUserActionRequestedObservable(): Observable<Texture>;
  104514. private _generateMipMaps;
  104515. private _engine;
  104516. private _stillImageCaptured;
  104517. private _displayingPosterTexture;
  104518. private _settings;
  104519. private _createInternalTextureOnEvent;
  104520. private _frameId;
  104521. private _currentSrc;
  104522. /**
  104523. * Creates a video texture.
  104524. * If you want to display a video in your scene, this is the special texture for that.
  104525. * This special texture works similar to other textures, with the exception of a few parameters.
  104526. * @see https://doc.babylonjs.com/how_to/video_texture
  104527. * @param name optional name, will detect from video source, if not defined
  104528. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104529. * @param scene is obviously the current scene.
  104530. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104531. * @param invertY is false by default but can be used to invert video on Y axis
  104532. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104533. * @param settings allows finer control over video usage
  104534. */
  104535. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104536. private _getName;
  104537. private _getVideo;
  104538. private _createInternalTexture;
  104539. private reset;
  104540. /**
  104541. * @hidden Internal method to initiate `update`.
  104542. */
  104543. _rebuild(): void;
  104544. /**
  104545. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104546. */
  104547. update(): void;
  104548. /**
  104549. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104550. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104551. */
  104552. updateTexture(isVisible: boolean): void;
  104553. protected _updateInternalTexture: () => void;
  104554. /**
  104555. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104556. * @param url New url.
  104557. */
  104558. updateURL(url: string): void;
  104559. /**
  104560. * Clones the texture.
  104561. * @returns the cloned texture
  104562. */
  104563. clone(): VideoTexture;
  104564. /**
  104565. * Dispose the texture and release its associated resources.
  104566. */
  104567. dispose(): void;
  104568. /**
  104569. * Creates a video texture straight from a stream.
  104570. * @param scene Define the scene the texture should be created in
  104571. * @param stream Define the stream the texture should be created from
  104572. * @returns The created video texture as a promise
  104573. */
  104574. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104575. /**
  104576. * Creates a video texture straight from your WebCam video feed.
  104577. * @param scene Define the scene the texture should be created in
  104578. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104579. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104580. * @returns The created video texture as a promise
  104581. */
  104582. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104583. minWidth: number;
  104584. maxWidth: number;
  104585. minHeight: number;
  104586. maxHeight: number;
  104587. deviceId: string;
  104588. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104589. /**
  104590. * Creates a video texture straight from your WebCam video feed.
  104591. * @param scene Define the scene the texture should be created in
  104592. * @param onReady Define a callback to triggered once the texture will be ready
  104593. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104594. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104595. */
  104596. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104597. minWidth: number;
  104598. maxWidth: number;
  104599. minHeight: number;
  104600. maxHeight: number;
  104601. deviceId: string;
  104602. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104603. }
  104604. }
  104605. declare module BABYLON {
  104606. /**
  104607. * Defines the interface used by objects working like Scene
  104608. * @hidden
  104609. */
  104610. export interface ISceneLike {
  104611. _addPendingData(data: any): void;
  104612. _removePendingData(data: any): void;
  104613. offlineProvider: IOfflineProvider;
  104614. }
  104615. /** Interface defining initialization parameters for Engine class */
  104616. export interface EngineOptions extends WebGLContextAttributes {
  104617. /**
  104618. * Defines if the engine should no exceed a specified device ratio
  104619. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104620. */
  104621. limitDeviceRatio?: number;
  104622. /**
  104623. * Defines if webvr should be enabled automatically
  104624. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104625. */
  104626. autoEnableWebVR?: boolean;
  104627. /**
  104628. * Defines if webgl2 should be turned off even if supported
  104629. * @see http://doc.babylonjs.com/features/webgl2
  104630. */
  104631. disableWebGL2Support?: boolean;
  104632. /**
  104633. * Defines if webaudio should be initialized as well
  104634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104635. */
  104636. audioEngine?: boolean;
  104637. /**
  104638. * Defines if animations should run using a deterministic lock step
  104639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104640. */
  104641. deterministicLockstep?: boolean;
  104642. /** Defines the maximum steps to use with deterministic lock step mode */
  104643. lockstepMaxSteps?: number;
  104644. /** Defines the seconds between each deterministic lock step */
  104645. timeStep?: number;
  104646. /**
  104647. * Defines that engine should ignore context lost events
  104648. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104649. */
  104650. doNotHandleContextLost?: boolean;
  104651. /**
  104652. * Defines that engine should ignore modifying touch action attribute and style
  104653. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104654. */
  104655. doNotHandleTouchAction?: boolean;
  104656. /**
  104657. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104658. */
  104659. useHighPrecisionFloats?: boolean;
  104660. }
  104661. /**
  104662. * The base engine class (root of all engines)
  104663. */
  104664. export class ThinEngine {
  104665. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104666. static ExceptionList: ({
  104667. key: string;
  104668. capture: string;
  104669. captureConstraint: number;
  104670. targets: string[];
  104671. } | {
  104672. key: string;
  104673. capture: null;
  104674. captureConstraint: null;
  104675. targets: string[];
  104676. })[];
  104677. /** @hidden */
  104678. static _TextureLoaders: IInternalTextureLoader[];
  104679. /**
  104680. * Returns the current npm package of the sdk
  104681. */
  104682. static get NpmPackage(): string;
  104683. /**
  104684. * Returns the current version of the framework
  104685. */
  104686. static get Version(): string;
  104687. /**
  104688. * Returns a string describing the current engine
  104689. */
  104690. get description(): string;
  104691. /**
  104692. * Gets or sets the epsilon value used by collision engine
  104693. */
  104694. static CollisionsEpsilon: number;
  104695. /**
  104696. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104697. */
  104698. static get ShadersRepository(): string;
  104699. static set ShadersRepository(value: string);
  104700. /** @hidden */
  104701. _shaderProcessor: IShaderProcessor;
  104702. /**
  104703. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104704. */
  104705. forcePOTTextures: boolean;
  104706. /**
  104707. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104708. */
  104709. isFullscreen: boolean;
  104710. /**
  104711. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104712. */
  104713. cullBackFaces: boolean;
  104714. /**
  104715. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104716. */
  104717. renderEvenInBackground: boolean;
  104718. /**
  104719. * Gets or sets a boolean indicating that cache can be kept between frames
  104720. */
  104721. preventCacheWipeBetweenFrames: boolean;
  104722. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104723. validateShaderPrograms: boolean;
  104724. /**
  104725. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104726. * This can provide greater z depth for distant objects.
  104727. */
  104728. useReverseDepthBuffer: boolean;
  104729. /**
  104730. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104731. */
  104732. disableUniformBuffers: boolean;
  104733. /** @hidden */
  104734. _uniformBuffers: UniformBuffer[];
  104735. /**
  104736. * Gets a boolean indicating that the engine supports uniform buffers
  104737. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104738. */
  104739. get supportsUniformBuffers(): boolean;
  104740. /** @hidden */
  104741. _gl: WebGLRenderingContext;
  104742. /** @hidden */
  104743. _webGLVersion: number;
  104744. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104745. protected _windowIsBackground: boolean;
  104746. protected _creationOptions: EngineOptions;
  104747. protected _highPrecisionShadersAllowed: boolean;
  104748. /** @hidden */
  104749. get _shouldUseHighPrecisionShader(): boolean;
  104750. /**
  104751. * Gets a boolean indicating that only power of 2 textures are supported
  104752. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104753. */
  104754. get needPOTTextures(): boolean;
  104755. /** @hidden */
  104756. _badOS: boolean;
  104757. /** @hidden */
  104758. _badDesktopOS: boolean;
  104759. private _hardwareScalingLevel;
  104760. /** @hidden */
  104761. _caps: EngineCapabilities;
  104762. private _isStencilEnable;
  104763. private _glVersion;
  104764. private _glRenderer;
  104765. private _glVendor;
  104766. /** @hidden */
  104767. _videoTextureSupported: boolean;
  104768. protected _renderingQueueLaunched: boolean;
  104769. protected _activeRenderLoops: (() => void)[];
  104770. /**
  104771. * Observable signaled when a context lost event is raised
  104772. */
  104773. onContextLostObservable: Observable<ThinEngine>;
  104774. /**
  104775. * Observable signaled when a context restored event is raised
  104776. */
  104777. onContextRestoredObservable: Observable<ThinEngine>;
  104778. private _onContextLost;
  104779. private _onContextRestored;
  104780. protected _contextWasLost: boolean;
  104781. /** @hidden */
  104782. _doNotHandleContextLost: boolean;
  104783. /**
  104784. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104786. */
  104787. get doNotHandleContextLost(): boolean;
  104788. set doNotHandleContextLost(value: boolean);
  104789. /**
  104790. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104791. */
  104792. disableVertexArrayObjects: boolean;
  104793. /** @hidden */
  104794. protected _colorWrite: boolean;
  104795. /** @hidden */
  104796. protected _colorWriteChanged: boolean;
  104797. /** @hidden */
  104798. protected _depthCullingState: DepthCullingState;
  104799. /** @hidden */
  104800. protected _stencilState: StencilState;
  104801. /** @hidden */
  104802. _alphaState: AlphaState;
  104803. /** @hidden */
  104804. _alphaMode: number;
  104805. /** @hidden */
  104806. _alphaEquation: number;
  104807. /** @hidden */
  104808. _internalTexturesCache: InternalTexture[];
  104809. /** @hidden */
  104810. protected _activeChannel: number;
  104811. private _currentTextureChannel;
  104812. /** @hidden */
  104813. protected _boundTexturesCache: {
  104814. [key: string]: Nullable<InternalTexture>;
  104815. };
  104816. /** @hidden */
  104817. protected _currentEffect: Nullable<Effect>;
  104818. /** @hidden */
  104819. protected _currentProgram: Nullable<WebGLProgram>;
  104820. private _compiledEffects;
  104821. private _vertexAttribArraysEnabled;
  104822. /** @hidden */
  104823. protected _cachedViewport: Nullable<IViewportLike>;
  104824. private _cachedVertexArrayObject;
  104825. /** @hidden */
  104826. protected _cachedVertexBuffers: any;
  104827. /** @hidden */
  104828. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104829. /** @hidden */
  104830. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104831. /** @hidden */
  104832. _currentRenderTarget: Nullable<InternalTexture>;
  104833. private _uintIndicesCurrentlySet;
  104834. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104835. /** @hidden */
  104836. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104837. private _currentBufferPointers;
  104838. private _currentInstanceLocations;
  104839. private _currentInstanceBuffers;
  104840. private _textureUnits;
  104841. /** @hidden */
  104842. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104843. /** @hidden */
  104844. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104845. /** @hidden */
  104846. _boundRenderFunction: any;
  104847. private _vaoRecordInProgress;
  104848. private _mustWipeVertexAttributes;
  104849. private _emptyTexture;
  104850. private _emptyCubeTexture;
  104851. private _emptyTexture3D;
  104852. private _emptyTexture2DArray;
  104853. /** @hidden */
  104854. _frameHandler: number;
  104855. private _nextFreeTextureSlots;
  104856. private _maxSimultaneousTextures;
  104857. private _activeRequests;
  104858. /** @hidden */
  104859. _transformTextureUrl: Nullable<(url: string) => string>;
  104860. protected get _supportsHardwareTextureRescaling(): boolean;
  104861. private _framebufferDimensionsObject;
  104862. /**
  104863. * sets the object from which width and height will be taken from when getting render width and height
  104864. * Will fallback to the gl object
  104865. * @param dimensions the framebuffer width and height that will be used.
  104866. */
  104867. set framebufferDimensionsObject(dimensions: Nullable<{
  104868. framebufferWidth: number;
  104869. framebufferHeight: number;
  104870. }>);
  104871. /**
  104872. * Gets the current viewport
  104873. */
  104874. get currentViewport(): Nullable<IViewportLike>;
  104875. /**
  104876. * Gets the default empty texture
  104877. */
  104878. get emptyTexture(): InternalTexture;
  104879. /**
  104880. * Gets the default empty 3D texture
  104881. */
  104882. get emptyTexture3D(): InternalTexture;
  104883. /**
  104884. * Gets the default empty 2D array texture
  104885. */
  104886. get emptyTexture2DArray(): InternalTexture;
  104887. /**
  104888. * Gets the default empty cube texture
  104889. */
  104890. get emptyCubeTexture(): InternalTexture;
  104891. /**
  104892. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104893. */
  104894. readonly premultipliedAlpha: boolean;
  104895. /**
  104896. * Observable event triggered before each texture is initialized
  104897. */
  104898. onBeforeTextureInitObservable: Observable<Texture>;
  104899. /**
  104900. * Creates a new engine
  104901. * @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
  104902. * @param antialias defines enable antialiasing (default: false)
  104903. * @param options defines further options to be sent to the getContext() function
  104904. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104905. */
  104906. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104907. private _rebuildInternalTextures;
  104908. private _rebuildEffects;
  104909. /**
  104910. * Gets a boolean indicating if all created effects are ready
  104911. * @returns true if all effects are ready
  104912. */
  104913. areAllEffectsReady(): boolean;
  104914. protected _rebuildBuffers(): void;
  104915. protected _initGLContext(): void;
  104916. /**
  104917. * Gets version of the current webGL context
  104918. */
  104919. get webGLVersion(): number;
  104920. /**
  104921. * Gets a string idenfifying the name of the class
  104922. * @returns "Engine" string
  104923. */
  104924. getClassName(): string;
  104925. /**
  104926. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104927. */
  104928. get isStencilEnable(): boolean;
  104929. /** @hidden */
  104930. _prepareWorkingCanvas(): void;
  104931. /**
  104932. * Reset the texture cache to empty state
  104933. */
  104934. resetTextureCache(): void;
  104935. /**
  104936. * Gets an object containing information about the current webGL context
  104937. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104938. */
  104939. getGlInfo(): {
  104940. vendor: string;
  104941. renderer: string;
  104942. version: string;
  104943. };
  104944. /**
  104945. * Defines the hardware scaling level.
  104946. * By default the hardware scaling level is computed from the window device ratio.
  104947. * 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.
  104948. * @param level defines the level to use
  104949. */
  104950. setHardwareScalingLevel(level: number): void;
  104951. /**
  104952. * Gets the current hardware scaling level.
  104953. * By default the hardware scaling level is computed from the window device ratio.
  104954. * 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.
  104955. * @returns a number indicating the current hardware scaling level
  104956. */
  104957. getHardwareScalingLevel(): number;
  104958. /**
  104959. * Gets the list of loaded textures
  104960. * @returns an array containing all loaded textures
  104961. */
  104962. getLoadedTexturesCache(): InternalTexture[];
  104963. /**
  104964. * Gets the object containing all engine capabilities
  104965. * @returns the EngineCapabilities object
  104966. */
  104967. getCaps(): EngineCapabilities;
  104968. /**
  104969. * stop executing a render loop function and remove it from the execution array
  104970. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104971. */
  104972. stopRenderLoop(renderFunction?: () => void): void;
  104973. /** @hidden */
  104974. _renderLoop(): void;
  104975. /**
  104976. * Gets the HTML canvas attached with the current webGL context
  104977. * @returns a HTML canvas
  104978. */
  104979. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104980. /**
  104981. * Gets host window
  104982. * @returns the host window object
  104983. */
  104984. getHostWindow(): Nullable<Window>;
  104985. /**
  104986. * Gets the current render width
  104987. * @param useScreen defines if screen size must be used (or the current render target if any)
  104988. * @returns a number defining the current render width
  104989. */
  104990. getRenderWidth(useScreen?: boolean): number;
  104991. /**
  104992. * Gets the current render height
  104993. * @param useScreen defines if screen size must be used (or the current render target if any)
  104994. * @returns a number defining the current render height
  104995. */
  104996. getRenderHeight(useScreen?: boolean): number;
  104997. /**
  104998. * Can be used to override the current requestAnimationFrame requester.
  104999. * @hidden
  105000. */
  105001. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105002. /**
  105003. * Register and execute a render loop. The engine can have more than one render function
  105004. * @param renderFunction defines the function to continuously execute
  105005. */
  105006. runRenderLoop(renderFunction: () => void): void;
  105007. /**
  105008. * Clear the current render buffer or the current render target (if any is set up)
  105009. * @param color defines the color to use
  105010. * @param backBuffer defines if the back buffer must be cleared
  105011. * @param depth defines if the depth buffer must be cleared
  105012. * @param stencil defines if the stencil buffer must be cleared
  105013. */
  105014. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105015. private _viewportCached;
  105016. /** @hidden */
  105017. _viewport(x: number, y: number, width: number, height: number): void;
  105018. /**
  105019. * Set the WebGL's viewport
  105020. * @param viewport defines the viewport element to be used
  105021. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105022. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105023. */
  105024. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105025. /**
  105026. * Begin a new frame
  105027. */
  105028. beginFrame(): void;
  105029. /**
  105030. * Enf the current frame
  105031. */
  105032. endFrame(): void;
  105033. /**
  105034. * Resize the view according to the canvas' size
  105035. */
  105036. resize(): void;
  105037. /**
  105038. * Force a specific size of the canvas
  105039. * @param width defines the new canvas' width
  105040. * @param height defines the new canvas' height
  105041. */
  105042. setSize(width: number, height: number): void;
  105043. /**
  105044. * Binds the frame buffer to the specified texture.
  105045. * @param texture The texture to render to or null for the default canvas
  105046. * @param faceIndex The face of the texture to render to in case of cube texture
  105047. * @param requiredWidth The width of the target to render to
  105048. * @param requiredHeight The height of the target to render to
  105049. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105050. * @param lodLevel defines the lod level to bind to the frame buffer
  105051. * @param layer defines the 2d array index to bind to frame buffer to
  105052. */
  105053. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105054. /** @hidden */
  105055. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105056. /**
  105057. * Unbind the current render target texture from the webGL context
  105058. * @param texture defines the render target texture to unbind
  105059. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105060. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105061. */
  105062. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105063. /**
  105064. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105065. */
  105066. flushFramebuffer(): void;
  105067. /**
  105068. * Unbind the current render target and bind the default framebuffer
  105069. */
  105070. restoreDefaultFramebuffer(): void;
  105071. /** @hidden */
  105072. protected _resetVertexBufferBinding(): void;
  105073. /**
  105074. * Creates a vertex buffer
  105075. * @param data the data for the vertex buffer
  105076. * @returns the new WebGL static buffer
  105077. */
  105078. createVertexBuffer(data: DataArray): DataBuffer;
  105079. private _createVertexBuffer;
  105080. /**
  105081. * Creates a dynamic vertex buffer
  105082. * @param data the data for the dynamic vertex buffer
  105083. * @returns the new WebGL dynamic buffer
  105084. */
  105085. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105086. protected _resetIndexBufferBinding(): void;
  105087. /**
  105088. * Creates a new index buffer
  105089. * @param indices defines the content of the index buffer
  105090. * @param updatable defines if the index buffer must be updatable
  105091. * @returns a new webGL buffer
  105092. */
  105093. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  105094. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  105095. /**
  105096. * Bind a webGL buffer to the webGL context
  105097. * @param buffer defines the buffer to bind
  105098. */
  105099. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  105100. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  105101. private bindBuffer;
  105102. /**
  105103. * update the bound buffer with the given data
  105104. * @param data defines the data to update
  105105. */
  105106. updateArrayBuffer(data: Float32Array): void;
  105107. private _vertexAttribPointer;
  105108. /** @hidden */
  105109. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  105110. private _bindVertexBuffersAttributes;
  105111. /**
  105112. * Records a vertex array object
  105113. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105114. * @param vertexBuffers defines the list of vertex buffers to store
  105115. * @param indexBuffer defines the index buffer to store
  105116. * @param effect defines the effect to store
  105117. * @returns the new vertex array object
  105118. */
  105119. recordVertexArrayObject(vertexBuffers: {
  105120. [key: string]: VertexBuffer;
  105121. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  105122. /**
  105123. * Bind a specific vertex array object
  105124. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105125. * @param vertexArrayObject defines the vertex array object to bind
  105126. * @param indexBuffer defines the index buffer to bind
  105127. */
  105128. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  105129. /**
  105130. * Bind webGl buffers directly to the webGL context
  105131. * @param vertexBuffer defines the vertex buffer to bind
  105132. * @param indexBuffer defines the index buffer to bind
  105133. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  105134. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  105135. * @param effect defines the effect associated with the vertex buffer
  105136. */
  105137. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  105138. private _unbindVertexArrayObject;
  105139. /**
  105140. * Bind a list of vertex buffers to the webGL context
  105141. * @param vertexBuffers defines the list of vertex buffers to bind
  105142. * @param indexBuffer defines the index buffer to bind
  105143. * @param effect defines the effect associated with the vertex buffers
  105144. */
  105145. bindBuffers(vertexBuffers: {
  105146. [key: string]: Nullable<VertexBuffer>;
  105147. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  105148. /**
  105149. * Unbind all instance attributes
  105150. */
  105151. unbindInstanceAttributes(): void;
  105152. /**
  105153. * Release and free the memory of a vertex array object
  105154. * @param vao defines the vertex array object to delete
  105155. */
  105156. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  105157. /** @hidden */
  105158. _releaseBuffer(buffer: DataBuffer): boolean;
  105159. protected _deleteBuffer(buffer: DataBuffer): void;
  105160. /**
  105161. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  105162. * @param instancesBuffer defines the webGL buffer to update and bind
  105163. * @param data defines the data to store in the buffer
  105164. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  105165. */
  105166. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  105167. /**
  105168. * Bind the content of a webGL buffer used with instantiation
  105169. * @param instancesBuffer defines the webGL buffer to bind
  105170. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  105171. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  105172. */
  105173. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  105174. /**
  105175. * Disable the instance attribute corresponding to the name in parameter
  105176. * @param name defines the name of the attribute to disable
  105177. */
  105178. disableInstanceAttributeByName(name: string): void;
  105179. /**
  105180. * Disable the instance attribute corresponding to the location in parameter
  105181. * @param attributeLocation defines the attribute location of the attribute to disable
  105182. */
  105183. disableInstanceAttribute(attributeLocation: number): void;
  105184. /**
  105185. * Disable the attribute corresponding to the location in parameter
  105186. * @param attributeLocation defines the attribute location of the attribute to disable
  105187. */
  105188. disableAttributeByIndex(attributeLocation: number): void;
  105189. /**
  105190. * Send a draw order
  105191. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105192. * @param indexStart defines the starting index
  105193. * @param indexCount defines the number of index to draw
  105194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105195. */
  105196. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  105197. /**
  105198. * Draw a list of points
  105199. * @param verticesStart defines the index of first vertex to draw
  105200. * @param verticesCount defines the count of vertices to draw
  105201. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105202. */
  105203. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105204. /**
  105205. * Draw a list of unindexed primitives
  105206. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105207. * @param verticesStart defines the index of first vertex to draw
  105208. * @param verticesCount defines the count of vertices to draw
  105209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105210. */
  105211. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105212. /**
  105213. * Draw a list of indexed primitives
  105214. * @param fillMode defines the primitive to use
  105215. * @param indexStart defines the starting index
  105216. * @param indexCount defines the number of index to draw
  105217. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105218. */
  105219. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  105220. /**
  105221. * Draw a list of unindexed primitives
  105222. * @param fillMode defines the primitive to use
  105223. * @param verticesStart defines the index of first vertex to draw
  105224. * @param verticesCount defines the count of vertices to draw
  105225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105226. */
  105227. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105228. private _drawMode;
  105229. /** @hidden */
  105230. protected _reportDrawCall(): void;
  105231. /** @hidden */
  105232. _releaseEffect(effect: Effect): void;
  105233. /** @hidden */
  105234. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  105235. /**
  105236. * Create a new effect (used to store vertex/fragment shaders)
  105237. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  105238. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  105239. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  105240. * @param samplers defines an array of string used to represent textures
  105241. * @param defines defines the string containing the defines to use to compile the shaders
  105242. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105243. * @param onCompiled defines a function to call when the effect creation is successful
  105244. * @param onError defines a function to call when the effect creation has failed
  105245. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  105246. * @returns the new Effect
  105247. */
  105248. 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;
  105249. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  105250. private _compileShader;
  105251. private _compileRawShader;
  105252. /** @hidden */
  105253. _getShaderSource(shader: WebGLShader): Nullable<string>;
  105254. /**
  105255. * Directly creates a webGL program
  105256. * @param pipelineContext defines the pipeline context to attach to
  105257. * @param vertexCode defines the vertex shader code to use
  105258. * @param fragmentCode defines the fragment shader code to use
  105259. * @param context defines the webGL context to use (if not set, the current one will be used)
  105260. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105261. * @returns the new webGL program
  105262. */
  105263. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105264. /**
  105265. * Creates a webGL program
  105266. * @param pipelineContext defines the pipeline context to attach to
  105267. * @param vertexCode defines the vertex shader code to use
  105268. * @param fragmentCode defines the fragment shader code to use
  105269. * @param defines defines the string containing the defines to use to compile the shaders
  105270. * @param context defines the webGL context to use (if not set, the current one will be used)
  105271. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105272. * @returns the new webGL program
  105273. */
  105274. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105275. /**
  105276. * Creates a new pipeline context
  105277. * @returns the new pipeline
  105278. */
  105279. createPipelineContext(): IPipelineContext;
  105280. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105281. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  105282. /** @hidden */
  105283. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  105284. /** @hidden */
  105285. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  105286. /** @hidden */
  105287. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  105288. /**
  105289. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  105290. * @param pipelineContext defines the pipeline context to use
  105291. * @param uniformsNames defines the list of uniform names
  105292. * @returns an array of webGL uniform locations
  105293. */
  105294. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105295. /**
  105296. * Gets the lsit of active attributes for a given webGL program
  105297. * @param pipelineContext defines the pipeline context to use
  105298. * @param attributesNames defines the list of attribute names to get
  105299. * @returns an array of indices indicating the offset of each attribute
  105300. */
  105301. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105302. /**
  105303. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105304. * @param effect defines the effect to activate
  105305. */
  105306. enableEffect(effect: Nullable<Effect>): void;
  105307. /**
  105308. * Set the value of an uniform to a number (int)
  105309. * @param uniform defines the webGL uniform location where to store the value
  105310. * @param value defines the int number to store
  105311. */
  105312. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105313. /**
  105314. * Set the value of an uniform to an array of int32
  105315. * @param uniform defines the webGL uniform location where to store the value
  105316. * @param array defines the array of int32 to store
  105317. */
  105318. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105319. /**
  105320. * Set the value of an uniform to an array of int32 (stored as vec2)
  105321. * @param uniform defines the webGL uniform location where to store the value
  105322. * @param array defines the array of int32 to store
  105323. */
  105324. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105325. /**
  105326. * Set the value of an uniform to an array of int32 (stored as vec3)
  105327. * @param uniform defines the webGL uniform location where to store the value
  105328. * @param array defines the array of int32 to store
  105329. */
  105330. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105331. /**
  105332. * Set the value of an uniform to an array of int32 (stored as vec4)
  105333. * @param uniform defines the webGL uniform location where to store the value
  105334. * @param array defines the array of int32 to store
  105335. */
  105336. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105337. /**
  105338. * Set the value of an uniform to an array of number
  105339. * @param uniform defines the webGL uniform location where to store the value
  105340. * @param array defines the array of number to store
  105341. */
  105342. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105343. /**
  105344. * Set the value of an uniform to an array of number (stored as vec2)
  105345. * @param uniform defines the webGL uniform location where to store the value
  105346. * @param array defines the array of number to store
  105347. */
  105348. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105349. /**
  105350. * Set the value of an uniform to an array of number (stored as vec3)
  105351. * @param uniform defines the webGL uniform location where to store the value
  105352. * @param array defines the array of number to store
  105353. */
  105354. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105355. /**
  105356. * Set the value of an uniform to an array of number (stored as vec4)
  105357. * @param uniform defines the webGL uniform location where to store the value
  105358. * @param array defines the array of number to store
  105359. */
  105360. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105361. /**
  105362. * Set the value of an uniform to an array of float32 (stored as matrices)
  105363. * @param uniform defines the webGL uniform location where to store the value
  105364. * @param matrices defines the array of float32 to store
  105365. */
  105366. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  105367. /**
  105368. * Set the value of an uniform to a matrix (3x3)
  105369. * @param uniform defines the webGL uniform location where to store the value
  105370. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  105371. */
  105372. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105373. /**
  105374. * Set the value of an uniform to a matrix (2x2)
  105375. * @param uniform defines the webGL uniform location where to store the value
  105376. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  105377. */
  105378. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105379. /**
  105380. * Set the value of an uniform to a number (float)
  105381. * @param uniform defines the webGL uniform location where to store the value
  105382. * @param value defines the float number to store
  105383. */
  105384. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105385. /**
  105386. * Set the value of an uniform to a vec2
  105387. * @param uniform defines the webGL uniform location where to store the value
  105388. * @param x defines the 1st component of the value
  105389. * @param y defines the 2nd component of the value
  105390. */
  105391. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  105392. /**
  105393. * Set the value of an uniform to a vec3
  105394. * @param uniform defines the webGL uniform location where to store the value
  105395. * @param x defines the 1st component of the value
  105396. * @param y defines the 2nd component of the value
  105397. * @param z defines the 3rd component of the value
  105398. */
  105399. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  105400. /**
  105401. * Set the value of an uniform to a vec4
  105402. * @param uniform defines the webGL uniform location where to store the value
  105403. * @param x defines the 1st component of the value
  105404. * @param y defines the 2nd component of the value
  105405. * @param z defines the 3rd component of the value
  105406. * @param w defines the 4th component of the value
  105407. */
  105408. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105409. /**
  105410. * Apply all cached states (depth, culling, stencil and alpha)
  105411. */
  105412. applyStates(): void;
  105413. /**
  105414. * Enable or disable color writing
  105415. * @param enable defines the state to set
  105416. */
  105417. setColorWrite(enable: boolean): void;
  105418. /**
  105419. * Gets a boolean indicating if color writing is enabled
  105420. * @returns the current color writing state
  105421. */
  105422. getColorWrite(): boolean;
  105423. /**
  105424. * Gets the depth culling state manager
  105425. */
  105426. get depthCullingState(): DepthCullingState;
  105427. /**
  105428. * Gets the alpha state manager
  105429. */
  105430. get alphaState(): AlphaState;
  105431. /**
  105432. * Gets the stencil state manager
  105433. */
  105434. get stencilState(): StencilState;
  105435. /**
  105436. * Clears the list of texture accessible through engine.
  105437. * This can help preventing texture load conflict due to name collision.
  105438. */
  105439. clearInternalTexturesCache(): void;
  105440. /**
  105441. * Force the entire cache to be cleared
  105442. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105443. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105444. */
  105445. wipeCaches(bruteForce?: boolean): void;
  105446. /** @hidden */
  105447. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105448. min: number;
  105449. mag: number;
  105450. };
  105451. /** @hidden */
  105452. _createTexture(): WebGLTexture;
  105453. /**
  105454. * Usually called from Texture.ts.
  105455. * Passed information to create a WebGLTexture
  105456. * @param url defines a value which contains one of the following:
  105457. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105458. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105459. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105460. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105461. * @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)
  105462. * @param scene needed for loading to the correct scene
  105463. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105464. * @param onLoad optional callback to be called upon successful completion
  105465. * @param onError optional callback to be called upon failure
  105466. * @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
  105467. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105468. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105469. * @param forcedExtension defines the extension to use to pick the right loader
  105470. * @param mimeType defines an optional mime type
  105471. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105472. */
  105473. 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;
  105474. /**
  105475. * Loads an image as an HTMLImageElement.
  105476. * @param input url string, ArrayBuffer, or Blob to load
  105477. * @param onLoad callback called when the image successfully loads
  105478. * @param onError callback called when the image fails to load
  105479. * @param offlineProvider offline provider for caching
  105480. * @param mimeType optional mime type
  105481. * @returns the HTMLImageElement of the loaded image
  105482. * @hidden
  105483. */
  105484. 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>;
  105485. /**
  105486. * @hidden
  105487. */
  105488. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105489. /**
  105490. * Creates a raw texture
  105491. * @param data defines the data to store in the texture
  105492. * @param width defines the width of the texture
  105493. * @param height defines the height of the texture
  105494. * @param format defines the format of the data
  105495. * @param generateMipMaps defines if the engine should generate the mip levels
  105496. * @param invertY defines if data must be stored with Y axis inverted
  105497. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105498. * @param compression defines the compression used (null by default)
  105499. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105500. * @returns the raw texture inside an InternalTexture
  105501. */
  105502. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105503. /**
  105504. * Creates a new raw cube texture
  105505. * @param data defines the array of data to use to create each face
  105506. * @param size defines the size of the textures
  105507. * @param format defines the format of the data
  105508. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105509. * @param generateMipMaps defines if the engine should generate the mip levels
  105510. * @param invertY defines if data must be stored with Y axis inverted
  105511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105512. * @param compression defines the compression used (null by default)
  105513. * @returns the cube texture as an InternalTexture
  105514. */
  105515. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105516. /**
  105517. * Creates a new raw 3D texture
  105518. * @param data defines the data used to create the texture
  105519. * @param width defines the width of the texture
  105520. * @param height defines the height of the texture
  105521. * @param depth defines the depth of the texture
  105522. * @param format defines the format of the texture
  105523. * @param generateMipMaps defines if the engine must generate mip levels
  105524. * @param invertY defines if data must be stored with Y axis inverted
  105525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105526. * @param compression defines the compressed used (can be null)
  105527. * @param textureType defines the compressed used (can be null)
  105528. * @returns a new raw 3D texture (stored in an InternalTexture)
  105529. */
  105530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105531. /**
  105532. * Creates a new raw 2D array texture
  105533. * @param data defines the data used to create the texture
  105534. * @param width defines the width of the texture
  105535. * @param height defines the height of the texture
  105536. * @param depth defines the number of layers of the texture
  105537. * @param format defines the format of the texture
  105538. * @param generateMipMaps defines if the engine must generate mip levels
  105539. * @param invertY defines if data must be stored with Y axis inverted
  105540. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105541. * @param compression defines the compressed used (can be null)
  105542. * @param textureType defines the compressed used (can be null)
  105543. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105544. */
  105545. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105546. private _unpackFlipYCached;
  105547. /**
  105548. * In case you are sharing the context with other applications, it might
  105549. * be interested to not cache the unpack flip y state to ensure a consistent
  105550. * value would be set.
  105551. */
  105552. enableUnpackFlipYCached: boolean;
  105553. /** @hidden */
  105554. _unpackFlipY(value: boolean): void;
  105555. /** @hidden */
  105556. _getUnpackAlignement(): number;
  105557. private _getTextureTarget;
  105558. /**
  105559. * Update the sampling mode of a given texture
  105560. * @param samplingMode defines the required sampling mode
  105561. * @param texture defines the texture to update
  105562. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105563. */
  105564. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105565. /**
  105566. * Update the sampling mode of a given texture
  105567. * @param texture defines the texture to update
  105568. * @param wrapU defines the texture wrap mode of the u coordinates
  105569. * @param wrapV defines the texture wrap mode of the v coordinates
  105570. * @param wrapR defines the texture wrap mode of the r coordinates
  105571. */
  105572. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105573. /** @hidden */
  105574. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105575. width: number;
  105576. height: number;
  105577. layers?: number;
  105578. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105579. /** @hidden */
  105580. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105581. /** @hidden */
  105582. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105583. /**
  105584. * Update a portion of an internal texture
  105585. * @param texture defines the texture to update
  105586. * @param imageData defines the data to store into the texture
  105587. * @param xOffset defines the x coordinates of the update rectangle
  105588. * @param yOffset defines the y coordinates of the update rectangle
  105589. * @param width defines the width of the update rectangle
  105590. * @param height defines the height of the update rectangle
  105591. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105592. * @param lod defines the lod level to update (0 by default)
  105593. */
  105594. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105595. /** @hidden */
  105596. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105597. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105598. private _prepareWebGLTexture;
  105599. /** @hidden */
  105600. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105601. private _getDepthStencilBuffer;
  105602. /** @hidden */
  105603. _releaseFramebufferObjects(texture: InternalTexture): void;
  105604. /** @hidden */
  105605. _releaseTexture(texture: InternalTexture): void;
  105606. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105607. protected _setProgram(program: WebGLProgram): void;
  105608. protected _boundUniforms: {
  105609. [key: number]: WebGLUniformLocation;
  105610. };
  105611. /**
  105612. * Binds an effect to the webGL context
  105613. * @param effect defines the effect to bind
  105614. */
  105615. bindSamplers(effect: Effect): void;
  105616. private _activateCurrentTexture;
  105617. /** @hidden */
  105618. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105619. /** @hidden */
  105620. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105621. /**
  105622. * Unbind all textures from the webGL context
  105623. */
  105624. unbindAllTextures(): void;
  105625. /**
  105626. * Sets a texture to the according uniform.
  105627. * @param channel The texture channel
  105628. * @param uniform The uniform to set
  105629. * @param texture The texture to apply
  105630. */
  105631. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105632. private _bindSamplerUniformToChannel;
  105633. private _getTextureWrapMode;
  105634. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105635. /**
  105636. * Sets an array of texture to the webGL context
  105637. * @param channel defines the channel where the texture array must be set
  105638. * @param uniform defines the associated uniform location
  105639. * @param textures defines the array of textures to bind
  105640. */
  105641. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105642. /** @hidden */
  105643. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105644. private _setTextureParameterFloat;
  105645. private _setTextureParameterInteger;
  105646. /**
  105647. * Unbind all vertex attributes from the webGL context
  105648. */
  105649. unbindAllAttributes(): void;
  105650. /**
  105651. * 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
  105652. */
  105653. releaseEffects(): void;
  105654. /**
  105655. * Dispose and release all associated resources
  105656. */
  105657. dispose(): void;
  105658. /**
  105659. * Attach a new callback raised when context lost event is fired
  105660. * @param callback defines the callback to call
  105661. */
  105662. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105663. /**
  105664. * Attach a new callback raised when context restored event is fired
  105665. * @param callback defines the callback to call
  105666. */
  105667. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105668. /**
  105669. * Get the current error code of the webGL context
  105670. * @returns the error code
  105671. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105672. */
  105673. getError(): number;
  105674. private _canRenderToFloatFramebuffer;
  105675. private _canRenderToHalfFloatFramebuffer;
  105676. private _canRenderToFramebuffer;
  105677. /** @hidden */
  105678. _getWebGLTextureType(type: number): number;
  105679. /** @hidden */
  105680. _getInternalFormat(format: number): number;
  105681. /** @hidden */
  105682. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105683. /** @hidden */
  105684. _getRGBAMultiSampleBufferFormat(type: number): number;
  105685. /** @hidden */
  105686. _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;
  105687. /**
  105688. * Loads a file from a url
  105689. * @param url url to load
  105690. * @param onSuccess callback called when the file successfully loads
  105691. * @param onProgress callback called while file is loading (if the server supports this mode)
  105692. * @param offlineProvider defines the offline provider for caching
  105693. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105694. * @param onError callback called when the file fails to load
  105695. * @returns a file request object
  105696. * @hidden
  105697. */
  105698. 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;
  105699. /**
  105700. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105701. * @param x defines the x coordinate of the rectangle where pixels must be read
  105702. * @param y defines the y coordinate of the rectangle where pixels must be read
  105703. * @param width defines the width of the rectangle where pixels must be read
  105704. * @param height defines the height of the rectangle where pixels must be read
  105705. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105706. * @returns a Uint8Array containing RGBA colors
  105707. */
  105708. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105709. private static _isSupported;
  105710. /**
  105711. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105712. * @returns true if the engine can be created
  105713. * @ignorenaming
  105714. */
  105715. static isSupported(): boolean;
  105716. /**
  105717. * Find the next highest power of two.
  105718. * @param x Number to start search from.
  105719. * @return Next highest power of two.
  105720. */
  105721. static CeilingPOT(x: number): number;
  105722. /**
  105723. * Find the next lowest power of two.
  105724. * @param x Number to start search from.
  105725. * @return Next lowest power of two.
  105726. */
  105727. static FloorPOT(x: number): number;
  105728. /**
  105729. * Find the nearest power of two.
  105730. * @param x Number to start search from.
  105731. * @return Next nearest power of two.
  105732. */
  105733. static NearestPOT(x: number): number;
  105734. /**
  105735. * Get the closest exponent of two
  105736. * @param value defines the value to approximate
  105737. * @param max defines the maximum value to return
  105738. * @param mode defines how to define the closest value
  105739. * @returns closest exponent of two of the given value
  105740. */
  105741. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105742. /**
  105743. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105744. * @param func - the function to be called
  105745. * @param requester - the object that will request the next frame. Falls back to window.
  105746. * @returns frame number
  105747. */
  105748. static QueueNewFrame(func: () => void, requester?: any): number;
  105749. /**
  105750. * Gets host document
  105751. * @returns the host document object
  105752. */
  105753. getHostDocument(): Nullable<Document>;
  105754. }
  105755. }
  105756. declare module BABYLON {
  105757. /**
  105758. * Class representing spherical harmonics coefficients to the 3rd degree
  105759. */
  105760. export class SphericalHarmonics {
  105761. /**
  105762. * Defines whether or not the harmonics have been prescaled for rendering.
  105763. */
  105764. preScaled: boolean;
  105765. /**
  105766. * The l0,0 coefficients of the spherical harmonics
  105767. */
  105768. l00: Vector3;
  105769. /**
  105770. * The l1,-1 coefficients of the spherical harmonics
  105771. */
  105772. l1_1: Vector3;
  105773. /**
  105774. * The l1,0 coefficients of the spherical harmonics
  105775. */
  105776. l10: Vector3;
  105777. /**
  105778. * The l1,1 coefficients of the spherical harmonics
  105779. */
  105780. l11: Vector3;
  105781. /**
  105782. * The l2,-2 coefficients of the spherical harmonics
  105783. */
  105784. l2_2: Vector3;
  105785. /**
  105786. * The l2,-1 coefficients of the spherical harmonics
  105787. */
  105788. l2_1: Vector3;
  105789. /**
  105790. * The l2,0 coefficients of the spherical harmonics
  105791. */
  105792. l20: Vector3;
  105793. /**
  105794. * The l2,1 coefficients of the spherical harmonics
  105795. */
  105796. l21: Vector3;
  105797. /**
  105798. * The l2,2 coefficients of the spherical harmonics
  105799. */
  105800. l22: Vector3;
  105801. /**
  105802. * Adds a light to the spherical harmonics
  105803. * @param direction the direction of the light
  105804. * @param color the color of the light
  105805. * @param deltaSolidAngle the delta solid angle of the light
  105806. */
  105807. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105808. /**
  105809. * Scales the spherical harmonics by the given amount
  105810. * @param scale the amount to scale
  105811. */
  105812. scaleInPlace(scale: number): void;
  105813. /**
  105814. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105815. *
  105816. * ```
  105817. * E_lm = A_l * L_lm
  105818. * ```
  105819. *
  105820. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105821. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105822. * the scaling factors are given in equation 9.
  105823. */
  105824. convertIncidentRadianceToIrradiance(): void;
  105825. /**
  105826. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105827. *
  105828. * ```
  105829. * L = (1/pi) * E * rho
  105830. * ```
  105831. *
  105832. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105833. */
  105834. convertIrradianceToLambertianRadiance(): void;
  105835. /**
  105836. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105837. * required operations at run time.
  105838. *
  105839. * This is simply done by scaling back the SH with Ylm constants parameter.
  105840. * The trigonometric part being applied by the shader at run time.
  105841. */
  105842. preScaleForRendering(): void;
  105843. /**
  105844. * Constructs a spherical harmonics from an array.
  105845. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105846. * @returns the spherical harmonics
  105847. */
  105848. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105849. /**
  105850. * Gets the spherical harmonics from polynomial
  105851. * @param polynomial the spherical polynomial
  105852. * @returns the spherical harmonics
  105853. */
  105854. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105855. }
  105856. /**
  105857. * Class representing spherical polynomial coefficients to the 3rd degree
  105858. */
  105859. export class SphericalPolynomial {
  105860. private _harmonics;
  105861. /**
  105862. * The spherical harmonics used to create the polynomials.
  105863. */
  105864. get preScaledHarmonics(): SphericalHarmonics;
  105865. /**
  105866. * The x coefficients of the spherical polynomial
  105867. */
  105868. x: Vector3;
  105869. /**
  105870. * The y coefficients of the spherical polynomial
  105871. */
  105872. y: Vector3;
  105873. /**
  105874. * The z coefficients of the spherical polynomial
  105875. */
  105876. z: Vector3;
  105877. /**
  105878. * The xx coefficients of the spherical polynomial
  105879. */
  105880. xx: Vector3;
  105881. /**
  105882. * The yy coefficients of the spherical polynomial
  105883. */
  105884. yy: Vector3;
  105885. /**
  105886. * The zz coefficients of the spherical polynomial
  105887. */
  105888. zz: Vector3;
  105889. /**
  105890. * The xy coefficients of the spherical polynomial
  105891. */
  105892. xy: Vector3;
  105893. /**
  105894. * The yz coefficients of the spherical polynomial
  105895. */
  105896. yz: Vector3;
  105897. /**
  105898. * The zx coefficients of the spherical polynomial
  105899. */
  105900. zx: Vector3;
  105901. /**
  105902. * Adds an ambient color to the spherical polynomial
  105903. * @param color the color to add
  105904. */
  105905. addAmbient(color: Color3): void;
  105906. /**
  105907. * Scales the spherical polynomial by the given amount
  105908. * @param scale the amount to scale
  105909. */
  105910. scaleInPlace(scale: number): void;
  105911. /**
  105912. * Gets the spherical polynomial from harmonics
  105913. * @param harmonics the spherical harmonics
  105914. * @returns the spherical polynomial
  105915. */
  105916. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105917. /**
  105918. * Constructs a spherical polynomial from an array.
  105919. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105920. * @returns the spherical polynomial
  105921. */
  105922. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105923. }
  105924. }
  105925. declare module BABYLON {
  105926. /**
  105927. * Defines the source of the internal texture
  105928. */
  105929. export enum InternalTextureSource {
  105930. /**
  105931. * The source of the texture data is unknown
  105932. */
  105933. Unknown = 0,
  105934. /**
  105935. * Texture data comes from an URL
  105936. */
  105937. Url = 1,
  105938. /**
  105939. * Texture data is only used for temporary storage
  105940. */
  105941. Temp = 2,
  105942. /**
  105943. * Texture data comes from raw data (ArrayBuffer)
  105944. */
  105945. Raw = 3,
  105946. /**
  105947. * Texture content is dynamic (video or dynamic texture)
  105948. */
  105949. Dynamic = 4,
  105950. /**
  105951. * Texture content is generated by rendering to it
  105952. */
  105953. RenderTarget = 5,
  105954. /**
  105955. * Texture content is part of a multi render target process
  105956. */
  105957. MultiRenderTarget = 6,
  105958. /**
  105959. * Texture data comes from a cube data file
  105960. */
  105961. Cube = 7,
  105962. /**
  105963. * Texture data comes from a raw cube data
  105964. */
  105965. CubeRaw = 8,
  105966. /**
  105967. * Texture data come from a prefiltered cube data file
  105968. */
  105969. CubePrefiltered = 9,
  105970. /**
  105971. * Texture content is raw 3D data
  105972. */
  105973. Raw3D = 10,
  105974. /**
  105975. * Texture content is raw 2D array data
  105976. */
  105977. Raw2DArray = 11,
  105978. /**
  105979. * Texture content is a depth texture
  105980. */
  105981. Depth = 12,
  105982. /**
  105983. * Texture data comes from a raw cube data encoded with RGBD
  105984. */
  105985. CubeRawRGBD = 13
  105986. }
  105987. /**
  105988. * Class used to store data associated with WebGL texture data for the engine
  105989. * This class should not be used directly
  105990. */
  105991. export class InternalTexture {
  105992. /** @hidden */
  105993. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105994. /**
  105995. * Defines if the texture is ready
  105996. */
  105997. isReady: boolean;
  105998. /**
  105999. * Defines if the texture is a cube texture
  106000. */
  106001. isCube: boolean;
  106002. /**
  106003. * Defines if the texture contains 3D data
  106004. */
  106005. is3D: boolean;
  106006. /**
  106007. * Defines if the texture contains 2D array data
  106008. */
  106009. is2DArray: boolean;
  106010. /**
  106011. * Defines if the texture contains multiview data
  106012. */
  106013. isMultiview: boolean;
  106014. /**
  106015. * Gets the URL used to load this texture
  106016. */
  106017. url: string;
  106018. /**
  106019. * Gets the sampling mode of the texture
  106020. */
  106021. samplingMode: number;
  106022. /**
  106023. * Gets a boolean indicating if the texture needs mipmaps generation
  106024. */
  106025. generateMipMaps: boolean;
  106026. /**
  106027. * Gets the number of samples used by the texture (WebGL2+ only)
  106028. */
  106029. samples: number;
  106030. /**
  106031. * Gets the type of the texture (int, float...)
  106032. */
  106033. type: number;
  106034. /**
  106035. * Gets the format of the texture (RGB, RGBA...)
  106036. */
  106037. format: number;
  106038. /**
  106039. * Observable called when the texture is loaded
  106040. */
  106041. onLoadedObservable: Observable<InternalTexture>;
  106042. /**
  106043. * Gets the width of the texture
  106044. */
  106045. width: number;
  106046. /**
  106047. * Gets the height of the texture
  106048. */
  106049. height: number;
  106050. /**
  106051. * Gets the depth of the texture
  106052. */
  106053. depth: number;
  106054. /**
  106055. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106056. */
  106057. baseWidth: number;
  106058. /**
  106059. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106060. */
  106061. baseHeight: number;
  106062. /**
  106063. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106064. */
  106065. baseDepth: number;
  106066. /**
  106067. * Gets a boolean indicating if the texture is inverted on Y axis
  106068. */
  106069. invertY: boolean;
  106070. /** @hidden */
  106071. _invertVScale: boolean;
  106072. /** @hidden */
  106073. _associatedChannel: number;
  106074. /** @hidden */
  106075. _source: InternalTextureSource;
  106076. /** @hidden */
  106077. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106078. /** @hidden */
  106079. _bufferView: Nullable<ArrayBufferView>;
  106080. /** @hidden */
  106081. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106082. /** @hidden */
  106083. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106084. /** @hidden */
  106085. _size: number;
  106086. /** @hidden */
  106087. _extension: string;
  106088. /** @hidden */
  106089. _files: Nullable<string[]>;
  106090. /** @hidden */
  106091. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  106092. /** @hidden */
  106093. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  106094. /** @hidden */
  106095. _framebuffer: Nullable<WebGLFramebuffer>;
  106096. /** @hidden */
  106097. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  106098. /** @hidden */
  106099. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  106100. /** @hidden */
  106101. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  106102. /** @hidden */
  106103. _attachments: Nullable<number[]>;
  106104. /** @hidden */
  106105. _cachedCoordinatesMode: Nullable<number>;
  106106. /** @hidden */
  106107. _cachedWrapU: Nullable<number>;
  106108. /** @hidden */
  106109. _cachedWrapV: Nullable<number>;
  106110. /** @hidden */
  106111. _cachedWrapR: Nullable<number>;
  106112. /** @hidden */
  106113. _cachedAnisotropicFilteringLevel: Nullable<number>;
  106114. /** @hidden */
  106115. _isDisabled: boolean;
  106116. /** @hidden */
  106117. _compression: Nullable<string>;
  106118. /** @hidden */
  106119. _generateStencilBuffer: boolean;
  106120. /** @hidden */
  106121. _generateDepthBuffer: boolean;
  106122. /** @hidden */
  106123. _comparisonFunction: number;
  106124. /** @hidden */
  106125. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  106126. /** @hidden */
  106127. _lodGenerationScale: number;
  106128. /** @hidden */
  106129. _lodGenerationOffset: number;
  106130. /** @hidden */
  106131. _depthStencilTexture: Nullable<InternalTexture>;
  106132. /** @hidden */
  106133. _colorTextureArray: Nullable<WebGLTexture>;
  106134. /** @hidden */
  106135. _depthStencilTextureArray: Nullable<WebGLTexture>;
  106136. /** @hidden */
  106137. _lodTextureHigh: Nullable<BaseTexture>;
  106138. /** @hidden */
  106139. _lodTextureMid: Nullable<BaseTexture>;
  106140. /** @hidden */
  106141. _lodTextureLow: Nullable<BaseTexture>;
  106142. /** @hidden */
  106143. _isRGBD: boolean;
  106144. /** @hidden */
  106145. _linearSpecularLOD: boolean;
  106146. /** @hidden */
  106147. _irradianceTexture: Nullable<BaseTexture>;
  106148. /** @hidden */
  106149. _webGLTexture: Nullable<WebGLTexture>;
  106150. /** @hidden */
  106151. _references: number;
  106152. private _engine;
  106153. /**
  106154. * Gets the Engine the texture belongs to.
  106155. * @returns The babylon engine
  106156. */
  106157. getEngine(): ThinEngine;
  106158. /**
  106159. * Gets the data source type of the texture
  106160. */
  106161. get source(): InternalTextureSource;
  106162. /**
  106163. * Creates a new InternalTexture
  106164. * @param engine defines the engine to use
  106165. * @param source defines the type of data that will be used
  106166. * @param delayAllocation if the texture allocation should be delayed (default: false)
  106167. */
  106168. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  106169. /**
  106170. * Increments the number of references (ie. the number of Texture that point to it)
  106171. */
  106172. incrementReferences(): void;
  106173. /**
  106174. * Change the size of the texture (not the size of the content)
  106175. * @param width defines the new width
  106176. * @param height defines the new height
  106177. * @param depth defines the new depth (1 by default)
  106178. */
  106179. updateSize(width: int, height: int, depth?: int): void;
  106180. /** @hidden */
  106181. _rebuild(): void;
  106182. /** @hidden */
  106183. _swapAndDie(target: InternalTexture): void;
  106184. /**
  106185. * Dispose the current allocated resources
  106186. */
  106187. dispose(): void;
  106188. }
  106189. }
  106190. declare module BABYLON {
  106191. /**
  106192. * Class used to work with sound analyzer using fast fourier transform (FFT)
  106193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106194. */
  106195. export class Analyser {
  106196. /**
  106197. * Gets or sets the smoothing
  106198. * @ignorenaming
  106199. */
  106200. SMOOTHING: number;
  106201. /**
  106202. * Gets or sets the FFT table size
  106203. * @ignorenaming
  106204. */
  106205. FFT_SIZE: number;
  106206. /**
  106207. * Gets or sets the bar graph amplitude
  106208. * @ignorenaming
  106209. */
  106210. BARGRAPHAMPLITUDE: number;
  106211. /**
  106212. * Gets or sets the position of the debug canvas
  106213. * @ignorenaming
  106214. */
  106215. DEBUGCANVASPOS: {
  106216. x: number;
  106217. y: number;
  106218. };
  106219. /**
  106220. * Gets or sets the debug canvas size
  106221. * @ignorenaming
  106222. */
  106223. DEBUGCANVASSIZE: {
  106224. width: number;
  106225. height: number;
  106226. };
  106227. private _byteFreqs;
  106228. private _byteTime;
  106229. private _floatFreqs;
  106230. private _webAudioAnalyser;
  106231. private _debugCanvas;
  106232. private _debugCanvasContext;
  106233. private _scene;
  106234. private _registerFunc;
  106235. private _audioEngine;
  106236. /**
  106237. * Creates a new analyser
  106238. * @param scene defines hosting scene
  106239. */
  106240. constructor(scene: Scene);
  106241. /**
  106242. * Get the number of data values you will have to play with for the visualization
  106243. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  106244. * @returns a number
  106245. */
  106246. getFrequencyBinCount(): number;
  106247. /**
  106248. * Gets the current frequency data as a byte array
  106249. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106250. * @returns a Uint8Array
  106251. */
  106252. getByteFrequencyData(): Uint8Array;
  106253. /**
  106254. * Gets the current waveform as a byte array
  106255. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  106256. * @returns a Uint8Array
  106257. */
  106258. getByteTimeDomainData(): Uint8Array;
  106259. /**
  106260. * Gets the current frequency data as a float array
  106261. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106262. * @returns a Float32Array
  106263. */
  106264. getFloatFrequencyData(): Float32Array;
  106265. /**
  106266. * Renders the debug canvas
  106267. */
  106268. drawDebugCanvas(): void;
  106269. /**
  106270. * Stops rendering the debug canvas and removes it
  106271. */
  106272. stopDebugCanvas(): void;
  106273. /**
  106274. * Connects two audio nodes
  106275. * @param inputAudioNode defines first node to connect
  106276. * @param outputAudioNode defines second node to connect
  106277. */
  106278. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  106279. /**
  106280. * Releases all associated resources
  106281. */
  106282. dispose(): void;
  106283. }
  106284. }
  106285. declare module BABYLON {
  106286. /**
  106287. * This represents an audio engine and it is responsible
  106288. * to play, synchronize and analyse sounds throughout the application.
  106289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106290. */
  106291. export interface IAudioEngine extends IDisposable {
  106292. /**
  106293. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106294. */
  106295. readonly canUseWebAudio: boolean;
  106296. /**
  106297. * Gets the current AudioContext if available.
  106298. */
  106299. readonly audioContext: Nullable<AudioContext>;
  106300. /**
  106301. * The master gain node defines the global audio volume of your audio engine.
  106302. */
  106303. readonly masterGain: GainNode;
  106304. /**
  106305. * Gets whether or not mp3 are supported by your browser.
  106306. */
  106307. readonly isMP3supported: boolean;
  106308. /**
  106309. * Gets whether or not ogg are supported by your browser.
  106310. */
  106311. readonly isOGGsupported: boolean;
  106312. /**
  106313. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106314. * @ignoreNaming
  106315. */
  106316. WarnedWebAudioUnsupported: boolean;
  106317. /**
  106318. * Defines if the audio engine relies on a custom unlocked button.
  106319. * In this case, the embedded button will not be displayed.
  106320. */
  106321. useCustomUnlockedButton: boolean;
  106322. /**
  106323. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  106324. */
  106325. readonly unlocked: boolean;
  106326. /**
  106327. * Event raised when audio has been unlocked on the browser.
  106328. */
  106329. onAudioUnlockedObservable: Observable<AudioEngine>;
  106330. /**
  106331. * Event raised when audio has been locked on the browser.
  106332. */
  106333. onAudioLockedObservable: Observable<AudioEngine>;
  106334. /**
  106335. * Flags the audio engine in Locked state.
  106336. * This happens due to new browser policies preventing audio to autoplay.
  106337. */
  106338. lock(): void;
  106339. /**
  106340. * Unlocks the audio engine once a user action has been done on the dom.
  106341. * This is helpful to resume play once browser policies have been satisfied.
  106342. */
  106343. unlock(): void;
  106344. /**
  106345. * Gets the global volume sets on the master gain.
  106346. * @returns the global volume if set or -1 otherwise
  106347. */
  106348. getGlobalVolume(): number;
  106349. /**
  106350. * Sets the global volume of your experience (sets on the master gain).
  106351. * @param newVolume Defines the new global volume of the application
  106352. */
  106353. setGlobalVolume(newVolume: number): void;
  106354. /**
  106355. * Connect the audio engine to an audio analyser allowing some amazing
  106356. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106358. * @param analyser The analyser to connect to the engine
  106359. */
  106360. connectToAnalyser(analyser: Analyser): void;
  106361. }
  106362. /**
  106363. * This represents the default audio engine used in babylon.
  106364. * It is responsible to play, synchronize and analyse sounds throughout the application.
  106365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106366. */
  106367. export class AudioEngine implements IAudioEngine {
  106368. private _audioContext;
  106369. private _audioContextInitialized;
  106370. private _muteButton;
  106371. private _hostElement;
  106372. /**
  106373. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106374. */
  106375. canUseWebAudio: boolean;
  106376. /**
  106377. * The master gain node defines the global audio volume of your audio engine.
  106378. */
  106379. masterGain: GainNode;
  106380. /**
  106381. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106382. * @ignoreNaming
  106383. */
  106384. WarnedWebAudioUnsupported: boolean;
  106385. /**
  106386. * Gets whether or not mp3 are supported by your browser.
  106387. */
  106388. isMP3supported: boolean;
  106389. /**
  106390. * Gets whether or not ogg are supported by your browser.
  106391. */
  106392. isOGGsupported: boolean;
  106393. /**
  106394. * Gets whether audio has been unlocked on the device.
  106395. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  106396. * a user interaction has happened.
  106397. */
  106398. unlocked: boolean;
  106399. /**
  106400. * Defines if the audio engine relies on a custom unlocked button.
  106401. * In this case, the embedded button will not be displayed.
  106402. */
  106403. useCustomUnlockedButton: boolean;
  106404. /**
  106405. * Event raised when audio has been unlocked on the browser.
  106406. */
  106407. onAudioUnlockedObservable: Observable<AudioEngine>;
  106408. /**
  106409. * Event raised when audio has been locked on the browser.
  106410. */
  106411. onAudioLockedObservable: Observable<AudioEngine>;
  106412. /**
  106413. * Gets the current AudioContext if available.
  106414. */
  106415. get audioContext(): Nullable<AudioContext>;
  106416. private _connectedAnalyser;
  106417. /**
  106418. * Instantiates a new audio engine.
  106419. *
  106420. * There should be only one per page as some browsers restrict the number
  106421. * of audio contexts you can create.
  106422. * @param hostElement defines the host element where to display the mute icon if necessary
  106423. */
  106424. constructor(hostElement?: Nullable<HTMLElement>);
  106425. /**
  106426. * Flags the audio engine in Locked state.
  106427. * This happens due to new browser policies preventing audio to autoplay.
  106428. */
  106429. lock(): void;
  106430. /**
  106431. * Unlocks the audio engine once a user action has been done on the dom.
  106432. * This is helpful to resume play once browser policies have been satisfied.
  106433. */
  106434. unlock(): void;
  106435. private _resumeAudioContext;
  106436. private _initializeAudioContext;
  106437. private _tryToRun;
  106438. private _triggerRunningState;
  106439. private _triggerSuspendedState;
  106440. private _displayMuteButton;
  106441. private _moveButtonToTopLeft;
  106442. private _onResize;
  106443. private _hideMuteButton;
  106444. /**
  106445. * Destroy and release the resources associated with the audio ccontext.
  106446. */
  106447. dispose(): void;
  106448. /**
  106449. * Gets the global volume sets on the master gain.
  106450. * @returns the global volume if set or -1 otherwise
  106451. */
  106452. getGlobalVolume(): number;
  106453. /**
  106454. * Sets the global volume of your experience (sets on the master gain).
  106455. * @param newVolume Defines the new global volume of the application
  106456. */
  106457. setGlobalVolume(newVolume: number): void;
  106458. /**
  106459. * Connect the audio engine to an audio analyser allowing some amazing
  106460. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106462. * @param analyser The analyser to connect to the engine
  106463. */
  106464. connectToAnalyser(analyser: Analyser): void;
  106465. }
  106466. }
  106467. declare module BABYLON {
  106468. /**
  106469. * Interface used to present a loading screen while loading a scene
  106470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106471. */
  106472. export interface ILoadingScreen {
  106473. /**
  106474. * Function called to display the loading screen
  106475. */
  106476. displayLoadingUI: () => void;
  106477. /**
  106478. * Function called to hide the loading screen
  106479. */
  106480. hideLoadingUI: () => void;
  106481. /**
  106482. * Gets or sets the color to use for the background
  106483. */
  106484. loadingUIBackgroundColor: string;
  106485. /**
  106486. * Gets or sets the text to display while loading
  106487. */
  106488. loadingUIText: string;
  106489. }
  106490. /**
  106491. * Class used for the default loading screen
  106492. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106493. */
  106494. export class DefaultLoadingScreen implements ILoadingScreen {
  106495. private _renderingCanvas;
  106496. private _loadingText;
  106497. private _loadingDivBackgroundColor;
  106498. private _loadingDiv;
  106499. private _loadingTextDiv;
  106500. /** Gets or sets the logo url to use for the default loading screen */
  106501. static DefaultLogoUrl: string;
  106502. /** Gets or sets the spinner url to use for the default loading screen */
  106503. static DefaultSpinnerUrl: string;
  106504. /**
  106505. * Creates a new default loading screen
  106506. * @param _renderingCanvas defines the canvas used to render the scene
  106507. * @param _loadingText defines the default text to display
  106508. * @param _loadingDivBackgroundColor defines the default background color
  106509. */
  106510. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106511. /**
  106512. * Function called to display the loading screen
  106513. */
  106514. displayLoadingUI(): void;
  106515. /**
  106516. * Function called to hide the loading screen
  106517. */
  106518. hideLoadingUI(): void;
  106519. /**
  106520. * Gets or sets the text to display while loading
  106521. */
  106522. set loadingUIText(text: string);
  106523. get loadingUIText(): string;
  106524. /**
  106525. * Gets or sets the color to use for the background
  106526. */
  106527. get loadingUIBackgroundColor(): string;
  106528. set loadingUIBackgroundColor(color: string);
  106529. private _resizeLoadingUI;
  106530. }
  106531. }
  106532. declare module BABYLON {
  106533. /**
  106534. * Interface for any object that can request an animation frame
  106535. */
  106536. export interface ICustomAnimationFrameRequester {
  106537. /**
  106538. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106539. */
  106540. renderFunction?: Function;
  106541. /**
  106542. * Called to request the next frame to render to
  106543. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106544. */
  106545. requestAnimationFrame: Function;
  106546. /**
  106547. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106548. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106549. */
  106550. requestID?: number;
  106551. }
  106552. }
  106553. declare module BABYLON {
  106554. /**
  106555. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106556. */
  106557. export class PerformanceMonitor {
  106558. private _enabled;
  106559. private _rollingFrameTime;
  106560. private _lastFrameTimeMs;
  106561. /**
  106562. * constructor
  106563. * @param frameSampleSize The number of samples required to saturate the sliding window
  106564. */
  106565. constructor(frameSampleSize?: number);
  106566. /**
  106567. * Samples current frame
  106568. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106569. */
  106570. sampleFrame(timeMs?: number): void;
  106571. /**
  106572. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106573. */
  106574. get averageFrameTime(): number;
  106575. /**
  106576. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106577. */
  106578. get averageFrameTimeVariance(): number;
  106579. /**
  106580. * Returns the frame time of the most recent frame
  106581. */
  106582. get instantaneousFrameTime(): number;
  106583. /**
  106584. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106585. */
  106586. get averageFPS(): number;
  106587. /**
  106588. * Returns the average framerate in frames per second using the most recent frame time
  106589. */
  106590. get instantaneousFPS(): number;
  106591. /**
  106592. * Returns true if enough samples have been taken to completely fill the sliding window
  106593. */
  106594. get isSaturated(): boolean;
  106595. /**
  106596. * Enables contributions to the sliding window sample set
  106597. */
  106598. enable(): void;
  106599. /**
  106600. * Disables contributions to the sliding window sample set
  106601. * Samples will not be interpolated over the disabled period
  106602. */
  106603. disable(): void;
  106604. /**
  106605. * Returns true if sampling is enabled
  106606. */
  106607. get isEnabled(): boolean;
  106608. /**
  106609. * Resets performance monitor
  106610. */
  106611. reset(): void;
  106612. }
  106613. /**
  106614. * RollingAverage
  106615. *
  106616. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106617. */
  106618. export class RollingAverage {
  106619. /**
  106620. * Current average
  106621. */
  106622. average: number;
  106623. /**
  106624. * Current variance
  106625. */
  106626. variance: number;
  106627. protected _samples: Array<number>;
  106628. protected _sampleCount: number;
  106629. protected _pos: number;
  106630. protected _m2: number;
  106631. /**
  106632. * constructor
  106633. * @param length The number of samples required to saturate the sliding window
  106634. */
  106635. constructor(length: number);
  106636. /**
  106637. * Adds a sample to the sample set
  106638. * @param v The sample value
  106639. */
  106640. add(v: number): void;
  106641. /**
  106642. * Returns previously added values or null if outside of history or outside the sliding window domain
  106643. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106644. * @return Value previously recorded with add() or null if outside of range
  106645. */
  106646. history(i: number): number;
  106647. /**
  106648. * Returns true if enough samples have been taken to completely fill the sliding window
  106649. * @return true if sample-set saturated
  106650. */
  106651. isSaturated(): boolean;
  106652. /**
  106653. * Resets the rolling average (equivalent to 0 samples taken so far)
  106654. */
  106655. reset(): void;
  106656. /**
  106657. * Wraps a value around the sample range boundaries
  106658. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106659. * @return Wrapped position in sample range
  106660. */
  106661. protected _wrapPosition(i: number): number;
  106662. }
  106663. }
  106664. declare module BABYLON {
  106665. /**
  106666. * This class is used to track a performance counter which is number based.
  106667. * The user has access to many properties which give statistics of different nature.
  106668. *
  106669. * The implementer can track two kinds of Performance Counter: time and count.
  106670. * 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.
  106671. * 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.
  106672. */
  106673. export class PerfCounter {
  106674. /**
  106675. * Gets or sets a global boolean to turn on and off all the counters
  106676. */
  106677. static Enabled: boolean;
  106678. /**
  106679. * Returns the smallest value ever
  106680. */
  106681. get min(): number;
  106682. /**
  106683. * Returns the biggest value ever
  106684. */
  106685. get max(): number;
  106686. /**
  106687. * Returns the average value since the performance counter is running
  106688. */
  106689. get average(): number;
  106690. /**
  106691. * Returns the average value of the last second the counter was monitored
  106692. */
  106693. get lastSecAverage(): number;
  106694. /**
  106695. * Returns the current value
  106696. */
  106697. get current(): number;
  106698. /**
  106699. * Gets the accumulated total
  106700. */
  106701. get total(): number;
  106702. /**
  106703. * Gets the total value count
  106704. */
  106705. get count(): number;
  106706. /**
  106707. * Creates a new counter
  106708. */
  106709. constructor();
  106710. /**
  106711. * Call this method to start monitoring a new frame.
  106712. * 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.
  106713. */
  106714. fetchNewFrame(): void;
  106715. /**
  106716. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106717. * @param newCount the count value to add to the monitored count
  106718. * @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.
  106719. */
  106720. addCount(newCount: number, fetchResult: boolean): void;
  106721. /**
  106722. * Start monitoring this performance counter
  106723. */
  106724. beginMonitoring(): void;
  106725. /**
  106726. * Compute the time lapsed since the previous beginMonitoring() call.
  106727. * @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
  106728. */
  106729. endMonitoring(newFrame?: boolean): void;
  106730. private _fetchResult;
  106731. private _startMonitoringTime;
  106732. private _min;
  106733. private _max;
  106734. private _average;
  106735. private _current;
  106736. private _totalValueCount;
  106737. private _totalAccumulated;
  106738. private _lastSecAverage;
  106739. private _lastSecAccumulated;
  106740. private _lastSecTime;
  106741. private _lastSecValueCount;
  106742. }
  106743. }
  106744. declare module BABYLON {
  106745. interface ThinEngine {
  106746. /**
  106747. * Sets alpha constants used by some alpha blending modes
  106748. * @param r defines the red component
  106749. * @param g defines the green component
  106750. * @param b defines the blue component
  106751. * @param a defines the alpha component
  106752. */
  106753. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106754. /**
  106755. * Sets the current alpha mode
  106756. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106757. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106758. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106759. */
  106760. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106761. /**
  106762. * Gets the current alpha mode
  106763. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106764. * @returns the current alpha mode
  106765. */
  106766. getAlphaMode(): number;
  106767. /**
  106768. * Sets the current alpha equation
  106769. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106770. */
  106771. setAlphaEquation(equation: number): void;
  106772. /**
  106773. * Gets the current alpha equation.
  106774. * @returns the current alpha equation
  106775. */
  106776. getAlphaEquation(): number;
  106777. }
  106778. }
  106779. declare module BABYLON {
  106780. /**
  106781. * Defines the interface used by display changed events
  106782. */
  106783. export interface IDisplayChangedEventArgs {
  106784. /** Gets the vrDisplay object (if any) */
  106785. vrDisplay: Nullable<any>;
  106786. /** Gets a boolean indicating if webVR is supported */
  106787. vrSupported: boolean;
  106788. }
  106789. /**
  106790. * Defines the interface used by objects containing a viewport (like a camera)
  106791. */
  106792. interface IViewportOwnerLike {
  106793. /**
  106794. * Gets or sets the viewport
  106795. */
  106796. viewport: IViewportLike;
  106797. }
  106798. /**
  106799. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106800. */
  106801. export class Engine extends ThinEngine {
  106802. /** Defines that alpha blending is disabled */
  106803. static readonly ALPHA_DISABLE: number;
  106804. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106805. static readonly ALPHA_ADD: number;
  106806. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106807. static readonly ALPHA_COMBINE: number;
  106808. /** Defines that alpha blending to DEST - SRC * DEST */
  106809. static readonly ALPHA_SUBTRACT: number;
  106810. /** Defines that alpha blending to SRC * DEST */
  106811. static readonly ALPHA_MULTIPLY: number;
  106812. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106813. static readonly ALPHA_MAXIMIZED: number;
  106814. /** Defines that alpha blending to SRC + DEST */
  106815. static readonly ALPHA_ONEONE: number;
  106816. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106817. static readonly ALPHA_PREMULTIPLIED: number;
  106818. /**
  106819. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106820. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106821. */
  106822. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106823. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106824. static readonly ALPHA_INTERPOLATE: number;
  106825. /**
  106826. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106827. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106828. */
  106829. static readonly ALPHA_SCREENMODE: number;
  106830. /** Defines that the ressource is not delayed*/
  106831. static readonly DELAYLOADSTATE_NONE: number;
  106832. /** Defines that the ressource was successfully delay loaded */
  106833. static readonly DELAYLOADSTATE_LOADED: number;
  106834. /** Defines that the ressource is currently delay loading */
  106835. static readonly DELAYLOADSTATE_LOADING: number;
  106836. /** Defines that the ressource is delayed and has not started loading */
  106837. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106839. static readonly NEVER: number;
  106840. /** 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 */
  106841. static readonly ALWAYS: number;
  106842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106843. static readonly LESS: number;
  106844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106845. static readonly EQUAL: number;
  106846. /** 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 */
  106847. static readonly LEQUAL: number;
  106848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106849. static readonly GREATER: number;
  106850. /** 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 */
  106851. static readonly GEQUAL: number;
  106852. /** 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 */
  106853. static readonly NOTEQUAL: number;
  106854. /** Passed to stencilOperation to specify that stencil value must be kept */
  106855. static readonly KEEP: number;
  106856. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106857. static readonly REPLACE: number;
  106858. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106859. static readonly INCR: number;
  106860. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106861. static readonly DECR: number;
  106862. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106863. static readonly INVERT: number;
  106864. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106865. static readonly INCR_WRAP: number;
  106866. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106867. static readonly DECR_WRAP: number;
  106868. /** Texture is not repeating outside of 0..1 UVs */
  106869. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106870. /** Texture is repeating outside of 0..1 UVs */
  106871. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106872. /** Texture is repeating and mirrored */
  106873. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106874. /** ALPHA */
  106875. static readonly TEXTUREFORMAT_ALPHA: number;
  106876. /** LUMINANCE */
  106877. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106878. /** LUMINANCE_ALPHA */
  106879. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106880. /** RGB */
  106881. static readonly TEXTUREFORMAT_RGB: number;
  106882. /** RGBA */
  106883. static readonly TEXTUREFORMAT_RGBA: number;
  106884. /** RED */
  106885. static readonly TEXTUREFORMAT_RED: number;
  106886. /** RED (2nd reference) */
  106887. static readonly TEXTUREFORMAT_R: number;
  106888. /** RG */
  106889. static readonly TEXTUREFORMAT_RG: number;
  106890. /** RED_INTEGER */
  106891. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106892. /** RED_INTEGER (2nd reference) */
  106893. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106894. /** RG_INTEGER */
  106895. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106896. /** RGB_INTEGER */
  106897. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106898. /** RGBA_INTEGER */
  106899. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106900. /** UNSIGNED_BYTE */
  106901. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106902. /** UNSIGNED_BYTE (2nd reference) */
  106903. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106904. /** FLOAT */
  106905. static readonly TEXTURETYPE_FLOAT: number;
  106906. /** HALF_FLOAT */
  106907. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106908. /** BYTE */
  106909. static readonly TEXTURETYPE_BYTE: number;
  106910. /** SHORT */
  106911. static readonly TEXTURETYPE_SHORT: number;
  106912. /** UNSIGNED_SHORT */
  106913. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106914. /** INT */
  106915. static readonly TEXTURETYPE_INT: number;
  106916. /** UNSIGNED_INT */
  106917. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106918. /** UNSIGNED_SHORT_4_4_4_4 */
  106919. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106920. /** UNSIGNED_SHORT_5_5_5_1 */
  106921. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106922. /** UNSIGNED_SHORT_5_6_5 */
  106923. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106924. /** UNSIGNED_INT_2_10_10_10_REV */
  106925. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106926. /** UNSIGNED_INT_24_8 */
  106927. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106928. /** UNSIGNED_INT_10F_11F_11F_REV */
  106929. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106930. /** UNSIGNED_INT_5_9_9_9_REV */
  106931. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106932. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106933. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106934. /** nearest is mag = nearest and min = nearest and mip = linear */
  106935. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106936. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106937. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106938. /** Trilinear is mag = linear and min = linear and mip = linear */
  106939. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106940. /** nearest is mag = nearest and min = nearest and mip = linear */
  106941. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106943. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106944. /** Trilinear is mag = linear and min = linear and mip = linear */
  106945. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106946. /** mag = nearest and min = nearest and mip = nearest */
  106947. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106948. /** mag = nearest and min = linear and mip = nearest */
  106949. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106950. /** mag = nearest and min = linear and mip = linear */
  106951. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106952. /** mag = nearest and min = linear and mip = none */
  106953. static readonly TEXTURE_NEAREST_LINEAR: number;
  106954. /** mag = nearest and min = nearest and mip = none */
  106955. static readonly TEXTURE_NEAREST_NEAREST: number;
  106956. /** mag = linear and min = nearest and mip = nearest */
  106957. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106958. /** mag = linear and min = nearest and mip = linear */
  106959. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106960. /** mag = linear and min = linear and mip = none */
  106961. static readonly TEXTURE_LINEAR_LINEAR: number;
  106962. /** mag = linear and min = nearest and mip = none */
  106963. static readonly TEXTURE_LINEAR_NEAREST: number;
  106964. /** Explicit coordinates mode */
  106965. static readonly TEXTURE_EXPLICIT_MODE: number;
  106966. /** Spherical coordinates mode */
  106967. static readonly TEXTURE_SPHERICAL_MODE: number;
  106968. /** Planar coordinates mode */
  106969. static readonly TEXTURE_PLANAR_MODE: number;
  106970. /** Cubic coordinates mode */
  106971. static readonly TEXTURE_CUBIC_MODE: number;
  106972. /** Projection coordinates mode */
  106973. static readonly TEXTURE_PROJECTION_MODE: number;
  106974. /** Skybox coordinates mode */
  106975. static readonly TEXTURE_SKYBOX_MODE: number;
  106976. /** Inverse Cubic coordinates mode */
  106977. static readonly TEXTURE_INVCUBIC_MODE: number;
  106978. /** Equirectangular coordinates mode */
  106979. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106980. /** Equirectangular Fixed coordinates mode */
  106981. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106982. /** Equirectangular Fixed Mirrored coordinates mode */
  106983. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106984. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106985. static readonly SCALEMODE_FLOOR: number;
  106986. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106987. static readonly SCALEMODE_NEAREST: number;
  106988. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106989. static readonly SCALEMODE_CEILING: number;
  106990. /**
  106991. * Returns the current npm package of the sdk
  106992. */
  106993. static get NpmPackage(): string;
  106994. /**
  106995. * Returns the current version of the framework
  106996. */
  106997. static get Version(): string;
  106998. /** Gets the list of created engines */
  106999. static get Instances(): Engine[];
  107000. /**
  107001. * Gets the latest created engine
  107002. */
  107003. static get LastCreatedEngine(): Nullable<Engine>;
  107004. /**
  107005. * Gets the latest created scene
  107006. */
  107007. static get LastCreatedScene(): Nullable<Scene>;
  107008. /**
  107009. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107010. * @param flag defines which part of the materials must be marked as dirty
  107011. * @param predicate defines a predicate used to filter which materials should be affected
  107012. */
  107013. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107014. /**
  107015. * Method called to create the default loading screen.
  107016. * This can be overriden in your own app.
  107017. * @param canvas The rendering canvas element
  107018. * @returns The loading screen
  107019. */
  107020. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107021. /**
  107022. * Method called to create the default rescale post process on each engine.
  107023. */
  107024. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107025. /**
  107026. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107027. **/
  107028. enableOfflineSupport: boolean;
  107029. /**
  107030. * 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)
  107031. **/
  107032. disableManifestCheck: boolean;
  107033. /**
  107034. * Gets the list of created scenes
  107035. */
  107036. scenes: Scene[];
  107037. /**
  107038. * Event raised when a new scene is created
  107039. */
  107040. onNewSceneAddedObservable: Observable<Scene>;
  107041. /**
  107042. * Gets the list of created postprocesses
  107043. */
  107044. postProcesses: PostProcess[];
  107045. /**
  107046. * Gets a boolean indicating if the pointer is currently locked
  107047. */
  107048. isPointerLock: boolean;
  107049. /**
  107050. * Observable event triggered each time the rendering canvas is resized
  107051. */
  107052. onResizeObservable: Observable<Engine>;
  107053. /**
  107054. * Observable event triggered each time the canvas loses focus
  107055. */
  107056. onCanvasBlurObservable: Observable<Engine>;
  107057. /**
  107058. * Observable event triggered each time the canvas gains focus
  107059. */
  107060. onCanvasFocusObservable: Observable<Engine>;
  107061. /**
  107062. * Observable event triggered each time the canvas receives pointerout event
  107063. */
  107064. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107065. /**
  107066. * Observable raised when the engine begins a new frame
  107067. */
  107068. onBeginFrameObservable: Observable<Engine>;
  107069. /**
  107070. * If set, will be used to request the next animation frame for the render loop
  107071. */
  107072. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107073. /**
  107074. * Observable raised when the engine ends the current frame
  107075. */
  107076. onEndFrameObservable: Observable<Engine>;
  107077. /**
  107078. * Observable raised when the engine is about to compile a shader
  107079. */
  107080. onBeforeShaderCompilationObservable: Observable<Engine>;
  107081. /**
  107082. * Observable raised when the engine has jsut compiled a shader
  107083. */
  107084. onAfterShaderCompilationObservable: Observable<Engine>;
  107085. /**
  107086. * Gets the audio engine
  107087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107088. * @ignorenaming
  107089. */
  107090. static audioEngine: IAudioEngine;
  107091. /**
  107092. * Default AudioEngine factory responsible of creating the Audio Engine.
  107093. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  107094. */
  107095. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  107096. /**
  107097. * Default offline support factory responsible of creating a tool used to store data locally.
  107098. * By default, this will create a Database object if the workload has been embedded.
  107099. */
  107100. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  107101. private _loadingScreen;
  107102. private _pointerLockRequested;
  107103. private _dummyFramebuffer;
  107104. private _rescalePostProcess;
  107105. private _deterministicLockstep;
  107106. private _lockstepMaxSteps;
  107107. private _timeStep;
  107108. protected get _supportsHardwareTextureRescaling(): boolean;
  107109. private _fps;
  107110. private _deltaTime;
  107111. /** @hidden */
  107112. _drawCalls: PerfCounter;
  107113. /** 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 */
  107114. canvasTabIndex: number;
  107115. /**
  107116. * Turn this value on if you want to pause FPS computation when in background
  107117. */
  107118. disablePerformanceMonitorInBackground: boolean;
  107119. private _performanceMonitor;
  107120. /**
  107121. * Gets the performance monitor attached to this engine
  107122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  107123. */
  107124. get performanceMonitor(): PerformanceMonitor;
  107125. private _onFocus;
  107126. private _onBlur;
  107127. private _onCanvasPointerOut;
  107128. private _onCanvasBlur;
  107129. private _onCanvasFocus;
  107130. private _onFullscreenChange;
  107131. private _onPointerLockChange;
  107132. /**
  107133. * Gets the HTML element used to attach event listeners
  107134. * @returns a HTML element
  107135. */
  107136. getInputElement(): Nullable<HTMLElement>;
  107137. /**
  107138. * Creates a new engine
  107139. * @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
  107140. * @param antialias defines enable antialiasing (default: false)
  107141. * @param options defines further options to be sent to the getContext() function
  107142. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107143. */
  107144. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107145. /**
  107146. * Gets current aspect ratio
  107147. * @param viewportOwner defines the camera to use to get the aspect ratio
  107148. * @param useScreen defines if screen size must be used (or the current render target if any)
  107149. * @returns a number defining the aspect ratio
  107150. */
  107151. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  107152. /**
  107153. * Gets current screen aspect ratio
  107154. * @returns a number defining the aspect ratio
  107155. */
  107156. getScreenAspectRatio(): number;
  107157. /**
  107158. * Gets the client rect of the HTML canvas attached with the current webGL context
  107159. * @returns a client rectanglee
  107160. */
  107161. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  107162. /**
  107163. * Gets the client rect of the HTML element used for events
  107164. * @returns a client rectanglee
  107165. */
  107166. getInputElementClientRect(): Nullable<ClientRect>;
  107167. /**
  107168. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  107169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107170. * @returns true if engine is in deterministic lock step mode
  107171. */
  107172. isDeterministicLockStep(): boolean;
  107173. /**
  107174. * Gets the max steps when engine is running in deterministic lock step
  107175. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107176. * @returns the max steps
  107177. */
  107178. getLockstepMaxSteps(): number;
  107179. /**
  107180. * Returns the time in ms between steps when using deterministic lock step.
  107181. * @returns time step in (ms)
  107182. */
  107183. getTimeStep(): number;
  107184. /**
  107185. * Force the mipmap generation for the given render target texture
  107186. * @param texture defines the render target texture to use
  107187. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  107188. */
  107189. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  107190. /** States */
  107191. /**
  107192. * Set various states to the webGL context
  107193. * @param culling defines backface culling state
  107194. * @param zOffset defines the value to apply to zOffset (0 by default)
  107195. * @param force defines if states must be applied even if cache is up to date
  107196. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  107197. */
  107198. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107199. /**
  107200. * Set the z offset to apply to current rendering
  107201. * @param value defines the offset to apply
  107202. */
  107203. setZOffset(value: number): void;
  107204. /**
  107205. * Gets the current value of the zOffset
  107206. * @returns the current zOffset state
  107207. */
  107208. getZOffset(): number;
  107209. /**
  107210. * Enable or disable depth buffering
  107211. * @param enable defines the state to set
  107212. */
  107213. setDepthBuffer(enable: boolean): void;
  107214. /**
  107215. * Gets a boolean indicating if depth writing is enabled
  107216. * @returns the current depth writing state
  107217. */
  107218. getDepthWrite(): boolean;
  107219. /**
  107220. * Enable or disable depth writing
  107221. * @param enable defines the state to set
  107222. */
  107223. setDepthWrite(enable: boolean): void;
  107224. /**
  107225. * Gets a boolean indicating if stencil buffer is enabled
  107226. * @returns the current stencil buffer state
  107227. */
  107228. getStencilBuffer(): boolean;
  107229. /**
  107230. * Enable or disable the stencil buffer
  107231. * @param enable defines if the stencil buffer must be enabled or disabled
  107232. */
  107233. setStencilBuffer(enable: boolean): void;
  107234. /**
  107235. * Gets the current stencil mask
  107236. * @returns a number defining the new stencil mask to use
  107237. */
  107238. getStencilMask(): number;
  107239. /**
  107240. * Sets the current stencil mask
  107241. * @param mask defines the new stencil mask to use
  107242. */
  107243. setStencilMask(mask: number): void;
  107244. /**
  107245. * Gets the current stencil function
  107246. * @returns a number defining the stencil function to use
  107247. */
  107248. getStencilFunction(): number;
  107249. /**
  107250. * Gets the current stencil reference value
  107251. * @returns a number defining the stencil reference value to use
  107252. */
  107253. getStencilFunctionReference(): number;
  107254. /**
  107255. * Gets the current stencil mask
  107256. * @returns a number defining the stencil mask to use
  107257. */
  107258. getStencilFunctionMask(): number;
  107259. /**
  107260. * Sets the current stencil function
  107261. * @param stencilFunc defines the new stencil function to use
  107262. */
  107263. setStencilFunction(stencilFunc: number): void;
  107264. /**
  107265. * Sets the current stencil reference
  107266. * @param reference defines the new stencil reference to use
  107267. */
  107268. setStencilFunctionReference(reference: number): void;
  107269. /**
  107270. * Sets the current stencil mask
  107271. * @param mask defines the new stencil mask to use
  107272. */
  107273. setStencilFunctionMask(mask: number): void;
  107274. /**
  107275. * Gets the current stencil operation when stencil fails
  107276. * @returns a number defining stencil operation to use when stencil fails
  107277. */
  107278. getStencilOperationFail(): number;
  107279. /**
  107280. * Gets the current stencil operation when depth fails
  107281. * @returns a number defining stencil operation to use when depth fails
  107282. */
  107283. getStencilOperationDepthFail(): number;
  107284. /**
  107285. * Gets the current stencil operation when stencil passes
  107286. * @returns a number defining stencil operation to use when stencil passes
  107287. */
  107288. getStencilOperationPass(): number;
  107289. /**
  107290. * Sets the stencil operation to use when stencil fails
  107291. * @param operation defines the stencil operation to use when stencil fails
  107292. */
  107293. setStencilOperationFail(operation: number): void;
  107294. /**
  107295. * Sets the stencil operation to use when depth fails
  107296. * @param operation defines the stencil operation to use when depth fails
  107297. */
  107298. setStencilOperationDepthFail(operation: number): void;
  107299. /**
  107300. * Sets the stencil operation to use when stencil passes
  107301. * @param operation defines the stencil operation to use when stencil passes
  107302. */
  107303. setStencilOperationPass(operation: number): void;
  107304. /**
  107305. * Sets a boolean indicating if the dithering state is enabled or disabled
  107306. * @param value defines the dithering state
  107307. */
  107308. setDitheringState(value: boolean): void;
  107309. /**
  107310. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107311. * @param value defines the rasterizer state
  107312. */
  107313. setRasterizerState(value: boolean): void;
  107314. /**
  107315. * Gets the current depth function
  107316. * @returns a number defining the depth function
  107317. */
  107318. getDepthFunction(): Nullable<number>;
  107319. /**
  107320. * Sets the current depth function
  107321. * @param depthFunc defines the function to use
  107322. */
  107323. setDepthFunction(depthFunc: number): void;
  107324. /**
  107325. * Sets the current depth function to GREATER
  107326. */
  107327. setDepthFunctionToGreater(): void;
  107328. /**
  107329. * Sets the current depth function to GEQUAL
  107330. */
  107331. setDepthFunctionToGreaterOrEqual(): void;
  107332. /**
  107333. * Sets the current depth function to LESS
  107334. */
  107335. setDepthFunctionToLess(): void;
  107336. /**
  107337. * Sets the current depth function to LEQUAL
  107338. */
  107339. setDepthFunctionToLessOrEqual(): void;
  107340. private _cachedStencilBuffer;
  107341. private _cachedStencilFunction;
  107342. private _cachedStencilMask;
  107343. private _cachedStencilOperationPass;
  107344. private _cachedStencilOperationFail;
  107345. private _cachedStencilOperationDepthFail;
  107346. private _cachedStencilReference;
  107347. /**
  107348. * Caches the the state of the stencil buffer
  107349. */
  107350. cacheStencilState(): void;
  107351. /**
  107352. * Restores the state of the stencil buffer
  107353. */
  107354. restoreStencilState(): void;
  107355. /**
  107356. * Directly set the WebGL Viewport
  107357. * @param x defines the x coordinate of the viewport (in screen space)
  107358. * @param y defines the y coordinate of the viewport (in screen space)
  107359. * @param width defines the width of the viewport (in screen space)
  107360. * @param height defines the height of the viewport (in screen space)
  107361. * @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
  107362. */
  107363. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  107364. /**
  107365. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  107366. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107367. * @param y defines the y-coordinate of the corner of the clear rectangle
  107368. * @param width defines the width of the clear rectangle
  107369. * @param height defines the height of the clear rectangle
  107370. * @param clearColor defines the clear color
  107371. */
  107372. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  107373. /**
  107374. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  107375. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107376. * @param y defines the y-coordinate of the corner of the clear rectangle
  107377. * @param width defines the width of the clear rectangle
  107378. * @param height defines the height of the clear rectangle
  107379. */
  107380. enableScissor(x: number, y: number, width: number, height: number): void;
  107381. /**
  107382. * Disable previously set scissor test rectangle
  107383. */
  107384. disableScissor(): void;
  107385. protected _reportDrawCall(): void;
  107386. /**
  107387. * Initializes a webVR display and starts listening to display change events
  107388. * The onVRDisplayChangedObservable will be notified upon these changes
  107389. * @returns The onVRDisplayChangedObservable
  107390. */
  107391. initWebVR(): Observable<IDisplayChangedEventArgs>;
  107392. /** @hidden */
  107393. _prepareVRComponent(): void;
  107394. /** @hidden */
  107395. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  107396. /** @hidden */
  107397. _submitVRFrame(): void;
  107398. /**
  107399. * Call this function to leave webVR mode
  107400. * Will do nothing if webVR is not supported or if there is no webVR device
  107401. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107402. */
  107403. disableVR(): void;
  107404. /**
  107405. * Gets a boolean indicating that the system is in VR mode and is presenting
  107406. * @returns true if VR mode is engaged
  107407. */
  107408. isVRPresenting(): boolean;
  107409. /** @hidden */
  107410. _requestVRFrame(): void;
  107411. /** @hidden */
  107412. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107413. /**
  107414. * Gets the source code of the vertex shader associated with a specific webGL program
  107415. * @param program defines the program to use
  107416. * @returns a string containing the source code of the vertex shader associated with the program
  107417. */
  107418. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107419. /**
  107420. * Gets the source code of the fragment shader associated with a specific webGL program
  107421. * @param program defines the program to use
  107422. * @returns a string containing the source code of the fragment shader associated with the program
  107423. */
  107424. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107425. /**
  107426. * Sets a depth stencil texture from a render target to the according uniform.
  107427. * @param channel The texture channel
  107428. * @param uniform The uniform to set
  107429. * @param texture The render target texture containing the depth stencil texture to apply
  107430. */
  107431. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107432. /**
  107433. * Sets a texture to the webGL context from a postprocess
  107434. * @param channel defines the channel to use
  107435. * @param postProcess defines the source postprocess
  107436. */
  107437. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107438. /**
  107439. * Binds the output of the passed in post process to the texture channel specified
  107440. * @param channel The channel the texture should be bound to
  107441. * @param postProcess The post process which's output should be bound
  107442. */
  107443. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107444. /** @hidden */
  107445. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107446. protected _rebuildBuffers(): void;
  107447. /** @hidden */
  107448. _renderFrame(): void;
  107449. _renderLoop(): void;
  107450. /** @hidden */
  107451. _renderViews(): boolean;
  107452. /**
  107453. * Toggle full screen mode
  107454. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107455. */
  107456. switchFullscreen(requestPointerLock: boolean): void;
  107457. /**
  107458. * Enters full screen mode
  107459. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107460. */
  107461. enterFullscreen(requestPointerLock: boolean): void;
  107462. /**
  107463. * Exits full screen mode
  107464. */
  107465. exitFullscreen(): void;
  107466. /**
  107467. * Enters Pointerlock mode
  107468. */
  107469. enterPointerlock(): void;
  107470. /**
  107471. * Exits Pointerlock mode
  107472. */
  107473. exitPointerlock(): void;
  107474. /**
  107475. * Begin a new frame
  107476. */
  107477. beginFrame(): void;
  107478. /**
  107479. * Enf the current frame
  107480. */
  107481. endFrame(): void;
  107482. resize(): void;
  107483. /**
  107484. * Force a specific size of the canvas
  107485. * @param width defines the new canvas' width
  107486. * @param height defines the new canvas' height
  107487. */
  107488. setSize(width: number, height: number): void;
  107489. /**
  107490. * Updates a dynamic vertex buffer.
  107491. * @param vertexBuffer the vertex buffer to update
  107492. * @param data the data used to update the vertex buffer
  107493. * @param byteOffset the byte offset of the data
  107494. * @param byteLength the byte length of the data
  107495. */
  107496. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107497. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107498. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107499. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107500. _releaseTexture(texture: InternalTexture): void;
  107501. /**
  107502. * @hidden
  107503. * Rescales a texture
  107504. * @param source input texutre
  107505. * @param destination destination texture
  107506. * @param scene scene to use to render the resize
  107507. * @param internalFormat format to use when resizing
  107508. * @param onComplete callback to be called when resize has completed
  107509. */
  107510. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107511. /**
  107512. * Gets the current framerate
  107513. * @returns a number representing the framerate
  107514. */
  107515. getFps(): number;
  107516. /**
  107517. * Gets the time spent between current and previous frame
  107518. * @returns a number representing the delta time in ms
  107519. */
  107520. getDeltaTime(): number;
  107521. private _measureFps;
  107522. /** @hidden */
  107523. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107524. /**
  107525. * Update a dynamic index buffer
  107526. * @param indexBuffer defines the target index buffer
  107527. * @param indices defines the data to update
  107528. * @param offset defines the offset in the target index buffer where update should start
  107529. */
  107530. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107531. /**
  107532. * Updates the sample count of a render target texture
  107533. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107534. * @param texture defines the texture to update
  107535. * @param samples defines the sample count to set
  107536. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107537. */
  107538. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107539. /**
  107540. * Updates a depth texture Comparison Mode and Function.
  107541. * If the comparison Function is equal to 0, the mode will be set to none.
  107542. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107543. * @param texture The texture to set the comparison function for
  107544. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107545. */
  107546. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107547. /**
  107548. * Creates a webGL buffer to use with instanciation
  107549. * @param capacity defines the size of the buffer
  107550. * @returns the webGL buffer
  107551. */
  107552. createInstancesBuffer(capacity: number): DataBuffer;
  107553. /**
  107554. * Delete a webGL buffer used with instanciation
  107555. * @param buffer defines the webGL buffer to delete
  107556. */
  107557. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107558. private _clientWaitAsync;
  107559. /** @hidden */
  107560. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107561. /** @hidden */
  107562. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107563. dispose(): void;
  107564. private _disableTouchAction;
  107565. /**
  107566. * Display the loading screen
  107567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107568. */
  107569. displayLoadingUI(): void;
  107570. /**
  107571. * Hide the loading screen
  107572. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107573. */
  107574. hideLoadingUI(): void;
  107575. /**
  107576. * Gets the current loading screen object
  107577. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107578. */
  107579. get loadingScreen(): ILoadingScreen;
  107580. /**
  107581. * Sets the current loading screen object
  107582. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107583. */
  107584. set loadingScreen(loadingScreen: ILoadingScreen);
  107585. /**
  107586. * Sets the current loading screen text
  107587. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107588. */
  107589. set loadingUIText(text: string);
  107590. /**
  107591. * Sets the current loading screen background color
  107592. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107593. */
  107594. set loadingUIBackgroundColor(color: string);
  107595. /** Pointerlock and fullscreen */
  107596. /**
  107597. * Ask the browser to promote the current element to pointerlock mode
  107598. * @param element defines the DOM element to promote
  107599. */
  107600. static _RequestPointerlock(element: HTMLElement): void;
  107601. /**
  107602. * Asks the browser to exit pointerlock mode
  107603. */
  107604. static _ExitPointerlock(): void;
  107605. /**
  107606. * Ask the browser to promote the current element to fullscreen rendering mode
  107607. * @param element defines the DOM element to promote
  107608. */
  107609. static _RequestFullscreen(element: HTMLElement): void;
  107610. /**
  107611. * Asks the browser to exit fullscreen mode
  107612. */
  107613. static _ExitFullscreen(): void;
  107614. }
  107615. }
  107616. declare module BABYLON {
  107617. /**
  107618. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107619. * during the life time of the application.
  107620. */
  107621. export class EngineStore {
  107622. /** Gets the list of created engines */
  107623. static Instances: Engine[];
  107624. /** @hidden */
  107625. static _LastCreatedScene: Nullable<Scene>;
  107626. /**
  107627. * Gets the latest created engine
  107628. */
  107629. static get LastCreatedEngine(): Nullable<Engine>;
  107630. /**
  107631. * Gets the latest created scene
  107632. */
  107633. static get LastCreatedScene(): Nullable<Scene>;
  107634. /**
  107635. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107636. * @ignorenaming
  107637. */
  107638. static UseFallbackTexture: boolean;
  107639. /**
  107640. * Texture content used if a texture cannot loaded
  107641. * @ignorenaming
  107642. */
  107643. static FallbackTexture: string;
  107644. }
  107645. }
  107646. declare module BABYLON {
  107647. /**
  107648. * Helper class that provides a small promise polyfill
  107649. */
  107650. export class PromisePolyfill {
  107651. /**
  107652. * Static function used to check if the polyfill is required
  107653. * If this is the case then the function will inject the polyfill to window.Promise
  107654. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107655. */
  107656. static Apply(force?: boolean): void;
  107657. }
  107658. }
  107659. declare module BABYLON {
  107660. /**
  107661. * Interface for screenshot methods with describe argument called `size` as object with options
  107662. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107663. */
  107664. export interface IScreenshotSize {
  107665. /**
  107666. * number in pixels for canvas height
  107667. */
  107668. height?: number;
  107669. /**
  107670. * multiplier allowing render at a higher or lower resolution
  107671. * If value is defined then height and width will be ignored and taken from camera
  107672. */
  107673. precision?: number;
  107674. /**
  107675. * number in pixels for canvas width
  107676. */
  107677. width?: number;
  107678. }
  107679. }
  107680. declare module BABYLON {
  107681. interface IColor4Like {
  107682. r: float;
  107683. g: float;
  107684. b: float;
  107685. a: float;
  107686. }
  107687. /**
  107688. * Class containing a set of static utilities functions
  107689. */
  107690. export class Tools {
  107691. /**
  107692. * Gets or sets the base URL to use to load assets
  107693. */
  107694. static get BaseUrl(): string;
  107695. static set BaseUrl(value: string);
  107696. /**
  107697. * Enable/Disable Custom HTTP Request Headers globally.
  107698. * default = false
  107699. * @see CustomRequestHeaders
  107700. */
  107701. static UseCustomRequestHeaders: boolean;
  107702. /**
  107703. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107704. * i.e. when loading files, where the server/service expects an Authorization header
  107705. */
  107706. static CustomRequestHeaders: {
  107707. [key: string]: string;
  107708. };
  107709. /**
  107710. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107711. */
  107712. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107713. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107714. /**
  107715. * Default behaviour for cors in the application.
  107716. * It can be a string if the expected behavior is identical in the entire app.
  107717. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107718. */
  107719. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107720. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107721. /**
  107722. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107723. * @ignorenaming
  107724. */
  107725. static get UseFallbackTexture(): boolean;
  107726. static set UseFallbackTexture(value: boolean);
  107727. /**
  107728. * Use this object to register external classes like custom textures or material
  107729. * to allow the laoders to instantiate them
  107730. */
  107731. static get RegisteredExternalClasses(): {
  107732. [key: string]: Object;
  107733. };
  107734. static set RegisteredExternalClasses(classes: {
  107735. [key: string]: Object;
  107736. });
  107737. /**
  107738. * Texture content used if a texture cannot loaded
  107739. * @ignorenaming
  107740. */
  107741. static get fallbackTexture(): string;
  107742. static set fallbackTexture(value: string);
  107743. /**
  107744. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107745. * @param u defines the coordinate on X axis
  107746. * @param v defines the coordinate on Y axis
  107747. * @param width defines the width of the source data
  107748. * @param height defines the height of the source data
  107749. * @param pixels defines the source byte array
  107750. * @param color defines the output color
  107751. */
  107752. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107753. /**
  107754. * Interpolates between a and b via alpha
  107755. * @param a The lower value (returned when alpha = 0)
  107756. * @param b The upper value (returned when alpha = 1)
  107757. * @param alpha The interpolation-factor
  107758. * @return The mixed value
  107759. */
  107760. static Mix(a: number, b: number, alpha: number): number;
  107761. /**
  107762. * Tries to instantiate a new object from a given class name
  107763. * @param className defines the class name to instantiate
  107764. * @returns the new object or null if the system was not able to do the instantiation
  107765. */
  107766. static Instantiate(className: string): any;
  107767. /**
  107768. * Provides a slice function that will work even on IE
  107769. * @param data defines the array to slice
  107770. * @param start defines the start of the data (optional)
  107771. * @param end defines the end of the data (optional)
  107772. * @returns the new sliced array
  107773. */
  107774. static Slice<T>(data: T, start?: number, end?: number): T;
  107775. /**
  107776. * Polyfill for setImmediate
  107777. * @param action defines the action to execute after the current execution block
  107778. */
  107779. static SetImmediate(action: () => void): void;
  107780. /**
  107781. * Function indicating if a number is an exponent of 2
  107782. * @param value defines the value to test
  107783. * @returns true if the value is an exponent of 2
  107784. */
  107785. static IsExponentOfTwo(value: number): boolean;
  107786. private static _tmpFloatArray;
  107787. /**
  107788. * Returns the nearest 32-bit single precision float representation of a Number
  107789. * @param value A Number. If the parameter is of a different type, it will get converted
  107790. * to a number or to NaN if it cannot be converted
  107791. * @returns number
  107792. */
  107793. static FloatRound(value: number): number;
  107794. /**
  107795. * Extracts the filename from a path
  107796. * @param path defines the path to use
  107797. * @returns the filename
  107798. */
  107799. static GetFilename(path: string): string;
  107800. /**
  107801. * Extracts the "folder" part of a path (everything before the filename).
  107802. * @param uri The URI to extract the info from
  107803. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107804. * @returns The "folder" part of the path
  107805. */
  107806. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107807. /**
  107808. * Extracts text content from a DOM element hierarchy
  107809. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107810. */
  107811. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107812. /**
  107813. * Convert an angle in radians to degrees
  107814. * @param angle defines the angle to convert
  107815. * @returns the angle in degrees
  107816. */
  107817. static ToDegrees(angle: number): number;
  107818. /**
  107819. * Convert an angle in degrees to radians
  107820. * @param angle defines the angle to convert
  107821. * @returns the angle in radians
  107822. */
  107823. static ToRadians(angle: number): number;
  107824. /**
  107825. * Returns an array if obj is not an array
  107826. * @param obj defines the object to evaluate as an array
  107827. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107828. * @returns either obj directly if obj is an array or a new array containing obj
  107829. */
  107830. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107831. /**
  107832. * Gets the pointer prefix to use
  107833. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107834. */
  107835. static GetPointerPrefix(): string;
  107836. /**
  107837. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107838. * @param url define the url we are trying
  107839. * @param element define the dom element where to configure the cors policy
  107840. */
  107841. static SetCorsBehavior(url: string | string[], element: {
  107842. crossOrigin: string | null;
  107843. }): void;
  107844. /**
  107845. * Removes unwanted characters from an url
  107846. * @param url defines the url to clean
  107847. * @returns the cleaned url
  107848. */
  107849. static CleanUrl(url: string): string;
  107850. /**
  107851. * Gets or sets a function used to pre-process url before using them to load assets
  107852. */
  107853. static get PreprocessUrl(): (url: string) => string;
  107854. static set PreprocessUrl(processor: (url: string) => string);
  107855. /**
  107856. * Loads an image as an HTMLImageElement.
  107857. * @param input url string, ArrayBuffer, or Blob to load
  107858. * @param onLoad callback called when the image successfully loads
  107859. * @param onError callback called when the image fails to load
  107860. * @param offlineProvider offline provider for caching
  107861. * @param mimeType optional mime type
  107862. * @returns the HTMLImageElement of the loaded image
  107863. */
  107864. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107865. /**
  107866. * Loads a file from a url
  107867. * @param url url string, ArrayBuffer, or Blob to load
  107868. * @param onSuccess callback called when the file successfully loads
  107869. * @param onProgress callback called while file is loading (if the server supports this mode)
  107870. * @param offlineProvider defines the offline provider for caching
  107871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107872. * @param onError callback called when the file fails to load
  107873. * @returns a file request object
  107874. */
  107875. 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;
  107876. /**
  107877. * Loads a file from a url
  107878. * @param url the file url to load
  107879. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107880. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107881. */
  107882. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107883. /**
  107884. * Load a script (identified by an url). When the url returns, the
  107885. * content of this file is added into a new script element, attached to the DOM (body element)
  107886. * @param scriptUrl defines the url of the script to laod
  107887. * @param onSuccess defines the callback called when the script is loaded
  107888. * @param onError defines the callback to call if an error occurs
  107889. * @param scriptId defines the id of the script element
  107890. */
  107891. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107892. /**
  107893. * Load an asynchronous script (identified by an url). When the url returns, the
  107894. * content of this file is added into a new script element, attached to the DOM (body element)
  107895. * @param scriptUrl defines the url of the script to laod
  107896. * @param scriptId defines the id of the script element
  107897. * @returns a promise request object
  107898. */
  107899. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107900. /**
  107901. * Loads a file from a blob
  107902. * @param fileToLoad defines the blob to use
  107903. * @param callback defines the callback to call when data is loaded
  107904. * @param progressCallback defines the callback to call during loading process
  107905. * @returns a file request object
  107906. */
  107907. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107908. /**
  107909. * Reads a file from a File object
  107910. * @param file defines the file to load
  107911. * @param onSuccess defines the callback to call when data is loaded
  107912. * @param onProgress defines the callback to call during loading process
  107913. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107914. * @param onError defines the callback to call when an error occurs
  107915. * @returns a file request object
  107916. */
  107917. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107918. /**
  107919. * Creates a data url from a given string content
  107920. * @param content defines the content to convert
  107921. * @returns the new data url link
  107922. */
  107923. static FileAsURL(content: string): string;
  107924. /**
  107925. * Format the given number to a specific decimal format
  107926. * @param value defines the number to format
  107927. * @param decimals defines the number of decimals to use
  107928. * @returns the formatted string
  107929. */
  107930. static Format(value: number, decimals?: number): string;
  107931. /**
  107932. * Tries to copy an object by duplicating every property
  107933. * @param source defines the source object
  107934. * @param destination defines the target object
  107935. * @param doNotCopyList defines a list of properties to avoid
  107936. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107937. */
  107938. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107939. /**
  107940. * Gets a boolean indicating if the given object has no own property
  107941. * @param obj defines the object to test
  107942. * @returns true if object has no own property
  107943. */
  107944. static IsEmpty(obj: any): boolean;
  107945. /**
  107946. * Function used to register events at window level
  107947. * @param windowElement defines the Window object to use
  107948. * @param events defines the events to register
  107949. */
  107950. static RegisterTopRootEvents(windowElement: Window, events: {
  107951. name: string;
  107952. handler: Nullable<(e: FocusEvent) => any>;
  107953. }[]): void;
  107954. /**
  107955. * Function used to unregister events from window level
  107956. * @param windowElement defines the Window object to use
  107957. * @param events defines the events to unregister
  107958. */
  107959. static UnregisterTopRootEvents(windowElement: Window, events: {
  107960. name: string;
  107961. handler: Nullable<(e: FocusEvent) => any>;
  107962. }[]): void;
  107963. /**
  107964. * @ignore
  107965. */
  107966. static _ScreenshotCanvas: HTMLCanvasElement;
  107967. /**
  107968. * Dumps the current bound framebuffer
  107969. * @param width defines the rendering width
  107970. * @param height defines the rendering height
  107971. * @param engine defines the hosting engine
  107972. * @param successCallback defines the callback triggered once the data are available
  107973. * @param mimeType defines the mime type of the result
  107974. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107975. */
  107976. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107977. /**
  107978. * Converts the canvas data to blob.
  107979. * This acts as a polyfill for browsers not supporting the to blob function.
  107980. * @param canvas Defines the canvas to extract the data from
  107981. * @param successCallback Defines the callback triggered once the data are available
  107982. * @param mimeType Defines the mime type of the result
  107983. */
  107984. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107985. /**
  107986. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107987. * @param successCallback defines the callback triggered once the data are available
  107988. * @param mimeType defines the mime type of the result
  107989. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107990. */
  107991. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107992. /**
  107993. * Downloads a blob in the browser
  107994. * @param blob defines the blob to download
  107995. * @param fileName defines the name of the downloaded file
  107996. */
  107997. static Download(blob: Blob, fileName: string): void;
  107998. /**
  107999. * Captures a screenshot of the current rendering
  108000. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108001. * @param engine defines the rendering engine
  108002. * @param camera defines the source camera
  108003. * @param size This parameter can be set to a single number or to an object with the
  108004. * following (optional) properties: precision, width, height. If a single number is passed,
  108005. * it will be used for both width and height. If an object is passed, the screenshot size
  108006. * will be derived from the parameters. The precision property is a multiplier allowing
  108007. * rendering at a higher or lower resolution
  108008. * @param successCallback defines the callback receives a single parameter which contains the
  108009. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108010. * src parameter of an <img> to display it
  108011. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108012. * Check your browser for supported MIME types
  108013. */
  108014. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108015. /**
  108016. * Captures a screenshot of the current rendering
  108017. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108018. * @param engine defines the rendering engine
  108019. * @param camera defines the source camera
  108020. * @param size This parameter can be set to a single number or to an object with the
  108021. * following (optional) properties: precision, width, height. If a single number is passed,
  108022. * it will be used for both width and height. If an object is passed, the screenshot size
  108023. * will be derived from the parameters. The precision property is a multiplier allowing
  108024. * rendering at a higher or lower resolution
  108025. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108026. * Check your browser for supported MIME types
  108027. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108028. * to the src parameter of an <img> to display it
  108029. */
  108030. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108031. /**
  108032. * Generates an image screenshot from the specified camera.
  108033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108034. * @param engine The engine to use for rendering
  108035. * @param camera The camera to use for rendering
  108036. * @param size This parameter can be set to a single number or to an object with the
  108037. * following (optional) properties: precision, width, height. If a single number is passed,
  108038. * it will be used for both width and height. If an object is passed, the screenshot size
  108039. * will be derived from the parameters. The precision property is a multiplier allowing
  108040. * rendering at a higher or lower resolution
  108041. * @param successCallback The callback receives a single parameter which contains the
  108042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108043. * src parameter of an <img> to display it
  108044. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108045. * Check your browser for supported MIME types
  108046. * @param samples Texture samples (default: 1)
  108047. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108048. * @param fileName A name for for the downloaded file.
  108049. */
  108050. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108051. /**
  108052. * Generates an image screenshot from the specified camera.
  108053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108054. * @param engine The engine to use for rendering
  108055. * @param camera The camera to use for rendering
  108056. * @param size This parameter can be set to a single number or to an object with the
  108057. * following (optional) properties: precision, width, height. If a single number is passed,
  108058. * it will be used for both width and height. If an object is passed, the screenshot size
  108059. * will be derived from the parameters. The precision property is a multiplier allowing
  108060. * rendering at a higher or lower resolution
  108061. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108062. * Check your browser for supported MIME types
  108063. * @param samples Texture samples (default: 1)
  108064. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108065. * @param fileName A name for for the downloaded file.
  108066. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108067. * to the src parameter of an <img> to display it
  108068. */
  108069. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108070. /**
  108071. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108072. * Be aware Math.random() could cause collisions, but:
  108073. * "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"
  108074. * @returns a pseudo random id
  108075. */
  108076. static RandomId(): string;
  108077. /**
  108078. * Test if the given uri is a base64 string
  108079. * @param uri The uri to test
  108080. * @return True if the uri is a base64 string or false otherwise
  108081. */
  108082. static IsBase64(uri: string): boolean;
  108083. /**
  108084. * Decode the given base64 uri.
  108085. * @param uri The uri to decode
  108086. * @return The decoded base64 data.
  108087. */
  108088. static DecodeBase64(uri: string): ArrayBuffer;
  108089. /**
  108090. * Gets the absolute url.
  108091. * @param url the input url
  108092. * @return the absolute url
  108093. */
  108094. static GetAbsoluteUrl(url: string): string;
  108095. /**
  108096. * No log
  108097. */
  108098. static readonly NoneLogLevel: number;
  108099. /**
  108100. * Only message logs
  108101. */
  108102. static readonly MessageLogLevel: number;
  108103. /**
  108104. * Only warning logs
  108105. */
  108106. static readonly WarningLogLevel: number;
  108107. /**
  108108. * Only error logs
  108109. */
  108110. static readonly ErrorLogLevel: number;
  108111. /**
  108112. * All logs
  108113. */
  108114. static readonly AllLogLevel: number;
  108115. /**
  108116. * Gets a value indicating the number of loading errors
  108117. * @ignorenaming
  108118. */
  108119. static get errorsCount(): number;
  108120. /**
  108121. * Callback called when a new log is added
  108122. */
  108123. static OnNewCacheEntry: (entry: string) => void;
  108124. /**
  108125. * Log a message to the console
  108126. * @param message defines the message to log
  108127. */
  108128. static Log(message: string): void;
  108129. /**
  108130. * Write a warning message to the console
  108131. * @param message defines the message to log
  108132. */
  108133. static Warn(message: string): void;
  108134. /**
  108135. * Write an error message to the console
  108136. * @param message defines the message to log
  108137. */
  108138. static Error(message: string): void;
  108139. /**
  108140. * Gets current log cache (list of logs)
  108141. */
  108142. static get LogCache(): string;
  108143. /**
  108144. * Clears the log cache
  108145. */
  108146. static ClearLogCache(): void;
  108147. /**
  108148. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  108149. */
  108150. static set LogLevels(level: number);
  108151. /**
  108152. * Checks if the window object exists
  108153. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  108154. */
  108155. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  108156. /**
  108157. * No performance log
  108158. */
  108159. static readonly PerformanceNoneLogLevel: number;
  108160. /**
  108161. * Use user marks to log performance
  108162. */
  108163. static readonly PerformanceUserMarkLogLevel: number;
  108164. /**
  108165. * Log performance to the console
  108166. */
  108167. static readonly PerformanceConsoleLogLevel: number;
  108168. private static _performance;
  108169. /**
  108170. * Sets the current performance log level
  108171. */
  108172. static set PerformanceLogLevel(level: number);
  108173. private static _StartPerformanceCounterDisabled;
  108174. private static _EndPerformanceCounterDisabled;
  108175. private static _StartUserMark;
  108176. private static _EndUserMark;
  108177. private static _StartPerformanceConsole;
  108178. private static _EndPerformanceConsole;
  108179. /**
  108180. * Starts a performance counter
  108181. */
  108182. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108183. /**
  108184. * Ends a specific performance coutner
  108185. */
  108186. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108187. /**
  108188. * Gets either window.performance.now() if supported or Date.now() else
  108189. */
  108190. static get Now(): number;
  108191. /**
  108192. * This method will return the name of the class used to create the instance of the given object.
  108193. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  108194. * @param object the object to get the class name from
  108195. * @param isType defines if the object is actually a type
  108196. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  108197. */
  108198. static GetClassName(object: any, isType?: boolean): string;
  108199. /**
  108200. * Gets the first element of an array satisfying a given predicate
  108201. * @param array defines the array to browse
  108202. * @param predicate defines the predicate to use
  108203. * @returns null if not found or the element
  108204. */
  108205. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  108206. /**
  108207. * This method will return the name of the full name of the class, including its owning module (if any).
  108208. * 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).
  108209. * @param object the object to get the class name from
  108210. * @param isType defines if the object is actually a type
  108211. * @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.
  108212. * @ignorenaming
  108213. */
  108214. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  108215. /**
  108216. * Returns a promise that resolves after the given amount of time.
  108217. * @param delay Number of milliseconds to delay
  108218. * @returns Promise that resolves after the given amount of time
  108219. */
  108220. static DelayAsync(delay: number): Promise<void>;
  108221. /**
  108222. * Utility function to detect if the current user agent is Safari
  108223. * @returns whether or not the current user agent is safari
  108224. */
  108225. static IsSafari(): boolean;
  108226. }
  108227. /**
  108228. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  108229. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  108230. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  108231. * @param name The name of the class, case should be preserved
  108232. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  108233. */
  108234. export function className(name: string, module?: string): (target: Object) => void;
  108235. /**
  108236. * An implementation of a loop for asynchronous functions.
  108237. */
  108238. export class AsyncLoop {
  108239. /**
  108240. * Defines the number of iterations for the loop
  108241. */
  108242. iterations: number;
  108243. /**
  108244. * Defines the current index of the loop.
  108245. */
  108246. index: number;
  108247. private _done;
  108248. private _fn;
  108249. private _successCallback;
  108250. /**
  108251. * Constructor.
  108252. * @param iterations the number of iterations.
  108253. * @param func the function to run each iteration
  108254. * @param successCallback the callback that will be called upon succesful execution
  108255. * @param offset starting offset.
  108256. */
  108257. constructor(
  108258. /**
  108259. * Defines the number of iterations for the loop
  108260. */
  108261. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  108262. /**
  108263. * Execute the next iteration. Must be called after the last iteration was finished.
  108264. */
  108265. executeNext(): void;
  108266. /**
  108267. * Break the loop and run the success callback.
  108268. */
  108269. breakLoop(): void;
  108270. /**
  108271. * Create and run an async loop.
  108272. * @param iterations the number of iterations.
  108273. * @param fn the function to run each iteration
  108274. * @param successCallback the callback that will be called upon succesful execution
  108275. * @param offset starting offset.
  108276. * @returns the created async loop object
  108277. */
  108278. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  108279. /**
  108280. * A for-loop that will run a given number of iterations synchronous and the rest async.
  108281. * @param iterations total number of iterations
  108282. * @param syncedIterations number of synchronous iterations in each async iteration.
  108283. * @param fn the function to call each iteration.
  108284. * @param callback a success call back that will be called when iterating stops.
  108285. * @param breakFunction a break condition (optional)
  108286. * @param timeout timeout settings for the setTimeout function. default - 0.
  108287. * @returns the created async loop object
  108288. */
  108289. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  108290. }
  108291. }
  108292. declare module BABYLON {
  108293. /**
  108294. * This class implement a typical dictionary using a string as key and the generic type T as value.
  108295. * The underlying implementation relies on an associative array to ensure the best performances.
  108296. * The value can be anything including 'null' but except 'undefined'
  108297. */
  108298. export class StringDictionary<T> {
  108299. /**
  108300. * This will clear this dictionary and copy the content from the 'source' one.
  108301. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  108302. * @param source the dictionary to take the content from and copy to this dictionary
  108303. */
  108304. copyFrom(source: StringDictionary<T>): void;
  108305. /**
  108306. * Get a value based from its key
  108307. * @param key the given key to get the matching value from
  108308. * @return the value if found, otherwise undefined is returned
  108309. */
  108310. get(key: string): T | undefined;
  108311. /**
  108312. * Get a value from its key or add it if it doesn't exist.
  108313. * This method will ensure you that a given key/data will be present in the dictionary.
  108314. * @param key the given key to get the matching value from
  108315. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108316. * The factory will only be invoked if there's no data for the given key.
  108317. * @return the value corresponding to the key.
  108318. */
  108319. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108320. /**
  108321. * Get a value from its key if present in the dictionary otherwise add it
  108322. * @param key the key to get the value from
  108323. * @param val if there's no such key/value pair in the dictionary add it with this value
  108324. * @return the value corresponding to the key
  108325. */
  108326. getOrAdd(key: string, val: T): T;
  108327. /**
  108328. * Check if there's a given key in the dictionary
  108329. * @param key the key to check for
  108330. * @return true if the key is present, false otherwise
  108331. */
  108332. contains(key: string): boolean;
  108333. /**
  108334. * Add a new key and its corresponding value
  108335. * @param key the key to add
  108336. * @param value the value corresponding to the key
  108337. * @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
  108338. */
  108339. add(key: string, value: T): boolean;
  108340. /**
  108341. * Update a specific value associated to a key
  108342. * @param key defines the key to use
  108343. * @param value defines the value to store
  108344. * @returns true if the value was updated (or false if the key was not found)
  108345. */
  108346. set(key: string, value: T): boolean;
  108347. /**
  108348. * Get the element of the given key and remove it from the dictionary
  108349. * @param key defines the key to search
  108350. * @returns the value associated with the key or null if not found
  108351. */
  108352. getAndRemove(key: string): Nullable<T>;
  108353. /**
  108354. * Remove a key/value from the dictionary.
  108355. * @param key the key to remove
  108356. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  108357. */
  108358. remove(key: string): boolean;
  108359. /**
  108360. * Clear the whole content of the dictionary
  108361. */
  108362. clear(): void;
  108363. /**
  108364. * Gets the current count
  108365. */
  108366. get count(): number;
  108367. /**
  108368. * Execute a callback on each key/val of the dictionary.
  108369. * Note that you can remove any element in this dictionary in the callback implementation
  108370. * @param callback the callback to execute on a given key/value pair
  108371. */
  108372. forEach(callback: (key: string, val: T) => void): void;
  108373. /**
  108374. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  108375. * If the callback returns null or undefined the method will iterate to the next key/value pair
  108376. * Note that you can remove any element in this dictionary in the callback implementation
  108377. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  108378. * @returns the first item
  108379. */
  108380. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  108381. private _count;
  108382. private _data;
  108383. }
  108384. }
  108385. declare module BABYLON {
  108386. /** @hidden */
  108387. export interface ICollisionCoordinator {
  108388. createCollider(): Collider;
  108389. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108390. init(scene: Scene): void;
  108391. }
  108392. /** @hidden */
  108393. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108394. private _scene;
  108395. private _scaledPosition;
  108396. private _scaledVelocity;
  108397. private _finalPosition;
  108398. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108399. createCollider(): Collider;
  108400. init(scene: Scene): void;
  108401. private _collideWithWorld;
  108402. }
  108403. }
  108404. declare module BABYLON {
  108405. /**
  108406. * Class used to manage all inputs for the scene.
  108407. */
  108408. export class InputManager {
  108409. /** The distance in pixel that you have to move to prevent some events */
  108410. static DragMovementThreshold: number;
  108411. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108412. static LongPressDelay: number;
  108413. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108414. static DoubleClickDelay: number;
  108415. /** If you need to check double click without raising a single click at first click, enable this flag */
  108416. static ExclusiveDoubleClickMode: boolean;
  108417. private _wheelEventName;
  108418. private _onPointerMove;
  108419. private _onPointerDown;
  108420. private _onPointerUp;
  108421. private _initClickEvent;
  108422. private _initActionManager;
  108423. private _delayedSimpleClick;
  108424. private _delayedSimpleClickTimeout;
  108425. private _previousDelayedSimpleClickTimeout;
  108426. private _meshPickProceed;
  108427. private _previousButtonPressed;
  108428. private _currentPickResult;
  108429. private _previousPickResult;
  108430. private _totalPointersPressed;
  108431. private _doubleClickOccured;
  108432. private _pointerOverMesh;
  108433. private _pickedDownMesh;
  108434. private _pickedUpMesh;
  108435. private _pointerX;
  108436. private _pointerY;
  108437. private _unTranslatedPointerX;
  108438. private _unTranslatedPointerY;
  108439. private _startingPointerPosition;
  108440. private _previousStartingPointerPosition;
  108441. private _startingPointerTime;
  108442. private _previousStartingPointerTime;
  108443. private _pointerCaptures;
  108444. private _onKeyDown;
  108445. private _onKeyUp;
  108446. private _onCanvasFocusObserver;
  108447. private _onCanvasBlurObserver;
  108448. private _scene;
  108449. /**
  108450. * Creates a new InputManager
  108451. * @param scene defines the hosting scene
  108452. */
  108453. constructor(scene: Scene);
  108454. /**
  108455. * Gets the mesh that is currently under the pointer
  108456. */
  108457. get meshUnderPointer(): Nullable<AbstractMesh>;
  108458. /**
  108459. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108460. */
  108461. get unTranslatedPointer(): Vector2;
  108462. /**
  108463. * Gets or sets the current on-screen X position of the pointer
  108464. */
  108465. get pointerX(): number;
  108466. set pointerX(value: number);
  108467. /**
  108468. * Gets or sets the current on-screen Y position of the pointer
  108469. */
  108470. get pointerY(): number;
  108471. set pointerY(value: number);
  108472. private _updatePointerPosition;
  108473. private _processPointerMove;
  108474. private _setRayOnPointerInfo;
  108475. private _checkPrePointerObservable;
  108476. /**
  108477. * Use this method to simulate a pointer move on a mesh
  108478. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108479. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108480. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108481. */
  108482. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108483. /**
  108484. * Use this method to simulate a pointer down on a mesh
  108485. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108486. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108487. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108488. */
  108489. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108490. private _processPointerDown;
  108491. /** @hidden */
  108492. _isPointerSwiping(): boolean;
  108493. /**
  108494. * Use this method to simulate a pointer up on a mesh
  108495. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108496. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108497. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108498. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108499. */
  108500. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108501. private _processPointerUp;
  108502. /**
  108503. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108504. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108505. * @returns true if the pointer was captured
  108506. */
  108507. isPointerCaptured(pointerId?: number): boolean;
  108508. /**
  108509. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108510. * @param attachUp defines if you want to attach events to pointerup
  108511. * @param attachDown defines if you want to attach events to pointerdown
  108512. * @param attachMove defines if you want to attach events to pointermove
  108513. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108514. */
  108515. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108516. /**
  108517. * Detaches all event handlers
  108518. */
  108519. detachControl(): void;
  108520. /**
  108521. * Force the value of meshUnderPointer
  108522. * @param mesh defines the mesh to use
  108523. */
  108524. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108525. /**
  108526. * Gets the mesh under the pointer
  108527. * @returns a Mesh or null if no mesh is under the pointer
  108528. */
  108529. getPointerOverMesh(): Nullable<AbstractMesh>;
  108530. }
  108531. }
  108532. declare module BABYLON {
  108533. /**
  108534. * Helper class used to generate session unique ID
  108535. */
  108536. export class UniqueIdGenerator {
  108537. private static _UniqueIdCounter;
  108538. /**
  108539. * Gets an unique (relatively to the current scene) Id
  108540. */
  108541. static get UniqueId(): number;
  108542. }
  108543. }
  108544. declare module BABYLON {
  108545. /**
  108546. * This class defines the direct association between an animation and a target
  108547. */
  108548. export class TargetedAnimation {
  108549. /**
  108550. * Animation to perform
  108551. */
  108552. animation: Animation;
  108553. /**
  108554. * Target to animate
  108555. */
  108556. target: any;
  108557. /**
  108558. * Serialize the object
  108559. * @returns the JSON object representing the current entity
  108560. */
  108561. serialize(): any;
  108562. }
  108563. /**
  108564. * Use this class to create coordinated animations on multiple targets
  108565. */
  108566. export class AnimationGroup implements IDisposable {
  108567. /** The name of the animation group */
  108568. name: string;
  108569. private _scene;
  108570. private _targetedAnimations;
  108571. private _animatables;
  108572. private _from;
  108573. private _to;
  108574. private _isStarted;
  108575. private _isPaused;
  108576. private _speedRatio;
  108577. private _loopAnimation;
  108578. /**
  108579. * Gets or sets the unique id of the node
  108580. */
  108581. uniqueId: number;
  108582. /**
  108583. * This observable will notify when one animation have ended
  108584. */
  108585. onAnimationEndObservable: Observable<TargetedAnimation>;
  108586. /**
  108587. * Observer raised when one animation loops
  108588. */
  108589. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108590. /**
  108591. * Observer raised when all animations have looped
  108592. */
  108593. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108594. /**
  108595. * This observable will notify when all animations have ended.
  108596. */
  108597. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108598. /**
  108599. * This observable will notify when all animations have paused.
  108600. */
  108601. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108602. /**
  108603. * This observable will notify when all animations are playing.
  108604. */
  108605. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108606. /**
  108607. * Gets the first frame
  108608. */
  108609. get from(): number;
  108610. /**
  108611. * Gets the last frame
  108612. */
  108613. get to(): number;
  108614. /**
  108615. * Define if the animations are started
  108616. */
  108617. get isStarted(): boolean;
  108618. /**
  108619. * Gets a value indicating that the current group is playing
  108620. */
  108621. get isPlaying(): boolean;
  108622. /**
  108623. * Gets or sets the speed ratio to use for all animations
  108624. */
  108625. get speedRatio(): number;
  108626. /**
  108627. * Gets or sets the speed ratio to use for all animations
  108628. */
  108629. set speedRatio(value: number);
  108630. /**
  108631. * Gets or sets if all animations should loop or not
  108632. */
  108633. get loopAnimation(): boolean;
  108634. set loopAnimation(value: boolean);
  108635. /**
  108636. * Gets the targeted animations for this animation group
  108637. */
  108638. get targetedAnimations(): Array<TargetedAnimation>;
  108639. /**
  108640. * returning the list of animatables controlled by this animation group.
  108641. */
  108642. get animatables(): Array<Animatable>;
  108643. /**
  108644. * Instantiates a new Animation Group.
  108645. * This helps managing several animations at once.
  108646. * @see http://doc.babylonjs.com/how_to/group
  108647. * @param name Defines the name of the group
  108648. * @param scene Defines the scene the group belongs to
  108649. */
  108650. constructor(
  108651. /** The name of the animation group */
  108652. name: string, scene?: Nullable<Scene>);
  108653. /**
  108654. * Add an animation (with its target) in the group
  108655. * @param animation defines the animation we want to add
  108656. * @param target defines the target of the animation
  108657. * @returns the TargetedAnimation object
  108658. */
  108659. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108660. /**
  108661. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108662. * It can add constant keys at begin or end
  108663. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108664. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108665. * @returns the animation group
  108666. */
  108667. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108668. private _animationLoopCount;
  108669. private _animationLoopFlags;
  108670. private _processLoop;
  108671. /**
  108672. * Start all animations on given targets
  108673. * @param loop defines if animations must loop
  108674. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108675. * @param from defines the from key (optional)
  108676. * @param to defines the to key (optional)
  108677. * @returns the current animation group
  108678. */
  108679. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108680. /**
  108681. * Pause all animations
  108682. * @returns the animation group
  108683. */
  108684. pause(): AnimationGroup;
  108685. /**
  108686. * Play all animations to initial state
  108687. * This function will start() the animations if they were not started or will restart() them if they were paused
  108688. * @param loop defines if animations must loop
  108689. * @returns the animation group
  108690. */
  108691. play(loop?: boolean): AnimationGroup;
  108692. /**
  108693. * Reset all animations to initial state
  108694. * @returns the animation group
  108695. */
  108696. reset(): AnimationGroup;
  108697. /**
  108698. * Restart animations from key 0
  108699. * @returns the animation group
  108700. */
  108701. restart(): AnimationGroup;
  108702. /**
  108703. * Stop all animations
  108704. * @returns the animation group
  108705. */
  108706. stop(): AnimationGroup;
  108707. /**
  108708. * Set animation weight for all animatables
  108709. * @param weight defines the weight to use
  108710. * @return the animationGroup
  108711. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108712. */
  108713. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108714. /**
  108715. * Synchronize and normalize all animatables with a source animatable
  108716. * @param root defines the root animatable to synchronize with
  108717. * @return the animationGroup
  108718. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108719. */
  108720. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108721. /**
  108722. * Goes to a specific frame in this animation group
  108723. * @param frame the frame number to go to
  108724. * @return the animationGroup
  108725. */
  108726. goToFrame(frame: number): AnimationGroup;
  108727. /**
  108728. * Dispose all associated resources
  108729. */
  108730. dispose(): void;
  108731. private _checkAnimationGroupEnded;
  108732. /**
  108733. * Clone the current animation group and returns a copy
  108734. * @param newName defines the name of the new group
  108735. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108736. * @returns the new aniamtion group
  108737. */
  108738. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108739. /**
  108740. * Serializes the animationGroup to an object
  108741. * @returns Serialized object
  108742. */
  108743. serialize(): any;
  108744. /**
  108745. * Returns a new AnimationGroup object parsed from the source provided.
  108746. * @param parsedAnimationGroup defines the source
  108747. * @param scene defines the scene that will receive the animationGroup
  108748. * @returns a new AnimationGroup
  108749. */
  108750. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108751. /**
  108752. * Returns the string "AnimationGroup"
  108753. * @returns "AnimationGroup"
  108754. */
  108755. getClassName(): string;
  108756. /**
  108757. * Creates a detailled string about the object
  108758. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108759. * @returns a string representing the object
  108760. */
  108761. toString(fullDetails?: boolean): string;
  108762. }
  108763. }
  108764. declare module BABYLON {
  108765. /**
  108766. * Define an interface for all classes that will hold resources
  108767. */
  108768. export interface IDisposable {
  108769. /**
  108770. * Releases all held resources
  108771. */
  108772. dispose(): void;
  108773. }
  108774. /** Interface defining initialization parameters for Scene class */
  108775. export interface SceneOptions {
  108776. /**
  108777. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108778. * It will improve performance when the number of geometries becomes important.
  108779. */
  108780. useGeometryUniqueIdsMap?: boolean;
  108781. /**
  108782. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108783. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108784. */
  108785. useMaterialMeshMap?: boolean;
  108786. /**
  108787. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108788. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108789. */
  108790. useClonedMeshMap?: boolean;
  108791. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108792. virtual?: boolean;
  108793. }
  108794. /**
  108795. * Represents a scene to be rendered by the engine.
  108796. * @see http://doc.babylonjs.com/features/scene
  108797. */
  108798. export class Scene extends AbstractScene implements IAnimatable {
  108799. /** The fog is deactivated */
  108800. static readonly FOGMODE_NONE: number;
  108801. /** The fog density is following an exponential function */
  108802. static readonly FOGMODE_EXP: number;
  108803. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108804. static readonly FOGMODE_EXP2: number;
  108805. /** The fog density is following a linear function. */
  108806. static readonly FOGMODE_LINEAR: number;
  108807. /**
  108808. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108809. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108810. */
  108811. static MinDeltaTime: number;
  108812. /**
  108813. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108815. */
  108816. static MaxDeltaTime: number;
  108817. /**
  108818. * Factory used to create the default material.
  108819. * @param name The name of the material to create
  108820. * @param scene The scene to create the material for
  108821. * @returns The default material
  108822. */
  108823. static DefaultMaterialFactory(scene: Scene): Material;
  108824. /**
  108825. * Factory used to create the a collision coordinator.
  108826. * @returns The collision coordinator
  108827. */
  108828. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108829. /** @hidden */
  108830. _inputManager: InputManager;
  108831. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108832. cameraToUseForPointers: Nullable<Camera>;
  108833. /** @hidden */
  108834. readonly _isScene: boolean;
  108835. /** @hidden */
  108836. _blockEntityCollection: boolean;
  108837. /**
  108838. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108839. */
  108840. autoClear: boolean;
  108841. /**
  108842. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108843. */
  108844. autoClearDepthAndStencil: boolean;
  108845. /**
  108846. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108847. */
  108848. clearColor: Color4;
  108849. /**
  108850. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108851. */
  108852. ambientColor: Color3;
  108853. /**
  108854. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108855. * It should only be one of the following (if not the default embedded one):
  108856. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108857. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108858. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108859. * The material properties need to be setup according to the type of texture in use.
  108860. */
  108861. environmentBRDFTexture: BaseTexture;
  108862. /** @hidden */
  108863. protected _environmentTexture: Nullable<BaseTexture>;
  108864. /**
  108865. * Texture used in all pbr material as the reflection texture.
  108866. * As in the majority of the scene they are the same (exception for multi room and so on),
  108867. * this is easier to reference from here than from all the materials.
  108868. */
  108869. get environmentTexture(): Nullable<BaseTexture>;
  108870. /**
  108871. * Texture used in all pbr material as the reflection texture.
  108872. * As in the majority of the scene they are the same (exception for multi room and so on),
  108873. * this is easier to set here than in all the materials.
  108874. */
  108875. set environmentTexture(value: Nullable<BaseTexture>);
  108876. /** @hidden */
  108877. protected _environmentIntensity: number;
  108878. /**
  108879. * Intensity of the environment in all pbr material.
  108880. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108881. * As in the majority of the scene they are the same (exception for multi room and so on),
  108882. * this is easier to reference from here than from all the materials.
  108883. */
  108884. get environmentIntensity(): number;
  108885. /**
  108886. * Intensity of the environment in all pbr material.
  108887. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108888. * As in the majority of the scene they are the same (exception for multi room and so on),
  108889. * this is easier to set here than in all the materials.
  108890. */
  108891. set environmentIntensity(value: number);
  108892. /** @hidden */
  108893. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108894. /**
  108895. * Default image processing configuration used either in the rendering
  108896. * Forward main pass or through the imageProcessingPostProcess if present.
  108897. * As in the majority of the scene they are the same (exception for multi camera),
  108898. * this is easier to reference from here than from all the materials and post process.
  108899. *
  108900. * No setter as we it is a shared configuration, you can set the values instead.
  108901. */
  108902. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108903. private _forceWireframe;
  108904. /**
  108905. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108906. */
  108907. set forceWireframe(value: boolean);
  108908. get forceWireframe(): boolean;
  108909. private _skipFrustumClipping;
  108910. /**
  108911. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108912. */
  108913. set skipFrustumClipping(value: boolean);
  108914. get skipFrustumClipping(): boolean;
  108915. private _forcePointsCloud;
  108916. /**
  108917. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108918. */
  108919. set forcePointsCloud(value: boolean);
  108920. get forcePointsCloud(): boolean;
  108921. /**
  108922. * Gets or sets the active clipplane 1
  108923. */
  108924. clipPlane: Nullable<Plane>;
  108925. /**
  108926. * Gets or sets the active clipplane 2
  108927. */
  108928. clipPlane2: Nullable<Plane>;
  108929. /**
  108930. * Gets or sets the active clipplane 3
  108931. */
  108932. clipPlane3: Nullable<Plane>;
  108933. /**
  108934. * Gets or sets the active clipplane 4
  108935. */
  108936. clipPlane4: Nullable<Plane>;
  108937. /**
  108938. * Gets or sets the active clipplane 5
  108939. */
  108940. clipPlane5: Nullable<Plane>;
  108941. /**
  108942. * Gets or sets the active clipplane 6
  108943. */
  108944. clipPlane6: Nullable<Plane>;
  108945. /**
  108946. * Gets or sets a boolean indicating if animations are enabled
  108947. */
  108948. animationsEnabled: boolean;
  108949. private _animationPropertiesOverride;
  108950. /**
  108951. * Gets or sets the animation properties override
  108952. */
  108953. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108954. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108955. /**
  108956. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108957. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108958. */
  108959. useConstantAnimationDeltaTime: boolean;
  108960. /**
  108961. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108962. * Please note that it requires to run a ray cast through the scene on every frame
  108963. */
  108964. constantlyUpdateMeshUnderPointer: boolean;
  108965. /**
  108966. * Defines the HTML cursor to use when hovering over interactive elements
  108967. */
  108968. hoverCursor: string;
  108969. /**
  108970. * Defines the HTML default cursor to use (empty by default)
  108971. */
  108972. defaultCursor: string;
  108973. /**
  108974. * Defines whether cursors are handled by the scene.
  108975. */
  108976. doNotHandleCursors: boolean;
  108977. /**
  108978. * This is used to call preventDefault() on pointer down
  108979. * in order to block unwanted artifacts like system double clicks
  108980. */
  108981. preventDefaultOnPointerDown: boolean;
  108982. /**
  108983. * This is used to call preventDefault() on pointer up
  108984. * in order to block unwanted artifacts like system double clicks
  108985. */
  108986. preventDefaultOnPointerUp: boolean;
  108987. /**
  108988. * Gets or sets user defined metadata
  108989. */
  108990. metadata: any;
  108991. /**
  108992. * For internal use only. Please do not use.
  108993. */
  108994. reservedDataStore: any;
  108995. /**
  108996. * Gets the name of the plugin used to load this scene (null by default)
  108997. */
  108998. loadingPluginName: string;
  108999. /**
  109000. * Use this array to add regular expressions used to disable offline support for specific urls
  109001. */
  109002. disableOfflineSupportExceptionRules: RegExp[];
  109003. /**
  109004. * An event triggered when the scene is disposed.
  109005. */
  109006. onDisposeObservable: Observable<Scene>;
  109007. private _onDisposeObserver;
  109008. /** Sets a function to be executed when this scene is disposed. */
  109009. set onDispose(callback: () => void);
  109010. /**
  109011. * An event triggered before rendering the scene (right after animations and physics)
  109012. */
  109013. onBeforeRenderObservable: Observable<Scene>;
  109014. private _onBeforeRenderObserver;
  109015. /** Sets a function to be executed before rendering this scene */
  109016. set beforeRender(callback: Nullable<() => void>);
  109017. /**
  109018. * An event triggered after rendering the scene
  109019. */
  109020. onAfterRenderObservable: Observable<Scene>;
  109021. /**
  109022. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109023. */
  109024. onAfterRenderCameraObservable: Observable<Camera>;
  109025. private _onAfterRenderObserver;
  109026. /** Sets a function to be executed after rendering this scene */
  109027. set afterRender(callback: Nullable<() => void>);
  109028. /**
  109029. * An event triggered before animating the scene
  109030. */
  109031. onBeforeAnimationsObservable: Observable<Scene>;
  109032. /**
  109033. * An event triggered after animations processing
  109034. */
  109035. onAfterAnimationsObservable: Observable<Scene>;
  109036. /**
  109037. * An event triggered before draw calls are ready to be sent
  109038. */
  109039. onBeforeDrawPhaseObservable: Observable<Scene>;
  109040. /**
  109041. * An event triggered after draw calls have been sent
  109042. */
  109043. onAfterDrawPhaseObservable: Observable<Scene>;
  109044. /**
  109045. * An event triggered when the scene is ready
  109046. */
  109047. onReadyObservable: Observable<Scene>;
  109048. /**
  109049. * An event triggered before rendering a camera
  109050. */
  109051. onBeforeCameraRenderObservable: Observable<Camera>;
  109052. private _onBeforeCameraRenderObserver;
  109053. /** Sets a function to be executed before rendering a camera*/
  109054. set beforeCameraRender(callback: () => void);
  109055. /**
  109056. * An event triggered after rendering a camera
  109057. */
  109058. onAfterCameraRenderObservable: Observable<Camera>;
  109059. private _onAfterCameraRenderObserver;
  109060. /** Sets a function to be executed after rendering a camera*/
  109061. set afterCameraRender(callback: () => void);
  109062. /**
  109063. * An event triggered when active meshes evaluation is about to start
  109064. */
  109065. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109066. /**
  109067. * An event triggered when active meshes evaluation is done
  109068. */
  109069. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109070. /**
  109071. * An event triggered when particles rendering is about to start
  109072. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109073. */
  109074. onBeforeParticlesRenderingObservable: Observable<Scene>;
  109075. /**
  109076. * An event triggered when particles rendering is done
  109077. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109078. */
  109079. onAfterParticlesRenderingObservable: Observable<Scene>;
  109080. /**
  109081. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  109082. */
  109083. onDataLoadedObservable: Observable<Scene>;
  109084. /**
  109085. * An event triggered when a camera is created
  109086. */
  109087. onNewCameraAddedObservable: Observable<Camera>;
  109088. /**
  109089. * An event triggered when a camera is removed
  109090. */
  109091. onCameraRemovedObservable: Observable<Camera>;
  109092. /**
  109093. * An event triggered when a light is created
  109094. */
  109095. onNewLightAddedObservable: Observable<Light>;
  109096. /**
  109097. * An event triggered when a light is removed
  109098. */
  109099. onLightRemovedObservable: Observable<Light>;
  109100. /**
  109101. * An event triggered when a geometry is created
  109102. */
  109103. onNewGeometryAddedObservable: Observable<Geometry>;
  109104. /**
  109105. * An event triggered when a geometry is removed
  109106. */
  109107. onGeometryRemovedObservable: Observable<Geometry>;
  109108. /**
  109109. * An event triggered when a transform node is created
  109110. */
  109111. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  109112. /**
  109113. * An event triggered when a transform node is removed
  109114. */
  109115. onTransformNodeRemovedObservable: Observable<TransformNode>;
  109116. /**
  109117. * An event triggered when a mesh is created
  109118. */
  109119. onNewMeshAddedObservable: Observable<AbstractMesh>;
  109120. /**
  109121. * An event triggered when a mesh is removed
  109122. */
  109123. onMeshRemovedObservable: Observable<AbstractMesh>;
  109124. /**
  109125. * An event triggered when a skeleton is created
  109126. */
  109127. onNewSkeletonAddedObservable: Observable<Skeleton>;
  109128. /**
  109129. * An event triggered when a skeleton is removed
  109130. */
  109131. onSkeletonRemovedObservable: Observable<Skeleton>;
  109132. /**
  109133. * An event triggered when a material is created
  109134. */
  109135. onNewMaterialAddedObservable: Observable<Material>;
  109136. /**
  109137. * An event triggered when a material is removed
  109138. */
  109139. onMaterialRemovedObservable: Observable<Material>;
  109140. /**
  109141. * An event triggered when a texture is created
  109142. */
  109143. onNewTextureAddedObservable: Observable<BaseTexture>;
  109144. /**
  109145. * An event triggered when a texture is removed
  109146. */
  109147. onTextureRemovedObservable: Observable<BaseTexture>;
  109148. /**
  109149. * An event triggered when render targets are about to be rendered
  109150. * Can happen multiple times per frame.
  109151. */
  109152. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  109153. /**
  109154. * An event triggered when render targets were rendered.
  109155. * Can happen multiple times per frame.
  109156. */
  109157. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  109158. /**
  109159. * An event triggered before calculating deterministic simulation step
  109160. */
  109161. onBeforeStepObservable: Observable<Scene>;
  109162. /**
  109163. * An event triggered after calculating deterministic simulation step
  109164. */
  109165. onAfterStepObservable: Observable<Scene>;
  109166. /**
  109167. * An event triggered when the activeCamera property is updated
  109168. */
  109169. onActiveCameraChanged: Observable<Scene>;
  109170. /**
  109171. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  109172. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109173. * 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)
  109174. */
  109175. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109176. /**
  109177. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  109178. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109179. * 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)
  109180. */
  109181. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109182. /**
  109183. * This Observable will when a mesh has been imported into the scene.
  109184. */
  109185. onMeshImportedObservable: Observable<AbstractMesh>;
  109186. /**
  109187. * This Observable will when an animation file has been imported into the scene.
  109188. */
  109189. onAnimationFileImportedObservable: Observable<Scene>;
  109190. /**
  109191. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  109192. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  109193. */
  109194. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  109195. /** @hidden */
  109196. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  109197. /**
  109198. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  109199. */
  109200. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  109201. /**
  109202. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  109203. */
  109204. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  109205. /**
  109206. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  109207. */
  109208. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  109209. /** Callback called when a pointer move is detected */
  109210. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109211. /** Callback called when a pointer down is detected */
  109212. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109213. /** Callback called when a pointer up is detected */
  109214. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  109215. /** Callback called when a pointer pick is detected */
  109216. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  109217. /**
  109218. * 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).
  109219. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  109220. */
  109221. onPrePointerObservable: Observable<PointerInfoPre>;
  109222. /**
  109223. * Observable event triggered each time an input event is received from the rendering canvas
  109224. */
  109225. onPointerObservable: Observable<PointerInfo>;
  109226. /**
  109227. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  109228. */
  109229. get unTranslatedPointer(): Vector2;
  109230. /**
  109231. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  109232. */
  109233. static get DragMovementThreshold(): number;
  109234. static set DragMovementThreshold(value: number);
  109235. /**
  109236. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  109237. */
  109238. static get LongPressDelay(): number;
  109239. static set LongPressDelay(value: number);
  109240. /**
  109241. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  109242. */
  109243. static get DoubleClickDelay(): number;
  109244. static set DoubleClickDelay(value: number);
  109245. /** If you need to check double click without raising a single click at first click, enable this flag */
  109246. static get ExclusiveDoubleClickMode(): boolean;
  109247. static set ExclusiveDoubleClickMode(value: boolean);
  109248. /** @hidden */
  109249. _mirroredCameraPosition: Nullable<Vector3>;
  109250. /**
  109251. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  109252. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  109253. */
  109254. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  109255. /**
  109256. * Observable event triggered each time an keyboard event is received from the hosting window
  109257. */
  109258. onKeyboardObservable: Observable<KeyboardInfo>;
  109259. private _useRightHandedSystem;
  109260. /**
  109261. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  109262. */
  109263. set useRightHandedSystem(value: boolean);
  109264. get useRightHandedSystem(): boolean;
  109265. private _timeAccumulator;
  109266. private _currentStepId;
  109267. private _currentInternalStep;
  109268. /**
  109269. * Sets the step Id used by deterministic lock step
  109270. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109271. * @param newStepId defines the step Id
  109272. */
  109273. setStepId(newStepId: number): void;
  109274. /**
  109275. * Gets the step Id used by deterministic lock step
  109276. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109277. * @returns the step Id
  109278. */
  109279. getStepId(): number;
  109280. /**
  109281. * Gets the internal step used by deterministic lock step
  109282. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109283. * @returns the internal step
  109284. */
  109285. getInternalStep(): number;
  109286. private _fogEnabled;
  109287. /**
  109288. * Gets or sets a boolean indicating if fog is enabled on this scene
  109289. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109290. * (Default is true)
  109291. */
  109292. set fogEnabled(value: boolean);
  109293. get fogEnabled(): boolean;
  109294. private _fogMode;
  109295. /**
  109296. * Gets or sets the fog mode to use
  109297. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109298. * | mode | value |
  109299. * | --- | --- |
  109300. * | FOGMODE_NONE | 0 |
  109301. * | FOGMODE_EXP | 1 |
  109302. * | FOGMODE_EXP2 | 2 |
  109303. * | FOGMODE_LINEAR | 3 |
  109304. */
  109305. set fogMode(value: number);
  109306. get fogMode(): number;
  109307. /**
  109308. * Gets or sets the fog color to use
  109309. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109310. * (Default is Color3(0.2, 0.2, 0.3))
  109311. */
  109312. fogColor: Color3;
  109313. /**
  109314. * Gets or sets the fog density to use
  109315. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109316. * (Default is 0.1)
  109317. */
  109318. fogDensity: number;
  109319. /**
  109320. * Gets or sets the fog start distance to use
  109321. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109322. * (Default is 0)
  109323. */
  109324. fogStart: number;
  109325. /**
  109326. * Gets or sets the fog end distance to use
  109327. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109328. * (Default is 1000)
  109329. */
  109330. fogEnd: number;
  109331. private _shadowsEnabled;
  109332. /**
  109333. * Gets or sets a boolean indicating if shadows are enabled on this scene
  109334. */
  109335. set shadowsEnabled(value: boolean);
  109336. get shadowsEnabled(): boolean;
  109337. private _lightsEnabled;
  109338. /**
  109339. * Gets or sets a boolean indicating if lights are enabled on this scene
  109340. */
  109341. set lightsEnabled(value: boolean);
  109342. get lightsEnabled(): boolean;
  109343. /** All of the active cameras added to this scene. */
  109344. activeCameras: Camera[];
  109345. /** @hidden */
  109346. _activeCamera: Nullable<Camera>;
  109347. /** Gets or sets the current active camera */
  109348. get activeCamera(): Nullable<Camera>;
  109349. set activeCamera(value: Nullable<Camera>);
  109350. private _defaultMaterial;
  109351. /** The default material used on meshes when no material is affected */
  109352. get defaultMaterial(): Material;
  109353. /** The default material used on meshes when no material is affected */
  109354. set defaultMaterial(value: Material);
  109355. private _texturesEnabled;
  109356. /**
  109357. * Gets or sets a boolean indicating if textures are enabled on this scene
  109358. */
  109359. set texturesEnabled(value: boolean);
  109360. get texturesEnabled(): boolean;
  109361. /**
  109362. * Gets or sets a boolean indicating if particles are enabled on this scene
  109363. */
  109364. particlesEnabled: boolean;
  109365. /**
  109366. * Gets or sets a boolean indicating if sprites are enabled on this scene
  109367. */
  109368. spritesEnabled: boolean;
  109369. private _skeletonsEnabled;
  109370. /**
  109371. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  109372. */
  109373. set skeletonsEnabled(value: boolean);
  109374. get skeletonsEnabled(): boolean;
  109375. /**
  109376. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  109377. */
  109378. lensFlaresEnabled: boolean;
  109379. /**
  109380. * Gets or sets a boolean indicating if collisions are enabled on this scene
  109381. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109382. */
  109383. collisionsEnabled: boolean;
  109384. private _collisionCoordinator;
  109385. /** @hidden */
  109386. get collisionCoordinator(): ICollisionCoordinator;
  109387. /**
  109388. * Defines the gravity applied to this scene (used only for collisions)
  109389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109390. */
  109391. gravity: Vector3;
  109392. /**
  109393. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109394. */
  109395. postProcessesEnabled: boolean;
  109396. /**
  109397. * The list of postprocesses added to the scene
  109398. */
  109399. postProcesses: PostProcess[];
  109400. /**
  109401. * Gets the current postprocess manager
  109402. */
  109403. postProcessManager: PostProcessManager;
  109404. /**
  109405. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109406. */
  109407. renderTargetsEnabled: boolean;
  109408. /**
  109409. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109410. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109411. */
  109412. dumpNextRenderTargets: boolean;
  109413. /**
  109414. * The list of user defined render targets added to the scene
  109415. */
  109416. customRenderTargets: RenderTargetTexture[];
  109417. /**
  109418. * Defines if texture loading must be delayed
  109419. * If true, textures will only be loaded when they need to be rendered
  109420. */
  109421. useDelayedTextureLoading: boolean;
  109422. /**
  109423. * Gets the list of meshes imported to the scene through SceneLoader
  109424. */
  109425. importedMeshesFiles: String[];
  109426. /**
  109427. * Gets or sets a boolean indicating if probes are enabled on this scene
  109428. */
  109429. probesEnabled: boolean;
  109430. /**
  109431. * Gets or sets the current offline provider to use to store scene data
  109432. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109433. */
  109434. offlineProvider: IOfflineProvider;
  109435. /**
  109436. * Gets or sets the action manager associated with the scene
  109437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109438. */
  109439. actionManager: AbstractActionManager;
  109440. private _meshesForIntersections;
  109441. /**
  109442. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109443. */
  109444. proceduralTexturesEnabled: boolean;
  109445. private _engine;
  109446. private _totalVertices;
  109447. /** @hidden */
  109448. _activeIndices: PerfCounter;
  109449. /** @hidden */
  109450. _activeParticles: PerfCounter;
  109451. /** @hidden */
  109452. _activeBones: PerfCounter;
  109453. private _animationRatio;
  109454. /** @hidden */
  109455. _animationTimeLast: number;
  109456. /** @hidden */
  109457. _animationTime: number;
  109458. /**
  109459. * Gets or sets a general scale for animation speed
  109460. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109461. */
  109462. animationTimeScale: number;
  109463. /** @hidden */
  109464. _cachedMaterial: Nullable<Material>;
  109465. /** @hidden */
  109466. _cachedEffect: Nullable<Effect>;
  109467. /** @hidden */
  109468. _cachedVisibility: Nullable<number>;
  109469. private _renderId;
  109470. private _frameId;
  109471. private _executeWhenReadyTimeoutId;
  109472. private _intermediateRendering;
  109473. private _viewUpdateFlag;
  109474. private _projectionUpdateFlag;
  109475. /** @hidden */
  109476. _toBeDisposed: Nullable<IDisposable>[];
  109477. private _activeRequests;
  109478. /** @hidden */
  109479. _pendingData: any[];
  109480. private _isDisposed;
  109481. /**
  109482. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109483. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109484. */
  109485. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109486. private _activeMeshes;
  109487. private _processedMaterials;
  109488. private _renderTargets;
  109489. /** @hidden */
  109490. _activeParticleSystems: SmartArray<IParticleSystem>;
  109491. private _activeSkeletons;
  109492. private _softwareSkinnedMeshes;
  109493. private _renderingManager;
  109494. /** @hidden */
  109495. _activeAnimatables: Animatable[];
  109496. private _transformMatrix;
  109497. private _sceneUbo;
  109498. /** @hidden */
  109499. _viewMatrix: Matrix;
  109500. private _projectionMatrix;
  109501. /** @hidden */
  109502. _forcedViewPosition: Nullable<Vector3>;
  109503. /** @hidden */
  109504. _frustumPlanes: Plane[];
  109505. /**
  109506. * Gets the list of frustum planes (built from the active camera)
  109507. */
  109508. get frustumPlanes(): Plane[];
  109509. /**
  109510. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109511. * This is useful if there are more lights that the maximum simulteanous authorized
  109512. */
  109513. requireLightSorting: boolean;
  109514. /** @hidden */
  109515. readonly useMaterialMeshMap: boolean;
  109516. /** @hidden */
  109517. readonly useClonedMeshMap: boolean;
  109518. private _externalData;
  109519. private _uid;
  109520. /**
  109521. * @hidden
  109522. * Backing store of defined scene components.
  109523. */
  109524. _components: ISceneComponent[];
  109525. /**
  109526. * @hidden
  109527. * Backing store of defined scene components.
  109528. */
  109529. _serializableComponents: ISceneSerializableComponent[];
  109530. /**
  109531. * List of components to register on the next registration step.
  109532. */
  109533. private _transientComponents;
  109534. /**
  109535. * Registers the transient components if needed.
  109536. */
  109537. private _registerTransientComponents;
  109538. /**
  109539. * @hidden
  109540. * Add a component to the scene.
  109541. * Note that the ccomponent could be registered on th next frame if this is called after
  109542. * the register component stage.
  109543. * @param component Defines the component to add to the scene
  109544. */
  109545. _addComponent(component: ISceneComponent): void;
  109546. /**
  109547. * @hidden
  109548. * Gets a component from the scene.
  109549. * @param name defines the name of the component to retrieve
  109550. * @returns the component or null if not present
  109551. */
  109552. _getComponent(name: string): Nullable<ISceneComponent>;
  109553. /**
  109554. * @hidden
  109555. * Defines the actions happening before camera updates.
  109556. */
  109557. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109558. /**
  109559. * @hidden
  109560. * Defines the actions happening before clear the canvas.
  109561. */
  109562. _beforeClearStage: Stage<SimpleStageAction>;
  109563. /**
  109564. * @hidden
  109565. * Defines the actions when collecting render targets for the frame.
  109566. */
  109567. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109568. /**
  109569. * @hidden
  109570. * Defines the actions happening for one camera in the frame.
  109571. */
  109572. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109573. /**
  109574. * @hidden
  109575. * Defines the actions happening during the per mesh ready checks.
  109576. */
  109577. _isReadyForMeshStage: Stage<MeshStageAction>;
  109578. /**
  109579. * @hidden
  109580. * Defines the actions happening before evaluate active mesh checks.
  109581. */
  109582. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109583. /**
  109584. * @hidden
  109585. * Defines the actions happening during the evaluate sub mesh checks.
  109586. */
  109587. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109588. /**
  109589. * @hidden
  109590. * Defines the actions happening during the active mesh stage.
  109591. */
  109592. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109593. /**
  109594. * @hidden
  109595. * Defines the actions happening during the per camera render target step.
  109596. */
  109597. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109598. /**
  109599. * @hidden
  109600. * Defines the actions happening just before the active camera is drawing.
  109601. */
  109602. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109603. /**
  109604. * @hidden
  109605. * Defines the actions happening just before a render target is drawing.
  109606. */
  109607. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109608. /**
  109609. * @hidden
  109610. * Defines the actions happening just before a rendering group is drawing.
  109611. */
  109612. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109613. /**
  109614. * @hidden
  109615. * Defines the actions happening just before a mesh is drawing.
  109616. */
  109617. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109618. /**
  109619. * @hidden
  109620. * Defines the actions happening just after a mesh has been drawn.
  109621. */
  109622. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109623. /**
  109624. * @hidden
  109625. * Defines the actions happening just after a rendering group has been drawn.
  109626. */
  109627. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109628. /**
  109629. * @hidden
  109630. * Defines the actions happening just after the active camera has been drawn.
  109631. */
  109632. _afterCameraDrawStage: Stage<CameraStageAction>;
  109633. /**
  109634. * @hidden
  109635. * Defines the actions happening just after a render target has been drawn.
  109636. */
  109637. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109638. /**
  109639. * @hidden
  109640. * Defines the actions happening just after rendering all cameras and computing intersections.
  109641. */
  109642. _afterRenderStage: Stage<SimpleStageAction>;
  109643. /**
  109644. * @hidden
  109645. * Defines the actions happening when a pointer move event happens.
  109646. */
  109647. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109648. /**
  109649. * @hidden
  109650. * Defines the actions happening when a pointer down event happens.
  109651. */
  109652. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109653. /**
  109654. * @hidden
  109655. * Defines the actions happening when a pointer up event happens.
  109656. */
  109657. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109658. /**
  109659. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109660. */
  109661. private geometriesByUniqueId;
  109662. /**
  109663. * Creates a new Scene
  109664. * @param engine defines the engine to use to render this scene
  109665. * @param options defines the scene options
  109666. */
  109667. constructor(engine: Engine, options?: SceneOptions);
  109668. /**
  109669. * Gets a string idenfifying the name of the class
  109670. * @returns "Scene" string
  109671. */
  109672. getClassName(): string;
  109673. private _defaultMeshCandidates;
  109674. /**
  109675. * @hidden
  109676. */
  109677. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109678. private _defaultSubMeshCandidates;
  109679. /**
  109680. * @hidden
  109681. */
  109682. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109683. /**
  109684. * Sets the default candidate providers for the scene.
  109685. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109686. * and getCollidingSubMeshCandidates to their default function
  109687. */
  109688. setDefaultCandidateProviders(): void;
  109689. /**
  109690. * Gets the mesh that is currently under the pointer
  109691. */
  109692. get meshUnderPointer(): Nullable<AbstractMesh>;
  109693. /**
  109694. * Gets or sets the current on-screen X position of the pointer
  109695. */
  109696. get pointerX(): number;
  109697. set pointerX(value: number);
  109698. /**
  109699. * Gets or sets the current on-screen Y position of the pointer
  109700. */
  109701. get pointerY(): number;
  109702. set pointerY(value: number);
  109703. /**
  109704. * Gets the cached material (ie. the latest rendered one)
  109705. * @returns the cached material
  109706. */
  109707. getCachedMaterial(): Nullable<Material>;
  109708. /**
  109709. * Gets the cached effect (ie. the latest rendered one)
  109710. * @returns the cached effect
  109711. */
  109712. getCachedEffect(): Nullable<Effect>;
  109713. /**
  109714. * Gets the cached visibility state (ie. the latest rendered one)
  109715. * @returns the cached visibility state
  109716. */
  109717. getCachedVisibility(): Nullable<number>;
  109718. /**
  109719. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109720. * @param material defines the current material
  109721. * @param effect defines the current effect
  109722. * @param visibility defines the current visibility state
  109723. * @returns true if one parameter is not cached
  109724. */
  109725. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109726. /**
  109727. * Gets the engine associated with the scene
  109728. * @returns an Engine
  109729. */
  109730. getEngine(): Engine;
  109731. /**
  109732. * Gets the total number of vertices rendered per frame
  109733. * @returns the total number of vertices rendered per frame
  109734. */
  109735. getTotalVertices(): number;
  109736. /**
  109737. * Gets the performance counter for total vertices
  109738. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109739. */
  109740. get totalVerticesPerfCounter(): PerfCounter;
  109741. /**
  109742. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109743. * @returns the total number of active indices rendered per frame
  109744. */
  109745. getActiveIndices(): number;
  109746. /**
  109747. * Gets the performance counter for active indices
  109748. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109749. */
  109750. get totalActiveIndicesPerfCounter(): PerfCounter;
  109751. /**
  109752. * Gets the total number of active particles rendered per frame
  109753. * @returns the total number of active particles rendered per frame
  109754. */
  109755. getActiveParticles(): number;
  109756. /**
  109757. * Gets the performance counter for active particles
  109758. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109759. */
  109760. get activeParticlesPerfCounter(): PerfCounter;
  109761. /**
  109762. * Gets the total number of active bones rendered per frame
  109763. * @returns the total number of active bones rendered per frame
  109764. */
  109765. getActiveBones(): number;
  109766. /**
  109767. * Gets the performance counter for active bones
  109768. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109769. */
  109770. get activeBonesPerfCounter(): PerfCounter;
  109771. /**
  109772. * Gets the array of active meshes
  109773. * @returns an array of AbstractMesh
  109774. */
  109775. getActiveMeshes(): SmartArray<AbstractMesh>;
  109776. /**
  109777. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109778. * @returns a number
  109779. */
  109780. getAnimationRatio(): number;
  109781. /**
  109782. * Gets an unique Id for the current render phase
  109783. * @returns a number
  109784. */
  109785. getRenderId(): number;
  109786. /**
  109787. * Gets an unique Id for the current frame
  109788. * @returns a number
  109789. */
  109790. getFrameId(): number;
  109791. /** Call this function if you want to manually increment the render Id*/
  109792. incrementRenderId(): void;
  109793. private _createUbo;
  109794. /**
  109795. * Use this method to simulate a pointer move on a mesh
  109796. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109797. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109798. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109799. * @returns the current scene
  109800. */
  109801. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109802. /**
  109803. * Use this method to simulate a pointer down on a mesh
  109804. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109805. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109806. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109807. * @returns the current scene
  109808. */
  109809. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109810. /**
  109811. * Use this method to simulate a pointer up on a mesh
  109812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109815. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109816. * @returns the current scene
  109817. */
  109818. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109819. /**
  109820. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109821. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109822. * @returns true if the pointer was captured
  109823. */
  109824. isPointerCaptured(pointerId?: number): boolean;
  109825. /**
  109826. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109827. * @param attachUp defines if you want to attach events to pointerup
  109828. * @param attachDown defines if you want to attach events to pointerdown
  109829. * @param attachMove defines if you want to attach events to pointermove
  109830. */
  109831. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109832. /** Detaches all event handlers*/
  109833. detachControl(): void;
  109834. /**
  109835. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109836. * Delay loaded resources are not taking in account
  109837. * @return true if all required resources are ready
  109838. */
  109839. isReady(): boolean;
  109840. /** Resets all cached information relative to material (including effect and visibility) */
  109841. resetCachedMaterial(): void;
  109842. /**
  109843. * Registers a function to be called before every frame render
  109844. * @param func defines the function to register
  109845. */
  109846. registerBeforeRender(func: () => void): void;
  109847. /**
  109848. * Unregisters a function called before every frame render
  109849. * @param func defines the function to unregister
  109850. */
  109851. unregisterBeforeRender(func: () => void): void;
  109852. /**
  109853. * Registers a function to be called after every frame render
  109854. * @param func defines the function to register
  109855. */
  109856. registerAfterRender(func: () => void): void;
  109857. /**
  109858. * Unregisters a function called after every frame render
  109859. * @param func defines the function to unregister
  109860. */
  109861. unregisterAfterRender(func: () => void): void;
  109862. private _executeOnceBeforeRender;
  109863. /**
  109864. * The provided function will run before render once and will be disposed afterwards.
  109865. * A timeout delay can be provided so that the function will be executed in N ms.
  109866. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109867. * @param func The function to be executed.
  109868. * @param timeout optional delay in ms
  109869. */
  109870. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109871. /** @hidden */
  109872. _addPendingData(data: any): void;
  109873. /** @hidden */
  109874. _removePendingData(data: any): void;
  109875. /**
  109876. * Returns the number of items waiting to be loaded
  109877. * @returns the number of items waiting to be loaded
  109878. */
  109879. getWaitingItemsCount(): number;
  109880. /**
  109881. * Returns a boolean indicating if the scene is still loading data
  109882. */
  109883. get isLoading(): boolean;
  109884. /**
  109885. * Registers a function to be executed when the scene is ready
  109886. * @param {Function} func - the function to be executed
  109887. */
  109888. executeWhenReady(func: () => void): void;
  109889. /**
  109890. * Returns a promise that resolves when the scene is ready
  109891. * @returns A promise that resolves when the scene is ready
  109892. */
  109893. whenReadyAsync(): Promise<void>;
  109894. /** @hidden */
  109895. _checkIsReady(): void;
  109896. /**
  109897. * Gets all animatable attached to the scene
  109898. */
  109899. get animatables(): Animatable[];
  109900. /**
  109901. * Resets the last animation time frame.
  109902. * Useful to override when animations start running when loading a scene for the first time.
  109903. */
  109904. resetLastAnimationTimeFrame(): void;
  109905. /**
  109906. * Gets the current view matrix
  109907. * @returns a Matrix
  109908. */
  109909. getViewMatrix(): Matrix;
  109910. /**
  109911. * Gets the current projection matrix
  109912. * @returns a Matrix
  109913. */
  109914. getProjectionMatrix(): Matrix;
  109915. /**
  109916. * Gets the current transform matrix
  109917. * @returns a Matrix made of View * Projection
  109918. */
  109919. getTransformMatrix(): Matrix;
  109920. /**
  109921. * Sets the current transform matrix
  109922. * @param viewL defines the View matrix to use
  109923. * @param projectionL defines the Projection matrix to use
  109924. * @param viewR defines the right View matrix to use (if provided)
  109925. * @param projectionR defines the right Projection matrix to use (if provided)
  109926. */
  109927. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109928. /**
  109929. * Gets the uniform buffer used to store scene data
  109930. * @returns a UniformBuffer
  109931. */
  109932. getSceneUniformBuffer(): UniformBuffer;
  109933. /**
  109934. * Gets an unique (relatively to the current scene) Id
  109935. * @returns an unique number for the scene
  109936. */
  109937. getUniqueId(): number;
  109938. /**
  109939. * Add a mesh to the list of scene's meshes
  109940. * @param newMesh defines the mesh to add
  109941. * @param recursive if all child meshes should also be added to the scene
  109942. */
  109943. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109944. /**
  109945. * Remove a mesh for the list of scene's meshes
  109946. * @param toRemove defines the mesh to remove
  109947. * @param recursive if all child meshes should also be removed from the scene
  109948. * @returns the index where the mesh was in the mesh list
  109949. */
  109950. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109951. /**
  109952. * Add a transform node to the list of scene's transform nodes
  109953. * @param newTransformNode defines the transform node to add
  109954. */
  109955. addTransformNode(newTransformNode: TransformNode): void;
  109956. /**
  109957. * Remove a transform node for the list of scene's transform nodes
  109958. * @param toRemove defines the transform node to remove
  109959. * @returns the index where the transform node was in the transform node list
  109960. */
  109961. removeTransformNode(toRemove: TransformNode): number;
  109962. /**
  109963. * Remove a skeleton for the list of scene's skeletons
  109964. * @param toRemove defines the skeleton to remove
  109965. * @returns the index where the skeleton was in the skeleton list
  109966. */
  109967. removeSkeleton(toRemove: Skeleton): number;
  109968. /**
  109969. * Remove a morph target for the list of scene's morph targets
  109970. * @param toRemove defines the morph target to remove
  109971. * @returns the index where the morph target was in the morph target list
  109972. */
  109973. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109974. /**
  109975. * Remove a light for the list of scene's lights
  109976. * @param toRemove defines the light to remove
  109977. * @returns the index where the light was in the light list
  109978. */
  109979. removeLight(toRemove: Light): number;
  109980. /**
  109981. * Remove a camera for the list of scene's cameras
  109982. * @param toRemove defines the camera to remove
  109983. * @returns the index where the camera was in the camera list
  109984. */
  109985. removeCamera(toRemove: Camera): number;
  109986. /**
  109987. * Remove a particle system for the list of scene's particle systems
  109988. * @param toRemove defines the particle system to remove
  109989. * @returns the index where the particle system was in the particle system list
  109990. */
  109991. removeParticleSystem(toRemove: IParticleSystem): number;
  109992. /**
  109993. * Remove a animation for the list of scene's animations
  109994. * @param toRemove defines the animation to remove
  109995. * @returns the index where the animation was in the animation list
  109996. */
  109997. removeAnimation(toRemove: Animation): number;
  109998. /**
  109999. * Will stop the animation of the given target
  110000. * @param target - the target
  110001. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110002. * @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)
  110003. */
  110004. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110005. /**
  110006. * Removes the given animation group from this scene.
  110007. * @param toRemove The animation group to remove
  110008. * @returns The index of the removed animation group
  110009. */
  110010. removeAnimationGroup(toRemove: AnimationGroup): number;
  110011. /**
  110012. * Removes the given multi-material from this scene.
  110013. * @param toRemove The multi-material to remove
  110014. * @returns The index of the removed multi-material
  110015. */
  110016. removeMultiMaterial(toRemove: MultiMaterial): number;
  110017. /**
  110018. * Removes the given material from this scene.
  110019. * @param toRemove The material to remove
  110020. * @returns The index of the removed material
  110021. */
  110022. removeMaterial(toRemove: Material): number;
  110023. /**
  110024. * Removes the given action manager from this scene.
  110025. * @param toRemove The action manager to remove
  110026. * @returns The index of the removed action manager
  110027. */
  110028. removeActionManager(toRemove: AbstractActionManager): number;
  110029. /**
  110030. * Removes the given texture from this scene.
  110031. * @param toRemove The texture to remove
  110032. * @returns The index of the removed texture
  110033. */
  110034. removeTexture(toRemove: BaseTexture): number;
  110035. /**
  110036. * Adds the given light to this scene
  110037. * @param newLight The light to add
  110038. */
  110039. addLight(newLight: Light): void;
  110040. /**
  110041. * Sorts the list list based on light priorities
  110042. */
  110043. sortLightsByPriority(): void;
  110044. /**
  110045. * Adds the given camera to this scene
  110046. * @param newCamera The camera to add
  110047. */
  110048. addCamera(newCamera: Camera): void;
  110049. /**
  110050. * Adds the given skeleton to this scene
  110051. * @param newSkeleton The skeleton to add
  110052. */
  110053. addSkeleton(newSkeleton: Skeleton): void;
  110054. /**
  110055. * Adds the given particle system to this scene
  110056. * @param newParticleSystem The particle system to add
  110057. */
  110058. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110059. /**
  110060. * Adds the given animation to this scene
  110061. * @param newAnimation The animation to add
  110062. */
  110063. addAnimation(newAnimation: Animation): void;
  110064. /**
  110065. * Adds the given animation group to this scene.
  110066. * @param newAnimationGroup The animation group to add
  110067. */
  110068. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110069. /**
  110070. * Adds the given multi-material to this scene
  110071. * @param newMultiMaterial The multi-material to add
  110072. */
  110073. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  110074. /**
  110075. * Adds the given material to this scene
  110076. * @param newMaterial The material to add
  110077. */
  110078. addMaterial(newMaterial: Material): void;
  110079. /**
  110080. * Adds the given morph target to this scene
  110081. * @param newMorphTargetManager The morph target to add
  110082. */
  110083. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  110084. /**
  110085. * Adds the given geometry to this scene
  110086. * @param newGeometry The geometry to add
  110087. */
  110088. addGeometry(newGeometry: Geometry): void;
  110089. /**
  110090. * Adds the given action manager to this scene
  110091. * @param newActionManager The action manager to add
  110092. */
  110093. addActionManager(newActionManager: AbstractActionManager): void;
  110094. /**
  110095. * Adds the given texture to this scene.
  110096. * @param newTexture The texture to add
  110097. */
  110098. addTexture(newTexture: BaseTexture): void;
  110099. /**
  110100. * Switch active camera
  110101. * @param newCamera defines the new active camera
  110102. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  110103. */
  110104. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  110105. /**
  110106. * sets the active camera of the scene using its ID
  110107. * @param id defines the camera's ID
  110108. * @return the new active camera or null if none found.
  110109. */
  110110. setActiveCameraByID(id: string): Nullable<Camera>;
  110111. /**
  110112. * sets the active camera of the scene using its name
  110113. * @param name defines the camera's name
  110114. * @returns the new active camera or null if none found.
  110115. */
  110116. setActiveCameraByName(name: string): Nullable<Camera>;
  110117. /**
  110118. * get an animation group using its name
  110119. * @param name defines the material's name
  110120. * @return the animation group or null if none found.
  110121. */
  110122. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  110123. /**
  110124. * Get a material using its unique id
  110125. * @param uniqueId defines the material's unique id
  110126. * @return the material or null if none found.
  110127. */
  110128. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  110129. /**
  110130. * get a material using its id
  110131. * @param id defines the material's ID
  110132. * @return the material or null if none found.
  110133. */
  110134. getMaterialByID(id: string): Nullable<Material>;
  110135. /**
  110136. * Gets a the last added material using a given id
  110137. * @param id defines the material's ID
  110138. * @return the last material with the given id or null if none found.
  110139. */
  110140. getLastMaterialByID(id: string): Nullable<Material>;
  110141. /**
  110142. * Gets a material using its name
  110143. * @param name defines the material's name
  110144. * @return the material or null if none found.
  110145. */
  110146. getMaterialByName(name: string): Nullable<Material>;
  110147. /**
  110148. * Get a texture using its unique id
  110149. * @param uniqueId defines the texture's unique id
  110150. * @return the texture or null if none found.
  110151. */
  110152. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  110153. /**
  110154. * Gets a camera using its id
  110155. * @param id defines the id to look for
  110156. * @returns the camera or null if not found
  110157. */
  110158. getCameraByID(id: string): Nullable<Camera>;
  110159. /**
  110160. * Gets a camera using its unique id
  110161. * @param uniqueId defines the unique id to look for
  110162. * @returns the camera or null if not found
  110163. */
  110164. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  110165. /**
  110166. * Gets a camera using its name
  110167. * @param name defines the camera's name
  110168. * @return the camera or null if none found.
  110169. */
  110170. getCameraByName(name: string): Nullable<Camera>;
  110171. /**
  110172. * Gets a bone using its id
  110173. * @param id defines the bone's id
  110174. * @return the bone or null if not found
  110175. */
  110176. getBoneByID(id: string): Nullable<Bone>;
  110177. /**
  110178. * Gets a bone using its id
  110179. * @param name defines the bone's name
  110180. * @return the bone or null if not found
  110181. */
  110182. getBoneByName(name: string): Nullable<Bone>;
  110183. /**
  110184. * Gets a light node using its name
  110185. * @param name defines the the light's name
  110186. * @return the light or null if none found.
  110187. */
  110188. getLightByName(name: string): Nullable<Light>;
  110189. /**
  110190. * Gets a light node using its id
  110191. * @param id defines the light's id
  110192. * @return the light or null if none found.
  110193. */
  110194. getLightByID(id: string): Nullable<Light>;
  110195. /**
  110196. * Gets a light node using its scene-generated unique ID
  110197. * @param uniqueId defines the light's unique id
  110198. * @return the light or null if none found.
  110199. */
  110200. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  110201. /**
  110202. * Gets a particle system by id
  110203. * @param id defines the particle system id
  110204. * @return the corresponding system or null if none found
  110205. */
  110206. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  110207. /**
  110208. * Gets a geometry using its ID
  110209. * @param id defines the geometry's id
  110210. * @return the geometry or null if none found.
  110211. */
  110212. getGeometryByID(id: string): Nullable<Geometry>;
  110213. private _getGeometryByUniqueID;
  110214. /**
  110215. * Add a new geometry to this scene
  110216. * @param geometry defines the geometry to be added to the scene.
  110217. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  110218. * @return a boolean defining if the geometry was added or not
  110219. */
  110220. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  110221. /**
  110222. * Removes an existing geometry
  110223. * @param geometry defines the geometry to be removed from the scene
  110224. * @return a boolean defining if the geometry was removed or not
  110225. */
  110226. removeGeometry(geometry: Geometry): boolean;
  110227. /**
  110228. * Gets the list of geometries attached to the scene
  110229. * @returns an array of Geometry
  110230. */
  110231. getGeometries(): Geometry[];
  110232. /**
  110233. * Gets the first added mesh found of a given ID
  110234. * @param id defines the id to search for
  110235. * @return the mesh found or null if not found at all
  110236. */
  110237. getMeshByID(id: string): Nullable<AbstractMesh>;
  110238. /**
  110239. * Gets a list of meshes using their id
  110240. * @param id defines the id to search for
  110241. * @returns a list of meshes
  110242. */
  110243. getMeshesByID(id: string): Array<AbstractMesh>;
  110244. /**
  110245. * Gets the first added transform node found of a given ID
  110246. * @param id defines the id to search for
  110247. * @return the found transform node or null if not found at all.
  110248. */
  110249. getTransformNodeByID(id: string): Nullable<TransformNode>;
  110250. /**
  110251. * Gets a transform node with its auto-generated unique id
  110252. * @param uniqueId efines the unique id to search for
  110253. * @return the found transform node or null if not found at all.
  110254. */
  110255. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  110256. /**
  110257. * Gets a list of transform nodes using their id
  110258. * @param id defines the id to search for
  110259. * @returns a list of transform nodes
  110260. */
  110261. getTransformNodesByID(id: string): Array<TransformNode>;
  110262. /**
  110263. * Gets a mesh with its auto-generated unique id
  110264. * @param uniqueId defines the unique id to search for
  110265. * @return the found mesh or null if not found at all.
  110266. */
  110267. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  110268. /**
  110269. * Gets a the last added mesh using a given id
  110270. * @param id defines the id to search for
  110271. * @return the found mesh or null if not found at all.
  110272. */
  110273. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  110274. /**
  110275. * Gets a the last added node (Mesh, Camera, Light) using a given id
  110276. * @param id defines the id to search for
  110277. * @return the found node or null if not found at all
  110278. */
  110279. getLastEntryByID(id: string): Nullable<Node>;
  110280. /**
  110281. * Gets a node (Mesh, Camera, Light) using a given id
  110282. * @param id defines the id to search for
  110283. * @return the found node or null if not found at all
  110284. */
  110285. getNodeByID(id: string): Nullable<Node>;
  110286. /**
  110287. * Gets a node (Mesh, Camera, Light) using a given name
  110288. * @param name defines the name to search for
  110289. * @return the found node or null if not found at all.
  110290. */
  110291. getNodeByName(name: string): Nullable<Node>;
  110292. /**
  110293. * Gets a mesh using a given name
  110294. * @param name defines the name to search for
  110295. * @return the found mesh or null if not found at all.
  110296. */
  110297. getMeshByName(name: string): Nullable<AbstractMesh>;
  110298. /**
  110299. * Gets a transform node using a given name
  110300. * @param name defines the name to search for
  110301. * @return the found transform node or null if not found at all.
  110302. */
  110303. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110304. /**
  110305. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110306. * @param id defines the id to search for
  110307. * @return the found skeleton or null if not found at all.
  110308. */
  110309. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  110310. /**
  110311. * Gets a skeleton using a given auto generated unique id
  110312. * @param uniqueId defines the unique id to search for
  110313. * @return the found skeleton or null if not found at all.
  110314. */
  110315. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  110316. /**
  110317. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  110318. * @param id defines the id to search for
  110319. * @return the found skeleton or null if not found at all.
  110320. */
  110321. getSkeletonById(id: string): Nullable<Skeleton>;
  110322. /**
  110323. * Gets a skeleton using a given name
  110324. * @param name defines the name to search for
  110325. * @return the found skeleton or null if not found at all.
  110326. */
  110327. getSkeletonByName(name: string): Nullable<Skeleton>;
  110328. /**
  110329. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  110330. * @param id defines the id to search for
  110331. * @return the found morph target manager or null if not found at all.
  110332. */
  110333. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  110334. /**
  110335. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  110336. * @param id defines the id to search for
  110337. * @return the found morph target or null if not found at all.
  110338. */
  110339. getMorphTargetById(id: string): Nullable<MorphTarget>;
  110340. /**
  110341. * Gets a boolean indicating if the given mesh is active
  110342. * @param mesh defines the mesh to look for
  110343. * @returns true if the mesh is in the active list
  110344. */
  110345. isActiveMesh(mesh: AbstractMesh): boolean;
  110346. /**
  110347. * Return a unique id as a string which can serve as an identifier for the scene
  110348. */
  110349. get uid(): string;
  110350. /**
  110351. * Add an externaly attached data from its key.
  110352. * This method call will fail and return false, if such key already exists.
  110353. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  110354. * @param key the unique key that identifies the data
  110355. * @param data the data object to associate to the key for this Engine instance
  110356. * @return true if no such key were already present and the data was added successfully, false otherwise
  110357. */
  110358. addExternalData<T>(key: string, data: T): boolean;
  110359. /**
  110360. * Get an externaly attached data from its key
  110361. * @param key the unique key that identifies the data
  110362. * @return the associated data, if present (can be null), or undefined if not present
  110363. */
  110364. getExternalData<T>(key: string): Nullable<T>;
  110365. /**
  110366. * Get an externaly attached data from its key, create it using a factory if it's not already present
  110367. * @param key the unique key that identifies the data
  110368. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  110369. * @return the associated data, can be null if the factory returned null.
  110370. */
  110371. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  110372. /**
  110373. * Remove an externaly attached data from the Engine instance
  110374. * @param key the unique key that identifies the data
  110375. * @return true if the data was successfully removed, false if it doesn't exist
  110376. */
  110377. removeExternalData(key: string): boolean;
  110378. private _evaluateSubMesh;
  110379. /**
  110380. * Clear the processed materials smart array preventing retention point in material dispose.
  110381. */
  110382. freeProcessedMaterials(): void;
  110383. private _preventFreeActiveMeshesAndRenderingGroups;
  110384. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  110385. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  110386. * when disposing several meshes in a row or a hierarchy of meshes.
  110387. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  110388. */
  110389. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  110390. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110391. /**
  110392. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110393. */
  110394. freeActiveMeshes(): void;
  110395. /**
  110396. * Clear the info related to rendering groups preventing retention points during dispose.
  110397. */
  110398. freeRenderingGroups(): void;
  110399. /** @hidden */
  110400. _isInIntermediateRendering(): boolean;
  110401. /**
  110402. * Lambda returning the list of potentially active meshes.
  110403. */
  110404. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110405. /**
  110406. * Lambda returning the list of potentially active sub meshes.
  110407. */
  110408. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110409. /**
  110410. * Lambda returning the list of potentially intersecting sub meshes.
  110411. */
  110412. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110413. /**
  110414. * Lambda returning the list of potentially colliding sub meshes.
  110415. */
  110416. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110417. private _activeMeshesFrozen;
  110418. private _skipEvaluateActiveMeshesCompletely;
  110419. /**
  110420. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110421. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110422. * @returns the current scene
  110423. */
  110424. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110425. /**
  110426. * Use this function to restart evaluating active meshes on every frame
  110427. * @returns the current scene
  110428. */
  110429. unfreezeActiveMeshes(): Scene;
  110430. private _evaluateActiveMeshes;
  110431. private _activeMesh;
  110432. /**
  110433. * Update the transform matrix to update from the current active camera
  110434. * @param force defines a boolean used to force the update even if cache is up to date
  110435. */
  110436. updateTransformMatrix(force?: boolean): void;
  110437. private _bindFrameBuffer;
  110438. /** @hidden */
  110439. _allowPostProcessClearColor: boolean;
  110440. /** @hidden */
  110441. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110442. private _processSubCameras;
  110443. private _checkIntersections;
  110444. /** @hidden */
  110445. _advancePhysicsEngineStep(step: number): void;
  110446. /**
  110447. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110448. */
  110449. getDeterministicFrameTime: () => number;
  110450. /** @hidden */
  110451. _animate(): void;
  110452. /** Execute all animations (for a frame) */
  110453. animate(): void;
  110454. /**
  110455. * Render the scene
  110456. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110457. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110458. */
  110459. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110460. /**
  110461. * Freeze all materials
  110462. * A frozen material will not be updatable but should be faster to render
  110463. */
  110464. freezeMaterials(): void;
  110465. /**
  110466. * Unfreeze all materials
  110467. * A frozen material will not be updatable but should be faster to render
  110468. */
  110469. unfreezeMaterials(): void;
  110470. /**
  110471. * Releases all held ressources
  110472. */
  110473. dispose(): void;
  110474. /**
  110475. * Gets if the scene is already disposed
  110476. */
  110477. get isDisposed(): boolean;
  110478. /**
  110479. * Call this function to reduce memory footprint of the scene.
  110480. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110481. */
  110482. clearCachedVertexData(): void;
  110483. /**
  110484. * This function will remove the local cached buffer data from texture.
  110485. * It will save memory but will prevent the texture from being rebuilt
  110486. */
  110487. cleanCachedTextureBuffer(): void;
  110488. /**
  110489. * Get the world extend vectors with an optional filter
  110490. *
  110491. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110492. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110493. */
  110494. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110495. min: Vector3;
  110496. max: Vector3;
  110497. };
  110498. /**
  110499. * Creates a ray that can be used to pick in the scene
  110500. * @param x defines the x coordinate of the origin (on-screen)
  110501. * @param y defines the y coordinate of the origin (on-screen)
  110502. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110503. * @param camera defines the camera to use for the picking
  110504. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110505. * @returns a Ray
  110506. */
  110507. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110508. /**
  110509. * Creates a ray that can be used to pick in the scene
  110510. * @param x defines the x coordinate of the origin (on-screen)
  110511. * @param y defines the y coordinate of the origin (on-screen)
  110512. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110513. * @param result defines the ray where to store the picking ray
  110514. * @param camera defines the camera to use for the picking
  110515. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110516. * @returns the current scene
  110517. */
  110518. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110519. /**
  110520. * Creates a ray that can be used to pick in the scene
  110521. * @param x defines the x coordinate of the origin (on-screen)
  110522. * @param y defines the y coordinate of the origin (on-screen)
  110523. * @param camera defines the camera to use for the picking
  110524. * @returns a Ray
  110525. */
  110526. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110527. /**
  110528. * Creates a ray that can be used to pick in the scene
  110529. * @param x defines the x coordinate of the origin (on-screen)
  110530. * @param y defines the y coordinate of the origin (on-screen)
  110531. * @param result defines the ray where to store the picking ray
  110532. * @param camera defines the camera to use for the picking
  110533. * @returns the current scene
  110534. */
  110535. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110536. /** Launch a ray to try to pick a mesh in the scene
  110537. * @param x position on screen
  110538. * @param y position on screen
  110539. * @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
  110540. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110541. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110542. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110543. * @returns a PickingInfo
  110544. */
  110545. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110546. /** Use the given ray to pick a mesh in the scene
  110547. * @param ray The ray to use to pick meshes
  110548. * @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
  110549. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110550. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110551. * @returns a PickingInfo
  110552. */
  110553. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110554. /**
  110555. * Launch a ray to try to pick a mesh in the scene
  110556. * @param x X position on screen
  110557. * @param y Y position on screen
  110558. * @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
  110559. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110560. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110561. * @returns an array of PickingInfo
  110562. */
  110563. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110564. /**
  110565. * Launch a ray to try to pick a mesh in the scene
  110566. * @param ray Ray to use
  110567. * @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
  110568. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110569. * @returns an array of PickingInfo
  110570. */
  110571. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110572. /**
  110573. * Force the value of meshUnderPointer
  110574. * @param mesh defines the mesh to use
  110575. */
  110576. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110577. /**
  110578. * Gets the mesh under the pointer
  110579. * @returns a Mesh or null if no mesh is under the pointer
  110580. */
  110581. getPointerOverMesh(): Nullable<AbstractMesh>;
  110582. /** @hidden */
  110583. _rebuildGeometries(): void;
  110584. /** @hidden */
  110585. _rebuildTextures(): void;
  110586. private _getByTags;
  110587. /**
  110588. * Get a list of meshes by tags
  110589. * @param tagsQuery defines the tags query to use
  110590. * @param forEach defines a predicate used to filter results
  110591. * @returns an array of Mesh
  110592. */
  110593. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110594. /**
  110595. * Get a list of cameras by tags
  110596. * @param tagsQuery defines the tags query to use
  110597. * @param forEach defines a predicate used to filter results
  110598. * @returns an array of Camera
  110599. */
  110600. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110601. /**
  110602. * Get a list of lights by tags
  110603. * @param tagsQuery defines the tags query to use
  110604. * @param forEach defines a predicate used to filter results
  110605. * @returns an array of Light
  110606. */
  110607. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110608. /**
  110609. * Get a list of materials by tags
  110610. * @param tagsQuery defines the tags query to use
  110611. * @param forEach defines a predicate used to filter results
  110612. * @returns an array of Material
  110613. */
  110614. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110615. /**
  110616. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110617. * This allowed control for front to back rendering or reversly depending of the special needs.
  110618. *
  110619. * @param renderingGroupId The rendering group id corresponding to its index
  110620. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110621. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110622. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110623. */
  110624. 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;
  110625. /**
  110626. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110627. *
  110628. * @param renderingGroupId The rendering group id corresponding to its index
  110629. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110630. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110631. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110632. */
  110633. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110634. /**
  110635. * Gets the current auto clear configuration for one rendering group of the rendering
  110636. * manager.
  110637. * @param index the rendering group index to get the information for
  110638. * @returns The auto clear setup for the requested rendering group
  110639. */
  110640. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110641. private _blockMaterialDirtyMechanism;
  110642. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110643. get blockMaterialDirtyMechanism(): boolean;
  110644. set blockMaterialDirtyMechanism(value: boolean);
  110645. /**
  110646. * Will flag all materials as dirty to trigger new shader compilation
  110647. * @param flag defines the flag used to specify which material part must be marked as dirty
  110648. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110649. */
  110650. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110651. /** @hidden */
  110652. _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;
  110653. /** @hidden */
  110654. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110655. /** @hidden */
  110656. _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;
  110657. /** @hidden */
  110658. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110659. /** @hidden */
  110660. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110661. /** @hidden */
  110662. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110663. }
  110664. }
  110665. declare module BABYLON {
  110666. /**
  110667. * Set of assets to keep when moving a scene into an asset container.
  110668. */
  110669. export class KeepAssets extends AbstractScene {
  110670. }
  110671. /**
  110672. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110673. */
  110674. export class InstantiatedEntries {
  110675. /**
  110676. * List of new root nodes (eg. nodes with no parent)
  110677. */
  110678. rootNodes: TransformNode[];
  110679. /**
  110680. * List of new skeletons
  110681. */
  110682. skeletons: Skeleton[];
  110683. /**
  110684. * List of new animation groups
  110685. */
  110686. animationGroups: AnimationGroup[];
  110687. }
  110688. /**
  110689. * Container with a set of assets that can be added or removed from a scene.
  110690. */
  110691. export class AssetContainer extends AbstractScene {
  110692. private _wasAddedToScene;
  110693. /**
  110694. * The scene the AssetContainer belongs to.
  110695. */
  110696. scene: Scene;
  110697. /**
  110698. * Instantiates an AssetContainer.
  110699. * @param scene The scene the AssetContainer belongs to.
  110700. */
  110701. constructor(scene: Scene);
  110702. /**
  110703. * Instantiate or clone all meshes and add the new ones to the scene.
  110704. * Skeletons and animation groups will all be cloned
  110705. * @param nameFunction defines an optional function used to get new names for clones
  110706. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110707. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110708. */
  110709. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110710. /**
  110711. * Adds all the assets from the container to the scene.
  110712. */
  110713. addAllToScene(): void;
  110714. /**
  110715. * Removes all the assets in the container from the scene
  110716. */
  110717. removeAllFromScene(): void;
  110718. /**
  110719. * Disposes all the assets in the container
  110720. */
  110721. dispose(): void;
  110722. private _moveAssets;
  110723. /**
  110724. * Removes all the assets contained in the scene and adds them to the container.
  110725. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110726. */
  110727. moveAllFromScene(keepAssets?: KeepAssets): void;
  110728. /**
  110729. * 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.
  110730. * @returns the root mesh
  110731. */
  110732. createRootMesh(): Mesh;
  110733. /**
  110734. * Merge animations from this asset container into a scene
  110735. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110736. * @param animatables set of animatables to retarget to a node from the scene
  110737. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110738. */
  110739. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110740. }
  110741. }
  110742. declare module BABYLON {
  110743. /**
  110744. * Defines how the parser contract is defined.
  110745. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110746. */
  110747. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110748. /**
  110749. * Defines how the individual parser contract is defined.
  110750. * These parser can parse an individual asset
  110751. */
  110752. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110753. /**
  110754. * Base class of the scene acting as a container for the different elements composing a scene.
  110755. * This class is dynamically extended by the different components of the scene increasing
  110756. * flexibility and reducing coupling
  110757. */
  110758. export abstract class AbstractScene {
  110759. /**
  110760. * Stores the list of available parsers in the application.
  110761. */
  110762. private static _BabylonFileParsers;
  110763. /**
  110764. * Stores the list of available individual parsers in the application.
  110765. */
  110766. private static _IndividualBabylonFileParsers;
  110767. /**
  110768. * Adds a parser in the list of available ones
  110769. * @param name Defines the name of the parser
  110770. * @param parser Defines the parser to add
  110771. */
  110772. static AddParser(name: string, parser: BabylonFileParser): void;
  110773. /**
  110774. * Gets a general parser from the list of avaialble ones
  110775. * @param name Defines the name of the parser
  110776. * @returns the requested parser or null
  110777. */
  110778. static GetParser(name: string): Nullable<BabylonFileParser>;
  110779. /**
  110780. * Adds n individual parser in the list of available ones
  110781. * @param name Defines the name of the parser
  110782. * @param parser Defines the parser to add
  110783. */
  110784. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110785. /**
  110786. * Gets an individual parser from the list of avaialble ones
  110787. * @param name Defines the name of the parser
  110788. * @returns the requested parser or null
  110789. */
  110790. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110791. /**
  110792. * Parser json data and populate both a scene and its associated container object
  110793. * @param jsonData Defines the data to parse
  110794. * @param scene Defines the scene to parse the data for
  110795. * @param container Defines the container attached to the parsing sequence
  110796. * @param rootUrl Defines the root url of the data
  110797. */
  110798. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110799. /**
  110800. * Gets the list of root nodes (ie. nodes with no parent)
  110801. */
  110802. rootNodes: Node[];
  110803. /** All of the cameras added to this scene
  110804. * @see http://doc.babylonjs.com/babylon101/cameras
  110805. */
  110806. cameras: Camera[];
  110807. /**
  110808. * All of the lights added to this scene
  110809. * @see http://doc.babylonjs.com/babylon101/lights
  110810. */
  110811. lights: Light[];
  110812. /**
  110813. * All of the (abstract) meshes added to this scene
  110814. */
  110815. meshes: AbstractMesh[];
  110816. /**
  110817. * The list of skeletons added to the scene
  110818. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110819. */
  110820. skeletons: Skeleton[];
  110821. /**
  110822. * All of the particle systems added to this scene
  110823. * @see http://doc.babylonjs.com/babylon101/particles
  110824. */
  110825. particleSystems: IParticleSystem[];
  110826. /**
  110827. * Gets a list of Animations associated with the scene
  110828. */
  110829. animations: Animation[];
  110830. /**
  110831. * All of the animation groups added to this scene
  110832. * @see http://doc.babylonjs.com/how_to/group
  110833. */
  110834. animationGroups: AnimationGroup[];
  110835. /**
  110836. * All of the multi-materials added to this scene
  110837. * @see http://doc.babylonjs.com/how_to/multi_materials
  110838. */
  110839. multiMaterials: MultiMaterial[];
  110840. /**
  110841. * All of the materials added to this scene
  110842. * In the context of a Scene, it is not supposed to be modified manually.
  110843. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110844. * Note also that the order of the Material within the array is not significant and might change.
  110845. * @see http://doc.babylonjs.com/babylon101/materials
  110846. */
  110847. materials: Material[];
  110848. /**
  110849. * The list of morph target managers added to the scene
  110850. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110851. */
  110852. morphTargetManagers: MorphTargetManager[];
  110853. /**
  110854. * The list of geometries used in the scene.
  110855. */
  110856. geometries: Geometry[];
  110857. /**
  110858. * All of the tranform nodes added to this scene
  110859. * In the context of a Scene, it is not supposed to be modified manually.
  110860. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110861. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110862. * @see http://doc.babylonjs.com/how_to/transformnode
  110863. */
  110864. transformNodes: TransformNode[];
  110865. /**
  110866. * ActionManagers available on the scene.
  110867. */
  110868. actionManagers: AbstractActionManager[];
  110869. /**
  110870. * Textures to keep.
  110871. */
  110872. textures: BaseTexture[];
  110873. /**
  110874. * Environment texture for the scene
  110875. */
  110876. environmentTexture: Nullable<BaseTexture>;
  110877. /**
  110878. * @returns all meshes, lights, cameras, transformNodes and bones
  110879. */
  110880. getNodes(): Array<Node>;
  110881. }
  110882. }
  110883. declare module BABYLON {
  110884. /**
  110885. * Interface used to define options for Sound class
  110886. */
  110887. export interface ISoundOptions {
  110888. /**
  110889. * Does the sound autoplay once loaded.
  110890. */
  110891. autoplay?: boolean;
  110892. /**
  110893. * Does the sound loop after it finishes playing once.
  110894. */
  110895. loop?: boolean;
  110896. /**
  110897. * Sound's volume
  110898. */
  110899. volume?: number;
  110900. /**
  110901. * Is it a spatial sound?
  110902. */
  110903. spatialSound?: boolean;
  110904. /**
  110905. * Maximum distance to hear that sound
  110906. */
  110907. maxDistance?: number;
  110908. /**
  110909. * Uses user defined attenuation function
  110910. */
  110911. useCustomAttenuation?: boolean;
  110912. /**
  110913. * Define the roll off factor of spatial sounds.
  110914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110915. */
  110916. rolloffFactor?: number;
  110917. /**
  110918. * Define the reference distance the sound should be heard perfectly.
  110919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110920. */
  110921. refDistance?: number;
  110922. /**
  110923. * Define the distance attenuation model the sound will follow.
  110924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110925. */
  110926. distanceModel?: string;
  110927. /**
  110928. * Defines the playback speed (1 by default)
  110929. */
  110930. playbackRate?: number;
  110931. /**
  110932. * Defines if the sound is from a streaming source
  110933. */
  110934. streaming?: boolean;
  110935. /**
  110936. * Defines an optional length (in seconds) inside the sound file
  110937. */
  110938. length?: number;
  110939. /**
  110940. * Defines an optional offset (in seconds) inside the sound file
  110941. */
  110942. offset?: number;
  110943. /**
  110944. * If true, URLs will not be required to state the audio file codec to use.
  110945. */
  110946. skipCodecCheck?: boolean;
  110947. }
  110948. /**
  110949. * Defines a sound that can be played in the application.
  110950. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110952. */
  110953. export class Sound {
  110954. /**
  110955. * The name of the sound in the scene.
  110956. */
  110957. name: string;
  110958. /**
  110959. * Does the sound autoplay once loaded.
  110960. */
  110961. autoplay: boolean;
  110962. /**
  110963. * Does the sound loop after it finishes playing once.
  110964. */
  110965. loop: boolean;
  110966. /**
  110967. * Does the sound use a custom attenuation curve to simulate the falloff
  110968. * happening when the source gets further away from the camera.
  110969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110970. */
  110971. useCustomAttenuation: boolean;
  110972. /**
  110973. * The sound track id this sound belongs to.
  110974. */
  110975. soundTrackId: number;
  110976. /**
  110977. * Is this sound currently played.
  110978. */
  110979. isPlaying: boolean;
  110980. /**
  110981. * Is this sound currently paused.
  110982. */
  110983. isPaused: boolean;
  110984. /**
  110985. * Does this sound enables spatial sound.
  110986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110987. */
  110988. spatialSound: boolean;
  110989. /**
  110990. * Define the reference distance the sound should be heard perfectly.
  110991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110992. */
  110993. refDistance: number;
  110994. /**
  110995. * Define the roll off factor of spatial sounds.
  110996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110997. */
  110998. rolloffFactor: number;
  110999. /**
  111000. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111002. */
  111003. maxDistance: number;
  111004. /**
  111005. * Define the distance attenuation model the sound will follow.
  111006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111007. */
  111008. distanceModel: string;
  111009. /**
  111010. * @hidden
  111011. * Back Compat
  111012. **/
  111013. onended: () => any;
  111014. /**
  111015. * Observable event when the current playing sound finishes.
  111016. */
  111017. onEndedObservable: Observable<Sound>;
  111018. private _panningModel;
  111019. private _playbackRate;
  111020. private _streaming;
  111021. private _startTime;
  111022. private _startOffset;
  111023. private _position;
  111024. /** @hidden */
  111025. _positionInEmitterSpace: boolean;
  111026. private _localDirection;
  111027. private _volume;
  111028. private _isReadyToPlay;
  111029. private _isDirectional;
  111030. private _readyToPlayCallback;
  111031. private _audioBuffer;
  111032. private _soundSource;
  111033. private _streamingSource;
  111034. private _soundPanner;
  111035. private _soundGain;
  111036. private _inputAudioNode;
  111037. private _outputAudioNode;
  111038. private _coneInnerAngle;
  111039. private _coneOuterAngle;
  111040. private _coneOuterGain;
  111041. private _scene;
  111042. private _connectedTransformNode;
  111043. private _customAttenuationFunction;
  111044. private _registerFunc;
  111045. private _isOutputConnected;
  111046. private _htmlAudioElement;
  111047. private _urlType;
  111048. private _length?;
  111049. private _offset?;
  111050. /** @hidden */
  111051. static _SceneComponentInitialization: (scene: Scene) => void;
  111052. /**
  111053. * Create a sound and attach it to a scene
  111054. * @param name Name of your sound
  111055. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111056. * @param scene defines the scene the sound belongs to
  111057. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111058. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111059. */
  111060. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111061. /**
  111062. * Release the sound and its associated resources
  111063. */
  111064. dispose(): void;
  111065. /**
  111066. * Gets if the sounds is ready to be played or not.
  111067. * @returns true if ready, otherwise false
  111068. */
  111069. isReady(): boolean;
  111070. private _soundLoaded;
  111071. /**
  111072. * Sets the data of the sound from an audiobuffer
  111073. * @param audioBuffer The audioBuffer containing the data
  111074. */
  111075. setAudioBuffer(audioBuffer: AudioBuffer): void;
  111076. /**
  111077. * Updates the current sounds options such as maxdistance, loop...
  111078. * @param options A JSON object containing values named as the object properties
  111079. */
  111080. updateOptions(options: ISoundOptions): void;
  111081. private _createSpatialParameters;
  111082. private _updateSpatialParameters;
  111083. /**
  111084. * Switch the panning model to HRTF:
  111085. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111087. */
  111088. switchPanningModelToHRTF(): void;
  111089. /**
  111090. * Switch the panning model to Equal Power:
  111091. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111093. */
  111094. switchPanningModelToEqualPower(): void;
  111095. private _switchPanningModel;
  111096. /**
  111097. * Connect this sound to a sound track audio node like gain...
  111098. * @param soundTrackAudioNode the sound track audio node to connect to
  111099. */
  111100. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  111101. /**
  111102. * Transform this sound into a directional source
  111103. * @param coneInnerAngle Size of the inner cone in degree
  111104. * @param coneOuterAngle Size of the outer cone in degree
  111105. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  111106. */
  111107. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  111108. /**
  111109. * Gets or sets the inner angle for the directional cone.
  111110. */
  111111. get directionalConeInnerAngle(): number;
  111112. /**
  111113. * Gets or sets the inner angle for the directional cone.
  111114. */
  111115. set directionalConeInnerAngle(value: number);
  111116. /**
  111117. * Gets or sets the outer angle for the directional cone.
  111118. */
  111119. get directionalConeOuterAngle(): number;
  111120. /**
  111121. * Gets or sets the outer angle for the directional cone.
  111122. */
  111123. set directionalConeOuterAngle(value: number);
  111124. /**
  111125. * Sets the position of the emitter if spatial sound is enabled
  111126. * @param newPosition Defines the new posisiton
  111127. */
  111128. setPosition(newPosition: Vector3): void;
  111129. /**
  111130. * Sets the local direction of the emitter if spatial sound is enabled
  111131. * @param newLocalDirection Defines the new local direction
  111132. */
  111133. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  111134. private _updateDirection;
  111135. /** @hidden */
  111136. updateDistanceFromListener(): void;
  111137. /**
  111138. * Sets a new custom attenuation function for the sound.
  111139. * @param callback Defines the function used for the attenuation
  111140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111141. */
  111142. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  111143. /**
  111144. * Play the sound
  111145. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  111146. * @param offset (optional) Start the sound at a specific time in seconds
  111147. * @param length (optional) Sound duration (in seconds)
  111148. */
  111149. play(time?: number, offset?: number, length?: number): void;
  111150. private _onended;
  111151. /**
  111152. * Stop the sound
  111153. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  111154. */
  111155. stop(time?: number): void;
  111156. /**
  111157. * Put the sound in pause
  111158. */
  111159. pause(): void;
  111160. /**
  111161. * Sets a dedicated volume for this sounds
  111162. * @param newVolume Define the new volume of the sound
  111163. * @param time Define time for gradual change to new volume
  111164. */
  111165. setVolume(newVolume: number, time?: number): void;
  111166. /**
  111167. * Set the sound play back rate
  111168. * @param newPlaybackRate Define the playback rate the sound should be played at
  111169. */
  111170. setPlaybackRate(newPlaybackRate: number): void;
  111171. /**
  111172. * Gets the volume of the sound.
  111173. * @returns the volume of the sound
  111174. */
  111175. getVolume(): number;
  111176. /**
  111177. * Attach the sound to a dedicated mesh
  111178. * @param transformNode The transform node to connect the sound with
  111179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111180. */
  111181. attachToMesh(transformNode: TransformNode): void;
  111182. /**
  111183. * Detach the sound from the previously attached mesh
  111184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111185. */
  111186. detachFromMesh(): void;
  111187. private _onRegisterAfterWorldMatrixUpdate;
  111188. /**
  111189. * Clone the current sound in the scene.
  111190. * @returns the new sound clone
  111191. */
  111192. clone(): Nullable<Sound>;
  111193. /**
  111194. * Gets the current underlying audio buffer containing the data
  111195. * @returns the audio buffer
  111196. */
  111197. getAudioBuffer(): Nullable<AudioBuffer>;
  111198. /**
  111199. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  111200. * @returns the source node
  111201. */
  111202. getSoundSource(): Nullable<AudioBufferSourceNode>;
  111203. /**
  111204. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  111205. * @returns the gain node
  111206. */
  111207. getSoundGain(): Nullable<GainNode>;
  111208. /**
  111209. * Serializes the Sound in a JSON representation
  111210. * @returns the JSON representation of the sound
  111211. */
  111212. serialize(): any;
  111213. /**
  111214. * Parse a JSON representation of a sound to innstantiate in a given scene
  111215. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  111216. * @param scene Define the scene the new parsed sound should be created in
  111217. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  111218. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  111219. * @returns the newly parsed sound
  111220. */
  111221. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  111222. }
  111223. }
  111224. declare module BABYLON {
  111225. /**
  111226. * This defines an action helpful to play a defined sound on a triggered action.
  111227. */
  111228. export class PlaySoundAction extends Action {
  111229. private _sound;
  111230. /**
  111231. * Instantiate the action
  111232. * @param triggerOptions defines the trigger options
  111233. * @param sound defines the sound to play
  111234. * @param condition defines the trigger related conditions
  111235. */
  111236. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111237. /** @hidden */
  111238. _prepare(): void;
  111239. /**
  111240. * Execute the action and play the sound.
  111241. */
  111242. execute(): void;
  111243. /**
  111244. * Serializes the actions and its related information.
  111245. * @param parent defines the object to serialize in
  111246. * @returns the serialized object
  111247. */
  111248. serialize(parent: any): any;
  111249. }
  111250. /**
  111251. * This defines an action helpful to stop a defined sound on a triggered action.
  111252. */
  111253. export class StopSoundAction extends Action {
  111254. private _sound;
  111255. /**
  111256. * Instantiate the action
  111257. * @param triggerOptions defines the trigger options
  111258. * @param sound defines the sound to stop
  111259. * @param condition defines the trigger related conditions
  111260. */
  111261. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111262. /** @hidden */
  111263. _prepare(): void;
  111264. /**
  111265. * Execute the action and stop the sound.
  111266. */
  111267. execute(): void;
  111268. /**
  111269. * Serializes the actions and its related information.
  111270. * @param parent defines the object to serialize in
  111271. * @returns the serialized object
  111272. */
  111273. serialize(parent: any): any;
  111274. }
  111275. }
  111276. declare module BABYLON {
  111277. /**
  111278. * This defines an action responsible to change the value of a property
  111279. * by interpolating between its current value and the newly set one once triggered.
  111280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  111281. */
  111282. export class InterpolateValueAction extends Action {
  111283. /**
  111284. * Defines the path of the property where the value should be interpolated
  111285. */
  111286. propertyPath: string;
  111287. /**
  111288. * Defines the target value at the end of the interpolation.
  111289. */
  111290. value: any;
  111291. /**
  111292. * Defines the time it will take for the property to interpolate to the value.
  111293. */
  111294. duration: number;
  111295. /**
  111296. * Defines if the other scene animations should be stopped when the action has been triggered
  111297. */
  111298. stopOtherAnimations?: boolean;
  111299. /**
  111300. * Defines a callback raised once the interpolation animation has been done.
  111301. */
  111302. onInterpolationDone?: () => void;
  111303. /**
  111304. * Observable triggered once the interpolation animation has been done.
  111305. */
  111306. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  111307. private _target;
  111308. private _effectiveTarget;
  111309. private _property;
  111310. /**
  111311. * Instantiate the action
  111312. * @param triggerOptions defines the trigger options
  111313. * @param target defines the object containing the value to interpolate
  111314. * @param propertyPath defines the path to the property in the target object
  111315. * @param value defines the target value at the end of the interpolation
  111316. * @param duration deines the time it will take for the property to interpolate to the value.
  111317. * @param condition defines the trigger related conditions
  111318. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  111319. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  111320. */
  111321. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  111322. /** @hidden */
  111323. _prepare(): void;
  111324. /**
  111325. * Execute the action starts the value interpolation.
  111326. */
  111327. execute(): void;
  111328. /**
  111329. * Serializes the actions and its related information.
  111330. * @param parent defines the object to serialize in
  111331. * @returns the serialized object
  111332. */
  111333. serialize(parent: any): any;
  111334. }
  111335. }
  111336. declare module BABYLON {
  111337. /**
  111338. * Options allowed during the creation of a sound track.
  111339. */
  111340. export interface ISoundTrackOptions {
  111341. /**
  111342. * The volume the sound track should take during creation
  111343. */
  111344. volume?: number;
  111345. /**
  111346. * Define if the sound track is the main sound track of the scene
  111347. */
  111348. mainTrack?: boolean;
  111349. }
  111350. /**
  111351. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  111352. * It will be also used in a future release to apply effects on a specific track.
  111353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111354. */
  111355. export class SoundTrack {
  111356. /**
  111357. * The unique identifier of the sound track in the scene.
  111358. */
  111359. id: number;
  111360. /**
  111361. * The list of sounds included in the sound track.
  111362. */
  111363. soundCollection: Array<Sound>;
  111364. private _outputAudioNode;
  111365. private _scene;
  111366. private _connectedAnalyser;
  111367. private _options;
  111368. private _isInitialized;
  111369. /**
  111370. * Creates a new sound track.
  111371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111372. * @param scene Define the scene the sound track belongs to
  111373. * @param options
  111374. */
  111375. constructor(scene: Scene, options?: ISoundTrackOptions);
  111376. private _initializeSoundTrackAudioGraph;
  111377. /**
  111378. * Release the sound track and its associated resources
  111379. */
  111380. dispose(): void;
  111381. /**
  111382. * Adds a sound to this sound track
  111383. * @param sound define the cound to add
  111384. * @ignoreNaming
  111385. */
  111386. AddSound(sound: Sound): void;
  111387. /**
  111388. * Removes a sound to this sound track
  111389. * @param sound define the cound to remove
  111390. * @ignoreNaming
  111391. */
  111392. RemoveSound(sound: Sound): void;
  111393. /**
  111394. * Set a global volume for the full sound track.
  111395. * @param newVolume Define the new volume of the sound track
  111396. */
  111397. setVolume(newVolume: number): void;
  111398. /**
  111399. * Switch the panning model to HRTF:
  111400. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111402. */
  111403. switchPanningModelToHRTF(): void;
  111404. /**
  111405. * Switch the panning model to Equal Power:
  111406. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111408. */
  111409. switchPanningModelToEqualPower(): void;
  111410. /**
  111411. * Connect the sound track to an audio analyser allowing some amazing
  111412. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111414. * @param analyser The analyser to connect to the engine
  111415. */
  111416. connectToAnalyser(analyser: Analyser): void;
  111417. }
  111418. }
  111419. declare module BABYLON {
  111420. interface AbstractScene {
  111421. /**
  111422. * The list of sounds used in the scene.
  111423. */
  111424. sounds: Nullable<Array<Sound>>;
  111425. }
  111426. interface Scene {
  111427. /**
  111428. * @hidden
  111429. * Backing field
  111430. */
  111431. _mainSoundTrack: SoundTrack;
  111432. /**
  111433. * The main sound track played by the scene.
  111434. * It cotains your primary collection of sounds.
  111435. */
  111436. mainSoundTrack: SoundTrack;
  111437. /**
  111438. * The list of sound tracks added to the scene
  111439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111440. */
  111441. soundTracks: Nullable<Array<SoundTrack>>;
  111442. /**
  111443. * Gets a sound using a given name
  111444. * @param name defines the name to search for
  111445. * @return the found sound or null if not found at all.
  111446. */
  111447. getSoundByName(name: string): Nullable<Sound>;
  111448. /**
  111449. * Gets or sets if audio support is enabled
  111450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111451. */
  111452. audioEnabled: boolean;
  111453. /**
  111454. * Gets or sets if audio will be output to headphones
  111455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111456. */
  111457. headphone: boolean;
  111458. /**
  111459. * Gets or sets custom audio listener position provider
  111460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111461. */
  111462. audioListenerPositionProvider: Nullable<() => Vector3>;
  111463. /**
  111464. * Gets or sets a refresh rate when using 3D audio positioning
  111465. */
  111466. audioPositioningRefreshRate: number;
  111467. }
  111468. /**
  111469. * Defines the sound scene component responsible to manage any sounds
  111470. * in a given scene.
  111471. */
  111472. export class AudioSceneComponent implements ISceneSerializableComponent {
  111473. /**
  111474. * The component name helpfull to identify the component in the list of scene components.
  111475. */
  111476. readonly name: string;
  111477. /**
  111478. * The scene the component belongs to.
  111479. */
  111480. scene: Scene;
  111481. private _audioEnabled;
  111482. /**
  111483. * Gets whether audio is enabled or not.
  111484. * Please use related enable/disable method to switch state.
  111485. */
  111486. get audioEnabled(): boolean;
  111487. private _headphone;
  111488. /**
  111489. * Gets whether audio is outputing to headphone or not.
  111490. * Please use the according Switch methods to change output.
  111491. */
  111492. get headphone(): boolean;
  111493. /**
  111494. * Gets or sets a refresh rate when using 3D audio positioning
  111495. */
  111496. audioPositioningRefreshRate: number;
  111497. private _audioListenerPositionProvider;
  111498. /**
  111499. * Gets the current audio listener position provider
  111500. */
  111501. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111502. /**
  111503. * Sets a custom listener position for all sounds in the scene
  111504. * By default, this is the position of the first active camera
  111505. */
  111506. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111507. /**
  111508. * Creates a new instance of the component for the given scene
  111509. * @param scene Defines the scene to register the component in
  111510. */
  111511. constructor(scene: Scene);
  111512. /**
  111513. * Registers the component in a given scene
  111514. */
  111515. register(): void;
  111516. /**
  111517. * Rebuilds the elements related to this component in case of
  111518. * context lost for instance.
  111519. */
  111520. rebuild(): void;
  111521. /**
  111522. * Serializes the component data to the specified json object
  111523. * @param serializationObject The object to serialize to
  111524. */
  111525. serialize(serializationObject: any): void;
  111526. /**
  111527. * Adds all the elements from the container to the scene
  111528. * @param container the container holding the elements
  111529. */
  111530. addFromContainer(container: AbstractScene): void;
  111531. /**
  111532. * Removes all the elements in the container from the scene
  111533. * @param container contains the elements to remove
  111534. * @param dispose if the removed element should be disposed (default: false)
  111535. */
  111536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111537. /**
  111538. * Disposes the component and the associated ressources.
  111539. */
  111540. dispose(): void;
  111541. /**
  111542. * Disables audio in the associated scene.
  111543. */
  111544. disableAudio(): void;
  111545. /**
  111546. * Enables audio in the associated scene.
  111547. */
  111548. enableAudio(): void;
  111549. /**
  111550. * Switch audio to headphone output.
  111551. */
  111552. switchAudioModeForHeadphones(): void;
  111553. /**
  111554. * Switch audio to normal speakers.
  111555. */
  111556. switchAudioModeForNormalSpeakers(): void;
  111557. private _cachedCameraDirection;
  111558. private _cachedCameraPosition;
  111559. private _lastCheck;
  111560. private _afterRender;
  111561. }
  111562. }
  111563. declare module BABYLON {
  111564. /**
  111565. * Wraps one or more Sound objects and selects one with random weight for playback.
  111566. */
  111567. export class WeightedSound {
  111568. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111569. loop: boolean;
  111570. private _coneInnerAngle;
  111571. private _coneOuterAngle;
  111572. private _volume;
  111573. /** A Sound is currently playing. */
  111574. isPlaying: boolean;
  111575. /** A Sound is currently paused. */
  111576. isPaused: boolean;
  111577. private _sounds;
  111578. private _weights;
  111579. private _currentIndex?;
  111580. /**
  111581. * Creates a new WeightedSound from the list of sounds given.
  111582. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111583. * @param sounds Array of Sounds that will be selected from.
  111584. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111585. */
  111586. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111587. /**
  111588. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111589. */
  111590. get directionalConeInnerAngle(): number;
  111591. /**
  111592. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111593. */
  111594. set directionalConeInnerAngle(value: number);
  111595. /**
  111596. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111597. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111598. */
  111599. get directionalConeOuterAngle(): number;
  111600. /**
  111601. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111602. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111603. */
  111604. set directionalConeOuterAngle(value: number);
  111605. /**
  111606. * Playback volume.
  111607. */
  111608. get volume(): number;
  111609. /**
  111610. * Playback volume.
  111611. */
  111612. set volume(value: number);
  111613. private _onended;
  111614. /**
  111615. * Suspend playback
  111616. */
  111617. pause(): void;
  111618. /**
  111619. * Stop playback
  111620. */
  111621. stop(): void;
  111622. /**
  111623. * Start playback.
  111624. * @param startOffset Position the clip head at a specific time in seconds.
  111625. */
  111626. play(startOffset?: number): void;
  111627. }
  111628. }
  111629. declare module BABYLON {
  111630. /**
  111631. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111632. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111633. */
  111634. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111635. /**
  111636. * Gets the name of the behavior.
  111637. */
  111638. get name(): string;
  111639. /**
  111640. * The easing function used by animations
  111641. */
  111642. static EasingFunction: BackEase;
  111643. /**
  111644. * The easing mode used by animations
  111645. */
  111646. static EasingMode: number;
  111647. /**
  111648. * The duration of the animation, in milliseconds
  111649. */
  111650. transitionDuration: number;
  111651. /**
  111652. * Length of the distance animated by the transition when lower radius is reached
  111653. */
  111654. lowerRadiusTransitionRange: number;
  111655. /**
  111656. * Length of the distance animated by the transition when upper radius is reached
  111657. */
  111658. upperRadiusTransitionRange: number;
  111659. private _autoTransitionRange;
  111660. /**
  111661. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111662. */
  111663. get autoTransitionRange(): boolean;
  111664. /**
  111665. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111666. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111667. */
  111668. set autoTransitionRange(value: boolean);
  111669. private _attachedCamera;
  111670. private _onAfterCheckInputsObserver;
  111671. private _onMeshTargetChangedObserver;
  111672. /**
  111673. * Initializes the behavior.
  111674. */
  111675. init(): void;
  111676. /**
  111677. * Attaches the behavior to its arc rotate camera.
  111678. * @param camera Defines the camera to attach the behavior to
  111679. */
  111680. attach(camera: ArcRotateCamera): void;
  111681. /**
  111682. * Detaches the behavior from its current arc rotate camera.
  111683. */
  111684. detach(): void;
  111685. private _radiusIsAnimating;
  111686. private _radiusBounceTransition;
  111687. private _animatables;
  111688. private _cachedWheelPrecision;
  111689. /**
  111690. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111691. * @param radiusLimit The limit to check against.
  111692. * @return Bool to indicate if at limit.
  111693. */
  111694. private _isRadiusAtLimit;
  111695. /**
  111696. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111697. * @param radiusDelta The delta by which to animate to. Can be negative.
  111698. */
  111699. private _applyBoundRadiusAnimation;
  111700. /**
  111701. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111702. */
  111703. protected _clearAnimationLocks(): void;
  111704. /**
  111705. * Stops and removes all animations that have been applied to the camera
  111706. */
  111707. stopAllAnimations(): void;
  111708. }
  111709. }
  111710. declare module BABYLON {
  111711. /**
  111712. * 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.
  111713. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111714. */
  111715. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111716. /**
  111717. * Gets the name of the behavior.
  111718. */
  111719. get name(): string;
  111720. private _mode;
  111721. private _radiusScale;
  111722. private _positionScale;
  111723. private _defaultElevation;
  111724. private _elevationReturnTime;
  111725. private _elevationReturnWaitTime;
  111726. private _zoomStopsAnimation;
  111727. private _framingTime;
  111728. /**
  111729. * The easing function used by animations
  111730. */
  111731. static EasingFunction: ExponentialEase;
  111732. /**
  111733. * The easing mode used by animations
  111734. */
  111735. static EasingMode: number;
  111736. /**
  111737. * Sets the current mode used by the behavior
  111738. */
  111739. set mode(mode: number);
  111740. /**
  111741. * Gets current mode used by the behavior.
  111742. */
  111743. get mode(): number;
  111744. /**
  111745. * Sets the scale applied to the radius (1 by default)
  111746. */
  111747. set radiusScale(radius: number);
  111748. /**
  111749. * Gets the scale applied to the radius
  111750. */
  111751. get radiusScale(): number;
  111752. /**
  111753. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111754. */
  111755. set positionScale(scale: number);
  111756. /**
  111757. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111758. */
  111759. get positionScale(): number;
  111760. /**
  111761. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111762. * behaviour is triggered, in radians.
  111763. */
  111764. set defaultElevation(elevation: number);
  111765. /**
  111766. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111767. * behaviour is triggered, in radians.
  111768. */
  111769. get defaultElevation(): number;
  111770. /**
  111771. * Sets the time (in milliseconds) taken to return to the default beta position.
  111772. * Negative value indicates camera should not return to default.
  111773. */
  111774. set elevationReturnTime(speed: number);
  111775. /**
  111776. * Gets the time (in milliseconds) taken to return to the default beta position.
  111777. * Negative value indicates camera should not return to default.
  111778. */
  111779. get elevationReturnTime(): number;
  111780. /**
  111781. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111782. */
  111783. set elevationReturnWaitTime(time: number);
  111784. /**
  111785. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111786. */
  111787. get elevationReturnWaitTime(): number;
  111788. /**
  111789. * Sets the flag that indicates if user zooming should stop animation.
  111790. */
  111791. set zoomStopsAnimation(flag: boolean);
  111792. /**
  111793. * Gets the flag that indicates if user zooming should stop animation.
  111794. */
  111795. get zoomStopsAnimation(): boolean;
  111796. /**
  111797. * Sets the transition time when framing the mesh, in milliseconds
  111798. */
  111799. set framingTime(time: number);
  111800. /**
  111801. * Gets the transition time when framing the mesh, in milliseconds
  111802. */
  111803. get framingTime(): number;
  111804. /**
  111805. * Define if the behavior should automatically change the configured
  111806. * camera limits and sensibilities.
  111807. */
  111808. autoCorrectCameraLimitsAndSensibility: boolean;
  111809. private _onPrePointerObservableObserver;
  111810. private _onAfterCheckInputsObserver;
  111811. private _onMeshTargetChangedObserver;
  111812. private _attachedCamera;
  111813. private _isPointerDown;
  111814. private _lastInteractionTime;
  111815. /**
  111816. * Initializes the behavior.
  111817. */
  111818. init(): void;
  111819. /**
  111820. * Attaches the behavior to its arc rotate camera.
  111821. * @param camera Defines the camera to attach the behavior to
  111822. */
  111823. attach(camera: ArcRotateCamera): void;
  111824. /**
  111825. * Detaches the behavior from its current arc rotate camera.
  111826. */
  111827. detach(): void;
  111828. private _animatables;
  111829. private _betaIsAnimating;
  111830. private _betaTransition;
  111831. private _radiusTransition;
  111832. private _vectorTransition;
  111833. /**
  111834. * Targets the given mesh and updates zoom level accordingly.
  111835. * @param mesh The mesh to target.
  111836. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111837. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111838. */
  111839. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111840. /**
  111841. * Targets the given mesh with its children and updates zoom level accordingly.
  111842. * @param mesh The mesh to target.
  111843. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111844. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111845. */
  111846. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111847. /**
  111848. * Targets the given meshes with their children and updates zoom level accordingly.
  111849. * @param meshes The mesh to target.
  111850. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111851. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111852. */
  111853. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111854. /**
  111855. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111856. * @param minimumWorld Determines the smaller position of the bounding box extend
  111857. * @param maximumWorld Determines the bigger position of the bounding box extend
  111858. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111859. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111860. */
  111861. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111862. /**
  111863. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111864. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111865. * frustum width.
  111866. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111867. * to fully enclose the mesh in the viewing frustum.
  111868. */
  111869. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111870. /**
  111871. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111872. * is automatically returned to its default position (expected to be above ground plane).
  111873. */
  111874. private _maintainCameraAboveGround;
  111875. /**
  111876. * Returns the frustum slope based on the canvas ratio and camera FOV
  111877. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111878. */
  111879. private _getFrustumSlope;
  111880. /**
  111881. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111882. */
  111883. private _clearAnimationLocks;
  111884. /**
  111885. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111886. */
  111887. private _applyUserInteraction;
  111888. /**
  111889. * Stops and removes all animations that have been applied to the camera
  111890. */
  111891. stopAllAnimations(): void;
  111892. /**
  111893. * Gets a value indicating if the user is moving the camera
  111894. */
  111895. get isUserIsMoving(): boolean;
  111896. /**
  111897. * The camera can move all the way towards the mesh.
  111898. */
  111899. static IgnoreBoundsSizeMode: number;
  111900. /**
  111901. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111902. */
  111903. static FitFrustumSidesMode: number;
  111904. }
  111905. }
  111906. declare module BABYLON {
  111907. /**
  111908. * Base class for Camera Pointer Inputs.
  111909. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111910. * for example usage.
  111911. */
  111912. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111913. /**
  111914. * Defines the camera the input is attached to.
  111915. */
  111916. abstract camera: Camera;
  111917. /**
  111918. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111919. */
  111920. protected _altKey: boolean;
  111921. protected _ctrlKey: boolean;
  111922. protected _metaKey: boolean;
  111923. protected _shiftKey: boolean;
  111924. /**
  111925. * Which mouse buttons were pressed at time of last mouse event.
  111926. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111927. */
  111928. protected _buttonsPressed: number;
  111929. /**
  111930. * Defines the buttons associated with the input to handle camera move.
  111931. */
  111932. buttons: number[];
  111933. /**
  111934. * Attach the input controls to a specific dom element to get the input from.
  111935. * @param element Defines the element the controls should be listened from
  111936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111937. */
  111938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111939. /**
  111940. * Detach the current controls from the specified dom element.
  111941. * @param element Defines the element to stop listening the inputs from
  111942. */
  111943. detachControl(element: Nullable<HTMLElement>): void;
  111944. /**
  111945. * Gets the class name of the current input.
  111946. * @returns the class name
  111947. */
  111948. getClassName(): string;
  111949. /**
  111950. * Get the friendly name associated with the input class.
  111951. * @returns the input friendly name
  111952. */
  111953. getSimpleName(): string;
  111954. /**
  111955. * Called on pointer POINTERDOUBLETAP event.
  111956. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111957. */
  111958. protected onDoubleTap(type: string): void;
  111959. /**
  111960. * Called on pointer POINTERMOVE event if only a single touch is active.
  111961. * Override this method to provide functionality.
  111962. */
  111963. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111964. /**
  111965. * Called on pointer POINTERMOVE event if multiple touches are active.
  111966. * Override this method to provide functionality.
  111967. */
  111968. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111969. /**
  111970. * Called on JS contextmenu event.
  111971. * Override this method to provide functionality.
  111972. */
  111973. protected onContextMenu(evt: PointerEvent): void;
  111974. /**
  111975. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111976. * press.
  111977. * Override this method to provide functionality.
  111978. */
  111979. protected onButtonDown(evt: PointerEvent): void;
  111980. /**
  111981. * Called each time a new POINTERUP event occurs. Ie, for each button
  111982. * release.
  111983. * Override this method to provide functionality.
  111984. */
  111985. protected onButtonUp(evt: PointerEvent): void;
  111986. /**
  111987. * Called when window becomes inactive.
  111988. * Override this method to provide functionality.
  111989. */
  111990. protected onLostFocus(): void;
  111991. private _pointerInput;
  111992. private _observer;
  111993. private _onLostFocus;
  111994. private pointA;
  111995. private pointB;
  111996. }
  111997. }
  111998. declare module BABYLON {
  111999. /**
  112000. * Manage the pointers inputs to control an arc rotate camera.
  112001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112002. */
  112003. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112004. /**
  112005. * Defines the camera the input is attached to.
  112006. */
  112007. camera: ArcRotateCamera;
  112008. /**
  112009. * Gets the class name of the current input.
  112010. * @returns the class name
  112011. */
  112012. getClassName(): string;
  112013. /**
  112014. * Defines the buttons associated with the input to handle camera move.
  112015. */
  112016. buttons: number[];
  112017. /**
  112018. * Defines the pointer angular sensibility along the X axis or how fast is
  112019. * the camera rotating.
  112020. */
  112021. angularSensibilityX: number;
  112022. /**
  112023. * Defines the pointer angular sensibility along the Y axis or how fast is
  112024. * the camera rotating.
  112025. */
  112026. angularSensibilityY: number;
  112027. /**
  112028. * Defines the pointer pinch precision or how fast is the camera zooming.
  112029. */
  112030. pinchPrecision: number;
  112031. /**
  112032. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112033. * from 0.
  112034. * It defines the percentage of current camera.radius to use as delta when
  112035. * pinch zoom is used.
  112036. */
  112037. pinchDeltaPercentage: number;
  112038. /**
  112039. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112040. * that any object in the plane at the camera's target point will scale
  112041. * perfectly with finger motion.
  112042. * Overrides pinchDeltaPercentage and pinchPrecision.
  112043. */
  112044. useNaturalPinchZoom: boolean;
  112045. /**
  112046. * Defines the pointer panning sensibility or how fast is the camera moving.
  112047. */
  112048. panningSensibility: number;
  112049. /**
  112050. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112051. */
  112052. multiTouchPanning: boolean;
  112053. /**
  112054. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112055. * zoom (pinch) through multitouch.
  112056. */
  112057. multiTouchPanAndZoom: boolean;
  112058. /**
  112059. * Revers pinch action direction.
  112060. */
  112061. pinchInwards: boolean;
  112062. private _isPanClick;
  112063. private _twoFingerActivityCount;
  112064. private _isPinching;
  112065. /**
  112066. * Called on pointer POINTERMOVE event if only a single touch is active.
  112067. */
  112068. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112069. /**
  112070. * Called on pointer POINTERDOUBLETAP event.
  112071. */
  112072. protected onDoubleTap(type: string): void;
  112073. /**
  112074. * Called on pointer POINTERMOVE event if multiple touches are active.
  112075. */
  112076. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112077. /**
  112078. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112079. * press.
  112080. */
  112081. protected onButtonDown(evt: PointerEvent): void;
  112082. /**
  112083. * Called each time a new POINTERUP event occurs. Ie, for each button
  112084. * release.
  112085. */
  112086. protected onButtonUp(evt: PointerEvent): void;
  112087. /**
  112088. * Called when window becomes inactive.
  112089. */
  112090. protected onLostFocus(): void;
  112091. }
  112092. }
  112093. declare module BABYLON {
  112094. /**
  112095. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  112096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112097. */
  112098. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  112099. /**
  112100. * Defines the camera the input is attached to.
  112101. */
  112102. camera: ArcRotateCamera;
  112103. /**
  112104. * Defines the list of key codes associated with the up action (increase alpha)
  112105. */
  112106. keysUp: number[];
  112107. /**
  112108. * Defines the list of key codes associated with the down action (decrease alpha)
  112109. */
  112110. keysDown: number[];
  112111. /**
  112112. * Defines the list of key codes associated with the left action (increase beta)
  112113. */
  112114. keysLeft: number[];
  112115. /**
  112116. * Defines the list of key codes associated with the right action (decrease beta)
  112117. */
  112118. keysRight: number[];
  112119. /**
  112120. * Defines the list of key codes associated with the reset action.
  112121. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  112122. */
  112123. keysReset: number[];
  112124. /**
  112125. * Defines the panning sensibility of the inputs.
  112126. * (How fast is the camera panning)
  112127. */
  112128. panningSensibility: number;
  112129. /**
  112130. * Defines the zooming sensibility of the inputs.
  112131. * (How fast is the camera zooming)
  112132. */
  112133. zoomingSensibility: number;
  112134. /**
  112135. * Defines whether maintaining the alt key down switch the movement mode from
  112136. * orientation to zoom.
  112137. */
  112138. useAltToZoom: boolean;
  112139. /**
  112140. * Rotation speed of the camera
  112141. */
  112142. angularSpeed: number;
  112143. private _keys;
  112144. private _ctrlPressed;
  112145. private _altPressed;
  112146. private _onCanvasBlurObserver;
  112147. private _onKeyboardObserver;
  112148. private _engine;
  112149. private _scene;
  112150. /**
  112151. * Attach the input controls to a specific dom element to get the input from.
  112152. * @param element Defines the element the controls should be listened from
  112153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112154. */
  112155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112156. /**
  112157. * Detach the current controls from the specified dom element.
  112158. * @param element Defines the element to stop listening the inputs from
  112159. */
  112160. detachControl(element: Nullable<HTMLElement>): void;
  112161. /**
  112162. * Update the current camera state depending on the inputs that have been used this frame.
  112163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112164. */
  112165. checkInputs(): void;
  112166. /**
  112167. * Gets the class name of the current intput.
  112168. * @returns the class name
  112169. */
  112170. getClassName(): string;
  112171. /**
  112172. * Get the friendly name associated with the input class.
  112173. * @returns the input friendly name
  112174. */
  112175. getSimpleName(): string;
  112176. }
  112177. }
  112178. declare module BABYLON {
  112179. /**
  112180. * Manage the mouse wheel inputs to control an arc rotate camera.
  112181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112182. */
  112183. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  112184. /**
  112185. * Defines the camera the input is attached to.
  112186. */
  112187. camera: ArcRotateCamera;
  112188. /**
  112189. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112190. */
  112191. wheelPrecision: number;
  112192. /**
  112193. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112194. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112195. */
  112196. wheelDeltaPercentage: number;
  112197. private _wheel;
  112198. private _observer;
  112199. private computeDeltaFromMouseWheelLegacyEvent;
  112200. /**
  112201. * Attach the input controls to a specific dom element to get the input from.
  112202. * @param element Defines the element the controls should be listened from
  112203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112204. */
  112205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112206. /**
  112207. * Detach the current controls from the specified dom element.
  112208. * @param element Defines the element to stop listening the inputs from
  112209. */
  112210. detachControl(element: Nullable<HTMLElement>): void;
  112211. /**
  112212. * Gets the class name of the current intput.
  112213. * @returns the class name
  112214. */
  112215. getClassName(): string;
  112216. /**
  112217. * Get the friendly name associated with the input class.
  112218. * @returns the input friendly name
  112219. */
  112220. getSimpleName(): string;
  112221. }
  112222. }
  112223. declare module BABYLON {
  112224. /**
  112225. * Default Inputs manager for the ArcRotateCamera.
  112226. * It groups all the default supported inputs for ease of use.
  112227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112228. */
  112229. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  112230. /**
  112231. * Instantiates a new ArcRotateCameraInputsManager.
  112232. * @param camera Defines the camera the inputs belong to
  112233. */
  112234. constructor(camera: ArcRotateCamera);
  112235. /**
  112236. * Add mouse wheel input support to the input manager.
  112237. * @returns the current input manager
  112238. */
  112239. addMouseWheel(): ArcRotateCameraInputsManager;
  112240. /**
  112241. * Add pointers input support to the input manager.
  112242. * @returns the current input manager
  112243. */
  112244. addPointers(): ArcRotateCameraInputsManager;
  112245. /**
  112246. * Add keyboard input support to the input manager.
  112247. * @returns the current input manager
  112248. */
  112249. addKeyboard(): ArcRotateCameraInputsManager;
  112250. }
  112251. }
  112252. declare module BABYLON {
  112253. /**
  112254. * This represents an orbital type of camera.
  112255. *
  112256. * 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.
  112257. * 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.
  112258. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  112259. */
  112260. export class ArcRotateCamera extends TargetCamera {
  112261. /**
  112262. * Defines the rotation angle of the camera along the longitudinal axis.
  112263. */
  112264. alpha: number;
  112265. /**
  112266. * Defines the rotation angle of the camera along the latitudinal axis.
  112267. */
  112268. beta: number;
  112269. /**
  112270. * Defines the radius of the camera from it s target point.
  112271. */
  112272. radius: number;
  112273. protected _target: Vector3;
  112274. protected _targetHost: Nullable<AbstractMesh>;
  112275. /**
  112276. * Defines the target point of the camera.
  112277. * The camera looks towards it form the radius distance.
  112278. */
  112279. get target(): Vector3;
  112280. set target(value: Vector3);
  112281. /**
  112282. * Define the current local position of the camera in the scene
  112283. */
  112284. get position(): Vector3;
  112285. set position(newPosition: Vector3);
  112286. protected _upVector: Vector3;
  112287. protected _upToYMatrix: Matrix;
  112288. protected _YToUpMatrix: Matrix;
  112289. /**
  112290. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  112291. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  112292. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  112293. */
  112294. set upVector(vec: Vector3);
  112295. get upVector(): Vector3;
  112296. /**
  112297. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  112298. */
  112299. setMatUp(): void;
  112300. /**
  112301. * Current inertia value on the longitudinal axis.
  112302. * The bigger this number the longer it will take for the camera to stop.
  112303. */
  112304. inertialAlphaOffset: number;
  112305. /**
  112306. * Current inertia value on the latitudinal axis.
  112307. * The bigger this number the longer it will take for the camera to stop.
  112308. */
  112309. inertialBetaOffset: number;
  112310. /**
  112311. * Current inertia value on the radius axis.
  112312. * The bigger this number the longer it will take for the camera to stop.
  112313. */
  112314. inertialRadiusOffset: number;
  112315. /**
  112316. * Minimum allowed angle on the longitudinal axis.
  112317. * This can help limiting how the Camera is able to move in the scene.
  112318. */
  112319. lowerAlphaLimit: Nullable<number>;
  112320. /**
  112321. * Maximum allowed angle on the longitudinal axis.
  112322. * This can help limiting how the Camera is able to move in the scene.
  112323. */
  112324. upperAlphaLimit: Nullable<number>;
  112325. /**
  112326. * Minimum allowed angle on the latitudinal axis.
  112327. * This can help limiting how the Camera is able to move in the scene.
  112328. */
  112329. lowerBetaLimit: number;
  112330. /**
  112331. * Maximum allowed angle on the latitudinal axis.
  112332. * This can help limiting how the Camera is able to move in the scene.
  112333. */
  112334. upperBetaLimit: number;
  112335. /**
  112336. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  112337. * This can help limiting how the Camera is able to move in the scene.
  112338. */
  112339. lowerRadiusLimit: Nullable<number>;
  112340. /**
  112341. * Maximum allowed distance of the camera to the target (The camera can not get further).
  112342. * This can help limiting how the Camera is able to move in the scene.
  112343. */
  112344. upperRadiusLimit: Nullable<number>;
  112345. /**
  112346. * Defines the current inertia value used during panning of the camera along the X axis.
  112347. */
  112348. inertialPanningX: number;
  112349. /**
  112350. * Defines the current inertia value used during panning of the camera along the Y axis.
  112351. */
  112352. inertialPanningY: number;
  112353. /**
  112354. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  112355. * Basically if your fingers moves away from more than this distance you will be considered
  112356. * in pinch mode.
  112357. */
  112358. pinchToPanMaxDistance: number;
  112359. /**
  112360. * Defines the maximum distance the camera can pan.
  112361. * This could help keeping the cammera always in your scene.
  112362. */
  112363. panningDistanceLimit: Nullable<number>;
  112364. /**
  112365. * Defines the target of the camera before paning.
  112366. */
  112367. panningOriginTarget: Vector3;
  112368. /**
  112369. * Defines the value of the inertia used during panning.
  112370. * 0 would mean stop inertia and one would mean no decelleration at all.
  112371. */
  112372. panningInertia: number;
  112373. /**
  112374. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  112375. */
  112376. get angularSensibilityX(): number;
  112377. set angularSensibilityX(value: number);
  112378. /**
  112379. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  112380. */
  112381. get angularSensibilityY(): number;
  112382. set angularSensibilityY(value: number);
  112383. /**
  112384. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  112385. */
  112386. get pinchPrecision(): number;
  112387. set pinchPrecision(value: number);
  112388. /**
  112389. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  112390. * It will be used instead of pinchDeltaPrecision if different from 0.
  112391. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112392. */
  112393. get pinchDeltaPercentage(): number;
  112394. set pinchDeltaPercentage(value: number);
  112395. /**
  112396. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  112397. * and pinch delta percentage.
  112398. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112399. * that any object in the plane at the camera's target point will scale
  112400. * perfectly with finger motion.
  112401. */
  112402. get useNaturalPinchZoom(): boolean;
  112403. set useNaturalPinchZoom(value: boolean);
  112404. /**
  112405. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112406. */
  112407. get panningSensibility(): number;
  112408. set panningSensibility(value: number);
  112409. /**
  112410. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112411. */
  112412. get keysUp(): number[];
  112413. set keysUp(value: number[]);
  112414. /**
  112415. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112416. */
  112417. get keysDown(): number[];
  112418. set keysDown(value: number[]);
  112419. /**
  112420. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112421. */
  112422. get keysLeft(): number[];
  112423. set keysLeft(value: number[]);
  112424. /**
  112425. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112426. */
  112427. get keysRight(): number[];
  112428. set keysRight(value: number[]);
  112429. /**
  112430. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112431. */
  112432. get wheelPrecision(): number;
  112433. set wheelPrecision(value: number);
  112434. /**
  112435. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112436. * It will be used instead of pinchDeltaPrecision if different from 0.
  112437. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112438. */
  112439. get wheelDeltaPercentage(): number;
  112440. set wheelDeltaPercentage(value: number);
  112441. /**
  112442. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112443. */
  112444. zoomOnFactor: number;
  112445. /**
  112446. * Defines a screen offset for the camera position.
  112447. */
  112448. targetScreenOffset: Vector2;
  112449. /**
  112450. * Allows the camera to be completely reversed.
  112451. * If false the camera can not arrive upside down.
  112452. */
  112453. allowUpsideDown: boolean;
  112454. /**
  112455. * Define if double tap/click is used to restore the previously saved state of the camera.
  112456. */
  112457. useInputToRestoreState: boolean;
  112458. /** @hidden */
  112459. _viewMatrix: Matrix;
  112460. /** @hidden */
  112461. _useCtrlForPanning: boolean;
  112462. /** @hidden */
  112463. _panningMouseButton: number;
  112464. /**
  112465. * Defines the input associated to the camera.
  112466. */
  112467. inputs: ArcRotateCameraInputsManager;
  112468. /** @hidden */
  112469. _reset: () => void;
  112470. /**
  112471. * Defines the allowed panning axis.
  112472. */
  112473. panningAxis: Vector3;
  112474. protected _localDirection: Vector3;
  112475. protected _transformedDirection: Vector3;
  112476. private _bouncingBehavior;
  112477. /**
  112478. * Gets the bouncing behavior of the camera if it has been enabled.
  112479. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112480. */
  112481. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112482. /**
  112483. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112484. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112485. */
  112486. get useBouncingBehavior(): boolean;
  112487. set useBouncingBehavior(value: boolean);
  112488. private _framingBehavior;
  112489. /**
  112490. * Gets the framing behavior of the camera if it has been enabled.
  112491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112492. */
  112493. get framingBehavior(): Nullable<FramingBehavior>;
  112494. /**
  112495. * Defines if the framing behavior of the camera is enabled on the camera.
  112496. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112497. */
  112498. get useFramingBehavior(): boolean;
  112499. set useFramingBehavior(value: boolean);
  112500. private _autoRotationBehavior;
  112501. /**
  112502. * Gets the auto rotation behavior of the camera if it has been enabled.
  112503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112504. */
  112505. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112506. /**
  112507. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112509. */
  112510. get useAutoRotationBehavior(): boolean;
  112511. set useAutoRotationBehavior(value: boolean);
  112512. /**
  112513. * Observable triggered when the mesh target has been changed on the camera.
  112514. */
  112515. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112516. /**
  112517. * Event raised when the camera is colliding with a mesh.
  112518. */
  112519. onCollide: (collidedMesh: AbstractMesh) => void;
  112520. /**
  112521. * Defines whether the camera should check collision with the objects oh the scene.
  112522. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112523. */
  112524. checkCollisions: boolean;
  112525. /**
  112526. * Defines the collision radius of the camera.
  112527. * This simulates a sphere around the camera.
  112528. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112529. */
  112530. collisionRadius: Vector3;
  112531. protected _collider: Collider;
  112532. protected _previousPosition: Vector3;
  112533. protected _collisionVelocity: Vector3;
  112534. protected _newPosition: Vector3;
  112535. protected _previousAlpha: number;
  112536. protected _previousBeta: number;
  112537. protected _previousRadius: number;
  112538. protected _collisionTriggered: boolean;
  112539. protected _targetBoundingCenter: Nullable<Vector3>;
  112540. private _computationVector;
  112541. /**
  112542. * Instantiates a new ArcRotateCamera in a given scene
  112543. * @param name Defines the name of the camera
  112544. * @param alpha Defines the camera rotation along the logitudinal axis
  112545. * @param beta Defines the camera rotation along the latitudinal axis
  112546. * @param radius Defines the camera distance from its target
  112547. * @param target Defines the camera target
  112548. * @param scene Defines the scene the camera belongs to
  112549. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112550. */
  112551. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112552. /** @hidden */
  112553. _initCache(): void;
  112554. /** @hidden */
  112555. _updateCache(ignoreParentClass?: boolean): void;
  112556. protected _getTargetPosition(): Vector3;
  112557. private _storedAlpha;
  112558. private _storedBeta;
  112559. private _storedRadius;
  112560. private _storedTarget;
  112561. private _storedTargetScreenOffset;
  112562. /**
  112563. * Stores the current state of the camera (alpha, beta, radius and target)
  112564. * @returns the camera itself
  112565. */
  112566. storeState(): Camera;
  112567. /**
  112568. * @hidden
  112569. * Restored camera state. You must call storeState() first
  112570. */
  112571. _restoreStateValues(): boolean;
  112572. /** @hidden */
  112573. _isSynchronizedViewMatrix(): boolean;
  112574. /**
  112575. * Attached controls to the current camera.
  112576. * @param element Defines the element the controls should be listened from
  112577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112578. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112579. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112580. */
  112581. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112582. /**
  112583. * Detach the current controls from the camera.
  112584. * The camera will stop reacting to inputs.
  112585. * @param element Defines the element to stop listening the inputs from
  112586. */
  112587. detachControl(element: HTMLElement): void;
  112588. /** @hidden */
  112589. _checkInputs(): void;
  112590. protected _checkLimits(): void;
  112591. /**
  112592. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112593. */
  112594. rebuildAnglesAndRadius(): void;
  112595. /**
  112596. * Use a position to define the current camera related information like alpha, beta and radius
  112597. * @param position Defines the position to set the camera at
  112598. */
  112599. setPosition(position: Vector3): void;
  112600. /**
  112601. * Defines the target the camera should look at.
  112602. * This will automatically adapt alpha beta and radius to fit within the new target.
  112603. * @param target Defines the new target as a Vector or a mesh
  112604. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112605. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112606. */
  112607. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112608. /** @hidden */
  112609. _getViewMatrix(): Matrix;
  112610. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112611. /**
  112612. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112613. * @param meshes Defines the mesh to zoom on
  112614. * @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)
  112615. */
  112616. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112617. /**
  112618. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112619. * The target will be changed but the radius
  112620. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112621. * @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)
  112622. */
  112623. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112624. min: Vector3;
  112625. max: Vector3;
  112626. distance: number;
  112627. }, doNotUpdateMaxZ?: boolean): void;
  112628. /**
  112629. * @override
  112630. * Override Camera.createRigCamera
  112631. */
  112632. createRigCamera(name: string, cameraIndex: number): Camera;
  112633. /**
  112634. * @hidden
  112635. * @override
  112636. * Override Camera._updateRigCameras
  112637. */
  112638. _updateRigCameras(): void;
  112639. /**
  112640. * Destroy the camera and release the current resources hold by it.
  112641. */
  112642. dispose(): void;
  112643. /**
  112644. * Gets the current object class name.
  112645. * @return the class name
  112646. */
  112647. getClassName(): string;
  112648. }
  112649. }
  112650. declare module BABYLON {
  112651. /**
  112652. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112654. */
  112655. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112656. /**
  112657. * Gets the name of the behavior.
  112658. */
  112659. get name(): string;
  112660. private _zoomStopsAnimation;
  112661. private _idleRotationSpeed;
  112662. private _idleRotationWaitTime;
  112663. private _idleRotationSpinupTime;
  112664. /**
  112665. * Sets the flag that indicates if user zooming should stop animation.
  112666. */
  112667. set zoomStopsAnimation(flag: boolean);
  112668. /**
  112669. * Gets the flag that indicates if user zooming should stop animation.
  112670. */
  112671. get zoomStopsAnimation(): boolean;
  112672. /**
  112673. * Sets the default speed at which the camera rotates around the model.
  112674. */
  112675. set idleRotationSpeed(speed: number);
  112676. /**
  112677. * Gets the default speed at which the camera rotates around the model.
  112678. */
  112679. get idleRotationSpeed(): number;
  112680. /**
  112681. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112682. */
  112683. set idleRotationWaitTime(time: number);
  112684. /**
  112685. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112686. */
  112687. get idleRotationWaitTime(): number;
  112688. /**
  112689. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112690. */
  112691. set idleRotationSpinupTime(time: number);
  112692. /**
  112693. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112694. */
  112695. get idleRotationSpinupTime(): number;
  112696. /**
  112697. * Gets a value indicating if the camera is currently rotating because of this behavior
  112698. */
  112699. get rotationInProgress(): boolean;
  112700. private _onPrePointerObservableObserver;
  112701. private _onAfterCheckInputsObserver;
  112702. private _attachedCamera;
  112703. private _isPointerDown;
  112704. private _lastFrameTime;
  112705. private _lastInteractionTime;
  112706. private _cameraRotationSpeed;
  112707. /**
  112708. * Initializes the behavior.
  112709. */
  112710. init(): void;
  112711. /**
  112712. * Attaches the behavior to its arc rotate camera.
  112713. * @param camera Defines the camera to attach the behavior to
  112714. */
  112715. attach(camera: ArcRotateCamera): void;
  112716. /**
  112717. * Detaches the behavior from its current arc rotate camera.
  112718. */
  112719. detach(): void;
  112720. /**
  112721. * Returns true if user is scrolling.
  112722. * @return true if user is scrolling.
  112723. */
  112724. private _userIsZooming;
  112725. private _lastFrameRadius;
  112726. private _shouldAnimationStopForInteraction;
  112727. /**
  112728. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112729. */
  112730. private _applyUserInteraction;
  112731. private _userIsMoving;
  112732. }
  112733. }
  112734. declare module BABYLON {
  112735. /**
  112736. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112737. */
  112738. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112739. private ui;
  112740. /**
  112741. * The name of the behavior
  112742. */
  112743. name: string;
  112744. /**
  112745. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112746. */
  112747. distanceAwayFromFace: number;
  112748. /**
  112749. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112750. */
  112751. distanceAwayFromBottomOfFace: number;
  112752. private _faceVectors;
  112753. private _target;
  112754. private _scene;
  112755. private _onRenderObserver;
  112756. private _tmpMatrix;
  112757. private _tmpVector;
  112758. /**
  112759. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112760. * @param ui The transform node that should be attched to the mesh
  112761. */
  112762. constructor(ui: TransformNode);
  112763. /**
  112764. * Initializes the behavior
  112765. */
  112766. init(): void;
  112767. private _closestFace;
  112768. private _zeroVector;
  112769. private _lookAtTmpMatrix;
  112770. private _lookAtToRef;
  112771. /**
  112772. * Attaches the AttachToBoxBehavior to the passed in mesh
  112773. * @param target The mesh that the specified node will be attached to
  112774. */
  112775. attach(target: Mesh): void;
  112776. /**
  112777. * Detaches the behavior from the mesh
  112778. */
  112779. detach(): void;
  112780. }
  112781. }
  112782. declare module BABYLON {
  112783. /**
  112784. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112785. */
  112786. export class FadeInOutBehavior implements Behavior<Mesh> {
  112787. /**
  112788. * Time in milliseconds to delay before fading in (Default: 0)
  112789. */
  112790. delay: number;
  112791. /**
  112792. * Time in milliseconds for the mesh to fade in (Default: 300)
  112793. */
  112794. fadeInTime: number;
  112795. private _millisecondsPerFrame;
  112796. private _hovered;
  112797. private _hoverValue;
  112798. private _ownerNode;
  112799. /**
  112800. * Instatiates the FadeInOutBehavior
  112801. */
  112802. constructor();
  112803. /**
  112804. * The name of the behavior
  112805. */
  112806. get name(): string;
  112807. /**
  112808. * Initializes the behavior
  112809. */
  112810. init(): void;
  112811. /**
  112812. * Attaches the fade behavior on the passed in mesh
  112813. * @param ownerNode The mesh that will be faded in/out once attached
  112814. */
  112815. attach(ownerNode: Mesh): void;
  112816. /**
  112817. * Detaches the behavior from the mesh
  112818. */
  112819. detach(): void;
  112820. /**
  112821. * Triggers the mesh to begin fading in or out
  112822. * @param value if the object should fade in or out (true to fade in)
  112823. */
  112824. fadeIn(value: boolean): void;
  112825. private _update;
  112826. private _setAllVisibility;
  112827. }
  112828. }
  112829. declare module BABYLON {
  112830. /**
  112831. * Class containing a set of static utilities functions for managing Pivots
  112832. * @hidden
  112833. */
  112834. export class PivotTools {
  112835. private static _PivotCached;
  112836. private static _OldPivotPoint;
  112837. private static _PivotTranslation;
  112838. private static _PivotTmpVector;
  112839. /** @hidden */
  112840. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112841. /** @hidden */
  112842. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112843. }
  112844. }
  112845. declare module BABYLON {
  112846. /**
  112847. * Class containing static functions to help procedurally build meshes
  112848. */
  112849. export class PlaneBuilder {
  112850. /**
  112851. * Creates a plane mesh
  112852. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112853. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112854. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112858. * @param name defines the name of the mesh
  112859. * @param options defines the options used to create the mesh
  112860. * @param scene defines the hosting scene
  112861. * @returns the plane mesh
  112862. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112863. */
  112864. static CreatePlane(name: string, options: {
  112865. size?: number;
  112866. width?: number;
  112867. height?: number;
  112868. sideOrientation?: number;
  112869. frontUVs?: Vector4;
  112870. backUVs?: Vector4;
  112871. updatable?: boolean;
  112872. sourcePlane?: Plane;
  112873. }, scene?: Nullable<Scene>): Mesh;
  112874. }
  112875. }
  112876. declare module BABYLON {
  112877. /**
  112878. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112879. */
  112880. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112881. private static _AnyMouseID;
  112882. /**
  112883. * Abstract mesh the behavior is set on
  112884. */
  112885. attachedNode: AbstractMesh;
  112886. private _dragPlane;
  112887. private _scene;
  112888. private _pointerObserver;
  112889. private _beforeRenderObserver;
  112890. private static _planeScene;
  112891. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112892. /**
  112893. * 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)
  112894. */
  112895. maxDragAngle: number;
  112896. /**
  112897. * @hidden
  112898. */
  112899. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112900. /**
  112901. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112902. */
  112903. currentDraggingPointerID: number;
  112904. /**
  112905. * The last position where the pointer hit the drag plane in world space
  112906. */
  112907. lastDragPosition: Vector3;
  112908. /**
  112909. * If the behavior is currently in a dragging state
  112910. */
  112911. dragging: boolean;
  112912. /**
  112913. * 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)
  112914. */
  112915. dragDeltaRatio: number;
  112916. /**
  112917. * If the drag plane orientation should be updated during the dragging (Default: true)
  112918. */
  112919. updateDragPlane: boolean;
  112920. private _debugMode;
  112921. private _moving;
  112922. /**
  112923. * Fires each time the attached mesh is dragged with the pointer
  112924. * * delta between last drag position and current drag position in world space
  112925. * * dragDistance along the drag axis
  112926. * * dragPlaneNormal normal of the current drag plane used during the drag
  112927. * * dragPlanePoint in world space where the drag intersects the drag plane
  112928. */
  112929. onDragObservable: Observable<{
  112930. delta: Vector3;
  112931. dragPlanePoint: Vector3;
  112932. dragPlaneNormal: Vector3;
  112933. dragDistance: number;
  112934. pointerId: number;
  112935. }>;
  112936. /**
  112937. * Fires each time a drag begins (eg. mouse down on mesh)
  112938. */
  112939. onDragStartObservable: Observable<{
  112940. dragPlanePoint: Vector3;
  112941. pointerId: number;
  112942. }>;
  112943. /**
  112944. * Fires each time a drag ends (eg. mouse release after drag)
  112945. */
  112946. onDragEndObservable: Observable<{
  112947. dragPlanePoint: Vector3;
  112948. pointerId: number;
  112949. }>;
  112950. /**
  112951. * If the attached mesh should be moved when dragged
  112952. */
  112953. moveAttached: boolean;
  112954. /**
  112955. * If the drag behavior will react to drag events (Default: true)
  112956. */
  112957. enabled: boolean;
  112958. /**
  112959. * If pointer events should start and release the drag (Default: true)
  112960. */
  112961. startAndReleaseDragOnPointerEvents: boolean;
  112962. /**
  112963. * If camera controls should be detached during the drag
  112964. */
  112965. detachCameraControls: boolean;
  112966. /**
  112967. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112968. */
  112969. useObjectOrientationForDragging: boolean;
  112970. private _options;
  112971. /**
  112972. * Gets the options used by the behavior
  112973. */
  112974. get options(): {
  112975. dragAxis?: Vector3;
  112976. dragPlaneNormal?: Vector3;
  112977. };
  112978. /**
  112979. * Sets the options used by the behavior
  112980. */
  112981. set options(options: {
  112982. dragAxis?: Vector3;
  112983. dragPlaneNormal?: Vector3;
  112984. });
  112985. /**
  112986. * Creates a pointer drag behavior that can be attached to a mesh
  112987. * @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)
  112988. */
  112989. constructor(options?: {
  112990. dragAxis?: Vector3;
  112991. dragPlaneNormal?: Vector3;
  112992. });
  112993. /**
  112994. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112995. */
  112996. validateDrag: (targetPosition: Vector3) => boolean;
  112997. /**
  112998. * The name of the behavior
  112999. */
  113000. get name(): string;
  113001. /**
  113002. * Initializes the behavior
  113003. */
  113004. init(): void;
  113005. private _tmpVector;
  113006. private _alternatePickedPoint;
  113007. private _worldDragAxis;
  113008. private _targetPosition;
  113009. private _attachedElement;
  113010. /**
  113011. * Attaches the drag behavior the passed in mesh
  113012. * @param ownerNode The mesh that will be dragged around once attached
  113013. * @param predicate Predicate to use for pick filtering
  113014. */
  113015. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113016. /**
  113017. * Force relase the drag action by code.
  113018. */
  113019. releaseDrag(): void;
  113020. private _startDragRay;
  113021. private _lastPointerRay;
  113022. /**
  113023. * Simulates the start of a pointer drag event on the behavior
  113024. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113025. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113026. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113027. */
  113028. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113029. private _startDrag;
  113030. private _dragDelta;
  113031. private _moveDrag;
  113032. private _pickWithRayOnDragPlane;
  113033. private _pointA;
  113034. private _pointB;
  113035. private _pointC;
  113036. private _lineA;
  113037. private _lineB;
  113038. private _localAxis;
  113039. private _lookAt;
  113040. private _updateDragPlanePosition;
  113041. /**
  113042. * Detaches the behavior from the mesh
  113043. */
  113044. detach(): void;
  113045. }
  113046. }
  113047. declare module BABYLON {
  113048. /**
  113049. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113050. */
  113051. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113052. private _dragBehaviorA;
  113053. private _dragBehaviorB;
  113054. private _startDistance;
  113055. private _initialScale;
  113056. private _targetScale;
  113057. private _ownerNode;
  113058. private _sceneRenderObserver;
  113059. /**
  113060. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113061. */
  113062. constructor();
  113063. /**
  113064. * The name of the behavior
  113065. */
  113066. get name(): string;
  113067. /**
  113068. * Initializes the behavior
  113069. */
  113070. init(): void;
  113071. private _getCurrentDistance;
  113072. /**
  113073. * Attaches the scale behavior the passed in mesh
  113074. * @param ownerNode The mesh that will be scaled around once attached
  113075. */
  113076. attach(ownerNode: Mesh): void;
  113077. /**
  113078. * Detaches the behavior from the mesh
  113079. */
  113080. detach(): void;
  113081. }
  113082. }
  113083. declare module BABYLON {
  113084. /**
  113085. * 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
  113086. */
  113087. export class SixDofDragBehavior implements Behavior<Mesh> {
  113088. private static _virtualScene;
  113089. private _ownerNode;
  113090. private _sceneRenderObserver;
  113091. private _scene;
  113092. private _targetPosition;
  113093. private _virtualOriginMesh;
  113094. private _virtualDragMesh;
  113095. private _pointerObserver;
  113096. private _moving;
  113097. private _startingOrientation;
  113098. /**
  113099. * 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)
  113100. */
  113101. private zDragFactor;
  113102. /**
  113103. * If the object should rotate to face the drag origin
  113104. */
  113105. rotateDraggedObject: boolean;
  113106. /**
  113107. * If the behavior is currently in a dragging state
  113108. */
  113109. dragging: boolean;
  113110. /**
  113111. * 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)
  113112. */
  113113. dragDeltaRatio: number;
  113114. /**
  113115. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113116. */
  113117. currentDraggingPointerID: number;
  113118. /**
  113119. * If camera controls should be detached during the drag
  113120. */
  113121. detachCameraControls: boolean;
  113122. /**
  113123. * Fires each time a drag starts
  113124. */
  113125. onDragStartObservable: Observable<{}>;
  113126. /**
  113127. * Fires each time a drag ends (eg. mouse release after drag)
  113128. */
  113129. onDragEndObservable: Observable<{}>;
  113130. /**
  113131. * 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
  113132. */
  113133. constructor();
  113134. /**
  113135. * The name of the behavior
  113136. */
  113137. get name(): string;
  113138. /**
  113139. * Initializes the behavior
  113140. */
  113141. init(): void;
  113142. /**
  113143. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  113144. */
  113145. private get _pointerCamera();
  113146. /**
  113147. * Attaches the scale behavior the passed in mesh
  113148. * @param ownerNode The mesh that will be scaled around once attached
  113149. */
  113150. attach(ownerNode: Mesh): void;
  113151. /**
  113152. * Detaches the behavior from the mesh
  113153. */
  113154. detach(): void;
  113155. }
  113156. }
  113157. declare module BABYLON {
  113158. /**
  113159. * Class used to apply inverse kinematics to bones
  113160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  113161. */
  113162. export class BoneIKController {
  113163. private static _tmpVecs;
  113164. private static _tmpQuat;
  113165. private static _tmpMats;
  113166. /**
  113167. * Gets or sets the target mesh
  113168. */
  113169. targetMesh: AbstractMesh;
  113170. /** Gets or sets the mesh used as pole */
  113171. poleTargetMesh: AbstractMesh;
  113172. /**
  113173. * Gets or sets the bone used as pole
  113174. */
  113175. poleTargetBone: Nullable<Bone>;
  113176. /**
  113177. * Gets or sets the target position
  113178. */
  113179. targetPosition: Vector3;
  113180. /**
  113181. * Gets or sets the pole target position
  113182. */
  113183. poleTargetPosition: Vector3;
  113184. /**
  113185. * Gets or sets the pole target local offset
  113186. */
  113187. poleTargetLocalOffset: Vector3;
  113188. /**
  113189. * Gets or sets the pole angle
  113190. */
  113191. poleAngle: number;
  113192. /**
  113193. * Gets or sets the mesh associated with the controller
  113194. */
  113195. mesh: AbstractMesh;
  113196. /**
  113197. * 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)
  113198. */
  113199. slerpAmount: number;
  113200. private _bone1Quat;
  113201. private _bone1Mat;
  113202. private _bone2Ang;
  113203. private _bone1;
  113204. private _bone2;
  113205. private _bone1Length;
  113206. private _bone2Length;
  113207. private _maxAngle;
  113208. private _maxReach;
  113209. private _rightHandedSystem;
  113210. private _bendAxis;
  113211. private _slerping;
  113212. private _adjustRoll;
  113213. /**
  113214. * Gets or sets maximum allowed angle
  113215. */
  113216. get maxAngle(): number;
  113217. set maxAngle(value: number);
  113218. /**
  113219. * Creates a new BoneIKController
  113220. * @param mesh defines the mesh to control
  113221. * @param bone defines the bone to control
  113222. * @param options defines options to set up the controller
  113223. */
  113224. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  113225. targetMesh?: AbstractMesh;
  113226. poleTargetMesh?: AbstractMesh;
  113227. poleTargetBone?: Bone;
  113228. poleTargetLocalOffset?: Vector3;
  113229. poleAngle?: number;
  113230. bendAxis?: Vector3;
  113231. maxAngle?: number;
  113232. slerpAmount?: number;
  113233. });
  113234. private _setMaxAngle;
  113235. /**
  113236. * Force the controller to update the bones
  113237. */
  113238. update(): void;
  113239. }
  113240. }
  113241. declare module BABYLON {
  113242. /**
  113243. * Class used to make a bone look toward a point in space
  113244. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  113245. */
  113246. export class BoneLookController {
  113247. private static _tmpVecs;
  113248. private static _tmpQuat;
  113249. private static _tmpMats;
  113250. /**
  113251. * The target Vector3 that the bone will look at
  113252. */
  113253. target: Vector3;
  113254. /**
  113255. * The mesh that the bone is attached to
  113256. */
  113257. mesh: AbstractMesh;
  113258. /**
  113259. * The bone that will be looking to the target
  113260. */
  113261. bone: Bone;
  113262. /**
  113263. * The up axis of the coordinate system that is used when the bone is rotated
  113264. */
  113265. upAxis: Vector3;
  113266. /**
  113267. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  113268. */
  113269. upAxisSpace: Space;
  113270. /**
  113271. * Used to make an adjustment to the yaw of the bone
  113272. */
  113273. adjustYaw: number;
  113274. /**
  113275. * Used to make an adjustment to the pitch of the bone
  113276. */
  113277. adjustPitch: number;
  113278. /**
  113279. * Used to make an adjustment to the roll of the bone
  113280. */
  113281. adjustRoll: number;
  113282. /**
  113283. * 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)
  113284. */
  113285. slerpAmount: number;
  113286. private _minYaw;
  113287. private _maxYaw;
  113288. private _minPitch;
  113289. private _maxPitch;
  113290. private _minYawSin;
  113291. private _minYawCos;
  113292. private _maxYawSin;
  113293. private _maxYawCos;
  113294. private _midYawConstraint;
  113295. private _minPitchTan;
  113296. private _maxPitchTan;
  113297. private _boneQuat;
  113298. private _slerping;
  113299. private _transformYawPitch;
  113300. private _transformYawPitchInv;
  113301. private _firstFrameSkipped;
  113302. private _yawRange;
  113303. private _fowardAxis;
  113304. /**
  113305. * Gets or sets the minimum yaw angle that the bone can look to
  113306. */
  113307. get minYaw(): number;
  113308. set minYaw(value: number);
  113309. /**
  113310. * Gets or sets the maximum yaw angle that the bone can look to
  113311. */
  113312. get maxYaw(): number;
  113313. set maxYaw(value: number);
  113314. /**
  113315. * Gets or sets the minimum pitch angle that the bone can look to
  113316. */
  113317. get minPitch(): number;
  113318. set minPitch(value: number);
  113319. /**
  113320. * Gets or sets the maximum pitch angle that the bone can look to
  113321. */
  113322. get maxPitch(): number;
  113323. set maxPitch(value: number);
  113324. /**
  113325. * Create a BoneLookController
  113326. * @param mesh the mesh that the bone belongs to
  113327. * @param bone the bone that will be looking to the target
  113328. * @param target the target Vector3 to look at
  113329. * @param options optional settings:
  113330. * * maxYaw: the maximum angle the bone will yaw to
  113331. * * minYaw: the minimum angle the bone will yaw to
  113332. * * maxPitch: the maximum angle the bone will pitch to
  113333. * * minPitch: the minimum angle the bone will yaw to
  113334. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  113335. * * upAxis: the up axis of the coordinate system
  113336. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  113337. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  113338. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  113339. * * adjustYaw: used to make an adjustment to the yaw of the bone
  113340. * * adjustPitch: used to make an adjustment to the pitch of the bone
  113341. * * adjustRoll: used to make an adjustment to the roll of the bone
  113342. **/
  113343. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  113344. maxYaw?: number;
  113345. minYaw?: number;
  113346. maxPitch?: number;
  113347. minPitch?: number;
  113348. slerpAmount?: number;
  113349. upAxis?: Vector3;
  113350. upAxisSpace?: Space;
  113351. yawAxis?: Vector3;
  113352. pitchAxis?: Vector3;
  113353. adjustYaw?: number;
  113354. adjustPitch?: number;
  113355. adjustRoll?: number;
  113356. });
  113357. /**
  113358. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  113359. */
  113360. update(): void;
  113361. private _getAngleDiff;
  113362. private _getAngleBetween;
  113363. private _isAngleBetween;
  113364. }
  113365. }
  113366. declare module BABYLON {
  113367. /**
  113368. * Manage the gamepad inputs to control an arc rotate camera.
  113369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113370. */
  113371. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  113372. /**
  113373. * Defines the camera the input is attached to.
  113374. */
  113375. camera: ArcRotateCamera;
  113376. /**
  113377. * Defines the gamepad the input is gathering event from.
  113378. */
  113379. gamepad: Nullable<Gamepad>;
  113380. /**
  113381. * Defines the gamepad rotation sensiblity.
  113382. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113383. */
  113384. gamepadRotationSensibility: number;
  113385. /**
  113386. * Defines the gamepad move sensiblity.
  113387. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113388. */
  113389. gamepadMoveSensibility: number;
  113390. private _yAxisScale;
  113391. /**
  113392. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113393. */
  113394. get invertYAxis(): boolean;
  113395. set invertYAxis(value: boolean);
  113396. private _onGamepadConnectedObserver;
  113397. private _onGamepadDisconnectedObserver;
  113398. /**
  113399. * Attach the input controls to a specific dom element to get the input from.
  113400. * @param element Defines the element the controls should be listened from
  113401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113402. */
  113403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113404. /**
  113405. * Detach the current controls from the specified dom element.
  113406. * @param element Defines the element to stop listening the inputs from
  113407. */
  113408. detachControl(element: Nullable<HTMLElement>): void;
  113409. /**
  113410. * Update the current camera state depending on the inputs that have been used this frame.
  113411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113412. */
  113413. checkInputs(): void;
  113414. /**
  113415. * Gets the class name of the current intput.
  113416. * @returns the class name
  113417. */
  113418. getClassName(): string;
  113419. /**
  113420. * Get the friendly name associated with the input class.
  113421. * @returns the input friendly name
  113422. */
  113423. getSimpleName(): string;
  113424. }
  113425. }
  113426. declare module BABYLON {
  113427. interface ArcRotateCameraInputsManager {
  113428. /**
  113429. * Add orientation input support to the input manager.
  113430. * @returns the current input manager
  113431. */
  113432. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113433. }
  113434. /**
  113435. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113437. */
  113438. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113439. /**
  113440. * Defines the camera the input is attached to.
  113441. */
  113442. camera: ArcRotateCamera;
  113443. /**
  113444. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113445. */
  113446. alphaCorrection: number;
  113447. /**
  113448. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113449. */
  113450. gammaCorrection: number;
  113451. private _alpha;
  113452. private _gamma;
  113453. private _dirty;
  113454. private _deviceOrientationHandler;
  113455. /**
  113456. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113457. */
  113458. constructor();
  113459. /**
  113460. * Attach the input controls to a specific dom element to get the input from.
  113461. * @param element Defines the element the controls should be listened from
  113462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113463. */
  113464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113465. /** @hidden */
  113466. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113467. /**
  113468. * Update the current camera state depending on the inputs that have been used this frame.
  113469. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113470. */
  113471. checkInputs(): void;
  113472. /**
  113473. * Detach the current controls from the specified dom element.
  113474. * @param element Defines the element to stop listening the inputs from
  113475. */
  113476. detachControl(element: Nullable<HTMLElement>): void;
  113477. /**
  113478. * Gets the class name of the current intput.
  113479. * @returns the class name
  113480. */
  113481. getClassName(): string;
  113482. /**
  113483. * Get the friendly name associated with the input class.
  113484. * @returns the input friendly name
  113485. */
  113486. getSimpleName(): string;
  113487. }
  113488. }
  113489. declare module BABYLON {
  113490. /**
  113491. * Listen to mouse events to control the camera.
  113492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113493. */
  113494. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113495. /**
  113496. * Defines the camera the input is attached to.
  113497. */
  113498. camera: FlyCamera;
  113499. /**
  113500. * Defines if touch is enabled. (Default is true.)
  113501. */
  113502. touchEnabled: boolean;
  113503. /**
  113504. * Defines the buttons associated with the input to handle camera rotation.
  113505. */
  113506. buttons: number[];
  113507. /**
  113508. * Assign buttons for Yaw control.
  113509. */
  113510. buttonsYaw: number[];
  113511. /**
  113512. * Assign buttons for Pitch control.
  113513. */
  113514. buttonsPitch: number[];
  113515. /**
  113516. * Assign buttons for Roll control.
  113517. */
  113518. buttonsRoll: number[];
  113519. /**
  113520. * Detect if any button is being pressed while mouse is moved.
  113521. * -1 = Mouse locked.
  113522. * 0 = Left button.
  113523. * 1 = Middle Button.
  113524. * 2 = Right Button.
  113525. */
  113526. activeButton: number;
  113527. /**
  113528. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113529. * Higher values reduce its sensitivity.
  113530. */
  113531. angularSensibility: number;
  113532. private _mousemoveCallback;
  113533. private _observer;
  113534. private _rollObserver;
  113535. private previousPosition;
  113536. private noPreventDefault;
  113537. private element;
  113538. /**
  113539. * Listen to mouse events to control the camera.
  113540. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113542. */
  113543. constructor(touchEnabled?: boolean);
  113544. /**
  113545. * Attach the mouse control to the HTML DOM element.
  113546. * @param element Defines the element that listens to the input events.
  113547. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113548. */
  113549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113550. /**
  113551. * Detach the current controls from the specified dom element.
  113552. * @param element Defines the element to stop listening the inputs from
  113553. */
  113554. detachControl(element: Nullable<HTMLElement>): void;
  113555. /**
  113556. * Gets the class name of the current input.
  113557. * @returns the class name.
  113558. */
  113559. getClassName(): string;
  113560. /**
  113561. * Get the friendly name associated with the input class.
  113562. * @returns the input's friendly name.
  113563. */
  113564. getSimpleName(): string;
  113565. private _pointerInput;
  113566. private _onMouseMove;
  113567. /**
  113568. * Rotate camera by mouse offset.
  113569. */
  113570. private rotateCamera;
  113571. }
  113572. }
  113573. declare module BABYLON {
  113574. /**
  113575. * Default Inputs manager for the FlyCamera.
  113576. * It groups all the default supported inputs for ease of use.
  113577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113578. */
  113579. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113580. /**
  113581. * Instantiates a new FlyCameraInputsManager.
  113582. * @param camera Defines the camera the inputs belong to.
  113583. */
  113584. constructor(camera: FlyCamera);
  113585. /**
  113586. * Add keyboard input support to the input manager.
  113587. * @returns the new FlyCameraKeyboardMoveInput().
  113588. */
  113589. addKeyboard(): FlyCameraInputsManager;
  113590. /**
  113591. * Add mouse input support to the input manager.
  113592. * @param touchEnabled Enable touch screen support.
  113593. * @returns the new FlyCameraMouseInput().
  113594. */
  113595. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113596. }
  113597. }
  113598. declare module BABYLON {
  113599. /**
  113600. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113601. * such as in a 3D Space Shooter or a Flight Simulator.
  113602. */
  113603. export class FlyCamera extends TargetCamera {
  113604. /**
  113605. * Define the collision ellipsoid of the camera.
  113606. * This is helpful for simulating a camera body, like a player's body.
  113607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113608. */
  113609. ellipsoid: Vector3;
  113610. /**
  113611. * Define an offset for the position of the ellipsoid around the camera.
  113612. * This can be helpful if the camera is attached away from the player's body center,
  113613. * such as at its head.
  113614. */
  113615. ellipsoidOffset: Vector3;
  113616. /**
  113617. * Enable or disable collisions of the camera with the rest of the scene objects.
  113618. */
  113619. checkCollisions: boolean;
  113620. /**
  113621. * Enable or disable gravity on the camera.
  113622. */
  113623. applyGravity: boolean;
  113624. /**
  113625. * Define the current direction the camera is moving to.
  113626. */
  113627. cameraDirection: Vector3;
  113628. /**
  113629. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113630. * This overrides and empties cameraRotation.
  113631. */
  113632. rotationQuaternion: Quaternion;
  113633. /**
  113634. * Track Roll to maintain the wanted Rolling when looking around.
  113635. */
  113636. _trackRoll: number;
  113637. /**
  113638. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113639. */
  113640. rollCorrect: number;
  113641. /**
  113642. * Mimic a banked turn, Rolling the camera when Yawing.
  113643. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113644. */
  113645. bankedTurn: boolean;
  113646. /**
  113647. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113648. */
  113649. bankedTurnLimit: number;
  113650. /**
  113651. * Value of 0 disables the banked Roll.
  113652. * Value of 1 is equal to the Yaw angle in radians.
  113653. */
  113654. bankedTurnMultiplier: number;
  113655. /**
  113656. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113657. */
  113658. inputs: FlyCameraInputsManager;
  113659. /**
  113660. * Gets the input sensibility for mouse input.
  113661. * Higher values reduce sensitivity.
  113662. */
  113663. get angularSensibility(): number;
  113664. /**
  113665. * Sets the input sensibility for a mouse input.
  113666. * Higher values reduce sensitivity.
  113667. */
  113668. set angularSensibility(value: number);
  113669. /**
  113670. * Get the keys for camera movement forward.
  113671. */
  113672. get keysForward(): number[];
  113673. /**
  113674. * Set the keys for camera movement forward.
  113675. */
  113676. set keysForward(value: number[]);
  113677. /**
  113678. * Get the keys for camera movement backward.
  113679. */
  113680. get keysBackward(): number[];
  113681. set keysBackward(value: number[]);
  113682. /**
  113683. * Get the keys for camera movement up.
  113684. */
  113685. get keysUp(): number[];
  113686. /**
  113687. * Set the keys for camera movement up.
  113688. */
  113689. set keysUp(value: number[]);
  113690. /**
  113691. * Get the keys for camera movement down.
  113692. */
  113693. get keysDown(): number[];
  113694. /**
  113695. * Set the keys for camera movement down.
  113696. */
  113697. set keysDown(value: number[]);
  113698. /**
  113699. * Get the keys for camera movement left.
  113700. */
  113701. get keysLeft(): number[];
  113702. /**
  113703. * Set the keys for camera movement left.
  113704. */
  113705. set keysLeft(value: number[]);
  113706. /**
  113707. * Set the keys for camera movement right.
  113708. */
  113709. get keysRight(): number[];
  113710. /**
  113711. * Set the keys for camera movement right.
  113712. */
  113713. set keysRight(value: number[]);
  113714. /**
  113715. * Event raised when the camera collides with a mesh in the scene.
  113716. */
  113717. onCollide: (collidedMesh: AbstractMesh) => void;
  113718. private _collider;
  113719. private _needMoveForGravity;
  113720. private _oldPosition;
  113721. private _diffPosition;
  113722. private _newPosition;
  113723. /** @hidden */
  113724. _localDirection: Vector3;
  113725. /** @hidden */
  113726. _transformedDirection: Vector3;
  113727. /**
  113728. * Instantiates a FlyCamera.
  113729. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113730. * such as in a 3D Space Shooter or a Flight Simulator.
  113731. * @param name Define the name of the camera in the scene.
  113732. * @param position Define the starting position of the camera in the scene.
  113733. * @param scene Define the scene the camera belongs to.
  113734. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113735. */
  113736. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113737. /**
  113738. * Attach a control to the HTML DOM element.
  113739. * @param element Defines the element that listens to the input events.
  113740. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113741. */
  113742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113743. /**
  113744. * Detach a control from the HTML DOM element.
  113745. * The camera will stop reacting to that input.
  113746. * @param element Defines the element that listens to the input events.
  113747. */
  113748. detachControl(element: HTMLElement): void;
  113749. private _collisionMask;
  113750. /**
  113751. * Get the mask that the camera ignores in collision events.
  113752. */
  113753. get collisionMask(): number;
  113754. /**
  113755. * Set the mask that the camera ignores in collision events.
  113756. */
  113757. set collisionMask(mask: number);
  113758. /** @hidden */
  113759. _collideWithWorld(displacement: Vector3): void;
  113760. /** @hidden */
  113761. private _onCollisionPositionChange;
  113762. /** @hidden */
  113763. _checkInputs(): void;
  113764. /** @hidden */
  113765. _decideIfNeedsToMove(): boolean;
  113766. /** @hidden */
  113767. _updatePosition(): void;
  113768. /**
  113769. * Restore the Roll to its target value at the rate specified.
  113770. * @param rate - Higher means slower restoring.
  113771. * @hidden
  113772. */
  113773. restoreRoll(rate: number): void;
  113774. /**
  113775. * Destroy the camera and release the current resources held by it.
  113776. */
  113777. dispose(): void;
  113778. /**
  113779. * Get the current object class name.
  113780. * @returns the class name.
  113781. */
  113782. getClassName(): string;
  113783. }
  113784. }
  113785. declare module BABYLON {
  113786. /**
  113787. * Listen to keyboard events to control the camera.
  113788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113789. */
  113790. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113791. /**
  113792. * Defines the camera the input is attached to.
  113793. */
  113794. camera: FlyCamera;
  113795. /**
  113796. * The list of keyboard keys used to control the forward move of the camera.
  113797. */
  113798. keysForward: number[];
  113799. /**
  113800. * The list of keyboard keys used to control the backward move of the camera.
  113801. */
  113802. keysBackward: number[];
  113803. /**
  113804. * The list of keyboard keys used to control the forward move of the camera.
  113805. */
  113806. keysUp: number[];
  113807. /**
  113808. * The list of keyboard keys used to control the backward move of the camera.
  113809. */
  113810. keysDown: number[];
  113811. /**
  113812. * The list of keyboard keys used to control the right strafe move of the camera.
  113813. */
  113814. keysRight: number[];
  113815. /**
  113816. * The list of keyboard keys used to control the left strafe move of the camera.
  113817. */
  113818. keysLeft: number[];
  113819. private _keys;
  113820. private _onCanvasBlurObserver;
  113821. private _onKeyboardObserver;
  113822. private _engine;
  113823. private _scene;
  113824. /**
  113825. * Attach the input controls to a specific dom element to get the input from.
  113826. * @param element Defines the element the controls should be listened from
  113827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113828. */
  113829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113830. /**
  113831. * Detach the current controls from the specified dom element.
  113832. * @param element Defines the element to stop listening the inputs from
  113833. */
  113834. detachControl(element: Nullable<HTMLElement>): void;
  113835. /**
  113836. * Gets the class name of the current intput.
  113837. * @returns the class name
  113838. */
  113839. getClassName(): string;
  113840. /** @hidden */
  113841. _onLostFocus(e: FocusEvent): void;
  113842. /**
  113843. * Get the friendly name associated with the input class.
  113844. * @returns the input friendly name
  113845. */
  113846. getSimpleName(): string;
  113847. /**
  113848. * Update the current camera state depending on the inputs that have been used this frame.
  113849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113850. */
  113851. checkInputs(): void;
  113852. }
  113853. }
  113854. declare module BABYLON {
  113855. /**
  113856. * Manage the mouse wheel inputs to control a follow camera.
  113857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113858. */
  113859. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113860. /**
  113861. * Defines the camera the input is attached to.
  113862. */
  113863. camera: FollowCamera;
  113864. /**
  113865. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113866. */
  113867. axisControlRadius: boolean;
  113868. /**
  113869. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113870. */
  113871. axisControlHeight: boolean;
  113872. /**
  113873. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113874. */
  113875. axisControlRotation: boolean;
  113876. /**
  113877. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113878. * relation to mouseWheel events.
  113879. */
  113880. wheelPrecision: number;
  113881. /**
  113882. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113883. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113884. */
  113885. wheelDeltaPercentage: number;
  113886. private _wheel;
  113887. private _observer;
  113888. /**
  113889. * Attach the input controls to a specific dom element to get the input from.
  113890. * @param element Defines the element the controls should be listened from
  113891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113892. */
  113893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113894. /**
  113895. * Detach the current controls from the specified dom element.
  113896. * @param element Defines the element to stop listening the inputs from
  113897. */
  113898. detachControl(element: Nullable<HTMLElement>): void;
  113899. /**
  113900. * Gets the class name of the current intput.
  113901. * @returns the class name
  113902. */
  113903. getClassName(): string;
  113904. /**
  113905. * Get the friendly name associated with the input class.
  113906. * @returns the input friendly name
  113907. */
  113908. getSimpleName(): string;
  113909. }
  113910. }
  113911. declare module BABYLON {
  113912. /**
  113913. * Manage the pointers inputs to control an follow camera.
  113914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113915. */
  113916. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113917. /**
  113918. * Defines the camera the input is attached to.
  113919. */
  113920. camera: FollowCamera;
  113921. /**
  113922. * Gets the class name of the current input.
  113923. * @returns the class name
  113924. */
  113925. getClassName(): string;
  113926. /**
  113927. * Defines the pointer angular sensibility along the X axis or how fast is
  113928. * the camera rotating.
  113929. * A negative number will reverse the axis direction.
  113930. */
  113931. angularSensibilityX: number;
  113932. /**
  113933. * Defines the pointer angular sensibility along the Y axis or how fast is
  113934. * the camera rotating.
  113935. * A negative number will reverse the axis direction.
  113936. */
  113937. angularSensibilityY: number;
  113938. /**
  113939. * Defines the pointer pinch precision or how fast is the camera zooming.
  113940. * A negative number will reverse the axis direction.
  113941. */
  113942. pinchPrecision: number;
  113943. /**
  113944. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113945. * from 0.
  113946. * It defines the percentage of current camera.radius to use as delta when
  113947. * pinch zoom is used.
  113948. */
  113949. pinchDeltaPercentage: number;
  113950. /**
  113951. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113952. */
  113953. axisXControlRadius: boolean;
  113954. /**
  113955. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113956. */
  113957. axisXControlHeight: boolean;
  113958. /**
  113959. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113960. */
  113961. axisXControlRotation: boolean;
  113962. /**
  113963. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113964. */
  113965. axisYControlRadius: boolean;
  113966. /**
  113967. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113968. */
  113969. axisYControlHeight: boolean;
  113970. /**
  113971. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113972. */
  113973. axisYControlRotation: boolean;
  113974. /**
  113975. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113976. */
  113977. axisPinchControlRadius: boolean;
  113978. /**
  113979. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113980. */
  113981. axisPinchControlHeight: boolean;
  113982. /**
  113983. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113984. */
  113985. axisPinchControlRotation: boolean;
  113986. /**
  113987. * Log error messages if basic misconfiguration has occurred.
  113988. */
  113989. warningEnable: boolean;
  113990. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113991. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113992. private _warningCounter;
  113993. private _warning;
  113994. }
  113995. }
  113996. declare module BABYLON {
  113997. /**
  113998. * Default Inputs manager for the FollowCamera.
  113999. * It groups all the default supported inputs for ease of use.
  114000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114001. */
  114002. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114003. /**
  114004. * Instantiates a new FollowCameraInputsManager.
  114005. * @param camera Defines the camera the inputs belong to
  114006. */
  114007. constructor(camera: FollowCamera);
  114008. /**
  114009. * Add keyboard input support to the input manager.
  114010. * @returns the current input manager
  114011. */
  114012. addKeyboard(): FollowCameraInputsManager;
  114013. /**
  114014. * Add mouse wheel input support to the input manager.
  114015. * @returns the current input manager
  114016. */
  114017. addMouseWheel(): FollowCameraInputsManager;
  114018. /**
  114019. * Add pointers input support to the input manager.
  114020. * @returns the current input manager
  114021. */
  114022. addPointers(): FollowCameraInputsManager;
  114023. /**
  114024. * Add orientation input support to the input manager.
  114025. * @returns the current input manager
  114026. */
  114027. addVRDeviceOrientation(): FollowCameraInputsManager;
  114028. }
  114029. }
  114030. declare module BABYLON {
  114031. /**
  114032. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114033. * an arc rotate version arcFollowCamera are available.
  114034. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114035. */
  114036. export class FollowCamera extends TargetCamera {
  114037. /**
  114038. * Distance the follow camera should follow an object at
  114039. */
  114040. radius: number;
  114041. /**
  114042. * Minimum allowed distance of the camera to the axis of rotation
  114043. * (The camera can not get closer).
  114044. * This can help limiting how the Camera is able to move in the scene.
  114045. */
  114046. lowerRadiusLimit: Nullable<number>;
  114047. /**
  114048. * Maximum allowed distance of the camera to the axis of rotation
  114049. * (The camera can not get further).
  114050. * This can help limiting how the Camera is able to move in the scene.
  114051. */
  114052. upperRadiusLimit: Nullable<number>;
  114053. /**
  114054. * Define a rotation offset between the camera and the object it follows
  114055. */
  114056. rotationOffset: number;
  114057. /**
  114058. * Minimum allowed angle to camera position relative to target object.
  114059. * This can help limiting how the Camera is able to move in the scene.
  114060. */
  114061. lowerRotationOffsetLimit: Nullable<number>;
  114062. /**
  114063. * Maximum allowed angle to camera position relative to target object.
  114064. * This can help limiting how the Camera is able to move in the scene.
  114065. */
  114066. upperRotationOffsetLimit: Nullable<number>;
  114067. /**
  114068. * Define a height offset between the camera and the object it follows.
  114069. * It can help following an object from the top (like a car chaing a plane)
  114070. */
  114071. heightOffset: number;
  114072. /**
  114073. * Minimum allowed height of camera position relative to target object.
  114074. * This can help limiting how the Camera is able to move in the scene.
  114075. */
  114076. lowerHeightOffsetLimit: Nullable<number>;
  114077. /**
  114078. * Maximum allowed height of camera position relative to target object.
  114079. * This can help limiting how the Camera is able to move in the scene.
  114080. */
  114081. upperHeightOffsetLimit: Nullable<number>;
  114082. /**
  114083. * Define how fast the camera can accelerate to follow it s target.
  114084. */
  114085. cameraAcceleration: number;
  114086. /**
  114087. * Define the speed limit of the camera following an object.
  114088. */
  114089. maxCameraSpeed: number;
  114090. /**
  114091. * Define the target of the camera.
  114092. */
  114093. lockedTarget: Nullable<AbstractMesh>;
  114094. /**
  114095. * Defines the input associated with the camera.
  114096. */
  114097. inputs: FollowCameraInputsManager;
  114098. /**
  114099. * Instantiates the follow camera.
  114100. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114101. * @param name Define the name of the camera in the scene
  114102. * @param position Define the position of the camera
  114103. * @param scene Define the scene the camera belong to
  114104. * @param lockedTarget Define the target of the camera
  114105. */
  114106. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  114107. private _follow;
  114108. /**
  114109. * Attached controls to the current camera.
  114110. * @param element Defines the element the controls should be listened from
  114111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114112. */
  114113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114114. /**
  114115. * Detach the current controls from the camera.
  114116. * The camera will stop reacting to inputs.
  114117. * @param element Defines the element to stop listening the inputs from
  114118. */
  114119. detachControl(element: HTMLElement): void;
  114120. /** @hidden */
  114121. _checkInputs(): void;
  114122. private _checkLimits;
  114123. /**
  114124. * Gets the camera class name.
  114125. * @returns the class name
  114126. */
  114127. getClassName(): string;
  114128. }
  114129. /**
  114130. * Arc Rotate version of the follow camera.
  114131. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  114132. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114133. */
  114134. export class ArcFollowCamera extends TargetCamera {
  114135. /** The longitudinal angle of the camera */
  114136. alpha: number;
  114137. /** The latitudinal angle of the camera */
  114138. beta: number;
  114139. /** The radius of the camera from its target */
  114140. radius: number;
  114141. /** Define the camera target (the messh it should follow) */
  114142. target: Nullable<AbstractMesh>;
  114143. private _cartesianCoordinates;
  114144. /**
  114145. * Instantiates a new ArcFollowCamera
  114146. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114147. * @param name Define the name of the camera
  114148. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  114149. * @param beta Define the rotation angle of the camera around the elevation axis
  114150. * @param radius Define the radius of the camera from its target point
  114151. * @param target Define the target of the camera
  114152. * @param scene Define the scene the camera belongs to
  114153. */
  114154. constructor(name: string,
  114155. /** The longitudinal angle of the camera */
  114156. alpha: number,
  114157. /** The latitudinal angle of the camera */
  114158. beta: number,
  114159. /** The radius of the camera from its target */
  114160. radius: number,
  114161. /** Define the camera target (the messh it should follow) */
  114162. target: Nullable<AbstractMesh>, scene: Scene);
  114163. private _follow;
  114164. /** @hidden */
  114165. _checkInputs(): void;
  114166. /**
  114167. * Returns the class name of the object.
  114168. * It is mostly used internally for serialization purposes.
  114169. */
  114170. getClassName(): string;
  114171. }
  114172. }
  114173. declare module BABYLON {
  114174. /**
  114175. * Manage the keyboard inputs to control the movement of a follow camera.
  114176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114177. */
  114178. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  114179. /**
  114180. * Defines the camera the input is attached to.
  114181. */
  114182. camera: FollowCamera;
  114183. /**
  114184. * Defines the list of key codes associated with the up action (increase heightOffset)
  114185. */
  114186. keysHeightOffsetIncr: number[];
  114187. /**
  114188. * Defines the list of key codes associated with the down action (decrease heightOffset)
  114189. */
  114190. keysHeightOffsetDecr: number[];
  114191. /**
  114192. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  114193. */
  114194. keysHeightOffsetModifierAlt: boolean;
  114195. /**
  114196. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  114197. */
  114198. keysHeightOffsetModifierCtrl: boolean;
  114199. /**
  114200. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  114201. */
  114202. keysHeightOffsetModifierShift: boolean;
  114203. /**
  114204. * Defines the list of key codes associated with the left action (increase rotationOffset)
  114205. */
  114206. keysRotationOffsetIncr: number[];
  114207. /**
  114208. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  114209. */
  114210. keysRotationOffsetDecr: number[];
  114211. /**
  114212. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  114213. */
  114214. keysRotationOffsetModifierAlt: boolean;
  114215. /**
  114216. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  114217. */
  114218. keysRotationOffsetModifierCtrl: boolean;
  114219. /**
  114220. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  114221. */
  114222. keysRotationOffsetModifierShift: boolean;
  114223. /**
  114224. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  114225. */
  114226. keysRadiusIncr: number[];
  114227. /**
  114228. * Defines the list of key codes associated with the zoom-out action (increase radius)
  114229. */
  114230. keysRadiusDecr: number[];
  114231. /**
  114232. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  114233. */
  114234. keysRadiusModifierAlt: boolean;
  114235. /**
  114236. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  114237. */
  114238. keysRadiusModifierCtrl: boolean;
  114239. /**
  114240. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  114241. */
  114242. keysRadiusModifierShift: boolean;
  114243. /**
  114244. * Defines the rate of change of heightOffset.
  114245. */
  114246. heightSensibility: number;
  114247. /**
  114248. * Defines the rate of change of rotationOffset.
  114249. */
  114250. rotationSensibility: number;
  114251. /**
  114252. * Defines the rate of change of radius.
  114253. */
  114254. radiusSensibility: number;
  114255. private _keys;
  114256. private _ctrlPressed;
  114257. private _altPressed;
  114258. private _shiftPressed;
  114259. private _onCanvasBlurObserver;
  114260. private _onKeyboardObserver;
  114261. private _engine;
  114262. private _scene;
  114263. /**
  114264. * Attach the input controls to a specific dom element to get the input from.
  114265. * @param element Defines the element the controls should be listened from
  114266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114267. */
  114268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114269. /**
  114270. * Detach the current controls from the specified dom element.
  114271. * @param element Defines the element to stop listening the inputs from
  114272. */
  114273. detachControl(element: Nullable<HTMLElement>): void;
  114274. /**
  114275. * Update the current camera state depending on the inputs that have been used this frame.
  114276. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114277. */
  114278. checkInputs(): void;
  114279. /**
  114280. * Gets the class name of the current input.
  114281. * @returns the class name
  114282. */
  114283. getClassName(): string;
  114284. /**
  114285. * Get the friendly name associated with the input class.
  114286. * @returns the input friendly name
  114287. */
  114288. getSimpleName(): string;
  114289. /**
  114290. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114291. * allow modification of the heightOffset value.
  114292. */
  114293. private _modifierHeightOffset;
  114294. /**
  114295. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114296. * allow modification of the rotationOffset value.
  114297. */
  114298. private _modifierRotationOffset;
  114299. /**
  114300. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114301. * allow modification of the radius value.
  114302. */
  114303. private _modifierRadius;
  114304. }
  114305. }
  114306. declare module BABYLON {
  114307. interface FreeCameraInputsManager {
  114308. /**
  114309. * @hidden
  114310. */
  114311. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  114312. /**
  114313. * Add orientation input support to the input manager.
  114314. * @returns the current input manager
  114315. */
  114316. addDeviceOrientation(): FreeCameraInputsManager;
  114317. }
  114318. /**
  114319. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  114320. * Screen rotation is taken into account.
  114321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114322. */
  114323. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  114324. private _camera;
  114325. private _screenOrientationAngle;
  114326. private _constantTranform;
  114327. private _screenQuaternion;
  114328. private _alpha;
  114329. private _beta;
  114330. private _gamma;
  114331. /**
  114332. * Can be used to detect if a device orientation sensor is available on a device
  114333. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  114334. * @returns a promise that will resolve on orientation change
  114335. */
  114336. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  114337. /**
  114338. * @hidden
  114339. */
  114340. _onDeviceOrientationChangedObservable: Observable<void>;
  114341. /**
  114342. * Instantiates a new input
  114343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114344. */
  114345. constructor();
  114346. /**
  114347. * Define the camera controlled by the input.
  114348. */
  114349. get camera(): FreeCamera;
  114350. set camera(camera: FreeCamera);
  114351. /**
  114352. * Attach the input controls to a specific dom element to get the input from.
  114353. * @param element Defines the element the controls should be listened from
  114354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114355. */
  114356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114357. private _orientationChanged;
  114358. private _deviceOrientation;
  114359. /**
  114360. * Detach the current controls from the specified dom element.
  114361. * @param element Defines the element to stop listening the inputs from
  114362. */
  114363. detachControl(element: Nullable<HTMLElement>): void;
  114364. /**
  114365. * Update the current camera state depending on the inputs that have been used this frame.
  114366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114367. */
  114368. checkInputs(): void;
  114369. /**
  114370. * Gets the class name of the current intput.
  114371. * @returns the class name
  114372. */
  114373. getClassName(): string;
  114374. /**
  114375. * Get the friendly name associated with the input class.
  114376. * @returns the input friendly name
  114377. */
  114378. getSimpleName(): string;
  114379. }
  114380. }
  114381. declare module BABYLON {
  114382. /**
  114383. * Manage the gamepad inputs to control a free camera.
  114384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114385. */
  114386. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  114387. /**
  114388. * Define the camera the input is attached to.
  114389. */
  114390. camera: FreeCamera;
  114391. /**
  114392. * Define the Gamepad controlling the input
  114393. */
  114394. gamepad: Nullable<Gamepad>;
  114395. /**
  114396. * Defines the gamepad rotation sensiblity.
  114397. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114398. */
  114399. gamepadAngularSensibility: number;
  114400. /**
  114401. * Defines the gamepad move sensiblity.
  114402. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114403. */
  114404. gamepadMoveSensibility: number;
  114405. private _yAxisScale;
  114406. /**
  114407. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114408. */
  114409. get invertYAxis(): boolean;
  114410. set invertYAxis(value: boolean);
  114411. private _onGamepadConnectedObserver;
  114412. private _onGamepadDisconnectedObserver;
  114413. private _cameraTransform;
  114414. private _deltaTransform;
  114415. private _vector3;
  114416. private _vector2;
  114417. /**
  114418. * Attach the input controls to a specific dom element to get the input from.
  114419. * @param element Defines the element the controls should be listened from
  114420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114421. */
  114422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114423. /**
  114424. * Detach the current controls from the specified dom element.
  114425. * @param element Defines the element to stop listening the inputs from
  114426. */
  114427. detachControl(element: Nullable<HTMLElement>): void;
  114428. /**
  114429. * Update the current camera state depending on the inputs that have been used this frame.
  114430. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114431. */
  114432. checkInputs(): void;
  114433. /**
  114434. * Gets the class name of the current intput.
  114435. * @returns the class name
  114436. */
  114437. getClassName(): string;
  114438. /**
  114439. * Get the friendly name associated with the input class.
  114440. * @returns the input friendly name
  114441. */
  114442. getSimpleName(): string;
  114443. }
  114444. }
  114445. declare module BABYLON {
  114446. /**
  114447. * Defines the potential axis of a Joystick
  114448. */
  114449. export enum JoystickAxis {
  114450. /** X axis */
  114451. X = 0,
  114452. /** Y axis */
  114453. Y = 1,
  114454. /** Z axis */
  114455. Z = 2
  114456. }
  114457. /**
  114458. * Class used to define virtual joystick (used in touch mode)
  114459. */
  114460. export class VirtualJoystick {
  114461. /**
  114462. * Gets or sets a boolean indicating that left and right values must be inverted
  114463. */
  114464. reverseLeftRight: boolean;
  114465. /**
  114466. * Gets or sets a boolean indicating that up and down values must be inverted
  114467. */
  114468. reverseUpDown: boolean;
  114469. /**
  114470. * Gets the offset value for the position (ie. the change of the position value)
  114471. */
  114472. deltaPosition: Vector3;
  114473. /**
  114474. * Gets a boolean indicating if the virtual joystick was pressed
  114475. */
  114476. pressed: boolean;
  114477. /**
  114478. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114479. */
  114480. static Canvas: Nullable<HTMLCanvasElement>;
  114481. private static _globalJoystickIndex;
  114482. private static vjCanvasContext;
  114483. private static vjCanvasWidth;
  114484. private static vjCanvasHeight;
  114485. private static halfWidth;
  114486. private _action;
  114487. private _axisTargetedByLeftAndRight;
  114488. private _axisTargetedByUpAndDown;
  114489. private _joystickSensibility;
  114490. private _inversedSensibility;
  114491. private _joystickPointerID;
  114492. private _joystickColor;
  114493. private _joystickPointerPos;
  114494. private _joystickPreviousPointerPos;
  114495. private _joystickPointerStartPos;
  114496. private _deltaJoystickVector;
  114497. private _leftJoystick;
  114498. private _touches;
  114499. private _onPointerDownHandlerRef;
  114500. private _onPointerMoveHandlerRef;
  114501. private _onPointerUpHandlerRef;
  114502. private _onResize;
  114503. /**
  114504. * Creates a new virtual joystick
  114505. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114506. */
  114507. constructor(leftJoystick?: boolean);
  114508. /**
  114509. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114510. * @param newJoystickSensibility defines the new sensibility
  114511. */
  114512. setJoystickSensibility(newJoystickSensibility: number): void;
  114513. private _onPointerDown;
  114514. private _onPointerMove;
  114515. private _onPointerUp;
  114516. /**
  114517. * Change the color of the virtual joystick
  114518. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114519. */
  114520. setJoystickColor(newColor: string): void;
  114521. /**
  114522. * Defines a callback to call when the joystick is touched
  114523. * @param action defines the callback
  114524. */
  114525. setActionOnTouch(action: () => any): void;
  114526. /**
  114527. * Defines which axis you'd like to control for left & right
  114528. * @param axis defines the axis to use
  114529. */
  114530. setAxisForLeftRight(axis: JoystickAxis): void;
  114531. /**
  114532. * Defines which axis you'd like to control for up & down
  114533. * @param axis defines the axis to use
  114534. */
  114535. setAxisForUpDown(axis: JoystickAxis): void;
  114536. private _drawVirtualJoystick;
  114537. /**
  114538. * Release internal HTML canvas
  114539. */
  114540. releaseCanvas(): void;
  114541. }
  114542. }
  114543. declare module BABYLON {
  114544. interface FreeCameraInputsManager {
  114545. /**
  114546. * Add virtual joystick input support to the input manager.
  114547. * @returns the current input manager
  114548. */
  114549. addVirtualJoystick(): FreeCameraInputsManager;
  114550. }
  114551. /**
  114552. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114554. */
  114555. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114556. /**
  114557. * Defines the camera the input is attached to.
  114558. */
  114559. camera: FreeCamera;
  114560. private _leftjoystick;
  114561. private _rightjoystick;
  114562. /**
  114563. * Gets the left stick of the virtual joystick.
  114564. * @returns The virtual Joystick
  114565. */
  114566. getLeftJoystick(): VirtualJoystick;
  114567. /**
  114568. * Gets the right stick of the virtual joystick.
  114569. * @returns The virtual Joystick
  114570. */
  114571. getRightJoystick(): VirtualJoystick;
  114572. /**
  114573. * Update the current camera state depending on the inputs that have been used this frame.
  114574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114575. */
  114576. checkInputs(): void;
  114577. /**
  114578. * Attach the input controls to a specific dom element to get the input from.
  114579. * @param element Defines the element the controls should be listened from
  114580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114581. */
  114582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114583. /**
  114584. * Detach the current controls from the specified dom element.
  114585. * @param element Defines the element to stop listening the inputs from
  114586. */
  114587. detachControl(element: Nullable<HTMLElement>): void;
  114588. /**
  114589. * Gets the class name of the current intput.
  114590. * @returns the class name
  114591. */
  114592. getClassName(): string;
  114593. /**
  114594. * Get the friendly name associated with the input class.
  114595. * @returns the input friendly name
  114596. */
  114597. getSimpleName(): string;
  114598. }
  114599. }
  114600. declare module BABYLON {
  114601. /**
  114602. * This represents a FPS type of camera controlled by touch.
  114603. * This is like a universal camera minus the Gamepad controls.
  114604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114605. */
  114606. export class TouchCamera extends FreeCamera {
  114607. /**
  114608. * Defines the touch sensibility for rotation.
  114609. * The higher the faster.
  114610. */
  114611. get touchAngularSensibility(): number;
  114612. set touchAngularSensibility(value: number);
  114613. /**
  114614. * Defines the touch sensibility for move.
  114615. * The higher the faster.
  114616. */
  114617. get touchMoveSensibility(): number;
  114618. set touchMoveSensibility(value: number);
  114619. /**
  114620. * Instantiates a new touch camera.
  114621. * This represents a FPS type of camera controlled by touch.
  114622. * This is like a universal camera minus the Gamepad controls.
  114623. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114624. * @param name Define the name of the camera in the scene
  114625. * @param position Define the start position of the camera in the scene
  114626. * @param scene Define the scene the camera belongs to
  114627. */
  114628. constructor(name: string, position: Vector3, scene: Scene);
  114629. /**
  114630. * Gets the current object class name.
  114631. * @return the class name
  114632. */
  114633. getClassName(): string;
  114634. /** @hidden */
  114635. _setupInputs(): void;
  114636. }
  114637. }
  114638. declare module BABYLON {
  114639. /**
  114640. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114641. * being tilted forward or back and left or right.
  114642. */
  114643. export class DeviceOrientationCamera extends FreeCamera {
  114644. private _initialQuaternion;
  114645. private _quaternionCache;
  114646. private _tmpDragQuaternion;
  114647. private _disablePointerInputWhenUsingDeviceOrientation;
  114648. /**
  114649. * Creates a new device orientation camera
  114650. * @param name The name of the camera
  114651. * @param position The start position camera
  114652. * @param scene The scene the camera belongs to
  114653. */
  114654. constructor(name: string, position: Vector3, scene: Scene);
  114655. /**
  114656. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114657. */
  114658. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114659. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114660. private _dragFactor;
  114661. /**
  114662. * Enabled turning on the y axis when the orientation sensor is active
  114663. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114664. */
  114665. enableHorizontalDragging(dragFactor?: number): void;
  114666. /**
  114667. * Gets the current instance class name ("DeviceOrientationCamera").
  114668. * This helps avoiding instanceof at run time.
  114669. * @returns the class name
  114670. */
  114671. getClassName(): string;
  114672. /**
  114673. * @hidden
  114674. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114675. */
  114676. _checkInputs(): void;
  114677. /**
  114678. * Reset the camera to its default orientation on the specified axis only.
  114679. * @param axis The axis to reset
  114680. */
  114681. resetToCurrentRotation(axis?: Axis): void;
  114682. }
  114683. }
  114684. declare module BABYLON {
  114685. /**
  114686. * Defines supported buttons for XBox360 compatible gamepads
  114687. */
  114688. export enum Xbox360Button {
  114689. /** A */
  114690. A = 0,
  114691. /** B */
  114692. B = 1,
  114693. /** X */
  114694. X = 2,
  114695. /** Y */
  114696. Y = 3,
  114697. /** Left button */
  114698. LB = 4,
  114699. /** Right button */
  114700. RB = 5,
  114701. /** Back */
  114702. Back = 8,
  114703. /** Start */
  114704. Start = 9,
  114705. /** Left stick */
  114706. LeftStick = 10,
  114707. /** Right stick */
  114708. RightStick = 11
  114709. }
  114710. /** Defines values for XBox360 DPad */
  114711. export enum Xbox360Dpad {
  114712. /** Up */
  114713. Up = 12,
  114714. /** Down */
  114715. Down = 13,
  114716. /** Left */
  114717. Left = 14,
  114718. /** Right */
  114719. Right = 15
  114720. }
  114721. /**
  114722. * Defines a XBox360 gamepad
  114723. */
  114724. export class Xbox360Pad extends Gamepad {
  114725. private _leftTrigger;
  114726. private _rightTrigger;
  114727. private _onlefttriggerchanged;
  114728. private _onrighttriggerchanged;
  114729. private _onbuttondown;
  114730. private _onbuttonup;
  114731. private _ondpaddown;
  114732. private _ondpadup;
  114733. /** Observable raised when a button is pressed */
  114734. onButtonDownObservable: Observable<Xbox360Button>;
  114735. /** Observable raised when a button is released */
  114736. onButtonUpObservable: Observable<Xbox360Button>;
  114737. /** Observable raised when a pad is pressed */
  114738. onPadDownObservable: Observable<Xbox360Dpad>;
  114739. /** Observable raised when a pad is released */
  114740. onPadUpObservable: Observable<Xbox360Dpad>;
  114741. private _buttonA;
  114742. private _buttonB;
  114743. private _buttonX;
  114744. private _buttonY;
  114745. private _buttonBack;
  114746. private _buttonStart;
  114747. private _buttonLB;
  114748. private _buttonRB;
  114749. private _buttonLeftStick;
  114750. private _buttonRightStick;
  114751. private _dPadUp;
  114752. private _dPadDown;
  114753. private _dPadLeft;
  114754. private _dPadRight;
  114755. private _isXboxOnePad;
  114756. /**
  114757. * Creates a new XBox360 gamepad object
  114758. * @param id defines the id of this gamepad
  114759. * @param index defines its index
  114760. * @param gamepad defines the internal HTML gamepad object
  114761. * @param xboxOne defines if it is a XBox One gamepad
  114762. */
  114763. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114764. /**
  114765. * Defines the callback to call when left trigger is pressed
  114766. * @param callback defines the callback to use
  114767. */
  114768. onlefttriggerchanged(callback: (value: number) => void): void;
  114769. /**
  114770. * Defines the callback to call when right trigger is pressed
  114771. * @param callback defines the callback to use
  114772. */
  114773. onrighttriggerchanged(callback: (value: number) => void): void;
  114774. /**
  114775. * Gets the left trigger value
  114776. */
  114777. get leftTrigger(): number;
  114778. /**
  114779. * Sets the left trigger value
  114780. */
  114781. set leftTrigger(newValue: number);
  114782. /**
  114783. * Gets the right trigger value
  114784. */
  114785. get rightTrigger(): number;
  114786. /**
  114787. * Sets the right trigger value
  114788. */
  114789. set rightTrigger(newValue: number);
  114790. /**
  114791. * Defines the callback to call when a button is pressed
  114792. * @param callback defines the callback to use
  114793. */
  114794. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114795. /**
  114796. * Defines the callback to call when a button is released
  114797. * @param callback defines the callback to use
  114798. */
  114799. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114800. /**
  114801. * Defines the callback to call when a pad is pressed
  114802. * @param callback defines the callback to use
  114803. */
  114804. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114805. /**
  114806. * Defines the callback to call when a pad is released
  114807. * @param callback defines the callback to use
  114808. */
  114809. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114810. private _setButtonValue;
  114811. private _setDPadValue;
  114812. /**
  114813. * Gets the value of the `A` button
  114814. */
  114815. get buttonA(): number;
  114816. /**
  114817. * Sets the value of the `A` button
  114818. */
  114819. set buttonA(value: number);
  114820. /**
  114821. * Gets the value of the `B` button
  114822. */
  114823. get buttonB(): number;
  114824. /**
  114825. * Sets the value of the `B` button
  114826. */
  114827. set buttonB(value: number);
  114828. /**
  114829. * Gets the value of the `X` button
  114830. */
  114831. get buttonX(): number;
  114832. /**
  114833. * Sets the value of the `X` button
  114834. */
  114835. set buttonX(value: number);
  114836. /**
  114837. * Gets the value of the `Y` button
  114838. */
  114839. get buttonY(): number;
  114840. /**
  114841. * Sets the value of the `Y` button
  114842. */
  114843. set buttonY(value: number);
  114844. /**
  114845. * Gets the value of the `Start` button
  114846. */
  114847. get buttonStart(): number;
  114848. /**
  114849. * Sets the value of the `Start` button
  114850. */
  114851. set buttonStart(value: number);
  114852. /**
  114853. * Gets the value of the `Back` button
  114854. */
  114855. get buttonBack(): number;
  114856. /**
  114857. * Sets the value of the `Back` button
  114858. */
  114859. set buttonBack(value: number);
  114860. /**
  114861. * Gets the value of the `Left` button
  114862. */
  114863. get buttonLB(): number;
  114864. /**
  114865. * Sets the value of the `Left` button
  114866. */
  114867. set buttonLB(value: number);
  114868. /**
  114869. * Gets the value of the `Right` button
  114870. */
  114871. get buttonRB(): number;
  114872. /**
  114873. * Sets the value of the `Right` button
  114874. */
  114875. set buttonRB(value: number);
  114876. /**
  114877. * Gets the value of the Left joystick
  114878. */
  114879. get buttonLeftStick(): number;
  114880. /**
  114881. * Sets the value of the Left joystick
  114882. */
  114883. set buttonLeftStick(value: number);
  114884. /**
  114885. * Gets the value of the Right joystick
  114886. */
  114887. get buttonRightStick(): number;
  114888. /**
  114889. * Sets the value of the Right joystick
  114890. */
  114891. set buttonRightStick(value: number);
  114892. /**
  114893. * Gets the value of D-pad up
  114894. */
  114895. get dPadUp(): number;
  114896. /**
  114897. * Sets the value of D-pad up
  114898. */
  114899. set dPadUp(value: number);
  114900. /**
  114901. * Gets the value of D-pad down
  114902. */
  114903. get dPadDown(): number;
  114904. /**
  114905. * Sets the value of D-pad down
  114906. */
  114907. set dPadDown(value: number);
  114908. /**
  114909. * Gets the value of D-pad left
  114910. */
  114911. get dPadLeft(): number;
  114912. /**
  114913. * Sets the value of D-pad left
  114914. */
  114915. set dPadLeft(value: number);
  114916. /**
  114917. * Gets the value of D-pad right
  114918. */
  114919. get dPadRight(): number;
  114920. /**
  114921. * Sets the value of D-pad right
  114922. */
  114923. set dPadRight(value: number);
  114924. /**
  114925. * Force the gamepad to synchronize with device values
  114926. */
  114927. update(): void;
  114928. /**
  114929. * Disposes the gamepad
  114930. */
  114931. dispose(): void;
  114932. }
  114933. }
  114934. declare module BABYLON {
  114935. /**
  114936. * Defines supported buttons for DualShock compatible gamepads
  114937. */
  114938. export enum DualShockButton {
  114939. /** Cross */
  114940. Cross = 0,
  114941. /** Circle */
  114942. Circle = 1,
  114943. /** Square */
  114944. Square = 2,
  114945. /** Triangle */
  114946. Triangle = 3,
  114947. /** L1 */
  114948. L1 = 4,
  114949. /** R1 */
  114950. R1 = 5,
  114951. /** Share */
  114952. Share = 8,
  114953. /** Options */
  114954. Options = 9,
  114955. /** Left stick */
  114956. LeftStick = 10,
  114957. /** Right stick */
  114958. RightStick = 11
  114959. }
  114960. /** Defines values for DualShock DPad */
  114961. export enum DualShockDpad {
  114962. /** Up */
  114963. Up = 12,
  114964. /** Down */
  114965. Down = 13,
  114966. /** Left */
  114967. Left = 14,
  114968. /** Right */
  114969. Right = 15
  114970. }
  114971. /**
  114972. * Defines a DualShock gamepad
  114973. */
  114974. export class DualShockPad extends Gamepad {
  114975. private _leftTrigger;
  114976. private _rightTrigger;
  114977. private _onlefttriggerchanged;
  114978. private _onrighttriggerchanged;
  114979. private _onbuttondown;
  114980. private _onbuttonup;
  114981. private _ondpaddown;
  114982. private _ondpadup;
  114983. /** Observable raised when a button is pressed */
  114984. onButtonDownObservable: Observable<DualShockButton>;
  114985. /** Observable raised when a button is released */
  114986. onButtonUpObservable: Observable<DualShockButton>;
  114987. /** Observable raised when a pad is pressed */
  114988. onPadDownObservable: Observable<DualShockDpad>;
  114989. /** Observable raised when a pad is released */
  114990. onPadUpObservable: Observable<DualShockDpad>;
  114991. private _buttonCross;
  114992. private _buttonCircle;
  114993. private _buttonSquare;
  114994. private _buttonTriangle;
  114995. private _buttonShare;
  114996. private _buttonOptions;
  114997. private _buttonL1;
  114998. private _buttonR1;
  114999. private _buttonLeftStick;
  115000. private _buttonRightStick;
  115001. private _dPadUp;
  115002. private _dPadDown;
  115003. private _dPadLeft;
  115004. private _dPadRight;
  115005. /**
  115006. * Creates a new DualShock gamepad object
  115007. * @param id defines the id of this gamepad
  115008. * @param index defines its index
  115009. * @param gamepad defines the internal HTML gamepad object
  115010. */
  115011. constructor(id: string, index: number, gamepad: any);
  115012. /**
  115013. * Defines the callback to call when left trigger is pressed
  115014. * @param callback defines the callback to use
  115015. */
  115016. onlefttriggerchanged(callback: (value: number) => void): void;
  115017. /**
  115018. * Defines the callback to call when right trigger is pressed
  115019. * @param callback defines the callback to use
  115020. */
  115021. onrighttriggerchanged(callback: (value: number) => void): void;
  115022. /**
  115023. * Gets the left trigger value
  115024. */
  115025. get leftTrigger(): number;
  115026. /**
  115027. * Sets the left trigger value
  115028. */
  115029. set leftTrigger(newValue: number);
  115030. /**
  115031. * Gets the right trigger value
  115032. */
  115033. get rightTrigger(): number;
  115034. /**
  115035. * Sets the right trigger value
  115036. */
  115037. set rightTrigger(newValue: number);
  115038. /**
  115039. * Defines the callback to call when a button is pressed
  115040. * @param callback defines the callback to use
  115041. */
  115042. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115043. /**
  115044. * Defines the callback to call when a button is released
  115045. * @param callback defines the callback to use
  115046. */
  115047. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115048. /**
  115049. * Defines the callback to call when a pad is pressed
  115050. * @param callback defines the callback to use
  115051. */
  115052. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115053. /**
  115054. * Defines the callback to call when a pad is released
  115055. * @param callback defines the callback to use
  115056. */
  115057. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115058. private _setButtonValue;
  115059. private _setDPadValue;
  115060. /**
  115061. * Gets the value of the `Cross` button
  115062. */
  115063. get buttonCross(): number;
  115064. /**
  115065. * Sets the value of the `Cross` button
  115066. */
  115067. set buttonCross(value: number);
  115068. /**
  115069. * Gets the value of the `Circle` button
  115070. */
  115071. get buttonCircle(): number;
  115072. /**
  115073. * Sets the value of the `Circle` button
  115074. */
  115075. set buttonCircle(value: number);
  115076. /**
  115077. * Gets the value of the `Square` button
  115078. */
  115079. get buttonSquare(): number;
  115080. /**
  115081. * Sets the value of the `Square` button
  115082. */
  115083. set buttonSquare(value: number);
  115084. /**
  115085. * Gets the value of the `Triangle` button
  115086. */
  115087. get buttonTriangle(): number;
  115088. /**
  115089. * Sets the value of the `Triangle` button
  115090. */
  115091. set buttonTriangle(value: number);
  115092. /**
  115093. * Gets the value of the `Options` button
  115094. */
  115095. get buttonOptions(): number;
  115096. /**
  115097. * Sets the value of the `Options` button
  115098. */
  115099. set buttonOptions(value: number);
  115100. /**
  115101. * Gets the value of the `Share` button
  115102. */
  115103. get buttonShare(): number;
  115104. /**
  115105. * Sets the value of the `Share` button
  115106. */
  115107. set buttonShare(value: number);
  115108. /**
  115109. * Gets the value of the `L1` button
  115110. */
  115111. get buttonL1(): number;
  115112. /**
  115113. * Sets the value of the `L1` button
  115114. */
  115115. set buttonL1(value: number);
  115116. /**
  115117. * Gets the value of the `R1` button
  115118. */
  115119. get buttonR1(): number;
  115120. /**
  115121. * Sets the value of the `R1` button
  115122. */
  115123. set buttonR1(value: number);
  115124. /**
  115125. * Gets the value of the Left joystick
  115126. */
  115127. get buttonLeftStick(): number;
  115128. /**
  115129. * Sets the value of the Left joystick
  115130. */
  115131. set buttonLeftStick(value: number);
  115132. /**
  115133. * Gets the value of the Right joystick
  115134. */
  115135. get buttonRightStick(): number;
  115136. /**
  115137. * Sets the value of the Right joystick
  115138. */
  115139. set buttonRightStick(value: number);
  115140. /**
  115141. * Gets the value of D-pad up
  115142. */
  115143. get dPadUp(): number;
  115144. /**
  115145. * Sets the value of D-pad up
  115146. */
  115147. set dPadUp(value: number);
  115148. /**
  115149. * Gets the value of D-pad down
  115150. */
  115151. get dPadDown(): number;
  115152. /**
  115153. * Sets the value of D-pad down
  115154. */
  115155. set dPadDown(value: number);
  115156. /**
  115157. * Gets the value of D-pad left
  115158. */
  115159. get dPadLeft(): number;
  115160. /**
  115161. * Sets the value of D-pad left
  115162. */
  115163. set dPadLeft(value: number);
  115164. /**
  115165. * Gets the value of D-pad right
  115166. */
  115167. get dPadRight(): number;
  115168. /**
  115169. * Sets the value of D-pad right
  115170. */
  115171. set dPadRight(value: number);
  115172. /**
  115173. * Force the gamepad to synchronize with device values
  115174. */
  115175. update(): void;
  115176. /**
  115177. * Disposes the gamepad
  115178. */
  115179. dispose(): void;
  115180. }
  115181. }
  115182. declare module BABYLON {
  115183. /**
  115184. * Manager for handling gamepads
  115185. */
  115186. export class GamepadManager {
  115187. private _scene?;
  115188. private _babylonGamepads;
  115189. private _oneGamepadConnected;
  115190. /** @hidden */
  115191. _isMonitoring: boolean;
  115192. private _gamepadEventSupported;
  115193. private _gamepadSupport?;
  115194. /**
  115195. * observable to be triggered when the gamepad controller has been connected
  115196. */
  115197. onGamepadConnectedObservable: Observable<Gamepad>;
  115198. /**
  115199. * observable to be triggered when the gamepad controller has been disconnected
  115200. */
  115201. onGamepadDisconnectedObservable: Observable<Gamepad>;
  115202. private _onGamepadConnectedEvent;
  115203. private _onGamepadDisconnectedEvent;
  115204. /**
  115205. * Initializes the gamepad manager
  115206. * @param _scene BabylonJS scene
  115207. */
  115208. constructor(_scene?: Scene | undefined);
  115209. /**
  115210. * The gamepads in the game pad manager
  115211. */
  115212. get gamepads(): Gamepad[];
  115213. /**
  115214. * Get the gamepad controllers based on type
  115215. * @param type The type of gamepad controller
  115216. * @returns Nullable gamepad
  115217. */
  115218. getGamepadByType(type?: number): Nullable<Gamepad>;
  115219. /**
  115220. * Disposes the gamepad manager
  115221. */
  115222. dispose(): void;
  115223. private _addNewGamepad;
  115224. private _startMonitoringGamepads;
  115225. private _stopMonitoringGamepads;
  115226. /** @hidden */
  115227. _checkGamepadsStatus(): void;
  115228. private _updateGamepadObjects;
  115229. }
  115230. }
  115231. declare module BABYLON {
  115232. interface Scene {
  115233. /** @hidden */
  115234. _gamepadManager: Nullable<GamepadManager>;
  115235. /**
  115236. * Gets the gamepad manager associated with the scene
  115237. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  115238. */
  115239. gamepadManager: GamepadManager;
  115240. }
  115241. /**
  115242. * Interface representing a free camera inputs manager
  115243. */
  115244. interface FreeCameraInputsManager {
  115245. /**
  115246. * Adds gamepad input support to the FreeCameraInputsManager.
  115247. * @returns the FreeCameraInputsManager
  115248. */
  115249. addGamepad(): FreeCameraInputsManager;
  115250. }
  115251. /**
  115252. * Interface representing an arc rotate camera inputs manager
  115253. */
  115254. interface ArcRotateCameraInputsManager {
  115255. /**
  115256. * Adds gamepad input support to the ArcRotateCamera InputManager.
  115257. * @returns the camera inputs manager
  115258. */
  115259. addGamepad(): ArcRotateCameraInputsManager;
  115260. }
  115261. /**
  115262. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  115263. */
  115264. export class GamepadSystemSceneComponent implements ISceneComponent {
  115265. /**
  115266. * The component name helpfull to identify the component in the list of scene components.
  115267. */
  115268. readonly name: string;
  115269. /**
  115270. * The scene the component belongs to.
  115271. */
  115272. scene: Scene;
  115273. /**
  115274. * Creates a new instance of the component for the given scene
  115275. * @param scene Defines the scene to register the component in
  115276. */
  115277. constructor(scene: Scene);
  115278. /**
  115279. * Registers the component in a given scene
  115280. */
  115281. register(): void;
  115282. /**
  115283. * Rebuilds the elements related to this component in case of
  115284. * context lost for instance.
  115285. */
  115286. rebuild(): void;
  115287. /**
  115288. * Disposes the component and the associated ressources
  115289. */
  115290. dispose(): void;
  115291. private _beforeCameraUpdate;
  115292. }
  115293. }
  115294. declare module BABYLON {
  115295. /**
  115296. * 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,
  115297. * which still works and will still be found in many Playgrounds.
  115298. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115299. */
  115300. export class UniversalCamera extends TouchCamera {
  115301. /**
  115302. * Defines the gamepad rotation sensiblity.
  115303. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115304. */
  115305. get gamepadAngularSensibility(): number;
  115306. set gamepadAngularSensibility(value: number);
  115307. /**
  115308. * Defines the gamepad move sensiblity.
  115309. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115310. */
  115311. get gamepadMoveSensibility(): number;
  115312. set gamepadMoveSensibility(value: number);
  115313. /**
  115314. * 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,
  115315. * which still works and will still be found in many Playgrounds.
  115316. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115317. * @param name Define the name of the camera in the scene
  115318. * @param position Define the start position of the camera in the scene
  115319. * @param scene Define the scene the camera belongs to
  115320. */
  115321. constructor(name: string, position: Vector3, scene: Scene);
  115322. /**
  115323. * Gets the current object class name.
  115324. * @return the class name
  115325. */
  115326. getClassName(): string;
  115327. }
  115328. }
  115329. declare module BABYLON {
  115330. /**
  115331. * This represents a FPS type of camera. This is only here for back compat purpose.
  115332. * Please use the UniversalCamera instead as both are identical.
  115333. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115334. */
  115335. export class GamepadCamera extends UniversalCamera {
  115336. /**
  115337. * Instantiates a new Gamepad Camera
  115338. * This represents a FPS type of camera. This is only here for back compat purpose.
  115339. * Please use the UniversalCamera instead as both are identical.
  115340. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115341. * @param name Define the name of the camera in the scene
  115342. * @param position Define the start position of the camera in the scene
  115343. * @param scene Define the scene the camera belongs to
  115344. */
  115345. constructor(name: string, position: Vector3, scene: Scene);
  115346. /**
  115347. * Gets the current object class name.
  115348. * @return the class name
  115349. */
  115350. getClassName(): string;
  115351. }
  115352. }
  115353. declare module BABYLON {
  115354. /** @hidden */
  115355. export var passPixelShader: {
  115356. name: string;
  115357. shader: string;
  115358. };
  115359. }
  115360. declare module BABYLON {
  115361. /** @hidden */
  115362. export var passCubePixelShader: {
  115363. name: string;
  115364. shader: string;
  115365. };
  115366. }
  115367. declare module BABYLON {
  115368. /**
  115369. * PassPostProcess which produces an output the same as it's input
  115370. */
  115371. export class PassPostProcess extends PostProcess {
  115372. /**
  115373. * Creates the PassPostProcess
  115374. * @param name The name of the effect.
  115375. * @param options The required width/height ratio to downsize to before computing the render pass.
  115376. * @param camera The camera to apply the render pass to.
  115377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115378. * @param engine The engine which the post process will be applied. (default: current engine)
  115379. * @param reusable If the post process can be reused on the same frame. (default: false)
  115380. * @param textureType The type of texture to be used when performing the post processing.
  115381. * @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)
  115382. */
  115383. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115384. }
  115385. /**
  115386. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  115387. */
  115388. export class PassCubePostProcess extends PostProcess {
  115389. private _face;
  115390. /**
  115391. * Gets or sets the cube face to display.
  115392. * * 0 is +X
  115393. * * 1 is -X
  115394. * * 2 is +Y
  115395. * * 3 is -Y
  115396. * * 4 is +Z
  115397. * * 5 is -Z
  115398. */
  115399. get face(): number;
  115400. set face(value: number);
  115401. /**
  115402. * Creates the PassCubePostProcess
  115403. * @param name The name of the effect.
  115404. * @param options The required width/height ratio to downsize to before computing the render pass.
  115405. * @param camera The camera to apply the render pass to.
  115406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115407. * @param engine The engine which the post process will be applied. (default: current engine)
  115408. * @param reusable If the post process can be reused on the same frame. (default: false)
  115409. * @param textureType The type of texture to be used when performing the post processing.
  115410. * @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)
  115411. */
  115412. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115413. }
  115414. }
  115415. declare module BABYLON {
  115416. /** @hidden */
  115417. export var anaglyphPixelShader: {
  115418. name: string;
  115419. shader: string;
  115420. };
  115421. }
  115422. declare module BABYLON {
  115423. /**
  115424. * Postprocess used to generate anaglyphic rendering
  115425. */
  115426. export class AnaglyphPostProcess extends PostProcess {
  115427. private _passedProcess;
  115428. /**
  115429. * Creates a new AnaglyphPostProcess
  115430. * @param name defines postprocess name
  115431. * @param options defines creation options or target ratio scale
  115432. * @param rigCameras defines cameras using this postprocess
  115433. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115434. * @param engine defines hosting engine
  115435. * @param reusable defines if the postprocess will be reused multiple times per frame
  115436. */
  115437. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115438. }
  115439. }
  115440. declare module BABYLON {
  115441. /**
  115442. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115443. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115444. */
  115445. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115446. /**
  115447. * Creates a new AnaglyphArcRotateCamera
  115448. * @param name defines camera name
  115449. * @param alpha defines alpha angle (in radians)
  115450. * @param beta defines beta angle (in radians)
  115451. * @param radius defines radius
  115452. * @param target defines camera target
  115453. * @param interaxialDistance defines distance between each color axis
  115454. * @param scene defines the hosting scene
  115455. */
  115456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115457. /**
  115458. * Gets camera class name
  115459. * @returns AnaglyphArcRotateCamera
  115460. */
  115461. getClassName(): string;
  115462. }
  115463. }
  115464. declare module BABYLON {
  115465. /**
  115466. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115467. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115468. */
  115469. export class AnaglyphFreeCamera extends FreeCamera {
  115470. /**
  115471. * Creates a new AnaglyphFreeCamera
  115472. * @param name defines camera name
  115473. * @param position defines initial position
  115474. * @param interaxialDistance defines distance between each color axis
  115475. * @param scene defines the hosting scene
  115476. */
  115477. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115478. /**
  115479. * Gets camera class name
  115480. * @returns AnaglyphFreeCamera
  115481. */
  115482. getClassName(): string;
  115483. }
  115484. }
  115485. declare module BABYLON {
  115486. /**
  115487. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115488. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115489. */
  115490. export class AnaglyphGamepadCamera extends GamepadCamera {
  115491. /**
  115492. * Creates a new AnaglyphGamepadCamera
  115493. * @param name defines camera name
  115494. * @param position defines initial position
  115495. * @param interaxialDistance defines distance between each color axis
  115496. * @param scene defines the hosting scene
  115497. */
  115498. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115499. /**
  115500. * Gets camera class name
  115501. * @returns AnaglyphGamepadCamera
  115502. */
  115503. getClassName(): string;
  115504. }
  115505. }
  115506. declare module BABYLON {
  115507. /**
  115508. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115509. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115510. */
  115511. export class AnaglyphUniversalCamera extends UniversalCamera {
  115512. /**
  115513. * Creates a new AnaglyphUniversalCamera
  115514. * @param name defines camera name
  115515. * @param position defines initial position
  115516. * @param interaxialDistance defines distance between each color axis
  115517. * @param scene defines the hosting scene
  115518. */
  115519. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115520. /**
  115521. * Gets camera class name
  115522. * @returns AnaglyphUniversalCamera
  115523. */
  115524. getClassName(): string;
  115525. }
  115526. }
  115527. declare module BABYLON {
  115528. /** @hidden */
  115529. export var stereoscopicInterlacePixelShader: {
  115530. name: string;
  115531. shader: string;
  115532. };
  115533. }
  115534. declare module BABYLON {
  115535. /**
  115536. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115537. */
  115538. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115539. private _stepSize;
  115540. private _passedProcess;
  115541. /**
  115542. * Initializes a StereoscopicInterlacePostProcessI
  115543. * @param name The name of the effect.
  115544. * @param rigCameras The rig cameras to be appled to the post process
  115545. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115546. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115548. * @param engine The engine which the post process will be applied. (default: current engine)
  115549. * @param reusable If the post process can be reused on the same frame. (default: false)
  115550. */
  115551. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115552. }
  115553. /**
  115554. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115555. */
  115556. export class StereoscopicInterlacePostProcess extends PostProcess {
  115557. private _stepSize;
  115558. private _passedProcess;
  115559. /**
  115560. * Initializes a StereoscopicInterlacePostProcess
  115561. * @param name The name of the effect.
  115562. * @param rigCameras The rig cameras to be appled to the post process
  115563. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115565. * @param engine The engine which the post process will be applied. (default: current engine)
  115566. * @param reusable If the post process can be reused on the same frame. (default: false)
  115567. */
  115568. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115569. }
  115570. }
  115571. declare module BABYLON {
  115572. /**
  115573. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115574. * @see http://doc.babylonjs.com/features/cameras
  115575. */
  115576. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115577. /**
  115578. * Creates a new StereoscopicArcRotateCamera
  115579. * @param name defines camera name
  115580. * @param alpha defines alpha angle (in radians)
  115581. * @param beta defines beta angle (in radians)
  115582. * @param radius defines radius
  115583. * @param target defines camera target
  115584. * @param interaxialDistance defines distance between each color axis
  115585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115586. * @param scene defines the hosting scene
  115587. */
  115588. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115589. /**
  115590. * Gets camera class name
  115591. * @returns StereoscopicArcRotateCamera
  115592. */
  115593. getClassName(): string;
  115594. }
  115595. }
  115596. declare module BABYLON {
  115597. /**
  115598. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115599. * @see http://doc.babylonjs.com/features/cameras
  115600. */
  115601. export class StereoscopicFreeCamera extends FreeCamera {
  115602. /**
  115603. * Creates a new StereoscopicFreeCamera
  115604. * @param name defines camera name
  115605. * @param position defines initial position
  115606. * @param interaxialDistance defines distance between each color axis
  115607. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115608. * @param scene defines the hosting scene
  115609. */
  115610. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115611. /**
  115612. * Gets camera class name
  115613. * @returns StereoscopicFreeCamera
  115614. */
  115615. getClassName(): string;
  115616. }
  115617. }
  115618. declare module BABYLON {
  115619. /**
  115620. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115621. * @see http://doc.babylonjs.com/features/cameras
  115622. */
  115623. export class StereoscopicGamepadCamera extends GamepadCamera {
  115624. /**
  115625. * Creates a new StereoscopicGamepadCamera
  115626. * @param name defines camera name
  115627. * @param position defines initial position
  115628. * @param interaxialDistance defines distance between each color axis
  115629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115630. * @param scene defines the hosting scene
  115631. */
  115632. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115633. /**
  115634. * Gets camera class name
  115635. * @returns StereoscopicGamepadCamera
  115636. */
  115637. getClassName(): string;
  115638. }
  115639. }
  115640. declare module BABYLON {
  115641. /**
  115642. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115643. * @see http://doc.babylonjs.com/features/cameras
  115644. */
  115645. export class StereoscopicUniversalCamera extends UniversalCamera {
  115646. /**
  115647. * Creates a new StereoscopicUniversalCamera
  115648. * @param name defines camera name
  115649. * @param position defines initial position
  115650. * @param interaxialDistance defines distance between each color axis
  115651. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115652. * @param scene defines the hosting scene
  115653. */
  115654. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115655. /**
  115656. * Gets camera class name
  115657. * @returns StereoscopicUniversalCamera
  115658. */
  115659. getClassName(): string;
  115660. }
  115661. }
  115662. declare module BABYLON {
  115663. /**
  115664. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115665. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115666. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115667. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115668. */
  115669. export class VirtualJoysticksCamera extends FreeCamera {
  115670. /**
  115671. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115672. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115673. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115674. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115675. * @param name Define the name of the camera in the scene
  115676. * @param position Define the start position of the camera in the scene
  115677. * @param scene Define the scene the camera belongs to
  115678. */
  115679. constructor(name: string, position: Vector3, scene: Scene);
  115680. /**
  115681. * Gets the current object class name.
  115682. * @return the class name
  115683. */
  115684. getClassName(): string;
  115685. }
  115686. }
  115687. declare module BABYLON {
  115688. /**
  115689. * This represents all the required metrics to create a VR camera.
  115690. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115691. */
  115692. export class VRCameraMetrics {
  115693. /**
  115694. * Define the horizontal resolution off the screen.
  115695. */
  115696. hResolution: number;
  115697. /**
  115698. * Define the vertical resolution off the screen.
  115699. */
  115700. vResolution: number;
  115701. /**
  115702. * Define the horizontal screen size.
  115703. */
  115704. hScreenSize: number;
  115705. /**
  115706. * Define the vertical screen size.
  115707. */
  115708. vScreenSize: number;
  115709. /**
  115710. * Define the vertical screen center position.
  115711. */
  115712. vScreenCenter: number;
  115713. /**
  115714. * Define the distance of the eyes to the screen.
  115715. */
  115716. eyeToScreenDistance: number;
  115717. /**
  115718. * Define the distance between both lenses
  115719. */
  115720. lensSeparationDistance: number;
  115721. /**
  115722. * Define the distance between both viewer's eyes.
  115723. */
  115724. interpupillaryDistance: number;
  115725. /**
  115726. * Define the distortion factor of the VR postprocess.
  115727. * Please, touch with care.
  115728. */
  115729. distortionK: number[];
  115730. /**
  115731. * Define the chromatic aberration correction factors for the VR post process.
  115732. */
  115733. chromaAbCorrection: number[];
  115734. /**
  115735. * Define the scale factor of the post process.
  115736. * The smaller the better but the slower.
  115737. */
  115738. postProcessScaleFactor: number;
  115739. /**
  115740. * Define an offset for the lens center.
  115741. */
  115742. lensCenterOffset: number;
  115743. /**
  115744. * Define if the current vr camera should compensate the distortion of the lense or not.
  115745. */
  115746. compensateDistortion: boolean;
  115747. /**
  115748. * Defines if multiview should be enabled when rendering (Default: false)
  115749. */
  115750. multiviewEnabled: boolean;
  115751. /**
  115752. * Gets the rendering aspect ratio based on the provided resolutions.
  115753. */
  115754. get aspectRatio(): number;
  115755. /**
  115756. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115757. */
  115758. get aspectRatioFov(): number;
  115759. /**
  115760. * @hidden
  115761. */
  115762. get leftHMatrix(): Matrix;
  115763. /**
  115764. * @hidden
  115765. */
  115766. get rightHMatrix(): Matrix;
  115767. /**
  115768. * @hidden
  115769. */
  115770. get leftPreViewMatrix(): Matrix;
  115771. /**
  115772. * @hidden
  115773. */
  115774. get rightPreViewMatrix(): Matrix;
  115775. /**
  115776. * Get the default VRMetrics based on the most generic setup.
  115777. * @returns the default vr metrics
  115778. */
  115779. static GetDefault(): VRCameraMetrics;
  115780. }
  115781. }
  115782. declare module BABYLON {
  115783. /** @hidden */
  115784. export var vrDistortionCorrectionPixelShader: {
  115785. name: string;
  115786. shader: string;
  115787. };
  115788. }
  115789. declare module BABYLON {
  115790. /**
  115791. * VRDistortionCorrectionPostProcess used for mobile VR
  115792. */
  115793. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115794. private _isRightEye;
  115795. private _distortionFactors;
  115796. private _postProcessScaleFactor;
  115797. private _lensCenterOffset;
  115798. private _scaleIn;
  115799. private _scaleFactor;
  115800. private _lensCenter;
  115801. /**
  115802. * Initializes the VRDistortionCorrectionPostProcess
  115803. * @param name The name of the effect.
  115804. * @param camera The camera to apply the render pass to.
  115805. * @param isRightEye If this is for the right eye distortion
  115806. * @param vrMetrics All the required metrics for the VR camera
  115807. */
  115808. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115809. }
  115810. }
  115811. declare module BABYLON {
  115812. /**
  115813. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115814. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115815. */
  115816. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115817. /**
  115818. * Creates a new VRDeviceOrientationArcRotateCamera
  115819. * @param name defines camera name
  115820. * @param alpha defines the camera rotation along the logitudinal axis
  115821. * @param beta defines the camera rotation along the latitudinal axis
  115822. * @param radius defines the camera distance from its target
  115823. * @param target defines the camera target
  115824. * @param scene defines the scene the camera belongs to
  115825. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115826. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115827. */
  115828. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115829. /**
  115830. * Gets camera class name
  115831. * @returns VRDeviceOrientationArcRotateCamera
  115832. */
  115833. getClassName(): string;
  115834. }
  115835. }
  115836. declare module BABYLON {
  115837. /**
  115838. * Camera used to simulate VR rendering (based on FreeCamera)
  115839. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115840. */
  115841. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115842. /**
  115843. * Creates a new VRDeviceOrientationFreeCamera
  115844. * @param name defines camera name
  115845. * @param position defines the start position of the camera
  115846. * @param scene defines the scene the camera belongs to
  115847. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115848. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115849. */
  115850. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115851. /**
  115852. * Gets camera class name
  115853. * @returns VRDeviceOrientationFreeCamera
  115854. */
  115855. getClassName(): string;
  115856. }
  115857. }
  115858. declare module BABYLON {
  115859. /**
  115860. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115861. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115862. */
  115863. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115864. /**
  115865. * Creates a new VRDeviceOrientationGamepadCamera
  115866. * @param name defines camera name
  115867. * @param position defines the start position of the camera
  115868. * @param scene defines the scene the camera belongs to
  115869. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115870. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115871. */
  115872. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115873. /**
  115874. * Gets camera class name
  115875. * @returns VRDeviceOrientationGamepadCamera
  115876. */
  115877. getClassName(): string;
  115878. }
  115879. }
  115880. declare module BABYLON {
  115881. /** @hidden */
  115882. export var imageProcessingPixelShader: {
  115883. name: string;
  115884. shader: string;
  115885. };
  115886. }
  115887. declare module BABYLON {
  115888. /**
  115889. * ImageProcessingPostProcess
  115890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115891. */
  115892. export class ImageProcessingPostProcess extends PostProcess {
  115893. /**
  115894. * Default configuration related to image processing available in the PBR Material.
  115895. */
  115896. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115897. /**
  115898. * Gets the image processing configuration used either in this material.
  115899. */
  115900. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115901. /**
  115902. * Sets the Default image processing configuration used either in the this material.
  115903. *
  115904. * If sets to null, the scene one is in use.
  115905. */
  115906. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115907. /**
  115908. * Keep track of the image processing observer to allow dispose and replace.
  115909. */
  115910. private _imageProcessingObserver;
  115911. /**
  115912. * Attaches a new image processing configuration to the PBR Material.
  115913. * @param configuration
  115914. */
  115915. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115916. /**
  115917. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115918. */
  115919. get colorCurves(): Nullable<ColorCurves>;
  115920. /**
  115921. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115922. */
  115923. set colorCurves(value: Nullable<ColorCurves>);
  115924. /**
  115925. * Gets wether the color curves effect is enabled.
  115926. */
  115927. get colorCurvesEnabled(): boolean;
  115928. /**
  115929. * Sets wether the color curves effect is enabled.
  115930. */
  115931. set colorCurvesEnabled(value: boolean);
  115932. /**
  115933. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115934. */
  115935. get colorGradingTexture(): Nullable<BaseTexture>;
  115936. /**
  115937. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115938. */
  115939. set colorGradingTexture(value: Nullable<BaseTexture>);
  115940. /**
  115941. * Gets wether the color grading effect is enabled.
  115942. */
  115943. get colorGradingEnabled(): boolean;
  115944. /**
  115945. * Gets wether the color grading effect is enabled.
  115946. */
  115947. set colorGradingEnabled(value: boolean);
  115948. /**
  115949. * Gets exposure used in the effect.
  115950. */
  115951. get exposure(): number;
  115952. /**
  115953. * Sets exposure used in the effect.
  115954. */
  115955. set exposure(value: number);
  115956. /**
  115957. * Gets wether tonemapping is enabled or not.
  115958. */
  115959. get toneMappingEnabled(): boolean;
  115960. /**
  115961. * Sets wether tonemapping is enabled or not
  115962. */
  115963. set toneMappingEnabled(value: boolean);
  115964. /**
  115965. * Gets the type of tone mapping effect.
  115966. */
  115967. get toneMappingType(): number;
  115968. /**
  115969. * Sets the type of tone mapping effect.
  115970. */
  115971. set toneMappingType(value: number);
  115972. /**
  115973. * Gets contrast used in the effect.
  115974. */
  115975. get contrast(): number;
  115976. /**
  115977. * Sets contrast used in the effect.
  115978. */
  115979. set contrast(value: number);
  115980. /**
  115981. * Gets Vignette stretch size.
  115982. */
  115983. get vignetteStretch(): number;
  115984. /**
  115985. * Sets Vignette stretch size.
  115986. */
  115987. set vignetteStretch(value: number);
  115988. /**
  115989. * Gets Vignette centre X Offset.
  115990. */
  115991. get vignetteCentreX(): number;
  115992. /**
  115993. * Sets Vignette centre X Offset.
  115994. */
  115995. set vignetteCentreX(value: number);
  115996. /**
  115997. * Gets Vignette centre Y Offset.
  115998. */
  115999. get vignetteCentreY(): number;
  116000. /**
  116001. * Sets Vignette centre Y Offset.
  116002. */
  116003. set vignetteCentreY(value: number);
  116004. /**
  116005. * Gets Vignette weight or intensity of the vignette effect.
  116006. */
  116007. get vignetteWeight(): number;
  116008. /**
  116009. * Sets Vignette weight or intensity of the vignette effect.
  116010. */
  116011. set vignetteWeight(value: number);
  116012. /**
  116013. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116014. * if vignetteEnabled is set to true.
  116015. */
  116016. get vignetteColor(): Color4;
  116017. /**
  116018. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116019. * if vignetteEnabled is set to true.
  116020. */
  116021. set vignetteColor(value: Color4);
  116022. /**
  116023. * Gets Camera field of view used by the Vignette effect.
  116024. */
  116025. get vignetteCameraFov(): number;
  116026. /**
  116027. * Sets Camera field of view used by the Vignette effect.
  116028. */
  116029. set vignetteCameraFov(value: number);
  116030. /**
  116031. * Gets the vignette blend mode allowing different kind of effect.
  116032. */
  116033. get vignetteBlendMode(): number;
  116034. /**
  116035. * Sets the vignette blend mode allowing different kind of effect.
  116036. */
  116037. set vignetteBlendMode(value: number);
  116038. /**
  116039. * Gets wether the vignette effect is enabled.
  116040. */
  116041. get vignetteEnabled(): boolean;
  116042. /**
  116043. * Sets wether the vignette effect is enabled.
  116044. */
  116045. set vignetteEnabled(value: boolean);
  116046. private _fromLinearSpace;
  116047. /**
  116048. * Gets wether the input of the processing is in Gamma or Linear Space.
  116049. */
  116050. get fromLinearSpace(): boolean;
  116051. /**
  116052. * Sets wether the input of the processing is in Gamma or Linear Space.
  116053. */
  116054. set fromLinearSpace(value: boolean);
  116055. /**
  116056. * Defines cache preventing GC.
  116057. */
  116058. private _defines;
  116059. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116060. /**
  116061. * "ImageProcessingPostProcess"
  116062. * @returns "ImageProcessingPostProcess"
  116063. */
  116064. getClassName(): string;
  116065. protected _updateParameters(): void;
  116066. dispose(camera?: Camera): void;
  116067. }
  116068. }
  116069. declare module BABYLON {
  116070. /**
  116071. * Class containing static functions to help procedurally build meshes
  116072. */
  116073. export class GroundBuilder {
  116074. /**
  116075. * Creates a ground mesh
  116076. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116077. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116079. * @param name defines the name of the mesh
  116080. * @param options defines the options used to create the mesh
  116081. * @param scene defines the hosting scene
  116082. * @returns the ground mesh
  116083. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116084. */
  116085. static CreateGround(name: string, options: {
  116086. width?: number;
  116087. height?: number;
  116088. subdivisions?: number;
  116089. subdivisionsX?: number;
  116090. subdivisionsY?: number;
  116091. updatable?: boolean;
  116092. }, scene: any): Mesh;
  116093. /**
  116094. * Creates a tiled ground mesh
  116095. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116096. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116097. * * 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
  116098. * * 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
  116099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116100. * @param name defines the name of the mesh
  116101. * @param options defines the options used to create the mesh
  116102. * @param scene defines the hosting scene
  116103. * @returns the tiled ground mesh
  116104. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116105. */
  116106. static CreateTiledGround(name: string, options: {
  116107. xmin: number;
  116108. zmin: number;
  116109. xmax: number;
  116110. zmax: number;
  116111. subdivisions?: {
  116112. w: number;
  116113. h: number;
  116114. };
  116115. precision?: {
  116116. w: number;
  116117. h: number;
  116118. };
  116119. updatable?: boolean;
  116120. }, scene?: Nullable<Scene>): Mesh;
  116121. /**
  116122. * Creates a ground mesh from a height map
  116123. * * The parameter `url` sets the URL of the height map image resource.
  116124. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116125. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116126. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116127. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116128. * * 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.
  116129. * * 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).
  116130. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116132. * @param name defines the name of the mesh
  116133. * @param url defines the url to the height map
  116134. * @param options defines the options used to create the mesh
  116135. * @param scene defines the hosting scene
  116136. * @returns the ground mesh
  116137. * @see https://doc.babylonjs.com/babylon101/height_map
  116138. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116139. */
  116140. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116141. width?: number;
  116142. height?: number;
  116143. subdivisions?: number;
  116144. minHeight?: number;
  116145. maxHeight?: number;
  116146. colorFilter?: Color3;
  116147. alphaFilter?: number;
  116148. updatable?: boolean;
  116149. onReady?: (mesh: GroundMesh) => void;
  116150. }, scene?: Nullable<Scene>): GroundMesh;
  116151. }
  116152. }
  116153. declare module BABYLON {
  116154. /**
  116155. * Class containing static functions to help procedurally build meshes
  116156. */
  116157. export class TorusBuilder {
  116158. /**
  116159. * Creates a torus mesh
  116160. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116161. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116162. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116166. * @param name defines the name of the mesh
  116167. * @param options defines the options used to create the mesh
  116168. * @param scene defines the hosting scene
  116169. * @returns the torus mesh
  116170. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116171. */
  116172. static CreateTorus(name: string, options: {
  116173. diameter?: number;
  116174. thickness?: number;
  116175. tessellation?: number;
  116176. updatable?: boolean;
  116177. sideOrientation?: number;
  116178. frontUVs?: Vector4;
  116179. backUVs?: Vector4;
  116180. }, scene: any): Mesh;
  116181. }
  116182. }
  116183. declare module BABYLON {
  116184. /**
  116185. * Class containing static functions to help procedurally build meshes
  116186. */
  116187. export class CylinderBuilder {
  116188. /**
  116189. * Creates a cylinder or a cone mesh
  116190. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116191. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116192. * * 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.
  116193. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116194. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116195. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116196. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116197. * * 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).
  116198. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116199. * * 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).
  116200. * * 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
  116201. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116202. * * 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
  116203. * * 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.
  116204. * * If `enclose` is false, a ring surface is one element.
  116205. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116206. * * 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
  116207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116210. * @param name defines the name of the mesh
  116211. * @param options defines the options used to create the mesh
  116212. * @param scene defines the hosting scene
  116213. * @returns the cylinder mesh
  116214. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116215. */
  116216. static CreateCylinder(name: string, options: {
  116217. height?: number;
  116218. diameterTop?: number;
  116219. diameterBottom?: number;
  116220. diameter?: number;
  116221. tessellation?: number;
  116222. subdivisions?: number;
  116223. arc?: number;
  116224. faceColors?: Color4[];
  116225. faceUV?: Vector4[];
  116226. updatable?: boolean;
  116227. hasRings?: boolean;
  116228. enclose?: boolean;
  116229. cap?: number;
  116230. sideOrientation?: number;
  116231. frontUVs?: Vector4;
  116232. backUVs?: Vector4;
  116233. }, scene: any): Mesh;
  116234. }
  116235. }
  116236. declare module BABYLON {
  116237. /**
  116238. * States of the webXR experience
  116239. */
  116240. export enum WebXRState {
  116241. /**
  116242. * Transitioning to being in XR mode
  116243. */
  116244. ENTERING_XR = 0,
  116245. /**
  116246. * Transitioning to non XR mode
  116247. */
  116248. EXITING_XR = 1,
  116249. /**
  116250. * In XR mode and presenting
  116251. */
  116252. IN_XR = 2,
  116253. /**
  116254. * Not entered XR mode
  116255. */
  116256. NOT_IN_XR = 3
  116257. }
  116258. /**
  116259. * Abstraction of the XR render target
  116260. */
  116261. export interface WebXRRenderTarget extends IDisposable {
  116262. /**
  116263. * xrpresent context of the canvas which can be used to display/mirror xr content
  116264. */
  116265. canvasContext: WebGLRenderingContext;
  116266. /**
  116267. * xr layer for the canvas
  116268. */
  116269. xrLayer: Nullable<XRWebGLLayer>;
  116270. /**
  116271. * Initializes the xr layer for the session
  116272. * @param xrSession xr session
  116273. * @returns a promise that will resolve once the XR Layer has been created
  116274. */
  116275. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116276. }
  116277. }
  116278. declare module BABYLON {
  116279. /**
  116280. * COnfiguration object for WebXR output canvas
  116281. */
  116282. export class WebXRManagedOutputCanvasOptions {
  116283. /**
  116284. * An optional canvas in case you wish to create it yourself and provide it here.
  116285. * If not provided, a new canvas will be created
  116286. */
  116287. canvasElement?: HTMLCanvasElement;
  116288. /**
  116289. * Options for this XR Layer output
  116290. */
  116291. canvasOptions?: XRWebGLLayerOptions;
  116292. /**
  116293. * CSS styling for a newly created canvas (if not provided)
  116294. */
  116295. newCanvasCssStyle?: string;
  116296. /**
  116297. * Get the default values of the configuration object
  116298. * @returns default values of this configuration object
  116299. */
  116300. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  116301. }
  116302. /**
  116303. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  116304. */
  116305. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  116306. private _options;
  116307. private _canvas;
  116308. private _engine;
  116309. /**
  116310. * Rendering context of the canvas which can be used to display/mirror xr content
  116311. */
  116312. canvasContext: WebGLRenderingContext;
  116313. /**
  116314. * xr layer for the canvas
  116315. */
  116316. xrLayer: Nullable<XRWebGLLayer>;
  116317. /**
  116318. * Initializes the canvas to be added/removed upon entering/exiting xr
  116319. * @param _xrSessionManager The XR Session manager
  116320. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  116321. */
  116322. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  116323. /**
  116324. * Disposes of the object
  116325. */
  116326. dispose(): void;
  116327. /**
  116328. * Initializes the xr layer for the session
  116329. * @param xrSession xr session
  116330. * @returns a promise that will resolve once the XR Layer has been created
  116331. */
  116332. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116333. private _addCanvas;
  116334. private _removeCanvas;
  116335. private _setManagedOutputCanvas;
  116336. }
  116337. }
  116338. declare module BABYLON {
  116339. /**
  116340. * Manages an XRSession to work with Babylon's engine
  116341. * @see https://doc.babylonjs.com/how_to/webxr
  116342. */
  116343. export class WebXRSessionManager implements IDisposable {
  116344. /** The scene which the session should be created for */
  116345. scene: Scene;
  116346. private _referenceSpace;
  116347. private _rttProvider;
  116348. private _sessionEnded;
  116349. private _xrNavigator;
  116350. private baseLayer;
  116351. /**
  116352. * The base reference space from which the session started. good if you want to reset your
  116353. * reference space
  116354. */
  116355. baseReferenceSpace: XRReferenceSpace;
  116356. /**
  116357. * Current XR frame
  116358. */
  116359. currentFrame: Nullable<XRFrame>;
  116360. /** WebXR timestamp updated every frame */
  116361. currentTimestamp: number;
  116362. /**
  116363. * Used just in case of a failure to initialize an immersive session.
  116364. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  116365. */
  116366. defaultHeightCompensation: number;
  116367. /**
  116368. * Fires every time a new xrFrame arrives which can be used to update the camera
  116369. */
  116370. onXRFrameObservable: Observable<XRFrame>;
  116371. /**
  116372. * Fires when the reference space changed
  116373. */
  116374. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  116375. /**
  116376. * Fires when the xr session is ended either by the device or manually done
  116377. */
  116378. onXRSessionEnded: Observable<any>;
  116379. /**
  116380. * Fires when the xr session is ended either by the device or manually done
  116381. */
  116382. onXRSessionInit: Observable<XRSession>;
  116383. /**
  116384. * Underlying xr session
  116385. */
  116386. session: XRSession;
  116387. /**
  116388. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  116389. * or get the offset the player is currently at.
  116390. */
  116391. viewerReferenceSpace: XRReferenceSpace;
  116392. /**
  116393. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116394. * @param scene The scene which the session should be created for
  116395. */
  116396. constructor(
  116397. /** The scene which the session should be created for */
  116398. scene: Scene);
  116399. /**
  116400. * The current reference space used in this session. This reference space can constantly change!
  116401. * It is mainly used to offset the camera's position.
  116402. */
  116403. get referenceSpace(): XRReferenceSpace;
  116404. /**
  116405. * Set a new reference space and triggers the observable
  116406. */
  116407. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  116408. /**
  116409. * Disposes of the session manager
  116410. */
  116411. dispose(): void;
  116412. /**
  116413. * Stops the xrSession and restores the render loop
  116414. * @returns Promise which resolves after it exits XR
  116415. */
  116416. exitXRAsync(): Promise<void>;
  116417. /**
  116418. * Gets the correct render target texture to be rendered this frame for this eye
  116419. * @param eye the eye for which to get the render target
  116420. * @returns the render target for the specified eye
  116421. */
  116422. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116423. /**
  116424. * Creates a WebXRRenderTarget object for the XR session
  116425. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116426. * @param options optional options to provide when creating a new render target
  116427. * @returns a WebXR render target to which the session can render
  116428. */
  116429. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116430. /**
  116431. * Initializes the manager
  116432. * After initialization enterXR can be called to start an XR session
  116433. * @returns Promise which resolves after it is initialized
  116434. */
  116435. initializeAsync(): Promise<void>;
  116436. /**
  116437. * Initializes an xr session
  116438. * @param xrSessionMode mode to initialize
  116439. * @param xrSessionInit defines optional and required values to pass to the session builder
  116440. * @returns a promise which will resolve once the session has been initialized
  116441. */
  116442. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116443. /**
  116444. * Checks if a session would be supported for the creation options specified
  116445. * @param sessionMode session mode to check if supported eg. immersive-vr
  116446. * @returns A Promise that resolves to true if supported and false if not
  116447. */
  116448. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116449. /**
  116450. * Resets the reference space to the one started the session
  116451. */
  116452. resetReferenceSpace(): void;
  116453. /**
  116454. * Starts rendering to the xr layer
  116455. */
  116456. runXRRenderLoop(): void;
  116457. /**
  116458. * Sets the reference space on the xr session
  116459. * @param referenceSpaceType space to set
  116460. * @returns a promise that will resolve once the reference space has been set
  116461. */
  116462. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116463. /**
  116464. * Updates the render state of the session
  116465. * @param state state to set
  116466. * @returns a promise that resolves once the render state has been updated
  116467. */
  116468. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116469. /**
  116470. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116471. * @param sessionMode defines the session to test
  116472. * @returns a promise with boolean as final value
  116473. */
  116474. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116475. private _createRenderTargetTexture;
  116476. }
  116477. }
  116478. declare module BABYLON {
  116479. /**
  116480. * WebXR Camera which holds the views for the xrSession
  116481. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116482. */
  116483. export class WebXRCamera extends FreeCamera {
  116484. private _xrSessionManager;
  116485. private _firstFrame;
  116486. private _referenceQuaternion;
  116487. private _referencedPosition;
  116488. private _xrInvPositionCache;
  116489. private _xrInvQuaternionCache;
  116490. /**
  116491. * Should position compensation execute on first frame.
  116492. * This is used when copying the position from a native (non XR) camera
  116493. */
  116494. compensateOnFirstFrame: boolean;
  116495. /**
  116496. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116497. * @param name the name of the camera
  116498. * @param scene the scene to add the camera to
  116499. * @param _xrSessionManager a constructed xr session manager
  116500. */
  116501. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116502. /**
  116503. * Return the user's height, unrelated to the current ground.
  116504. * This will be the y position of this camera, when ground level is 0.
  116505. */
  116506. get realWorldHeight(): number;
  116507. /** @hidden */
  116508. _updateForDualEyeDebugging(): void;
  116509. /**
  116510. * Sets this camera's transformation based on a non-vr camera
  116511. * @param otherCamera the non-vr camera to copy the transformation from
  116512. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116513. */
  116514. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116515. /**
  116516. * Gets the current instance class name ("WebXRCamera").
  116517. * @returns the class name
  116518. */
  116519. getClassName(): string;
  116520. private _updateFromXRSession;
  116521. private _updateNumberOfRigCameras;
  116522. private _updateReferenceSpace;
  116523. private _updateReferenceSpaceOffset;
  116524. }
  116525. }
  116526. declare module BABYLON {
  116527. /**
  116528. * Defining the interface required for a (webxr) feature
  116529. */
  116530. export interface IWebXRFeature extends IDisposable {
  116531. /**
  116532. * Is this feature attached
  116533. */
  116534. attached: boolean;
  116535. /**
  116536. * Should auto-attach be disabled?
  116537. */
  116538. disableAutoAttach: boolean;
  116539. /**
  116540. * Attach the feature to the session
  116541. * Will usually be called by the features manager
  116542. *
  116543. * @param force should attachment be forced (even when already attached)
  116544. * @returns true if successful.
  116545. */
  116546. attach(force?: boolean): boolean;
  116547. /**
  116548. * Detach the feature from the session
  116549. * Will usually be called by the features manager
  116550. *
  116551. * @returns true if successful.
  116552. */
  116553. detach(): boolean;
  116554. }
  116555. /**
  116556. * A list of the currently available features without referencing them
  116557. */
  116558. export class WebXRFeatureName {
  116559. /**
  116560. * The name of the anchor system feature
  116561. */
  116562. static ANCHOR_SYSTEM: string;
  116563. /**
  116564. * The name of the background remover feature
  116565. */
  116566. static BACKGROUND_REMOVER: string;
  116567. /**
  116568. * The name of the hit test feature
  116569. */
  116570. static HIT_TEST: string;
  116571. /**
  116572. * physics impostors for xr controllers feature
  116573. */
  116574. static PHYSICS_CONTROLLERS: string;
  116575. /**
  116576. * The name of the plane detection feature
  116577. */
  116578. static PLANE_DETECTION: string;
  116579. /**
  116580. * The name of the pointer selection feature
  116581. */
  116582. static POINTER_SELECTION: string;
  116583. /**
  116584. * The name of the teleportation feature
  116585. */
  116586. static TELEPORTATION: string;
  116587. }
  116588. /**
  116589. * Defining the constructor of a feature. Used to register the modules.
  116590. */
  116591. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116592. /**
  116593. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116594. * It is mainly used in AR sessions.
  116595. *
  116596. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116597. */
  116598. export class WebXRFeaturesManager implements IDisposable {
  116599. private _xrSessionManager;
  116600. private static readonly _AvailableFeatures;
  116601. private _features;
  116602. /**
  116603. * constructs a new features manages.
  116604. *
  116605. * @param _xrSessionManager an instance of WebXRSessionManager
  116606. */
  116607. constructor(_xrSessionManager: WebXRSessionManager);
  116608. /**
  116609. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116610. * Mainly used internally.
  116611. *
  116612. * @param featureName the name of the feature to register
  116613. * @param constructorFunction the function used to construct the module
  116614. * @param version the (babylon) version of the module
  116615. * @param stable is that a stable version of this module
  116616. */
  116617. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116618. /**
  116619. * Returns a constructor of a specific feature.
  116620. *
  116621. * @param featureName the name of the feature to construct
  116622. * @param version the version of the feature to load
  116623. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116624. * @param options optional options provided to the module.
  116625. * @returns a function that, when called, will return a new instance of this feature
  116626. */
  116627. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116628. /**
  116629. * Can be used to return the list of features currently registered
  116630. *
  116631. * @returns an Array of available features
  116632. */
  116633. static GetAvailableFeatures(): string[];
  116634. /**
  116635. * Gets the versions available for a specific feature
  116636. * @param featureName the name of the feature
  116637. * @returns an array with the available versions
  116638. */
  116639. static GetAvailableVersions(featureName: string): string[];
  116640. /**
  116641. * Return the latest unstable version of this feature
  116642. * @param featureName the name of the feature to search
  116643. * @returns the version number. if not found will return -1
  116644. */
  116645. static GetLatestVersionOfFeature(featureName: string): number;
  116646. /**
  116647. * Return the latest stable version of this feature
  116648. * @param featureName the name of the feature to search
  116649. * @returns the version number. if not found will return -1
  116650. */
  116651. static GetStableVersionOfFeature(featureName: string): number;
  116652. /**
  116653. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116654. * Can be used during a session to start a feature
  116655. * @param featureName the name of feature to attach
  116656. */
  116657. attachFeature(featureName: string): void;
  116658. /**
  116659. * Can be used inside a session or when the session ends to detach a specific feature
  116660. * @param featureName the name of the feature to detach
  116661. */
  116662. detachFeature(featureName: string): void;
  116663. /**
  116664. * Used to disable an already-enabled feature
  116665. * The feature will be disposed and will be recreated once enabled.
  116666. * @param featureName the feature to disable
  116667. * @returns true if disable was successful
  116668. */
  116669. disableFeature(featureName: string | {
  116670. Name: string;
  116671. }): boolean;
  116672. /**
  116673. * dispose this features manager
  116674. */
  116675. dispose(): void;
  116676. /**
  116677. * 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.
  116678. * 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.
  116679. *
  116680. * @param featureName the name of the feature to load or the class of the feature
  116681. * @param version optional version to load. if not provided the latest version will be enabled
  116682. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116683. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116684. * @returns a new constructed feature or throws an error if feature not found.
  116685. */
  116686. enableFeature(featureName: string | {
  116687. Name: string;
  116688. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116689. /**
  116690. * get the implementation of an enabled feature.
  116691. * @param featureName the name of the feature to load
  116692. * @returns the feature class, if found
  116693. */
  116694. getEnabledFeature(featureName: string): IWebXRFeature;
  116695. /**
  116696. * Get the list of enabled features
  116697. * @returns an array of enabled features
  116698. */
  116699. getEnabledFeatures(): string[];
  116700. }
  116701. }
  116702. declare module BABYLON {
  116703. /**
  116704. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116705. * @see https://doc.babylonjs.com/how_to/webxr
  116706. */
  116707. export class WebXRExperienceHelper implements IDisposable {
  116708. private scene;
  116709. private _nonVRCamera;
  116710. private _originalSceneAutoClear;
  116711. private _supported;
  116712. /**
  116713. * Camera used to render xr content
  116714. */
  116715. camera: WebXRCamera;
  116716. /** A features manager for this xr session */
  116717. featuresManager: WebXRFeaturesManager;
  116718. /**
  116719. * Observers registered here will be triggered after the camera's initial transformation is set
  116720. * This can be used to set a different ground level or an extra rotation.
  116721. *
  116722. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116723. * to the position set after this observable is done executing.
  116724. */
  116725. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116726. /**
  116727. * Fires when the state of the experience helper has changed
  116728. */
  116729. onStateChangedObservable: Observable<WebXRState>;
  116730. /** Session manager used to keep track of xr session */
  116731. sessionManager: WebXRSessionManager;
  116732. /**
  116733. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116734. */
  116735. state: WebXRState;
  116736. /**
  116737. * Creates a WebXRExperienceHelper
  116738. * @param scene The scene the helper should be created in
  116739. */
  116740. private constructor();
  116741. /**
  116742. * Creates the experience helper
  116743. * @param scene the scene to attach the experience helper to
  116744. * @returns a promise for the experience helper
  116745. */
  116746. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116747. /**
  116748. * Disposes of the experience helper
  116749. */
  116750. dispose(): void;
  116751. /**
  116752. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116753. * @param sessionMode options for the XR session
  116754. * @param referenceSpaceType frame of reference of the XR session
  116755. * @param renderTarget the output canvas that will be used to enter XR mode
  116756. * @returns promise that resolves after xr mode has entered
  116757. */
  116758. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116759. /**
  116760. * Exits XR mode and returns the scene to its original state
  116761. * @returns promise that resolves after xr mode has exited
  116762. */
  116763. exitXRAsync(): Promise<void>;
  116764. private _nonXRToXRCamera;
  116765. private _setState;
  116766. }
  116767. }
  116768. declare module BABYLON {
  116769. /**
  116770. * X-Y values for axes in WebXR
  116771. */
  116772. export interface IWebXRMotionControllerAxesValue {
  116773. /**
  116774. * The value of the x axis
  116775. */
  116776. x: number;
  116777. /**
  116778. * The value of the y-axis
  116779. */
  116780. y: number;
  116781. }
  116782. /**
  116783. * changed / previous values for the values of this component
  116784. */
  116785. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116786. /**
  116787. * current (this frame) value
  116788. */
  116789. current: T;
  116790. /**
  116791. * previous (last change) value
  116792. */
  116793. previous: T;
  116794. }
  116795. /**
  116796. * Represents changes in the component between current frame and last values recorded
  116797. */
  116798. export interface IWebXRMotionControllerComponentChanges {
  116799. /**
  116800. * will be populated with previous and current values if axes changed
  116801. */
  116802. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116803. /**
  116804. * will be populated with previous and current values if pressed changed
  116805. */
  116806. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116807. /**
  116808. * will be populated with previous and current values if touched changed
  116809. */
  116810. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116811. /**
  116812. * will be populated with previous and current values if value changed
  116813. */
  116814. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116815. }
  116816. /**
  116817. * This class represents a single component (for example button or thumbstick) of a motion controller
  116818. */
  116819. export class WebXRControllerComponent implements IDisposable {
  116820. /**
  116821. * the id of this component
  116822. */
  116823. id: string;
  116824. /**
  116825. * the type of the component
  116826. */
  116827. type: MotionControllerComponentType;
  116828. private _buttonIndex;
  116829. private _axesIndices;
  116830. private _axes;
  116831. private _changes;
  116832. private _currentValue;
  116833. private _hasChanges;
  116834. private _pressed;
  116835. private _touched;
  116836. /**
  116837. * button component type
  116838. */
  116839. static BUTTON_TYPE: MotionControllerComponentType;
  116840. /**
  116841. * squeeze component type
  116842. */
  116843. static SQUEEZE_TYPE: MotionControllerComponentType;
  116844. /**
  116845. * Thumbstick component type
  116846. */
  116847. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116848. /**
  116849. * Touchpad component type
  116850. */
  116851. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116852. /**
  116853. * trigger component type
  116854. */
  116855. static TRIGGER_TYPE: MotionControllerComponentType;
  116856. /**
  116857. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116858. * the axes data changes
  116859. */
  116860. onAxisValueChangedObservable: Observable<{
  116861. x: number;
  116862. y: number;
  116863. }>;
  116864. /**
  116865. * Observers registered here will be triggered when the state of a button changes
  116866. * State change is either pressed / touched / value
  116867. */
  116868. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116869. /**
  116870. * Creates a new component for a motion controller.
  116871. * It is created by the motion controller itself
  116872. *
  116873. * @param id the id of this component
  116874. * @param type the type of the component
  116875. * @param _buttonIndex index in the buttons array of the gamepad
  116876. * @param _axesIndices indices of the values in the axes array of the gamepad
  116877. */
  116878. constructor(
  116879. /**
  116880. * the id of this component
  116881. */
  116882. id: string,
  116883. /**
  116884. * the type of the component
  116885. */
  116886. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116887. /**
  116888. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116889. */
  116890. get axes(): IWebXRMotionControllerAxesValue;
  116891. /**
  116892. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116893. */
  116894. get changes(): IWebXRMotionControllerComponentChanges;
  116895. /**
  116896. * Return whether or not the component changed the last frame
  116897. */
  116898. get hasChanges(): boolean;
  116899. /**
  116900. * is the button currently pressed
  116901. */
  116902. get pressed(): boolean;
  116903. /**
  116904. * is the button currently touched
  116905. */
  116906. get touched(): boolean;
  116907. /**
  116908. * Get the current value of this component
  116909. */
  116910. get value(): number;
  116911. /**
  116912. * Dispose this component
  116913. */
  116914. dispose(): void;
  116915. /**
  116916. * Are there axes correlating to this component
  116917. * @return true is axes data is available
  116918. */
  116919. isAxes(): boolean;
  116920. /**
  116921. * Is this component a button (hence - pressable)
  116922. * @returns true if can be pressed
  116923. */
  116924. isButton(): boolean;
  116925. /**
  116926. * update this component using the gamepad object it is in. Called on every frame
  116927. * @param nativeController the native gamepad controller object
  116928. */
  116929. update(nativeController: IMinimalMotionControllerObject): void;
  116930. }
  116931. }
  116932. declare module BABYLON {
  116933. /**
  116934. * Class used to represent data loading progression
  116935. */
  116936. export class SceneLoaderProgressEvent {
  116937. /** defines if data length to load can be evaluated */
  116938. readonly lengthComputable: boolean;
  116939. /** defines the loaded data length */
  116940. readonly loaded: number;
  116941. /** defines the data length to load */
  116942. readonly total: number;
  116943. /**
  116944. * Create a new progress event
  116945. * @param lengthComputable defines if data length to load can be evaluated
  116946. * @param loaded defines the loaded data length
  116947. * @param total defines the data length to load
  116948. */
  116949. constructor(
  116950. /** defines if data length to load can be evaluated */
  116951. lengthComputable: boolean,
  116952. /** defines the loaded data length */
  116953. loaded: number,
  116954. /** defines the data length to load */
  116955. total: number);
  116956. /**
  116957. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116958. * @param event defines the source event
  116959. * @returns a new SceneLoaderProgressEvent
  116960. */
  116961. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116962. }
  116963. /**
  116964. * Interface used by SceneLoader plugins to define supported file extensions
  116965. */
  116966. export interface ISceneLoaderPluginExtensions {
  116967. /**
  116968. * Defines the list of supported extensions
  116969. */
  116970. [extension: string]: {
  116971. isBinary: boolean;
  116972. };
  116973. }
  116974. /**
  116975. * Interface used by SceneLoader plugin factory
  116976. */
  116977. export interface ISceneLoaderPluginFactory {
  116978. /**
  116979. * Defines the name of the factory
  116980. */
  116981. name: string;
  116982. /**
  116983. * Function called to create a new plugin
  116984. * @return the new plugin
  116985. */
  116986. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116987. /**
  116988. * The callback that returns true if the data can be directly loaded.
  116989. * @param data string containing the file data
  116990. * @returns if the data can be loaded directly
  116991. */
  116992. canDirectLoad?(data: string): boolean;
  116993. }
  116994. /**
  116995. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116996. */
  116997. export interface ISceneLoaderPluginBase {
  116998. /**
  116999. * The friendly name of this plugin.
  117000. */
  117001. name: string;
  117002. /**
  117003. * The file extensions supported by this plugin.
  117004. */
  117005. extensions: string | ISceneLoaderPluginExtensions;
  117006. /**
  117007. * The callback called when loading from a url.
  117008. * @param scene scene loading this url
  117009. * @param url url to load
  117010. * @param onSuccess callback called when the file successfully loads
  117011. * @param onProgress callback called while file is loading (if the server supports this mode)
  117012. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117013. * @param onError callback called when the file fails to load
  117014. * @returns a file request object
  117015. */
  117016. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117017. /**
  117018. * The callback called when loading from a file object.
  117019. * @param scene scene loading this file
  117020. * @param file defines the file to load
  117021. * @param onSuccess defines the callback to call when data is loaded
  117022. * @param onProgress defines the callback to call during loading process
  117023. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117024. * @param onError defines the callback to call when an error occurs
  117025. * @returns a file request object
  117026. */
  117027. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117028. /**
  117029. * The callback that returns true if the data can be directly loaded.
  117030. * @param data string containing the file data
  117031. * @returns if the data can be loaded directly
  117032. */
  117033. canDirectLoad?(data: string): boolean;
  117034. /**
  117035. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117036. * @param scene scene loading this data
  117037. * @param data string containing the data
  117038. * @returns data to pass to the plugin
  117039. */
  117040. directLoad?(scene: Scene, data: string): any;
  117041. /**
  117042. * The callback that allows custom handling of the root url based on the response url.
  117043. * @param rootUrl the original root url
  117044. * @param responseURL the response url if available
  117045. * @returns the new root url
  117046. */
  117047. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117048. }
  117049. /**
  117050. * Interface used to define a SceneLoader plugin
  117051. */
  117052. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117053. /**
  117054. * Import meshes into a scene.
  117055. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117056. * @param scene The scene to import into
  117057. * @param data The data to import
  117058. * @param rootUrl The root url for scene and resources
  117059. * @param meshes The meshes array to import into
  117060. * @param particleSystems The particle systems array to import into
  117061. * @param skeletons The skeletons array to import into
  117062. * @param onError The callback when import fails
  117063. * @returns True if successful or false otherwise
  117064. */
  117065. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117066. /**
  117067. * Load into a scene.
  117068. * @param scene The scene to load into
  117069. * @param data The data to import
  117070. * @param rootUrl The root url for scene and resources
  117071. * @param onError The callback when import fails
  117072. * @returns True if successful or false otherwise
  117073. */
  117074. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  117075. /**
  117076. * Load into an asset container.
  117077. * @param scene The scene to load into
  117078. * @param data The data to import
  117079. * @param rootUrl The root url for scene and resources
  117080. * @param onError The callback when import fails
  117081. * @returns The loaded asset container
  117082. */
  117083. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  117084. }
  117085. /**
  117086. * Interface used to define an async SceneLoader plugin
  117087. */
  117088. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  117089. /**
  117090. * Import meshes into a scene.
  117091. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117092. * @param scene The scene to import into
  117093. * @param data The data to import
  117094. * @param rootUrl The root url for scene and resources
  117095. * @param onProgress The callback when the load progresses
  117096. * @param fileName Defines the name of the file to load
  117097. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  117098. */
  117099. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  117100. meshes: AbstractMesh[];
  117101. particleSystems: IParticleSystem[];
  117102. skeletons: Skeleton[];
  117103. animationGroups: AnimationGroup[];
  117104. }>;
  117105. /**
  117106. * Load into a scene.
  117107. * @param scene The scene to load into
  117108. * @param data The data to import
  117109. * @param rootUrl The root url for scene and resources
  117110. * @param onProgress The callback when the load progresses
  117111. * @param fileName Defines the name of the file to load
  117112. * @returns Nothing
  117113. */
  117114. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  117115. /**
  117116. * Load into an asset container.
  117117. * @param scene The scene to load into
  117118. * @param data The data to import
  117119. * @param rootUrl The root url for scene and resources
  117120. * @param onProgress The callback when the load progresses
  117121. * @param fileName Defines the name of the file to load
  117122. * @returns The loaded asset container
  117123. */
  117124. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  117125. }
  117126. /**
  117127. * Mode that determines how to handle old animation groups before loading new ones.
  117128. */
  117129. export enum SceneLoaderAnimationGroupLoadingMode {
  117130. /**
  117131. * Reset all old animations to initial state then dispose them.
  117132. */
  117133. Clean = 0,
  117134. /**
  117135. * Stop all old animations.
  117136. */
  117137. Stop = 1,
  117138. /**
  117139. * Restart old animations from first frame.
  117140. */
  117141. Sync = 2,
  117142. /**
  117143. * Old animations remains untouched.
  117144. */
  117145. NoSync = 3
  117146. }
  117147. /**
  117148. * Class used to load scene from various file formats using registered plugins
  117149. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  117150. */
  117151. export class SceneLoader {
  117152. /**
  117153. * No logging while loading
  117154. */
  117155. static readonly NO_LOGGING: number;
  117156. /**
  117157. * Minimal logging while loading
  117158. */
  117159. static readonly MINIMAL_LOGGING: number;
  117160. /**
  117161. * Summary logging while loading
  117162. */
  117163. static readonly SUMMARY_LOGGING: number;
  117164. /**
  117165. * Detailled logging while loading
  117166. */
  117167. static readonly DETAILED_LOGGING: number;
  117168. /**
  117169. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  117170. */
  117171. static get ForceFullSceneLoadingForIncremental(): boolean;
  117172. static set ForceFullSceneLoadingForIncremental(value: boolean);
  117173. /**
  117174. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  117175. */
  117176. static get ShowLoadingScreen(): boolean;
  117177. static set ShowLoadingScreen(value: boolean);
  117178. /**
  117179. * Defines the current logging level (while loading the scene)
  117180. * @ignorenaming
  117181. */
  117182. static get loggingLevel(): number;
  117183. static set loggingLevel(value: number);
  117184. /**
  117185. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  117186. */
  117187. static get CleanBoneMatrixWeights(): boolean;
  117188. static set CleanBoneMatrixWeights(value: boolean);
  117189. /**
  117190. * Event raised when a plugin is used to load a scene
  117191. */
  117192. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  117193. private static _registeredPlugins;
  117194. private static _getDefaultPlugin;
  117195. private static _getPluginForExtension;
  117196. private static _getPluginForDirectLoad;
  117197. private static _getPluginForFilename;
  117198. private static _getDirectLoad;
  117199. private static _loadData;
  117200. private static _getFileInfo;
  117201. /**
  117202. * Gets a plugin that can load the given extension
  117203. * @param extension defines the extension to load
  117204. * @returns a plugin or null if none works
  117205. */
  117206. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  117207. /**
  117208. * Gets a boolean indicating that the given extension can be loaded
  117209. * @param extension defines the extension to load
  117210. * @returns true if the extension is supported
  117211. */
  117212. static IsPluginForExtensionAvailable(extension: string): boolean;
  117213. /**
  117214. * Adds a new plugin to the list of registered plugins
  117215. * @param plugin defines the plugin to add
  117216. */
  117217. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  117218. /**
  117219. * Import meshes into a scene
  117220. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117221. * @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)
  117222. * @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)
  117223. * @param scene the instance of BABYLON.Scene to append to
  117224. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  117225. * @param onProgress a callback with a progress event for each file being loaded
  117226. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117227. * @param pluginExtension the extension used to determine the plugin
  117228. * @returns The loaded plugin
  117229. */
  117230. 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>;
  117231. /**
  117232. * Import meshes into a scene
  117233. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117234. * @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)
  117235. * @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)
  117236. * @param scene the instance of BABYLON.Scene to append to
  117237. * @param onProgress a callback with a progress event for each file being loaded
  117238. * @param pluginExtension the extension used to determine the plugin
  117239. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  117240. */
  117241. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  117242. meshes: AbstractMesh[];
  117243. particleSystems: IParticleSystem[];
  117244. skeletons: Skeleton[];
  117245. animationGroups: AnimationGroup[];
  117246. }>;
  117247. /**
  117248. * Load a scene
  117249. * @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)
  117250. * @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)
  117251. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117252. * @param onSuccess a callback with the scene when import succeeds
  117253. * @param onProgress a callback with a progress event for each file being loaded
  117254. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117255. * @param pluginExtension the extension used to determine the plugin
  117256. * @returns The loaded plugin
  117257. */
  117258. 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>;
  117259. /**
  117260. * Load a scene
  117261. * @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)
  117262. * @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)
  117263. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117264. * @param onProgress a callback with a progress event for each file being loaded
  117265. * @param pluginExtension the extension used to determine the plugin
  117266. * @returns The loaded scene
  117267. */
  117268. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117269. /**
  117270. * Append a scene
  117271. * @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)
  117272. * @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)
  117273. * @param scene is the instance of BABYLON.Scene to append to
  117274. * @param onSuccess a callback with the scene when import succeeds
  117275. * @param onProgress a callback with a progress event for each file being loaded
  117276. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117277. * @param pluginExtension the extension used to determine the plugin
  117278. * @returns The loaded plugin
  117279. */
  117280. 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>;
  117281. /**
  117282. * Append a scene
  117283. * @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)
  117284. * @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)
  117285. * @param scene is the instance of BABYLON.Scene to append to
  117286. * @param onProgress a callback with a progress event for each file being loaded
  117287. * @param pluginExtension the extension used to determine the plugin
  117288. * @returns The given scene
  117289. */
  117290. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117291. /**
  117292. * Load a scene into an asset container
  117293. * @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)
  117294. * @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)
  117295. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117296. * @param onSuccess a callback with the scene when import succeeds
  117297. * @param onProgress a callback with a progress event for each file being loaded
  117298. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117299. * @param pluginExtension the extension used to determine the plugin
  117300. * @returns The loaded plugin
  117301. */
  117302. 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>;
  117303. /**
  117304. * Load a scene into an asset container
  117305. * @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)
  117306. * @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)
  117307. * @param scene is the instance of Scene to append to
  117308. * @param onProgress a callback with a progress event for each file being loaded
  117309. * @param pluginExtension the extension used to determine the plugin
  117310. * @returns The loaded asset container
  117311. */
  117312. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  117313. /**
  117314. * Import animations from a file into a scene
  117315. * @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)
  117316. * @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)
  117317. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117318. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117319. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117320. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117321. * @param onSuccess a callback with the scene when import succeeds
  117322. * @param onProgress a callback with a progress event for each file being loaded
  117323. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117324. */
  117325. 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;
  117326. /**
  117327. * Import animations from a file into a scene
  117328. * @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)
  117329. * @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)
  117330. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117331. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117332. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117333. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117334. * @param onSuccess a callback with the scene when import succeeds
  117335. * @param onProgress a callback with a progress event for each file being loaded
  117336. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117337. * @returns the updated scene with imported animations
  117338. */
  117339. 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>;
  117340. }
  117341. }
  117342. declare module BABYLON {
  117343. /**
  117344. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  117345. */
  117346. export type MotionControllerHandness = "none" | "left" | "right";
  117347. /**
  117348. * The type of components available in motion controllers.
  117349. * This is not the name of the component.
  117350. */
  117351. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  117352. /**
  117353. * The state of a controller component
  117354. */
  117355. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  117356. /**
  117357. * The schema of motion controller layout.
  117358. * No object will be initialized using this interface
  117359. * This is used just to define the profile.
  117360. */
  117361. export interface IMotionControllerLayout {
  117362. /**
  117363. * Path to load the assets. Usually relative to the base path
  117364. */
  117365. assetPath: string;
  117366. /**
  117367. * Available components (unsorted)
  117368. */
  117369. components: {
  117370. /**
  117371. * A map of component Ids
  117372. */
  117373. [componentId: string]: {
  117374. /**
  117375. * The type of input the component outputs
  117376. */
  117377. type: MotionControllerComponentType;
  117378. /**
  117379. * The indices of this component in the gamepad object
  117380. */
  117381. gamepadIndices: {
  117382. /**
  117383. * Index of button
  117384. */
  117385. button?: number;
  117386. /**
  117387. * If available, index of x-axis
  117388. */
  117389. xAxis?: number;
  117390. /**
  117391. * If available, index of y-axis
  117392. */
  117393. yAxis?: number;
  117394. };
  117395. /**
  117396. * The mesh's root node name
  117397. */
  117398. rootNodeName: string;
  117399. /**
  117400. * Animation definitions for this model
  117401. */
  117402. visualResponses: {
  117403. [stateKey: string]: {
  117404. /**
  117405. * What property will be animated
  117406. */
  117407. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117408. /**
  117409. * What states influence this visual response
  117410. */
  117411. states: MotionControllerComponentStateType[];
  117412. /**
  117413. * Type of animation - movement or visibility
  117414. */
  117415. valueNodeProperty: "transform" | "visibility";
  117416. /**
  117417. * Base node name to move. Its position will be calculated according to the min and max nodes
  117418. */
  117419. valueNodeName?: string;
  117420. /**
  117421. * Minimum movement node
  117422. */
  117423. minNodeName?: string;
  117424. /**
  117425. * Max movement node
  117426. */
  117427. maxNodeName?: string;
  117428. };
  117429. };
  117430. /**
  117431. * If touch enabled, what is the name of node to display user feedback
  117432. */
  117433. touchPointNodeName?: string;
  117434. };
  117435. };
  117436. /**
  117437. * Is it xr standard mapping or not
  117438. */
  117439. gamepadMapping: "" | "xr-standard";
  117440. /**
  117441. * Base root node of this entire model
  117442. */
  117443. rootNodeName: string;
  117444. /**
  117445. * Defines the main button component id
  117446. */
  117447. selectComponentId: string;
  117448. }
  117449. /**
  117450. * A definition for the layout map in the input profile
  117451. */
  117452. export interface IMotionControllerLayoutMap {
  117453. /**
  117454. * Layouts with handness type as a key
  117455. */
  117456. [handness: string]: IMotionControllerLayout;
  117457. }
  117458. /**
  117459. * The XR Input profile schema
  117460. * Profiles can be found here:
  117461. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117462. */
  117463. export interface IMotionControllerProfile {
  117464. /**
  117465. * fallback profiles for this profileId
  117466. */
  117467. fallbackProfileIds: string[];
  117468. /**
  117469. * The layout map, with handness as key
  117470. */
  117471. layouts: IMotionControllerLayoutMap;
  117472. /**
  117473. * The id of this profile
  117474. * correlates to the profile(s) in the xrInput.profiles array
  117475. */
  117476. profileId: string;
  117477. }
  117478. /**
  117479. * A helper-interface for the 3 meshes needed for controller button animation
  117480. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117481. */
  117482. export interface IMotionControllerButtonMeshMap {
  117483. /**
  117484. * the mesh that defines the pressed value mesh position.
  117485. * This is used to find the max-position of this button
  117486. */
  117487. pressedMesh: AbstractMesh;
  117488. /**
  117489. * the mesh that defines the unpressed value mesh position.
  117490. * This is used to find the min (or initial) position of this button
  117491. */
  117492. unpressedMesh: AbstractMesh;
  117493. /**
  117494. * The mesh that will be changed when value changes
  117495. */
  117496. valueMesh: AbstractMesh;
  117497. }
  117498. /**
  117499. * A helper-interface for the 3 meshes needed for controller axis animation.
  117500. * This will be expanded when touchpad animations are fully supported
  117501. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117502. */
  117503. export interface IMotionControllerMeshMap {
  117504. /**
  117505. * the mesh that defines the maximum value mesh position.
  117506. */
  117507. maxMesh?: AbstractMesh;
  117508. /**
  117509. * the mesh that defines the minimum value mesh position.
  117510. */
  117511. minMesh?: AbstractMesh;
  117512. /**
  117513. * The mesh that will be changed when axis value changes
  117514. */
  117515. valueMesh: AbstractMesh;
  117516. }
  117517. /**
  117518. * The elements needed for change-detection of the gamepad objects in motion controllers
  117519. */
  117520. export interface IMinimalMotionControllerObject {
  117521. /**
  117522. * Available axes of this controller
  117523. */
  117524. axes: number[];
  117525. /**
  117526. * An array of available buttons
  117527. */
  117528. buttons: Array<{
  117529. /**
  117530. * Value of the button/trigger
  117531. */
  117532. value: number;
  117533. /**
  117534. * If the button/trigger is currently touched
  117535. */
  117536. touched: boolean;
  117537. /**
  117538. * If the button/trigger is currently pressed
  117539. */
  117540. pressed: boolean;
  117541. }>;
  117542. }
  117543. /**
  117544. * An Abstract Motion controller
  117545. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117546. * Each component has an observable to check for changes in value and state
  117547. */
  117548. export abstract class WebXRAbstractMotionController implements IDisposable {
  117549. protected scene: Scene;
  117550. protected layout: IMotionControllerLayout;
  117551. /**
  117552. * The gamepad object correlating to this controller
  117553. */
  117554. gamepadObject: IMinimalMotionControllerObject;
  117555. /**
  117556. * handness (left/right/none) of this controller
  117557. */
  117558. handness: MotionControllerHandness;
  117559. private _initComponent;
  117560. private _modelReady;
  117561. /**
  117562. * A map of components (WebXRControllerComponent) in this motion controller
  117563. * Components have a ComponentType and can also have both button and axis definitions
  117564. */
  117565. readonly components: {
  117566. [id: string]: WebXRControllerComponent;
  117567. };
  117568. /**
  117569. * Disable the model's animation. Can be set at any time.
  117570. */
  117571. disableAnimation: boolean;
  117572. /**
  117573. * Observers registered here will be triggered when the model of this controller is done loading
  117574. */
  117575. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117576. /**
  117577. * The profile id of this motion controller
  117578. */
  117579. abstract profileId: string;
  117580. /**
  117581. * The root mesh of the model. It is null if the model was not yet initialized
  117582. */
  117583. rootMesh: Nullable<AbstractMesh>;
  117584. /**
  117585. * constructs a new abstract motion controller
  117586. * @param scene the scene to which the model of the controller will be added
  117587. * @param layout The profile layout to load
  117588. * @param gamepadObject The gamepad object correlating to this controller
  117589. * @param handness handness (left/right/none) of this controller
  117590. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117591. */
  117592. constructor(scene: Scene, layout: IMotionControllerLayout,
  117593. /**
  117594. * The gamepad object correlating to this controller
  117595. */
  117596. gamepadObject: IMinimalMotionControllerObject,
  117597. /**
  117598. * handness (left/right/none) of this controller
  117599. */
  117600. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117601. /**
  117602. * Dispose this controller, the model mesh and all its components
  117603. */
  117604. dispose(): void;
  117605. /**
  117606. * Returns all components of specific type
  117607. * @param type the type to search for
  117608. * @return an array of components with this type
  117609. */
  117610. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117611. /**
  117612. * get a component based an its component id as defined in layout.components
  117613. * @param id the id of the component
  117614. * @returns the component correlates to the id or undefined if not found
  117615. */
  117616. getComponent(id: string): WebXRControllerComponent;
  117617. /**
  117618. * Get the list of components available in this motion controller
  117619. * @returns an array of strings correlating to available components
  117620. */
  117621. getComponentIds(): string[];
  117622. /**
  117623. * Get the first component of specific type
  117624. * @param type type of component to find
  117625. * @return a controller component or null if not found
  117626. */
  117627. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117628. /**
  117629. * Get the main (Select) component of this controller as defined in the layout
  117630. * @returns the main component of this controller
  117631. */
  117632. getMainComponent(): WebXRControllerComponent;
  117633. /**
  117634. * Loads the model correlating to this controller
  117635. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117636. * @returns A promise fulfilled with the result of the model loading
  117637. */
  117638. loadModel(): Promise<boolean>;
  117639. /**
  117640. * Update this model using the current XRFrame
  117641. * @param xrFrame the current xr frame to use and update the model
  117642. */
  117643. updateFromXRFrame(xrFrame: XRFrame): void;
  117644. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117645. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117646. /**
  117647. * Moves the axis on the controller mesh based on its current state
  117648. * @param axis the index of the axis
  117649. * @param axisValue the value of the axis which determines the meshes new position
  117650. * @hidden
  117651. */
  117652. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117653. /**
  117654. * Update the model itself with the current frame data
  117655. * @param xrFrame the frame to use for updating the model mesh
  117656. */
  117657. protected updateModel(xrFrame: XRFrame): void;
  117658. /**
  117659. * Get the filename and path for this controller's model
  117660. * @returns a map of filename and path
  117661. */
  117662. protected abstract _getFilenameAndPath(): {
  117663. filename: string;
  117664. path: string;
  117665. };
  117666. /**
  117667. * This function is called before the mesh is loaded. It checks for loading constraints.
  117668. * For example, this function can check if the GLB loader is available
  117669. * If this function returns false, the generic controller will be loaded instead
  117670. * @returns Is the client ready to load the mesh
  117671. */
  117672. protected abstract _getModelLoadingConstraints(): boolean;
  117673. /**
  117674. * This function will be called after the model was successfully loaded and can be used
  117675. * for mesh transformations before it is available for the user
  117676. * @param meshes the loaded meshes
  117677. */
  117678. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117679. /**
  117680. * Set the root mesh for this controller. Important for the WebXR controller class
  117681. * @param meshes the loaded meshes
  117682. */
  117683. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117684. /**
  117685. * A function executed each frame that updates the mesh (if needed)
  117686. * @param xrFrame the current xrFrame
  117687. */
  117688. protected abstract _updateModel(xrFrame: XRFrame): void;
  117689. private _getGenericFilenameAndPath;
  117690. private _getGenericParentMesh;
  117691. }
  117692. }
  117693. declare module BABYLON {
  117694. /**
  117695. * A generic trigger-only motion controller for WebXR
  117696. */
  117697. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117698. /**
  117699. * Static version of the profile id of this controller
  117700. */
  117701. static ProfileId: string;
  117702. profileId: string;
  117703. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117704. protected _getFilenameAndPath(): {
  117705. filename: string;
  117706. path: string;
  117707. };
  117708. protected _getModelLoadingConstraints(): boolean;
  117709. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117710. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117711. protected _updateModel(): void;
  117712. }
  117713. }
  117714. declare module BABYLON {
  117715. /**
  117716. * Class containing static functions to help procedurally build meshes
  117717. */
  117718. export class SphereBuilder {
  117719. /**
  117720. * Creates a sphere mesh
  117721. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117722. * * 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`)
  117723. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117724. * * 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
  117725. * * 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)
  117726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117729. * @param name defines the name of the mesh
  117730. * @param options defines the options used to create the mesh
  117731. * @param scene defines the hosting scene
  117732. * @returns the sphere mesh
  117733. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117734. */
  117735. static CreateSphere(name: string, options: {
  117736. segments?: number;
  117737. diameter?: number;
  117738. diameterX?: number;
  117739. diameterY?: number;
  117740. diameterZ?: number;
  117741. arc?: number;
  117742. slice?: number;
  117743. sideOrientation?: number;
  117744. frontUVs?: Vector4;
  117745. backUVs?: Vector4;
  117746. updatable?: boolean;
  117747. }, scene?: Nullable<Scene>): Mesh;
  117748. }
  117749. }
  117750. declare module BABYLON {
  117751. /**
  117752. * A profiled motion controller has its profile loaded from an online repository.
  117753. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117754. */
  117755. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117756. private _repositoryUrl;
  117757. private _buttonMeshMapping;
  117758. private _touchDots;
  117759. /**
  117760. * The profile ID of this controller. Will be populated when the controller initializes.
  117761. */
  117762. profileId: string;
  117763. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117764. dispose(): void;
  117765. protected _getFilenameAndPath(): {
  117766. filename: string;
  117767. path: string;
  117768. };
  117769. protected _getModelLoadingConstraints(): boolean;
  117770. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117771. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117772. protected _updateModel(_xrFrame: XRFrame): void;
  117773. }
  117774. }
  117775. declare module BABYLON {
  117776. /**
  117777. * A construction function type to create a new controller based on an xrInput object
  117778. */
  117779. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117780. /**
  117781. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117782. *
  117783. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117784. * it should be replaced with auto-loaded controllers.
  117785. *
  117786. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117787. */
  117788. export class WebXRMotionControllerManager {
  117789. private static _AvailableControllers;
  117790. private static _Fallbacks;
  117791. private static _ProfileLoadingPromises;
  117792. private static _ProfilesList;
  117793. /**
  117794. * The base URL of the online controller repository. Can be changed at any time.
  117795. */
  117796. static BaseRepositoryUrl: string;
  117797. /**
  117798. * Which repository gets priority - local or online
  117799. */
  117800. static PrioritizeOnlineRepository: boolean;
  117801. /**
  117802. * Use the online repository, or use only locally-defined controllers
  117803. */
  117804. static UseOnlineRepository: boolean;
  117805. /**
  117806. * Clear the cache used for profile loading and reload when requested again
  117807. */
  117808. static ClearProfilesCache(): void;
  117809. /**
  117810. * Register the default fallbacks.
  117811. * This function is called automatically when this file is imported.
  117812. */
  117813. static DefaultFallbacks(): void;
  117814. /**
  117815. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117816. * @param profileId the profile to which a fallback needs to be found
  117817. * @return an array with corresponding fallback profiles
  117818. */
  117819. static FindFallbackWithProfileId(profileId: string): string[];
  117820. /**
  117821. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117822. * The order of search:
  117823. *
  117824. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117825. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117826. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117827. * 4) return the generic trigger controller if none were found
  117828. *
  117829. * @param xrInput the xrInput to which a new controller is initialized
  117830. * @param scene the scene to which the model will be added
  117831. * @param forceProfile force a certain profile for this controller
  117832. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117833. */
  117834. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117835. /**
  117836. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117837. *
  117838. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117839. *
  117840. * @param type the profile type to register
  117841. * @param constructFunction the function to be called when loading this profile
  117842. */
  117843. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117844. /**
  117845. * Register a fallback to a specific profile.
  117846. * @param profileId the profileId that will receive the fallbacks
  117847. * @param fallbacks A list of fallback profiles
  117848. */
  117849. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117850. /**
  117851. * Will update the list of profiles available in the repository
  117852. * @return a promise that resolves to a map of profiles available online
  117853. */
  117854. static UpdateProfilesList(): Promise<{
  117855. [profile: string]: string;
  117856. }>;
  117857. private static _LoadProfileFromRepository;
  117858. private static _LoadProfilesFromAvailableControllers;
  117859. }
  117860. }
  117861. declare module BABYLON {
  117862. /**
  117863. * Configuration options for the WebXR controller creation
  117864. */
  117865. export interface IWebXRControllerOptions {
  117866. /**
  117867. * Should the controller mesh be animated when a user interacts with it
  117868. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117869. */
  117870. disableMotionControllerAnimation?: boolean;
  117871. /**
  117872. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117873. */
  117874. doNotLoadControllerMesh?: boolean;
  117875. /**
  117876. * Force a specific controller type for this controller.
  117877. * This can be used when creating your own profile or when testing different controllers
  117878. */
  117879. forceControllerProfile?: string;
  117880. }
  117881. /**
  117882. * Represents an XR controller
  117883. */
  117884. export class WebXRInputSource {
  117885. private _scene;
  117886. /** The underlying input source for the controller */
  117887. inputSource: XRInputSource;
  117888. private _options;
  117889. private _tmpQuaternion;
  117890. private _tmpVector;
  117891. private _uniqueId;
  117892. /**
  117893. * 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
  117894. */
  117895. grip?: AbstractMesh;
  117896. /**
  117897. * If available, this is the gamepad object related to this controller.
  117898. * Using this object it is possible to get click events and trackpad changes of the
  117899. * webxr controller that is currently being used.
  117900. */
  117901. motionController?: WebXRAbstractMotionController;
  117902. /**
  117903. * Event that fires when the controller is removed/disposed.
  117904. * The object provided as event data is this controller, after associated assets were disposed.
  117905. * uniqueId is still available.
  117906. */
  117907. onDisposeObservable: Observable<WebXRInputSource>;
  117908. /**
  117909. * Will be triggered when the mesh associated with the motion controller is done loading.
  117910. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117911. * A shortened version of controller -> motion controller -> on mesh loaded.
  117912. */
  117913. onMeshLoadedObservable: Observable<AbstractMesh>;
  117914. /**
  117915. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117916. */
  117917. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117918. /**
  117919. * Pointer which can be used to select objects or attach a visible laser to
  117920. */
  117921. pointer: AbstractMesh;
  117922. /**
  117923. * Creates the controller
  117924. * @see https://doc.babylonjs.com/how_to/webxr
  117925. * @param _scene the scene which the controller should be associated to
  117926. * @param inputSource the underlying input source for the controller
  117927. * @param _options options for this controller creation
  117928. */
  117929. constructor(_scene: Scene,
  117930. /** The underlying input source for the controller */
  117931. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117932. /**
  117933. * Get this controllers unique id
  117934. */
  117935. get uniqueId(): string;
  117936. /**
  117937. * Disposes of the object
  117938. */
  117939. dispose(): void;
  117940. /**
  117941. * Gets a world space ray coming from the pointer or grip
  117942. * @param result the resulting ray
  117943. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117944. */
  117945. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117946. /**
  117947. * Updates the controller pose based on the given XRFrame
  117948. * @param xrFrame xr frame to update the pose with
  117949. * @param referenceSpace reference space to use
  117950. */
  117951. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117952. }
  117953. }
  117954. declare module BABYLON {
  117955. /**
  117956. * The schema for initialization options of the XR Input class
  117957. */
  117958. export interface IWebXRInputOptions {
  117959. /**
  117960. * If set to true no model will be automatically loaded
  117961. */
  117962. doNotLoadControllerMeshes?: boolean;
  117963. /**
  117964. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117965. * If not found, the xr input profile data will be used.
  117966. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117967. */
  117968. forceInputProfile?: string;
  117969. /**
  117970. * Do not send a request to the controller repository to load the profile.
  117971. *
  117972. * Instead, use the controllers available in babylon itself.
  117973. */
  117974. disableOnlineControllerRepository?: boolean;
  117975. /**
  117976. * A custom URL for the controllers repository
  117977. */
  117978. customControllersRepositoryURL?: string;
  117979. /**
  117980. * Should the controller model's components not move according to the user input
  117981. */
  117982. disableControllerAnimation?: boolean;
  117983. }
  117984. /**
  117985. * XR input used to track XR inputs such as controllers/rays
  117986. */
  117987. export class WebXRInput implements IDisposable {
  117988. /**
  117989. * the xr session manager for this session
  117990. */
  117991. xrSessionManager: WebXRSessionManager;
  117992. /**
  117993. * the WebXR camera for this session. Mainly used for teleportation
  117994. */
  117995. xrCamera: WebXRCamera;
  117996. private readonly options;
  117997. /**
  117998. * XR controllers being tracked
  117999. */
  118000. controllers: Array<WebXRInputSource>;
  118001. private _frameObserver;
  118002. private _sessionEndedObserver;
  118003. private _sessionInitObserver;
  118004. /**
  118005. * Event when a controller has been connected/added
  118006. */
  118007. onControllerAddedObservable: Observable<WebXRInputSource>;
  118008. /**
  118009. * Event when a controller has been removed/disconnected
  118010. */
  118011. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118012. /**
  118013. * Initializes the WebXRInput
  118014. * @param xrSessionManager the xr session manager for this session
  118015. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118016. * @param options = initialization options for this xr input
  118017. */
  118018. constructor(
  118019. /**
  118020. * the xr session manager for this session
  118021. */
  118022. xrSessionManager: WebXRSessionManager,
  118023. /**
  118024. * the WebXR camera for this session. Mainly used for teleportation
  118025. */
  118026. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118027. private _onInputSourcesChange;
  118028. private _addAndRemoveControllers;
  118029. /**
  118030. * Disposes of the object
  118031. */
  118032. dispose(): void;
  118033. }
  118034. }
  118035. declare module BABYLON {
  118036. /**
  118037. * This is the base class for all WebXR features.
  118038. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118039. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118040. */
  118041. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118042. protected _xrSessionManager: WebXRSessionManager;
  118043. private _attached;
  118044. private _removeOnDetach;
  118045. /**
  118046. * Should auto-attach be disabled?
  118047. */
  118048. disableAutoAttach: boolean;
  118049. /**
  118050. * Construct a new (abstract) WebXR feature
  118051. * @param _xrSessionManager the xr session manager for this feature
  118052. */
  118053. constructor(_xrSessionManager: WebXRSessionManager);
  118054. /**
  118055. * Is this feature attached
  118056. */
  118057. get attached(): boolean;
  118058. /**
  118059. * attach this feature
  118060. *
  118061. * @param force should attachment be forced (even when already attached)
  118062. * @returns true if successful, false is failed or already attached
  118063. */
  118064. attach(force?: boolean): boolean;
  118065. /**
  118066. * detach this feature.
  118067. *
  118068. * @returns true if successful, false if failed or already detached
  118069. */
  118070. detach(): boolean;
  118071. /**
  118072. * Dispose this feature and all of the resources attached
  118073. */
  118074. dispose(): void;
  118075. /**
  118076. * This is used to register callbacks that will automatically be removed when detach is called.
  118077. * @param observable the observable to which the observer will be attached
  118078. * @param callback the callback to register
  118079. */
  118080. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  118081. /**
  118082. * Code in this function will be executed on each xrFrame received from the browser.
  118083. * This function will not execute after the feature is detached.
  118084. * @param _xrFrame the current frame
  118085. */
  118086. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  118087. }
  118088. }
  118089. declare module BABYLON {
  118090. /**
  118091. * Renders a layer on top of an existing scene
  118092. */
  118093. export class UtilityLayerRenderer implements IDisposable {
  118094. /** the original scene that will be rendered on top of */
  118095. originalScene: Scene;
  118096. private _pointerCaptures;
  118097. private _lastPointerEvents;
  118098. private static _DefaultUtilityLayer;
  118099. private static _DefaultKeepDepthUtilityLayer;
  118100. private _sharedGizmoLight;
  118101. private _renderCamera;
  118102. /**
  118103. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118104. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  118105. * @returns the camera that is used when rendering the utility layer
  118106. */
  118107. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  118108. /**
  118109. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118110. * @param cam the camera that should be used when rendering the utility layer
  118111. */
  118112. setRenderCamera(cam: Nullable<Camera>): void;
  118113. /**
  118114. * @hidden
  118115. * Light which used by gizmos to get light shading
  118116. */
  118117. _getSharedGizmoLight(): HemisphericLight;
  118118. /**
  118119. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118120. */
  118121. pickUtilitySceneFirst: boolean;
  118122. /**
  118123. * 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)
  118124. */
  118125. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118126. /**
  118127. * 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)
  118128. */
  118129. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118130. /**
  118131. * The scene that is rendered on top of the original scene
  118132. */
  118133. utilityLayerScene: Scene;
  118134. /**
  118135. * If the utility layer should automatically be rendered on top of existing scene
  118136. */
  118137. shouldRender: boolean;
  118138. /**
  118139. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118140. */
  118141. onlyCheckPointerDownEvents: boolean;
  118142. /**
  118143. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118144. */
  118145. processAllEvents: boolean;
  118146. /**
  118147. * Observable raised when the pointer move from the utility layer scene to the main scene
  118148. */
  118149. onPointerOutObservable: Observable<number>;
  118150. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118151. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118152. private _afterRenderObserver;
  118153. private _sceneDisposeObserver;
  118154. private _originalPointerObserver;
  118155. /**
  118156. * Instantiates a UtilityLayerRenderer
  118157. * @param originalScene the original scene that will be rendered on top of
  118158. * @param handleEvents boolean indicating if the utility layer should handle events
  118159. */
  118160. constructor(
  118161. /** the original scene that will be rendered on top of */
  118162. originalScene: Scene, handleEvents?: boolean);
  118163. private _notifyObservers;
  118164. /**
  118165. * Renders the utility layers scene on top of the original scene
  118166. */
  118167. render(): void;
  118168. /**
  118169. * Disposes of the renderer
  118170. */
  118171. dispose(): void;
  118172. private _updateCamera;
  118173. }
  118174. }
  118175. declare module BABYLON {
  118176. /**
  118177. * Options interface for the pointer selection module
  118178. */
  118179. export interface IWebXRControllerPointerSelectionOptions {
  118180. /**
  118181. * if provided, this scene will be used to render meshes.
  118182. */
  118183. customUtilityLayerScene?: Scene;
  118184. /**
  118185. * 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)
  118186. * If not disabled, the last picked point will be used to execute a pointer up event
  118187. * If disabled, pointer up event will be triggered right after the pointer down event.
  118188. * Used in screen and gaze target ray mode only
  118189. */
  118190. disablePointerUpOnTouchOut: boolean;
  118191. /**
  118192. * For gaze mode (time to select instead of press)
  118193. */
  118194. forceGazeMode: boolean;
  118195. /**
  118196. * 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
  118197. * to start a new countdown to the pointer down event.
  118198. * Defaults to 1.
  118199. */
  118200. gazeModePointerMovedFactor?: number;
  118201. /**
  118202. * Different button type to use instead of the main component
  118203. */
  118204. overrideButtonId?: string;
  118205. /**
  118206. * use this rendering group id for the meshes (optional)
  118207. */
  118208. renderingGroupId?: number;
  118209. /**
  118210. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  118211. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  118212. * 3000 means 3 seconds between pointing at something and selecting it
  118213. */
  118214. timeToSelect?: number;
  118215. /**
  118216. * Should meshes created here be added to a utility layer or the main scene
  118217. */
  118218. useUtilityLayer?: boolean;
  118219. /**
  118220. * the xr input to use with this pointer selection
  118221. */
  118222. xrInput: WebXRInput;
  118223. }
  118224. /**
  118225. * A module that will enable pointer selection for motion controllers of XR Input Sources
  118226. */
  118227. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  118228. private readonly _options;
  118229. private static _idCounter;
  118230. private _attachController;
  118231. private _controllers;
  118232. private _scene;
  118233. private _tmpVectorForPickCompare;
  118234. /**
  118235. * The module's name
  118236. */
  118237. static readonly Name: string;
  118238. /**
  118239. * The (Babylon) version of this module.
  118240. * This is an integer representing the implementation version.
  118241. * This number does not correspond to the WebXR specs version
  118242. */
  118243. static readonly Version: number;
  118244. /**
  118245. * Disable lighting on the laser pointer (so it will always be visible)
  118246. */
  118247. disablePointerLighting: boolean;
  118248. /**
  118249. * Disable lighting on the selection mesh (so it will always be visible)
  118250. */
  118251. disableSelectionMeshLighting: boolean;
  118252. /**
  118253. * Should the laser pointer be displayed
  118254. */
  118255. displayLaserPointer: boolean;
  118256. /**
  118257. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  118258. */
  118259. displaySelectionMesh: boolean;
  118260. /**
  118261. * This color will be set to the laser pointer when selection is triggered
  118262. */
  118263. laserPointerPickedColor: Color3;
  118264. /**
  118265. * Default color of the laser pointer
  118266. */
  118267. lasterPointerDefaultColor: Color3;
  118268. /**
  118269. * default color of the selection ring
  118270. */
  118271. selectionMeshDefaultColor: Color3;
  118272. /**
  118273. * This color will be applied to the selection ring when selection is triggered
  118274. */
  118275. selectionMeshPickedColor: Color3;
  118276. /**
  118277. * Optional filter to be used for ray selection. This predicate shares behavior with
  118278. * scene.pointerMovePredicate which takes priority if it is also assigned.
  118279. */
  118280. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118281. /**
  118282. * constructs a new background remover module
  118283. * @param _xrSessionManager the session manager for this module
  118284. * @param _options read-only options to be used in this module
  118285. */
  118286. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  118287. /**
  118288. * attach this feature
  118289. * Will usually be called by the features manager
  118290. *
  118291. * @returns true if successful.
  118292. */
  118293. attach(): boolean;
  118294. /**
  118295. * detach this feature.
  118296. * Will usually be called by the features manager
  118297. *
  118298. * @returns true if successful.
  118299. */
  118300. detach(): boolean;
  118301. /**
  118302. * Will get the mesh under a specific pointer.
  118303. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  118304. * @param controllerId the controllerId to check
  118305. * @returns The mesh under pointer or null if no mesh is under the pointer
  118306. */
  118307. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  118308. /**
  118309. * Get the xr controller that correlates to the pointer id in the pointer event
  118310. *
  118311. * @param id the pointer id to search for
  118312. * @returns the controller that correlates to this id or null if not found
  118313. */
  118314. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  118315. protected _onXRFrame(_xrFrame: XRFrame): void;
  118316. private _attachGazeMode;
  118317. private _attachScreenRayMode;
  118318. private _attachTrackedPointerRayMode;
  118319. private _convertNormalToDirectionOfRay;
  118320. private _detachController;
  118321. private _generateNewMeshPair;
  118322. private _pickingMoved;
  118323. private _updatePointerDistance;
  118324. }
  118325. }
  118326. declare module BABYLON {
  118327. /**
  118328. * Button which can be used to enter a different mode of XR
  118329. */
  118330. export class WebXREnterExitUIButton {
  118331. /** button element */
  118332. element: HTMLElement;
  118333. /** XR initialization options for the button */
  118334. sessionMode: XRSessionMode;
  118335. /** Reference space type */
  118336. referenceSpaceType: XRReferenceSpaceType;
  118337. /**
  118338. * Creates a WebXREnterExitUIButton
  118339. * @param element button element
  118340. * @param sessionMode XR initialization session mode
  118341. * @param referenceSpaceType the type of reference space to be used
  118342. */
  118343. constructor(
  118344. /** button element */
  118345. element: HTMLElement,
  118346. /** XR initialization options for the button */
  118347. sessionMode: XRSessionMode,
  118348. /** Reference space type */
  118349. referenceSpaceType: XRReferenceSpaceType);
  118350. /**
  118351. * Extendable function which can be used to update the button's visuals when the state changes
  118352. * @param activeButton the current active button in the UI
  118353. */
  118354. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  118355. }
  118356. /**
  118357. * Options to create the webXR UI
  118358. */
  118359. export class WebXREnterExitUIOptions {
  118360. /**
  118361. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  118362. */
  118363. customButtons?: Array<WebXREnterExitUIButton>;
  118364. /**
  118365. * A reference space type to use when creating the default button.
  118366. * Default is local-floor
  118367. */
  118368. referenceSpaceType?: XRReferenceSpaceType;
  118369. /**
  118370. * Context to enter xr with
  118371. */
  118372. renderTarget?: Nullable<WebXRRenderTarget>;
  118373. /**
  118374. * A session mode to use when creating the default button.
  118375. * Default is immersive-vr
  118376. */
  118377. sessionMode?: XRSessionMode;
  118378. }
  118379. /**
  118380. * UI to allow the user to enter/exit XR mode
  118381. */
  118382. export class WebXREnterExitUI implements IDisposable {
  118383. private scene;
  118384. /** version of the options passed to this UI */
  118385. options: WebXREnterExitUIOptions;
  118386. private _activeButton;
  118387. private _buttons;
  118388. private _overlay;
  118389. /**
  118390. * Fired every time the active button is changed.
  118391. *
  118392. * When xr is entered via a button that launches xr that button will be the callback parameter
  118393. *
  118394. * When exiting xr the callback parameter will be null)
  118395. */
  118396. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  118397. /**
  118398. *
  118399. * @param scene babylon scene object to use
  118400. * @param options (read-only) version of the options passed to this UI
  118401. */
  118402. private constructor();
  118403. /**
  118404. * Creates UI to allow the user to enter/exit XR mode
  118405. * @param scene the scene to add the ui to
  118406. * @param helper the xr experience helper to enter/exit xr with
  118407. * @param options options to configure the UI
  118408. * @returns the created ui
  118409. */
  118410. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118411. /**
  118412. * Disposes of the XR UI component
  118413. */
  118414. dispose(): void;
  118415. private _updateButtons;
  118416. }
  118417. }
  118418. declare module BABYLON {
  118419. /**
  118420. * Class containing static functions to help procedurally build meshes
  118421. */
  118422. export class LinesBuilder {
  118423. /**
  118424. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118425. * * 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
  118426. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118427. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118428. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118429. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118430. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118431. * * 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
  118432. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118435. * @param name defines the name of the new line system
  118436. * @param options defines the options used to create the line system
  118437. * @param scene defines the hosting scene
  118438. * @returns a new line system mesh
  118439. */
  118440. static CreateLineSystem(name: string, options: {
  118441. lines: Vector3[][];
  118442. updatable?: boolean;
  118443. instance?: Nullable<LinesMesh>;
  118444. colors?: Nullable<Color4[][]>;
  118445. useVertexAlpha?: boolean;
  118446. }, scene: Nullable<Scene>): LinesMesh;
  118447. /**
  118448. * Creates a line mesh
  118449. * 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
  118450. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118451. * * The parameter `points` is an array successive Vector3
  118452. * * 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
  118453. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118454. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118455. * * When updating an instance, remember that only point positions can change, not the number of points
  118456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118458. * @param name defines the name of the new line system
  118459. * @param options defines the options used to create the line system
  118460. * @param scene defines the hosting scene
  118461. * @returns a new line mesh
  118462. */
  118463. static CreateLines(name: string, options: {
  118464. points: Vector3[];
  118465. updatable?: boolean;
  118466. instance?: Nullable<LinesMesh>;
  118467. colors?: Color4[];
  118468. useVertexAlpha?: boolean;
  118469. }, scene?: Nullable<Scene>): LinesMesh;
  118470. /**
  118471. * Creates a dashed line mesh
  118472. * * 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
  118473. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118474. * * The parameter `points` is an array successive Vector3
  118475. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118476. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118477. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118478. * * 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
  118479. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118480. * * When updating an instance, remember that only point positions can change, not the number of points
  118481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118482. * @param name defines the name of the mesh
  118483. * @param options defines the options used to create the mesh
  118484. * @param scene defines the hosting scene
  118485. * @returns the dashed line mesh
  118486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118487. */
  118488. static CreateDashedLines(name: string, options: {
  118489. points: Vector3[];
  118490. dashSize?: number;
  118491. gapSize?: number;
  118492. dashNb?: number;
  118493. updatable?: boolean;
  118494. instance?: LinesMesh;
  118495. useVertexAlpha?: boolean;
  118496. }, scene?: Nullable<Scene>): LinesMesh;
  118497. }
  118498. }
  118499. declare module BABYLON {
  118500. /**
  118501. * The options container for the teleportation module
  118502. */
  118503. export interface IWebXRTeleportationOptions {
  118504. /**
  118505. * if provided, this scene will be used to render meshes.
  118506. */
  118507. customUtilityLayerScene?: Scene;
  118508. /**
  118509. * Values to configure the default target mesh
  118510. */
  118511. defaultTargetMeshOptions?: {
  118512. /**
  118513. * Fill color of the teleportation area
  118514. */
  118515. teleportationFillColor?: string;
  118516. /**
  118517. * Border color for the teleportation area
  118518. */
  118519. teleportationBorderColor?: string;
  118520. /**
  118521. * Disable the mesh's animation sequence
  118522. */
  118523. disableAnimation?: boolean;
  118524. /**
  118525. * Disable lighting on the material or the ring and arrow
  118526. */
  118527. disableLighting?: boolean;
  118528. /**
  118529. * Override the default material of the torus and arrow
  118530. */
  118531. torusArrowMaterial?: Material;
  118532. };
  118533. /**
  118534. * A list of meshes to use as floor meshes.
  118535. * Meshes can be added and removed after initializing the feature using the
  118536. * addFloorMesh and removeFloorMesh functions
  118537. * If empty, rotation will still work
  118538. */
  118539. floorMeshes?: AbstractMesh[];
  118540. /**
  118541. * use this rendering group id for the meshes (optional)
  118542. */
  118543. renderingGroupId?: number;
  118544. /**
  118545. * Should teleportation move only to snap points
  118546. */
  118547. snapPointsOnly?: boolean;
  118548. /**
  118549. * An array of points to which the teleportation will snap to.
  118550. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118551. */
  118552. snapPositions?: Vector3[];
  118553. /**
  118554. * How close should the teleportation ray be in order to snap to position.
  118555. * Default to 0.8 units (meters)
  118556. */
  118557. snapToPositionRadius?: number;
  118558. /**
  118559. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118560. * If you want to support rotation, make sure your mesh has a direction indicator.
  118561. *
  118562. * When left untouched, the default mesh will be initialized.
  118563. */
  118564. teleportationTargetMesh?: AbstractMesh;
  118565. /**
  118566. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118567. */
  118568. timeToTeleport?: number;
  118569. /**
  118570. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118571. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118572. */
  118573. useMainComponentOnly?: boolean;
  118574. /**
  118575. * Should meshes created here be added to a utility layer or the main scene
  118576. */
  118577. useUtilityLayer?: boolean;
  118578. /**
  118579. * Babylon XR Input class for controller
  118580. */
  118581. xrInput: WebXRInput;
  118582. }
  118583. /**
  118584. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118585. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118586. * the input of the attached controllers.
  118587. */
  118588. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118589. private _options;
  118590. private _controllers;
  118591. private _currentTeleportationControllerId;
  118592. private _floorMeshes;
  118593. private _quadraticBezierCurve;
  118594. private _selectionFeature;
  118595. private _snapToPositions;
  118596. private _snappedToPoint;
  118597. private _teleportationRingMaterial?;
  118598. private _tmpRay;
  118599. private _tmpVector;
  118600. /**
  118601. * The module's name
  118602. */
  118603. static readonly Name: string;
  118604. /**
  118605. * The (Babylon) version of this module.
  118606. * This is an integer representing the implementation version.
  118607. * This number does not correspond to the webxr specs version
  118608. */
  118609. static readonly Version: number;
  118610. /**
  118611. * Is movement backwards enabled
  118612. */
  118613. backwardsMovementEnabled: boolean;
  118614. /**
  118615. * Distance to travel when moving backwards
  118616. */
  118617. backwardsTeleportationDistance: number;
  118618. /**
  118619. * The distance from the user to the inspection point in the direction of the controller
  118620. * A higher number will allow the user to move further
  118621. * defaults to 5 (meters, in xr units)
  118622. */
  118623. parabolicCheckRadius: number;
  118624. /**
  118625. * Should the module support parabolic ray on top of direct ray
  118626. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118627. * Very helpful when moving between floors / different heights
  118628. */
  118629. parabolicRayEnabled: boolean;
  118630. /**
  118631. * How much rotation should be applied when rotating right and left
  118632. */
  118633. rotationAngle: number;
  118634. /**
  118635. * Is rotation enabled when moving forward?
  118636. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118637. */
  118638. rotationEnabled: boolean;
  118639. /**
  118640. * constructs a new anchor system
  118641. * @param _xrSessionManager an instance of WebXRSessionManager
  118642. * @param _options configuration object for this feature
  118643. */
  118644. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118645. /**
  118646. * Get the snapPointsOnly flag
  118647. */
  118648. get snapPointsOnly(): boolean;
  118649. /**
  118650. * Sets the snapPointsOnly flag
  118651. * @param snapToPoints should teleportation be exclusively to snap points
  118652. */
  118653. set snapPointsOnly(snapToPoints: boolean);
  118654. /**
  118655. * Add a new mesh to the floor meshes array
  118656. * @param mesh the mesh to use as floor mesh
  118657. */
  118658. addFloorMesh(mesh: AbstractMesh): void;
  118659. /**
  118660. * Add a new snap-to point to fix teleportation to this position
  118661. * @param newSnapPoint The new Snap-To point
  118662. */
  118663. addSnapPoint(newSnapPoint: Vector3): void;
  118664. attach(): boolean;
  118665. detach(): boolean;
  118666. dispose(): void;
  118667. /**
  118668. * Remove a mesh from the floor meshes array
  118669. * @param mesh the mesh to remove
  118670. */
  118671. removeFloorMesh(mesh: AbstractMesh): void;
  118672. /**
  118673. * Remove a mesh from the floor meshes array using its name
  118674. * @param name the mesh name to remove
  118675. */
  118676. removeFloorMeshByName(name: string): void;
  118677. /**
  118678. * 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
  118679. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118680. * @returns was the point found and removed or not
  118681. */
  118682. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118683. /**
  118684. * This function sets a selection feature that will be disabled when
  118685. * the forward ray is shown and will be reattached when hidden.
  118686. * This is used to remove the selection rays when moving.
  118687. * @param selectionFeature the feature to disable when forward movement is enabled
  118688. */
  118689. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118690. protected _onXRFrame(_xrFrame: XRFrame): void;
  118691. private _attachController;
  118692. private _createDefaultTargetMesh;
  118693. private _detachController;
  118694. private _findClosestSnapPointWithRadius;
  118695. private _setTargetMeshPosition;
  118696. private _setTargetMeshVisibility;
  118697. private _showParabolicPath;
  118698. private _teleportForward;
  118699. }
  118700. }
  118701. declare module BABYLON {
  118702. /**
  118703. * Options for the default xr helper
  118704. */
  118705. export class WebXRDefaultExperienceOptions {
  118706. /**
  118707. * Enable or disable default UI to enter XR
  118708. */
  118709. disableDefaultUI?: boolean;
  118710. /**
  118711. * Should teleportation not initialize. defaults to false.
  118712. */
  118713. disableTeleportation?: boolean;
  118714. /**
  118715. * Floor meshes that will be used for teleport
  118716. */
  118717. floorMeshes?: Array<AbstractMesh>;
  118718. /**
  118719. * If set to true, the first frame will not be used to reset position
  118720. * The first frame is mainly used when copying transformation from the old camera
  118721. * Mainly used in AR
  118722. */
  118723. ignoreNativeCameraTransformation?: boolean;
  118724. /**
  118725. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118726. */
  118727. inputOptions?: IWebXRInputOptions;
  118728. /**
  118729. * optional configuration for the output canvas
  118730. */
  118731. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118732. /**
  118733. * optional UI options. This can be used among other to change session mode and reference space type
  118734. */
  118735. uiOptions?: WebXREnterExitUIOptions;
  118736. /**
  118737. * When loading teleportation and pointer select, use stable versions instead of latest.
  118738. */
  118739. useStablePlugins?: boolean;
  118740. }
  118741. /**
  118742. * Default experience which provides a similar setup to the previous webVRExperience
  118743. */
  118744. export class WebXRDefaultExperience {
  118745. /**
  118746. * Base experience
  118747. */
  118748. baseExperience: WebXRExperienceHelper;
  118749. /**
  118750. * Enables ui for entering/exiting xr
  118751. */
  118752. enterExitUI: WebXREnterExitUI;
  118753. /**
  118754. * Input experience extension
  118755. */
  118756. input: WebXRInput;
  118757. /**
  118758. * Enables laser pointer and selection
  118759. */
  118760. pointerSelection: WebXRControllerPointerSelection;
  118761. /**
  118762. * Default target xr should render to
  118763. */
  118764. renderTarget: WebXRRenderTarget;
  118765. /**
  118766. * Enables teleportation
  118767. */
  118768. teleportation: WebXRMotionControllerTeleportation;
  118769. private constructor();
  118770. /**
  118771. * Creates the default xr experience
  118772. * @param scene scene
  118773. * @param options options for basic configuration
  118774. * @returns resulting WebXRDefaultExperience
  118775. */
  118776. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118777. /**
  118778. * DIsposes of the experience helper
  118779. */
  118780. dispose(): void;
  118781. }
  118782. }
  118783. declare module BABYLON {
  118784. /**
  118785. * Options to modify the vr teleportation behavior.
  118786. */
  118787. export interface VRTeleportationOptions {
  118788. /**
  118789. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118790. */
  118791. floorMeshName?: string;
  118792. /**
  118793. * A list of meshes to be used as the teleportation floor. (default: empty)
  118794. */
  118795. floorMeshes?: Mesh[];
  118796. /**
  118797. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118798. */
  118799. teleportationMode?: number;
  118800. /**
  118801. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118802. */
  118803. teleportationTime?: number;
  118804. /**
  118805. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118806. */
  118807. teleportationSpeed?: number;
  118808. /**
  118809. * The easing function used in the animation or null for Linear. (default CircleEase)
  118810. */
  118811. easingFunction?: EasingFunction;
  118812. }
  118813. /**
  118814. * Options to modify the vr experience helper's behavior.
  118815. */
  118816. export interface VRExperienceHelperOptions extends WebVROptions {
  118817. /**
  118818. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118819. */
  118820. createDeviceOrientationCamera?: boolean;
  118821. /**
  118822. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118823. */
  118824. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118825. /**
  118826. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118827. */
  118828. laserToggle?: boolean;
  118829. /**
  118830. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118831. */
  118832. floorMeshes?: Mesh[];
  118833. /**
  118834. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118835. */
  118836. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118837. /**
  118838. * Defines if WebXR should be used instead of WebVR (if available)
  118839. */
  118840. useXR?: boolean;
  118841. }
  118842. /**
  118843. * Event containing information after VR has been entered
  118844. */
  118845. export class OnAfterEnteringVRObservableEvent {
  118846. /**
  118847. * If entering vr was successful
  118848. */
  118849. success: boolean;
  118850. }
  118851. /**
  118852. * Helps to quickly add VR support to an existing scene.
  118853. * See http://doc.babylonjs.com/how_to/webvr_helper
  118854. */
  118855. export class VRExperienceHelper {
  118856. /** Options to modify the vr experience helper's behavior. */
  118857. webVROptions: VRExperienceHelperOptions;
  118858. private _scene;
  118859. private _position;
  118860. private _btnVR;
  118861. private _btnVRDisplayed;
  118862. private _webVRsupported;
  118863. private _webVRready;
  118864. private _webVRrequesting;
  118865. private _webVRpresenting;
  118866. private _hasEnteredVR;
  118867. private _fullscreenVRpresenting;
  118868. private _inputElement;
  118869. private _webVRCamera;
  118870. private _vrDeviceOrientationCamera;
  118871. private _deviceOrientationCamera;
  118872. private _existingCamera;
  118873. private _onKeyDown;
  118874. private _onVrDisplayPresentChange;
  118875. private _onVRDisplayChanged;
  118876. private _onVRRequestPresentStart;
  118877. private _onVRRequestPresentComplete;
  118878. /**
  118879. * 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)
  118880. */
  118881. enableGazeEvenWhenNoPointerLock: boolean;
  118882. /**
  118883. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118884. */
  118885. exitVROnDoubleTap: boolean;
  118886. /**
  118887. * Observable raised right before entering VR.
  118888. */
  118889. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118890. /**
  118891. * Observable raised when entering VR has completed.
  118892. */
  118893. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118894. /**
  118895. * Observable raised when exiting VR.
  118896. */
  118897. onExitingVRObservable: Observable<VRExperienceHelper>;
  118898. /**
  118899. * Observable raised when controller mesh is loaded.
  118900. */
  118901. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118902. /** Return this.onEnteringVRObservable
  118903. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118904. */
  118905. get onEnteringVR(): Observable<VRExperienceHelper>;
  118906. /** Return this.onExitingVRObservable
  118907. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118908. */
  118909. get onExitingVR(): Observable<VRExperienceHelper>;
  118910. /** Return this.onControllerMeshLoadedObservable
  118911. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118912. */
  118913. get onControllerMeshLoaded(): Observable<WebVRController>;
  118914. private _rayLength;
  118915. private _useCustomVRButton;
  118916. private _teleportationRequested;
  118917. private _teleportActive;
  118918. private _floorMeshName;
  118919. private _floorMeshesCollection;
  118920. private _teleportationMode;
  118921. private _teleportationTime;
  118922. private _teleportationSpeed;
  118923. private _teleportationEasing;
  118924. private _rotationAllowed;
  118925. private _teleportBackwardsVector;
  118926. private _teleportationTarget;
  118927. private _isDefaultTeleportationTarget;
  118928. private _postProcessMove;
  118929. private _teleportationFillColor;
  118930. private _teleportationBorderColor;
  118931. private _rotationAngle;
  118932. private _haloCenter;
  118933. private _cameraGazer;
  118934. private _padSensibilityUp;
  118935. private _padSensibilityDown;
  118936. private _leftController;
  118937. private _rightController;
  118938. private _gazeColor;
  118939. private _laserColor;
  118940. private _pickedLaserColor;
  118941. private _pickedGazeColor;
  118942. /**
  118943. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118944. */
  118945. onNewMeshSelected: Observable<AbstractMesh>;
  118946. /**
  118947. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118948. * This observable will provide the mesh and the controller used to select the mesh
  118949. */
  118950. onMeshSelectedWithController: Observable<{
  118951. mesh: AbstractMesh;
  118952. controller: WebVRController;
  118953. }>;
  118954. /**
  118955. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118956. */
  118957. onNewMeshPicked: Observable<PickingInfo>;
  118958. private _circleEase;
  118959. /**
  118960. * Observable raised before camera teleportation
  118961. */
  118962. onBeforeCameraTeleport: Observable<Vector3>;
  118963. /**
  118964. * Observable raised after camera teleportation
  118965. */
  118966. onAfterCameraTeleport: Observable<Vector3>;
  118967. /**
  118968. * Observable raised when current selected mesh gets unselected
  118969. */
  118970. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118971. private _raySelectionPredicate;
  118972. /**
  118973. * To be optionaly changed by user to define custom ray selection
  118974. */
  118975. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118976. /**
  118977. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118978. */
  118979. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118980. /**
  118981. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118982. */
  118983. teleportationEnabled: boolean;
  118984. private _defaultHeight;
  118985. private _teleportationInitialized;
  118986. private _interactionsEnabled;
  118987. private _interactionsRequested;
  118988. private _displayGaze;
  118989. private _displayLaserPointer;
  118990. /**
  118991. * The mesh used to display where the user is going to teleport.
  118992. */
  118993. get teleportationTarget(): Mesh;
  118994. /**
  118995. * Sets the mesh to be used to display where the user is going to teleport.
  118996. */
  118997. set teleportationTarget(value: Mesh);
  118998. /**
  118999. * 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
  119000. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119001. * See http://doc.babylonjs.com/resources/baking_transformations
  119002. */
  119003. get gazeTrackerMesh(): Mesh;
  119004. set gazeTrackerMesh(value: Mesh);
  119005. /**
  119006. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119007. */
  119008. updateGazeTrackerScale: boolean;
  119009. /**
  119010. * If the gaze trackers color should be updated when selecting meshes
  119011. */
  119012. updateGazeTrackerColor: boolean;
  119013. /**
  119014. * If the controller laser color should be updated when selecting meshes
  119015. */
  119016. updateControllerLaserColor: boolean;
  119017. /**
  119018. * The gaze tracking mesh corresponding to the left controller
  119019. */
  119020. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119021. /**
  119022. * The gaze tracking mesh corresponding to the right controller
  119023. */
  119024. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119025. /**
  119026. * If the ray of the gaze should be displayed.
  119027. */
  119028. get displayGaze(): boolean;
  119029. /**
  119030. * Sets if the ray of the gaze should be displayed.
  119031. */
  119032. set displayGaze(value: boolean);
  119033. /**
  119034. * If the ray of the LaserPointer should be displayed.
  119035. */
  119036. get displayLaserPointer(): boolean;
  119037. /**
  119038. * Sets if the ray of the LaserPointer should be displayed.
  119039. */
  119040. set displayLaserPointer(value: boolean);
  119041. /**
  119042. * The deviceOrientationCamera used as the camera when not in VR.
  119043. */
  119044. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119045. /**
  119046. * Based on the current WebVR support, returns the current VR camera used.
  119047. */
  119048. get currentVRCamera(): Nullable<Camera>;
  119049. /**
  119050. * The webVRCamera which is used when in VR.
  119051. */
  119052. get webVRCamera(): WebVRFreeCamera;
  119053. /**
  119054. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119055. */
  119056. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119057. /**
  119058. * The html button that is used to trigger entering into VR.
  119059. */
  119060. get vrButton(): Nullable<HTMLButtonElement>;
  119061. private get _teleportationRequestInitiated();
  119062. /**
  119063. * Defines whether or not Pointer lock should be requested when switching to
  119064. * full screen.
  119065. */
  119066. requestPointerLockOnFullScreen: boolean;
  119067. /**
  119068. * If asking to force XR, this will be populated with the default xr experience
  119069. */
  119070. xr: WebXRDefaultExperience;
  119071. /**
  119072. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  119073. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  119074. */
  119075. xrTestDone: boolean;
  119076. /**
  119077. * Instantiates a VRExperienceHelper.
  119078. * Helps to quickly add VR support to an existing scene.
  119079. * @param scene The scene the VRExperienceHelper belongs to.
  119080. * @param webVROptions Options to modify the vr experience helper's behavior.
  119081. */
  119082. constructor(scene: Scene,
  119083. /** Options to modify the vr experience helper's behavior. */
  119084. webVROptions?: VRExperienceHelperOptions);
  119085. private completeVRInit;
  119086. private _onDefaultMeshLoaded;
  119087. private _onResize;
  119088. private _onFullscreenChange;
  119089. /**
  119090. * Gets a value indicating if we are currently in VR mode.
  119091. */
  119092. get isInVRMode(): boolean;
  119093. private onVrDisplayPresentChange;
  119094. private onVRDisplayChanged;
  119095. private moveButtonToBottomRight;
  119096. private displayVRButton;
  119097. private updateButtonVisibility;
  119098. private _cachedAngularSensibility;
  119099. /**
  119100. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  119101. * Otherwise, will use the fullscreen API.
  119102. */
  119103. enterVR(): void;
  119104. /**
  119105. * Attempt to exit VR, or fullscreen.
  119106. */
  119107. exitVR(): void;
  119108. /**
  119109. * The position of the vr experience helper.
  119110. */
  119111. get position(): Vector3;
  119112. /**
  119113. * Sets the position of the vr experience helper.
  119114. */
  119115. set position(value: Vector3);
  119116. /**
  119117. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  119118. */
  119119. enableInteractions(): void;
  119120. private get _noControllerIsActive();
  119121. private beforeRender;
  119122. private _isTeleportationFloor;
  119123. /**
  119124. * Adds a floor mesh to be used for teleportation.
  119125. * @param floorMesh the mesh to be used for teleportation.
  119126. */
  119127. addFloorMesh(floorMesh: Mesh): void;
  119128. /**
  119129. * Removes a floor mesh from being used for teleportation.
  119130. * @param floorMesh the mesh to be removed.
  119131. */
  119132. removeFloorMesh(floorMesh: Mesh): void;
  119133. /**
  119134. * Enables interactions and teleportation using the VR controllers and gaze.
  119135. * @param vrTeleportationOptions options to modify teleportation behavior.
  119136. */
  119137. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  119138. private _onNewGamepadConnected;
  119139. private _tryEnableInteractionOnController;
  119140. private _onNewGamepadDisconnected;
  119141. private _enableInteractionOnController;
  119142. private _checkTeleportWithRay;
  119143. private _checkRotate;
  119144. private _checkTeleportBackwards;
  119145. private _enableTeleportationOnController;
  119146. private _createTeleportationCircles;
  119147. private _displayTeleportationTarget;
  119148. private _hideTeleportationTarget;
  119149. private _rotateCamera;
  119150. private _moveTeleportationSelectorTo;
  119151. private _workingVector;
  119152. private _workingQuaternion;
  119153. private _workingMatrix;
  119154. /**
  119155. * Time Constant Teleportation Mode
  119156. */
  119157. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  119158. /**
  119159. * Speed Constant Teleportation Mode
  119160. */
  119161. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  119162. /**
  119163. * Teleports the users feet to the desired location
  119164. * @param location The location where the user's feet should be placed
  119165. */
  119166. teleportCamera(location: Vector3): void;
  119167. private _convertNormalToDirectionOfRay;
  119168. private _castRayAndSelectObject;
  119169. private _notifySelectedMeshUnselected;
  119170. /**
  119171. * Permanently set new colors for the laser pointer
  119172. * @param color the new laser color
  119173. * @param pickedColor the new laser color when picked mesh detected
  119174. */
  119175. setLaserColor(color: Color3, pickedColor?: Color3): void;
  119176. /**
  119177. * Set lighting enabled / disabled on the laser pointer of both controllers
  119178. * @param enabled should the lighting be enabled on the laser pointer
  119179. */
  119180. setLaserLightingState(enabled?: boolean): void;
  119181. /**
  119182. * Permanently set new colors for the gaze pointer
  119183. * @param color the new gaze color
  119184. * @param pickedColor the new gaze color when picked mesh detected
  119185. */
  119186. setGazeColor(color: Color3, pickedColor?: Color3): void;
  119187. /**
  119188. * Sets the color of the laser ray from the vr controllers.
  119189. * @param color new color for the ray.
  119190. */
  119191. changeLaserColor(color: Color3): void;
  119192. /**
  119193. * Sets the color of the ray from the vr headsets gaze.
  119194. * @param color new color for the ray.
  119195. */
  119196. changeGazeColor(color: Color3): void;
  119197. /**
  119198. * Exits VR and disposes of the vr experience helper
  119199. */
  119200. dispose(): void;
  119201. /**
  119202. * Gets the name of the VRExperienceHelper class
  119203. * @returns "VRExperienceHelper"
  119204. */
  119205. getClassName(): string;
  119206. }
  119207. }
  119208. declare module BABYLON {
  119209. /**
  119210. * Contains an array of blocks representing the octree
  119211. */
  119212. export interface IOctreeContainer<T> {
  119213. /**
  119214. * Blocks within the octree
  119215. */
  119216. blocks: Array<OctreeBlock<T>>;
  119217. }
  119218. /**
  119219. * Class used to store a cell in an octree
  119220. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119221. */
  119222. export class OctreeBlock<T> {
  119223. /**
  119224. * Gets the content of the current block
  119225. */
  119226. entries: T[];
  119227. /**
  119228. * Gets the list of block children
  119229. */
  119230. blocks: Array<OctreeBlock<T>>;
  119231. private _depth;
  119232. private _maxDepth;
  119233. private _capacity;
  119234. private _minPoint;
  119235. private _maxPoint;
  119236. private _boundingVectors;
  119237. private _creationFunc;
  119238. /**
  119239. * Creates a new block
  119240. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  119241. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  119242. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119243. * @param depth defines the current depth of this block in the octree
  119244. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  119245. * @param creationFunc defines a callback to call when an element is added to the block
  119246. */
  119247. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  119248. /**
  119249. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119250. */
  119251. get capacity(): number;
  119252. /**
  119253. * Gets the minimum vector (in world space) of the block's bounding box
  119254. */
  119255. get minPoint(): Vector3;
  119256. /**
  119257. * Gets the maximum vector (in world space) of the block's bounding box
  119258. */
  119259. get maxPoint(): Vector3;
  119260. /**
  119261. * Add a new element to this block
  119262. * @param entry defines the element to add
  119263. */
  119264. addEntry(entry: T): void;
  119265. /**
  119266. * Remove an element from this block
  119267. * @param entry defines the element to remove
  119268. */
  119269. removeEntry(entry: T): void;
  119270. /**
  119271. * Add an array of elements to this block
  119272. * @param entries defines the array of elements to add
  119273. */
  119274. addEntries(entries: T[]): void;
  119275. /**
  119276. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  119277. * @param frustumPlanes defines the frustum planes to test
  119278. * @param selection defines the array to store current content if selection is positive
  119279. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119280. */
  119281. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119282. /**
  119283. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  119284. * @param sphereCenter defines the bounding sphere center
  119285. * @param sphereRadius defines the bounding sphere radius
  119286. * @param selection defines the array to store current content if selection is positive
  119287. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119288. */
  119289. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119290. /**
  119291. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  119292. * @param ray defines the ray to test with
  119293. * @param selection defines the array to store current content if selection is positive
  119294. */
  119295. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  119296. /**
  119297. * Subdivide the content into child blocks (this block will then be empty)
  119298. */
  119299. createInnerBlocks(): void;
  119300. /**
  119301. * @hidden
  119302. */
  119303. 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;
  119304. }
  119305. }
  119306. declare module BABYLON {
  119307. /**
  119308. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  119309. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119310. */
  119311. export class Octree<T> {
  119312. /** 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.) */
  119313. maxDepth: number;
  119314. /**
  119315. * Blocks within the octree containing objects
  119316. */
  119317. blocks: Array<OctreeBlock<T>>;
  119318. /**
  119319. * Content stored in the octree
  119320. */
  119321. dynamicContent: T[];
  119322. private _maxBlockCapacity;
  119323. private _selectionContent;
  119324. private _creationFunc;
  119325. /**
  119326. * Creates a octree
  119327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119328. * @param creationFunc function to be used to instatiate the octree
  119329. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  119330. * @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.)
  119331. */
  119332. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  119333. /** 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.) */
  119334. maxDepth?: number);
  119335. /**
  119336. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  119337. * @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);
  119338. * @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);
  119339. * @param entries meshes to be added to the octree blocks
  119340. */
  119341. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  119342. /**
  119343. * Adds a mesh to the octree
  119344. * @param entry Mesh to add to the octree
  119345. */
  119346. addMesh(entry: T): void;
  119347. /**
  119348. * Remove an element from the octree
  119349. * @param entry defines the element to remove
  119350. */
  119351. removeMesh(entry: T): void;
  119352. /**
  119353. * Selects an array of meshes within the frustum
  119354. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  119355. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  119356. * @returns array of meshes within the frustum
  119357. */
  119358. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  119359. /**
  119360. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  119361. * @param sphereCenter defines the bounding sphere center
  119362. * @param sphereRadius defines the bounding sphere radius
  119363. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119364. * @returns an array of objects that intersect the sphere
  119365. */
  119366. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  119367. /**
  119368. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  119369. * @param ray defines the ray to test with
  119370. * @returns array of intersected objects
  119371. */
  119372. intersectsRay(ray: Ray): SmartArray<T>;
  119373. /**
  119374. * Adds a mesh into the octree block if it intersects the block
  119375. */
  119376. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  119377. /**
  119378. * Adds a submesh into the octree block if it intersects the block
  119379. */
  119380. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  119381. }
  119382. }
  119383. declare module BABYLON {
  119384. interface Scene {
  119385. /**
  119386. * @hidden
  119387. * Backing Filed
  119388. */
  119389. _selectionOctree: Octree<AbstractMesh>;
  119390. /**
  119391. * Gets the octree used to boost mesh selection (picking)
  119392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119393. */
  119394. selectionOctree: Octree<AbstractMesh>;
  119395. /**
  119396. * Creates or updates the octree used to boost selection (picking)
  119397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119398. * @param maxCapacity defines the maximum capacity per leaf
  119399. * @param maxDepth defines the maximum depth of the octree
  119400. * @returns an octree of AbstractMesh
  119401. */
  119402. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  119403. }
  119404. interface AbstractMesh {
  119405. /**
  119406. * @hidden
  119407. * Backing Field
  119408. */
  119409. _submeshesOctree: Octree<SubMesh>;
  119410. /**
  119411. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119412. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119413. * @param maxCapacity defines the maximum size of each block (64 by default)
  119414. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119415. * @returns the new octree
  119416. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119418. */
  119419. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119420. }
  119421. /**
  119422. * Defines the octree scene component responsible to manage any octrees
  119423. * in a given scene.
  119424. */
  119425. export class OctreeSceneComponent {
  119426. /**
  119427. * The component name help to identify the component in the list of scene components.
  119428. */
  119429. readonly name: string;
  119430. /**
  119431. * The scene the component belongs to.
  119432. */
  119433. scene: Scene;
  119434. /**
  119435. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119436. */
  119437. readonly checksIsEnabled: boolean;
  119438. /**
  119439. * Creates a new instance of the component for the given scene
  119440. * @param scene Defines the scene to register the component in
  119441. */
  119442. constructor(scene: Scene);
  119443. /**
  119444. * Registers the component in a given scene
  119445. */
  119446. register(): void;
  119447. /**
  119448. * Return the list of active meshes
  119449. * @returns the list of active meshes
  119450. */
  119451. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119452. /**
  119453. * Return the list of active sub meshes
  119454. * @param mesh The mesh to get the candidates sub meshes from
  119455. * @returns the list of active sub meshes
  119456. */
  119457. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119458. private _tempRay;
  119459. /**
  119460. * Return the list of sub meshes intersecting with a given local ray
  119461. * @param mesh defines the mesh to find the submesh for
  119462. * @param localRay defines the ray in local space
  119463. * @returns the list of intersecting sub meshes
  119464. */
  119465. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119466. /**
  119467. * Return the list of sub meshes colliding with a collider
  119468. * @param mesh defines the mesh to find the submesh for
  119469. * @param collider defines the collider to evaluate the collision against
  119470. * @returns the list of colliding sub meshes
  119471. */
  119472. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119473. /**
  119474. * Rebuilds the elements related to this component in case of
  119475. * context lost for instance.
  119476. */
  119477. rebuild(): void;
  119478. /**
  119479. * Disposes the component and the associated ressources.
  119480. */
  119481. dispose(): void;
  119482. }
  119483. }
  119484. declare module BABYLON {
  119485. /**
  119486. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119487. */
  119488. export class Gizmo implements IDisposable {
  119489. /** The utility layer the gizmo will be added to */
  119490. gizmoLayer: UtilityLayerRenderer;
  119491. /**
  119492. * The root mesh of the gizmo
  119493. */
  119494. _rootMesh: Mesh;
  119495. private _attachedMesh;
  119496. /**
  119497. * Ratio for the scale of the gizmo (Default: 1)
  119498. */
  119499. scaleRatio: number;
  119500. /**
  119501. * If a custom mesh has been set (Default: false)
  119502. */
  119503. protected _customMeshSet: boolean;
  119504. /**
  119505. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119506. * * When set, interactions will be enabled
  119507. */
  119508. get attachedMesh(): Nullable<AbstractMesh>;
  119509. set attachedMesh(value: Nullable<AbstractMesh>);
  119510. /**
  119511. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119512. * @param mesh The mesh to replace the default mesh of the gizmo
  119513. */
  119514. setCustomMesh(mesh: Mesh): void;
  119515. /**
  119516. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119517. */
  119518. updateGizmoRotationToMatchAttachedMesh: boolean;
  119519. /**
  119520. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119521. */
  119522. updateGizmoPositionToMatchAttachedMesh: boolean;
  119523. /**
  119524. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119525. */
  119526. updateScale: boolean;
  119527. protected _interactionsEnabled: boolean;
  119528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119529. private _beforeRenderObserver;
  119530. private _tempVector;
  119531. /**
  119532. * Creates a gizmo
  119533. * @param gizmoLayer The utility layer the gizmo will be added to
  119534. */
  119535. constructor(
  119536. /** The utility layer the gizmo will be added to */
  119537. gizmoLayer?: UtilityLayerRenderer);
  119538. /**
  119539. * Updates the gizmo to match the attached mesh's position/rotation
  119540. */
  119541. protected _update(): void;
  119542. /**
  119543. * Disposes of the gizmo
  119544. */
  119545. dispose(): void;
  119546. }
  119547. }
  119548. declare module BABYLON {
  119549. /**
  119550. * Single plane drag gizmo
  119551. */
  119552. export class PlaneDragGizmo extends Gizmo {
  119553. /**
  119554. * Drag behavior responsible for the gizmos dragging interactions
  119555. */
  119556. dragBehavior: PointerDragBehavior;
  119557. private _pointerObserver;
  119558. /**
  119559. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119560. */
  119561. snapDistance: number;
  119562. /**
  119563. * Event that fires each time the gizmo snaps to a new location.
  119564. * * snapDistance is the the change in distance
  119565. */
  119566. onSnapObservable: Observable<{
  119567. snapDistance: number;
  119568. }>;
  119569. private _plane;
  119570. private _coloredMaterial;
  119571. private _hoverMaterial;
  119572. private _isEnabled;
  119573. private _parent;
  119574. /** @hidden */
  119575. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119576. /** @hidden */
  119577. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119578. /**
  119579. * Creates a PlaneDragGizmo
  119580. * @param gizmoLayer The utility layer the gizmo will be added to
  119581. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119582. * @param color The color of the gizmo
  119583. */
  119584. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119585. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119586. /**
  119587. * If the gizmo is enabled
  119588. */
  119589. set isEnabled(value: boolean);
  119590. get isEnabled(): boolean;
  119591. /**
  119592. * Disposes of the gizmo
  119593. */
  119594. dispose(): void;
  119595. }
  119596. }
  119597. declare module BABYLON {
  119598. /**
  119599. * Gizmo that enables dragging a mesh along 3 axis
  119600. */
  119601. export class PositionGizmo extends Gizmo {
  119602. /**
  119603. * Internal gizmo used for interactions on the x axis
  119604. */
  119605. xGizmo: AxisDragGizmo;
  119606. /**
  119607. * Internal gizmo used for interactions on the y axis
  119608. */
  119609. yGizmo: AxisDragGizmo;
  119610. /**
  119611. * Internal gizmo used for interactions on the z axis
  119612. */
  119613. zGizmo: AxisDragGizmo;
  119614. /**
  119615. * Internal gizmo used for interactions on the yz plane
  119616. */
  119617. xPlaneGizmo: PlaneDragGizmo;
  119618. /**
  119619. * Internal gizmo used for interactions on the xz plane
  119620. */
  119621. yPlaneGizmo: PlaneDragGizmo;
  119622. /**
  119623. * Internal gizmo used for interactions on the xy plane
  119624. */
  119625. zPlaneGizmo: PlaneDragGizmo;
  119626. /**
  119627. * private variables
  119628. */
  119629. private _meshAttached;
  119630. private _updateGizmoRotationToMatchAttachedMesh;
  119631. private _snapDistance;
  119632. private _scaleRatio;
  119633. /** Fires an event when any of it's sub gizmos are dragged */
  119634. onDragStartObservable: Observable<unknown>;
  119635. /** Fires an event when any of it's sub gizmos are released from dragging */
  119636. onDragEndObservable: Observable<unknown>;
  119637. /**
  119638. * If set to true, planar drag is enabled
  119639. */
  119640. private _planarGizmoEnabled;
  119641. get attachedMesh(): Nullable<AbstractMesh>;
  119642. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119643. /**
  119644. * Creates a PositionGizmo
  119645. * @param gizmoLayer The utility layer the gizmo will be added to
  119646. */
  119647. constructor(gizmoLayer?: UtilityLayerRenderer);
  119648. /**
  119649. * If the planar drag gizmo is enabled
  119650. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119651. */
  119652. set planarGizmoEnabled(value: boolean);
  119653. get planarGizmoEnabled(): boolean;
  119654. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119655. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119656. /**
  119657. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119658. */
  119659. set snapDistance(value: number);
  119660. get snapDistance(): number;
  119661. /**
  119662. * Ratio for the scale of the gizmo (Default: 1)
  119663. */
  119664. set scaleRatio(value: number);
  119665. get scaleRatio(): number;
  119666. /**
  119667. * Disposes of the gizmo
  119668. */
  119669. dispose(): void;
  119670. /**
  119671. * CustomMeshes are not supported by this gizmo
  119672. * @param mesh The mesh to replace the default mesh of the gizmo
  119673. */
  119674. setCustomMesh(mesh: Mesh): void;
  119675. }
  119676. }
  119677. declare module BABYLON {
  119678. /**
  119679. * Single axis drag gizmo
  119680. */
  119681. export class AxisDragGizmo extends Gizmo {
  119682. /**
  119683. * Drag behavior responsible for the gizmos dragging interactions
  119684. */
  119685. dragBehavior: PointerDragBehavior;
  119686. private _pointerObserver;
  119687. /**
  119688. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119689. */
  119690. snapDistance: number;
  119691. /**
  119692. * Event that fires each time the gizmo snaps to a new location.
  119693. * * snapDistance is the the change in distance
  119694. */
  119695. onSnapObservable: Observable<{
  119696. snapDistance: number;
  119697. }>;
  119698. private _isEnabled;
  119699. private _parent;
  119700. private _arrow;
  119701. private _coloredMaterial;
  119702. private _hoverMaterial;
  119703. /** @hidden */
  119704. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119705. /** @hidden */
  119706. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119707. /**
  119708. * Creates an AxisDragGizmo
  119709. * @param gizmoLayer The utility layer the gizmo will be added to
  119710. * @param dragAxis The axis which the gizmo will be able to drag on
  119711. * @param color The color of the gizmo
  119712. */
  119713. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119714. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119715. /**
  119716. * If the gizmo is enabled
  119717. */
  119718. set isEnabled(value: boolean);
  119719. get isEnabled(): boolean;
  119720. /**
  119721. * Disposes of the gizmo
  119722. */
  119723. dispose(): void;
  119724. }
  119725. }
  119726. declare module BABYLON.Debug {
  119727. /**
  119728. * The Axes viewer will show 3 axes in a specific point in space
  119729. */
  119730. export class AxesViewer {
  119731. private _xAxis;
  119732. private _yAxis;
  119733. private _zAxis;
  119734. private _scaleLinesFactor;
  119735. private _instanced;
  119736. /**
  119737. * Gets the hosting scene
  119738. */
  119739. scene: Scene;
  119740. /**
  119741. * Gets or sets a number used to scale line length
  119742. */
  119743. scaleLines: number;
  119744. /** Gets the node hierarchy used to render x-axis */
  119745. get xAxis(): TransformNode;
  119746. /** Gets the node hierarchy used to render y-axis */
  119747. get yAxis(): TransformNode;
  119748. /** Gets the node hierarchy used to render z-axis */
  119749. get zAxis(): TransformNode;
  119750. /**
  119751. * Creates a new AxesViewer
  119752. * @param scene defines the hosting scene
  119753. * @param scaleLines defines a number used to scale line length (1 by default)
  119754. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119755. * @param xAxis defines the node hierarchy used to render the x-axis
  119756. * @param yAxis defines the node hierarchy used to render the y-axis
  119757. * @param zAxis defines the node hierarchy used to render the z-axis
  119758. */
  119759. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119760. /**
  119761. * Force the viewer to update
  119762. * @param position defines the position of the viewer
  119763. * @param xaxis defines the x axis of the viewer
  119764. * @param yaxis defines the y axis of the viewer
  119765. * @param zaxis defines the z axis of the viewer
  119766. */
  119767. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119768. /**
  119769. * Creates an instance of this axes viewer.
  119770. * @returns a new axes viewer with instanced meshes
  119771. */
  119772. createInstance(): AxesViewer;
  119773. /** Releases resources */
  119774. dispose(): void;
  119775. private static _SetRenderingGroupId;
  119776. }
  119777. }
  119778. declare module BABYLON.Debug {
  119779. /**
  119780. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119781. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119782. */
  119783. export class BoneAxesViewer extends AxesViewer {
  119784. /**
  119785. * Gets or sets the target mesh where to display the axes viewer
  119786. */
  119787. mesh: Nullable<Mesh>;
  119788. /**
  119789. * Gets or sets the target bone where to display the axes viewer
  119790. */
  119791. bone: Nullable<Bone>;
  119792. /** Gets current position */
  119793. pos: Vector3;
  119794. /** Gets direction of X axis */
  119795. xaxis: Vector3;
  119796. /** Gets direction of Y axis */
  119797. yaxis: Vector3;
  119798. /** Gets direction of Z axis */
  119799. zaxis: Vector3;
  119800. /**
  119801. * Creates a new BoneAxesViewer
  119802. * @param scene defines the hosting scene
  119803. * @param bone defines the target bone
  119804. * @param mesh defines the target mesh
  119805. * @param scaleLines defines a scaling factor for line length (1 by default)
  119806. */
  119807. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119808. /**
  119809. * Force the viewer to update
  119810. */
  119811. update(): void;
  119812. /** Releases resources */
  119813. dispose(): void;
  119814. }
  119815. }
  119816. declare module BABYLON {
  119817. /**
  119818. * Interface used to define scene explorer extensibility option
  119819. */
  119820. export interface IExplorerExtensibilityOption {
  119821. /**
  119822. * Define the option label
  119823. */
  119824. label: string;
  119825. /**
  119826. * Defines the action to execute on click
  119827. */
  119828. action: (entity: any) => void;
  119829. }
  119830. /**
  119831. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119832. */
  119833. export interface IExplorerExtensibilityGroup {
  119834. /**
  119835. * Defines a predicate to test if a given type mut be extended
  119836. */
  119837. predicate: (entity: any) => boolean;
  119838. /**
  119839. * Gets the list of options added to a type
  119840. */
  119841. entries: IExplorerExtensibilityOption[];
  119842. }
  119843. /**
  119844. * Interface used to define the options to use to create the Inspector
  119845. */
  119846. export interface IInspectorOptions {
  119847. /**
  119848. * Display in overlay mode (default: false)
  119849. */
  119850. overlay?: boolean;
  119851. /**
  119852. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119853. */
  119854. globalRoot?: HTMLElement;
  119855. /**
  119856. * Display the Scene explorer
  119857. */
  119858. showExplorer?: boolean;
  119859. /**
  119860. * Display the property inspector
  119861. */
  119862. showInspector?: boolean;
  119863. /**
  119864. * Display in embed mode (both panes on the right)
  119865. */
  119866. embedMode?: boolean;
  119867. /**
  119868. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119869. */
  119870. handleResize?: boolean;
  119871. /**
  119872. * Allow the panes to popup (default: true)
  119873. */
  119874. enablePopup?: boolean;
  119875. /**
  119876. * Allow the panes to be closed by users (default: true)
  119877. */
  119878. enableClose?: boolean;
  119879. /**
  119880. * Optional list of extensibility entries
  119881. */
  119882. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119883. /**
  119884. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119885. */
  119886. inspectorURL?: string;
  119887. /**
  119888. * Optional initial tab (default to DebugLayerTab.Properties)
  119889. */
  119890. initialTab?: DebugLayerTab;
  119891. }
  119892. interface Scene {
  119893. /**
  119894. * @hidden
  119895. * Backing field
  119896. */
  119897. _debugLayer: DebugLayer;
  119898. /**
  119899. * Gets the debug layer (aka Inspector) associated with the scene
  119900. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119901. */
  119902. debugLayer: DebugLayer;
  119903. }
  119904. /**
  119905. * Enum of inspector action tab
  119906. */
  119907. export enum DebugLayerTab {
  119908. /**
  119909. * Properties tag (default)
  119910. */
  119911. Properties = 0,
  119912. /**
  119913. * Debug tab
  119914. */
  119915. Debug = 1,
  119916. /**
  119917. * Statistics tab
  119918. */
  119919. Statistics = 2,
  119920. /**
  119921. * Tools tab
  119922. */
  119923. Tools = 3,
  119924. /**
  119925. * Settings tab
  119926. */
  119927. Settings = 4
  119928. }
  119929. /**
  119930. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119931. * what is happening in your scene
  119932. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119933. */
  119934. export class DebugLayer {
  119935. /**
  119936. * Define the url to get the inspector script from.
  119937. * By default it uses the babylonjs CDN.
  119938. * @ignoreNaming
  119939. */
  119940. static InspectorURL: string;
  119941. private _scene;
  119942. private BJSINSPECTOR;
  119943. private _onPropertyChangedObservable?;
  119944. /**
  119945. * Observable triggered when a property is changed through the inspector.
  119946. */
  119947. get onPropertyChangedObservable(): any;
  119948. /**
  119949. * Instantiates a new debug layer.
  119950. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119951. * what is happening in your scene
  119952. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119953. * @param scene Defines the scene to inspect
  119954. */
  119955. constructor(scene: Scene);
  119956. /** Creates the inspector window. */
  119957. private _createInspector;
  119958. /**
  119959. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119960. * @param entity defines the entity to select
  119961. * @param lineContainerTitle defines the specific block to highlight
  119962. */
  119963. select(entity: any, lineContainerTitle?: string): void;
  119964. /** Get the inspector from bundle or global */
  119965. private _getGlobalInspector;
  119966. /**
  119967. * Get if the inspector is visible or not.
  119968. * @returns true if visible otherwise, false
  119969. */
  119970. isVisible(): boolean;
  119971. /**
  119972. * Hide the inspector and close its window.
  119973. */
  119974. hide(): void;
  119975. /**
  119976. * Launch the debugLayer.
  119977. * @param config Define the configuration of the inspector
  119978. * @return a promise fulfilled when the debug layer is visible
  119979. */
  119980. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119981. }
  119982. }
  119983. declare module BABYLON {
  119984. /**
  119985. * Class containing static functions to help procedurally build meshes
  119986. */
  119987. export class BoxBuilder {
  119988. /**
  119989. * Creates a box mesh
  119990. * * The parameter `size` sets the size (float) of each box side (default 1)
  119991. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119992. * * 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)
  119993. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119997. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119998. * @param name defines the name of the mesh
  119999. * @param options defines the options used to create the mesh
  120000. * @param scene defines the hosting scene
  120001. * @returns the box mesh
  120002. */
  120003. static CreateBox(name: string, options: {
  120004. size?: number;
  120005. width?: number;
  120006. height?: number;
  120007. depth?: number;
  120008. faceUV?: Vector4[];
  120009. faceColors?: Color4[];
  120010. sideOrientation?: number;
  120011. frontUVs?: Vector4;
  120012. backUVs?: Vector4;
  120013. wrap?: boolean;
  120014. topBaseAt?: number;
  120015. bottomBaseAt?: number;
  120016. updatable?: boolean;
  120017. }, scene?: Nullable<Scene>): Mesh;
  120018. }
  120019. }
  120020. declare module BABYLON.Debug {
  120021. /**
  120022. * Used to show the physics impostor around the specific mesh
  120023. */
  120024. export class PhysicsViewer {
  120025. /** @hidden */
  120026. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120027. /** @hidden */
  120028. protected _meshes: Array<Nullable<AbstractMesh>>;
  120029. /** @hidden */
  120030. protected _scene: Nullable<Scene>;
  120031. /** @hidden */
  120032. protected _numMeshes: number;
  120033. /** @hidden */
  120034. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120035. private _renderFunction;
  120036. private _utilityLayer;
  120037. private _debugBoxMesh;
  120038. private _debugSphereMesh;
  120039. private _debugCylinderMesh;
  120040. private _debugMaterial;
  120041. private _debugMeshMeshes;
  120042. /**
  120043. * Creates a new PhysicsViewer
  120044. * @param scene defines the hosting scene
  120045. */
  120046. constructor(scene: Scene);
  120047. /** @hidden */
  120048. protected _updateDebugMeshes(): void;
  120049. /**
  120050. * Renders a specified physic impostor
  120051. * @param impostor defines the impostor to render
  120052. * @param targetMesh defines the mesh represented by the impostor
  120053. * @returns the new debug mesh used to render the impostor
  120054. */
  120055. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120056. /**
  120057. * Hides a specified physic impostor
  120058. * @param impostor defines the impostor to hide
  120059. */
  120060. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120061. private _getDebugMaterial;
  120062. private _getDebugBoxMesh;
  120063. private _getDebugSphereMesh;
  120064. private _getDebugCylinderMesh;
  120065. private _getDebugMeshMesh;
  120066. private _getDebugMesh;
  120067. /** Releases all resources */
  120068. dispose(): void;
  120069. }
  120070. }
  120071. declare module BABYLON {
  120072. /**
  120073. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120074. * in order to better appreciate the issue one might have.
  120075. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120076. */
  120077. export class RayHelper {
  120078. /**
  120079. * Defines the ray we are currently tryin to visualize.
  120080. */
  120081. ray: Nullable<Ray>;
  120082. private _renderPoints;
  120083. private _renderLine;
  120084. private _renderFunction;
  120085. private _scene;
  120086. private _updateToMeshFunction;
  120087. private _attachedToMesh;
  120088. private _meshSpaceDirection;
  120089. private _meshSpaceOrigin;
  120090. /**
  120091. * Helper function to create a colored helper in a scene in one line.
  120092. * @param ray Defines the ray we are currently tryin to visualize
  120093. * @param scene Defines the scene the ray is used in
  120094. * @param color Defines the color we want to see the ray in
  120095. * @returns The newly created ray helper.
  120096. */
  120097. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  120098. /**
  120099. * Instantiate a new ray helper.
  120100. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120101. * in order to better appreciate the issue one might have.
  120102. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120103. * @param ray Defines the ray we are currently tryin to visualize
  120104. */
  120105. constructor(ray: Ray);
  120106. /**
  120107. * Shows the ray we are willing to debug.
  120108. * @param scene Defines the scene the ray needs to be rendered in
  120109. * @param color Defines the color the ray needs to be rendered in
  120110. */
  120111. show(scene: Scene, color?: Color3): void;
  120112. /**
  120113. * Hides the ray we are debugging.
  120114. */
  120115. hide(): void;
  120116. private _render;
  120117. /**
  120118. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  120119. * @param mesh Defines the mesh we want the helper attached to
  120120. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  120121. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  120122. * @param length Defines the length of the ray
  120123. */
  120124. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  120125. /**
  120126. * Detach the ray helper from the mesh it has previously been attached to.
  120127. */
  120128. detachFromMesh(): void;
  120129. private _updateToMesh;
  120130. /**
  120131. * Dispose the helper and release its associated resources.
  120132. */
  120133. dispose(): void;
  120134. }
  120135. }
  120136. declare module BABYLON.Debug {
  120137. /**
  120138. * Class used to render a debug view of a given skeleton
  120139. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  120140. */
  120141. export class SkeletonViewer {
  120142. /** defines the skeleton to render */
  120143. skeleton: Skeleton;
  120144. /** defines the mesh attached to the skeleton */
  120145. mesh: AbstractMesh;
  120146. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120147. autoUpdateBonesMatrices: boolean;
  120148. /** defines the rendering group id to use with the viewer */
  120149. renderingGroupId: number;
  120150. /** Gets or sets the color used to render the skeleton */
  120151. color: Color3;
  120152. private _scene;
  120153. private _debugLines;
  120154. private _debugMesh;
  120155. private _isEnabled;
  120156. private _renderFunction;
  120157. private _utilityLayer;
  120158. /**
  120159. * Returns the mesh used to render the bones
  120160. */
  120161. get debugMesh(): Nullable<LinesMesh>;
  120162. /**
  120163. * Creates a new SkeletonViewer
  120164. * @param skeleton defines the skeleton to render
  120165. * @param mesh defines the mesh attached to the skeleton
  120166. * @param scene defines the hosting scene
  120167. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  120168. * @param renderingGroupId defines the rendering group id to use with the viewer
  120169. */
  120170. constructor(
  120171. /** defines the skeleton to render */
  120172. skeleton: Skeleton,
  120173. /** defines the mesh attached to the skeleton */
  120174. mesh: AbstractMesh, scene: Scene,
  120175. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120176. autoUpdateBonesMatrices?: boolean,
  120177. /** defines the rendering group id to use with the viewer */
  120178. renderingGroupId?: number);
  120179. /** Gets or sets a boolean indicating if the viewer is enabled */
  120180. set isEnabled(value: boolean);
  120181. get isEnabled(): boolean;
  120182. private _getBonePosition;
  120183. private _getLinesForBonesWithLength;
  120184. private _getLinesForBonesNoLength;
  120185. /** Update the viewer to sync with current skeleton state */
  120186. update(): void;
  120187. /** Release associated resources */
  120188. dispose(): void;
  120189. }
  120190. }
  120191. declare module BABYLON {
  120192. /**
  120193. * Options to create the null engine
  120194. */
  120195. export class NullEngineOptions {
  120196. /**
  120197. * Render width (Default: 512)
  120198. */
  120199. renderWidth: number;
  120200. /**
  120201. * Render height (Default: 256)
  120202. */
  120203. renderHeight: number;
  120204. /**
  120205. * Texture size (Default: 512)
  120206. */
  120207. textureSize: number;
  120208. /**
  120209. * If delta time between frames should be constant
  120210. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120211. */
  120212. deterministicLockstep: boolean;
  120213. /**
  120214. * Maximum about of steps between frames (Default: 4)
  120215. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120216. */
  120217. lockstepMaxSteps: number;
  120218. }
  120219. /**
  120220. * The null engine class provides support for headless version of babylon.js.
  120221. * This can be used in server side scenario or for testing purposes
  120222. */
  120223. export class NullEngine extends Engine {
  120224. private _options;
  120225. /**
  120226. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  120227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120228. * @returns true if engine is in deterministic lock step mode
  120229. */
  120230. isDeterministicLockStep(): boolean;
  120231. /**
  120232. * Gets the max steps when engine is running in deterministic lock step
  120233. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120234. * @returns the max steps
  120235. */
  120236. getLockstepMaxSteps(): number;
  120237. /**
  120238. * Gets the current hardware scaling level.
  120239. * By default the hardware scaling level is computed from the window device ratio.
  120240. * 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.
  120241. * @returns a number indicating the current hardware scaling level
  120242. */
  120243. getHardwareScalingLevel(): number;
  120244. constructor(options?: NullEngineOptions);
  120245. /**
  120246. * Creates a vertex buffer
  120247. * @param vertices the data for the vertex buffer
  120248. * @returns the new WebGL static buffer
  120249. */
  120250. createVertexBuffer(vertices: FloatArray): DataBuffer;
  120251. /**
  120252. * Creates a new index buffer
  120253. * @param indices defines the content of the index buffer
  120254. * @param updatable defines if the index buffer must be updatable
  120255. * @returns a new webGL buffer
  120256. */
  120257. createIndexBuffer(indices: IndicesArray): DataBuffer;
  120258. /**
  120259. * Clear the current render buffer or the current render target (if any is set up)
  120260. * @param color defines the color to use
  120261. * @param backBuffer defines if the back buffer must be cleared
  120262. * @param depth defines if the depth buffer must be cleared
  120263. * @param stencil defines if the stencil buffer must be cleared
  120264. */
  120265. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120266. /**
  120267. * Gets the current render width
  120268. * @param useScreen defines if screen size must be used (or the current render target if any)
  120269. * @returns a number defining the current render width
  120270. */
  120271. getRenderWidth(useScreen?: boolean): number;
  120272. /**
  120273. * Gets the current render height
  120274. * @param useScreen defines if screen size must be used (or the current render target if any)
  120275. * @returns a number defining the current render height
  120276. */
  120277. getRenderHeight(useScreen?: boolean): number;
  120278. /**
  120279. * Set the WebGL's viewport
  120280. * @param viewport defines the viewport element to be used
  120281. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120282. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120283. */
  120284. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120285. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  120286. /**
  120287. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120288. * @param pipelineContext defines the pipeline context to use
  120289. * @param uniformsNames defines the list of uniform names
  120290. * @returns an array of webGL uniform locations
  120291. */
  120292. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120293. /**
  120294. * Gets the lsit of active attributes for a given webGL program
  120295. * @param pipelineContext defines the pipeline context to use
  120296. * @param attributesNames defines the list of attribute names to get
  120297. * @returns an array of indices indicating the offset of each attribute
  120298. */
  120299. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120300. /**
  120301. * Binds an effect to the webGL context
  120302. * @param effect defines the effect to bind
  120303. */
  120304. bindSamplers(effect: Effect): void;
  120305. /**
  120306. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120307. * @param effect defines the effect to activate
  120308. */
  120309. enableEffect(effect: Effect): void;
  120310. /**
  120311. * Set various states to the webGL context
  120312. * @param culling defines backface culling state
  120313. * @param zOffset defines the value to apply to zOffset (0 by default)
  120314. * @param force defines if states must be applied even if cache is up to date
  120315. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  120316. */
  120317. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120318. /**
  120319. * Set the value of an uniform to an array of int32
  120320. * @param uniform defines the webGL uniform location where to store the value
  120321. * @param array defines the array of int32 to store
  120322. */
  120323. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120324. /**
  120325. * Set the value of an uniform to an array of int32 (stored as vec2)
  120326. * @param uniform defines the webGL uniform location where to store the value
  120327. * @param array defines the array of int32 to store
  120328. */
  120329. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120330. /**
  120331. * Set the value of an uniform to an array of int32 (stored as vec3)
  120332. * @param uniform defines the webGL uniform location where to store the value
  120333. * @param array defines the array of int32 to store
  120334. */
  120335. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120336. /**
  120337. * Set the value of an uniform to an array of int32 (stored as vec4)
  120338. * @param uniform defines the webGL uniform location where to store the value
  120339. * @param array defines the array of int32 to store
  120340. */
  120341. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120342. /**
  120343. * Set the value of an uniform to an array of float32
  120344. * @param uniform defines the webGL uniform location where to store the value
  120345. * @param array defines the array of float32 to store
  120346. */
  120347. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120348. /**
  120349. * Set the value of an uniform to an array of float32 (stored as vec2)
  120350. * @param uniform defines the webGL uniform location where to store the value
  120351. * @param array defines the array of float32 to store
  120352. */
  120353. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120354. /**
  120355. * Set the value of an uniform to an array of float32 (stored as vec3)
  120356. * @param uniform defines the webGL uniform location where to store the value
  120357. * @param array defines the array of float32 to store
  120358. */
  120359. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120360. /**
  120361. * Set the value of an uniform to an array of float32 (stored as vec4)
  120362. * @param uniform defines the webGL uniform location where to store the value
  120363. * @param array defines the array of float32 to store
  120364. */
  120365. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120366. /**
  120367. * Set the value of an uniform to an array of number
  120368. * @param uniform defines the webGL uniform location where to store the value
  120369. * @param array defines the array of number to store
  120370. */
  120371. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120372. /**
  120373. * Set the value of an uniform to an array of number (stored as vec2)
  120374. * @param uniform defines the webGL uniform location where to store the value
  120375. * @param array defines the array of number to store
  120376. */
  120377. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120378. /**
  120379. * Set the value of an uniform to an array of number (stored as vec3)
  120380. * @param uniform defines the webGL uniform location where to store the value
  120381. * @param array defines the array of number to store
  120382. */
  120383. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120384. /**
  120385. * Set the value of an uniform to an array of number (stored as vec4)
  120386. * @param uniform defines the webGL uniform location where to store the value
  120387. * @param array defines the array of number to store
  120388. */
  120389. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120390. /**
  120391. * Set the value of an uniform to an array of float32 (stored as matrices)
  120392. * @param uniform defines the webGL uniform location where to store the value
  120393. * @param matrices defines the array of float32 to store
  120394. */
  120395. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120396. /**
  120397. * Set the value of an uniform to a matrix (3x3)
  120398. * @param uniform defines the webGL uniform location where to store the value
  120399. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120400. */
  120401. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120402. /**
  120403. * Set the value of an uniform to a matrix (2x2)
  120404. * @param uniform defines the webGL uniform location where to store the value
  120405. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120406. */
  120407. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120408. /**
  120409. * Set the value of an uniform to a number (float)
  120410. * @param uniform defines the webGL uniform location where to store the value
  120411. * @param value defines the float number to store
  120412. */
  120413. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120414. /**
  120415. * Set the value of an uniform to a vec2
  120416. * @param uniform defines the webGL uniform location where to store the value
  120417. * @param x defines the 1st component of the value
  120418. * @param y defines the 2nd component of the value
  120419. */
  120420. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120421. /**
  120422. * Set the value of an uniform to a vec3
  120423. * @param uniform defines the webGL uniform location where to store the value
  120424. * @param x defines the 1st component of the value
  120425. * @param y defines the 2nd component of the value
  120426. * @param z defines the 3rd component of the value
  120427. */
  120428. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120429. /**
  120430. * Set the value of an uniform to a boolean
  120431. * @param uniform defines the webGL uniform location where to store the value
  120432. * @param bool defines the boolean to store
  120433. */
  120434. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120435. /**
  120436. * Set the value of an uniform to a vec4
  120437. * @param uniform defines the webGL uniform location where to store the value
  120438. * @param x defines the 1st component of the value
  120439. * @param y defines the 2nd component of the value
  120440. * @param z defines the 3rd component of the value
  120441. * @param w defines the 4th component of the value
  120442. */
  120443. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120444. /**
  120445. * Sets the current alpha mode
  120446. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120447. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120448. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120449. */
  120450. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120451. /**
  120452. * Bind webGl buffers directly to the webGL context
  120453. * @param vertexBuffers defines the vertex buffer to bind
  120454. * @param indexBuffer defines the index buffer to bind
  120455. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120456. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120457. * @param effect defines the effect associated with the vertex buffer
  120458. */
  120459. bindBuffers(vertexBuffers: {
  120460. [key: string]: VertexBuffer;
  120461. }, indexBuffer: DataBuffer, effect: Effect): void;
  120462. /**
  120463. * Force the entire cache to be cleared
  120464. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120465. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120466. */
  120467. wipeCaches(bruteForce?: boolean): void;
  120468. /**
  120469. * Send a draw order
  120470. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120471. * @param indexStart defines the starting index
  120472. * @param indexCount defines the number of index to draw
  120473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120474. */
  120475. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120476. /**
  120477. * Draw a list of indexed primitives
  120478. * @param fillMode defines the primitive to use
  120479. * @param indexStart defines the starting index
  120480. * @param indexCount defines the number of index to draw
  120481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120482. */
  120483. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120484. /**
  120485. * Draw a list of unindexed primitives
  120486. * @param fillMode defines the primitive to use
  120487. * @param verticesStart defines the index of first vertex to draw
  120488. * @param verticesCount defines the count of vertices to draw
  120489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120490. */
  120491. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120492. /** @hidden */
  120493. _createTexture(): WebGLTexture;
  120494. /** @hidden */
  120495. _releaseTexture(texture: InternalTexture): void;
  120496. /**
  120497. * Usually called from Texture.ts.
  120498. * Passed information to create a WebGLTexture
  120499. * @param urlArg defines a value which contains one of the following:
  120500. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120501. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120502. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120503. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120504. * @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)
  120505. * @param scene needed for loading to the correct scene
  120506. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120507. * @param onLoad optional callback to be called upon successful completion
  120508. * @param onError optional callback to be called upon failure
  120509. * @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
  120510. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120511. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120512. * @param forcedExtension defines the extension to use to pick the right loader
  120513. * @param mimeType defines an optional mime type
  120514. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120515. */
  120516. 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;
  120517. /**
  120518. * Creates a new render target texture
  120519. * @param size defines the size of the texture
  120520. * @param options defines the options used to create the texture
  120521. * @returns a new render target texture stored in an InternalTexture
  120522. */
  120523. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120524. /**
  120525. * Update the sampling mode of a given texture
  120526. * @param samplingMode defines the required sampling mode
  120527. * @param texture defines the texture to update
  120528. */
  120529. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120530. /**
  120531. * Binds the frame buffer to the specified texture.
  120532. * @param texture The texture to render to or null for the default canvas
  120533. * @param faceIndex The face of the texture to render to in case of cube texture
  120534. * @param requiredWidth The width of the target to render to
  120535. * @param requiredHeight The height of the target to render to
  120536. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120537. * @param lodLevel defines le lod level to bind to the frame buffer
  120538. */
  120539. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120540. /**
  120541. * Unbind the current render target texture from the webGL context
  120542. * @param texture defines the render target texture to unbind
  120543. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120544. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120545. */
  120546. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120547. /**
  120548. * Creates a dynamic vertex buffer
  120549. * @param vertices the data for the dynamic vertex buffer
  120550. * @returns the new WebGL dynamic buffer
  120551. */
  120552. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120553. /**
  120554. * Update the content of a dynamic texture
  120555. * @param texture defines the texture to update
  120556. * @param canvas defines the canvas containing the source
  120557. * @param invertY defines if data must be stored with Y axis inverted
  120558. * @param premulAlpha defines if alpha is stored as premultiplied
  120559. * @param format defines the format of the data
  120560. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120561. */
  120562. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120563. /**
  120564. * Gets a boolean indicating if all created effects are ready
  120565. * @returns true if all effects are ready
  120566. */
  120567. areAllEffectsReady(): boolean;
  120568. /**
  120569. * @hidden
  120570. * Get the current error code of the webGL context
  120571. * @returns the error code
  120572. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120573. */
  120574. getError(): number;
  120575. /** @hidden */
  120576. _getUnpackAlignement(): number;
  120577. /** @hidden */
  120578. _unpackFlipY(value: boolean): void;
  120579. /**
  120580. * Update a dynamic index buffer
  120581. * @param indexBuffer defines the target index buffer
  120582. * @param indices defines the data to update
  120583. * @param offset defines the offset in the target index buffer where update should start
  120584. */
  120585. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120586. /**
  120587. * Updates a dynamic vertex buffer.
  120588. * @param vertexBuffer the vertex buffer to update
  120589. * @param vertices the data used to update the vertex buffer
  120590. * @param byteOffset the byte offset of the data (optional)
  120591. * @param byteLength the byte length of the data (optional)
  120592. */
  120593. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120594. /** @hidden */
  120595. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120596. /** @hidden */
  120597. _bindTexture(channel: number, texture: InternalTexture): void;
  120598. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120599. /**
  120600. * 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
  120601. */
  120602. releaseEffects(): void;
  120603. displayLoadingUI(): void;
  120604. hideLoadingUI(): void;
  120605. /** @hidden */
  120606. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120607. /** @hidden */
  120608. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120609. /** @hidden */
  120610. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120611. /** @hidden */
  120612. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120613. }
  120614. }
  120615. declare module BABYLON {
  120616. /**
  120617. * @hidden
  120618. **/
  120619. export class _TimeToken {
  120620. _startTimeQuery: Nullable<WebGLQuery>;
  120621. _endTimeQuery: Nullable<WebGLQuery>;
  120622. _timeElapsedQuery: Nullable<WebGLQuery>;
  120623. _timeElapsedQueryEnded: boolean;
  120624. }
  120625. }
  120626. declare module BABYLON {
  120627. /** @hidden */
  120628. export class _OcclusionDataStorage {
  120629. /** @hidden */
  120630. occlusionInternalRetryCounter: number;
  120631. /** @hidden */
  120632. isOcclusionQueryInProgress: boolean;
  120633. /** @hidden */
  120634. isOccluded: boolean;
  120635. /** @hidden */
  120636. occlusionRetryCount: number;
  120637. /** @hidden */
  120638. occlusionType: number;
  120639. /** @hidden */
  120640. occlusionQueryAlgorithmType: number;
  120641. }
  120642. interface Engine {
  120643. /**
  120644. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120645. * @return the new query
  120646. */
  120647. createQuery(): WebGLQuery;
  120648. /**
  120649. * Delete and release a webGL query
  120650. * @param query defines the query to delete
  120651. * @return the current engine
  120652. */
  120653. deleteQuery(query: WebGLQuery): Engine;
  120654. /**
  120655. * Check if a given query has resolved and got its value
  120656. * @param query defines the query to check
  120657. * @returns true if the query got its value
  120658. */
  120659. isQueryResultAvailable(query: WebGLQuery): boolean;
  120660. /**
  120661. * Gets the value of a given query
  120662. * @param query defines the query to check
  120663. * @returns the value of the query
  120664. */
  120665. getQueryResult(query: WebGLQuery): number;
  120666. /**
  120667. * Initiates an occlusion query
  120668. * @param algorithmType defines the algorithm to use
  120669. * @param query defines the query to use
  120670. * @returns the current engine
  120671. * @see http://doc.babylonjs.com/features/occlusionquery
  120672. */
  120673. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120674. /**
  120675. * Ends an occlusion query
  120676. * @see http://doc.babylonjs.com/features/occlusionquery
  120677. * @param algorithmType defines the algorithm to use
  120678. * @returns the current engine
  120679. */
  120680. endOcclusionQuery(algorithmType: number): Engine;
  120681. /**
  120682. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120683. * Please note that only one query can be issued at a time
  120684. * @returns a time token used to track the time span
  120685. */
  120686. startTimeQuery(): Nullable<_TimeToken>;
  120687. /**
  120688. * Ends a time query
  120689. * @param token defines the token used to measure the time span
  120690. * @returns the time spent (in ns)
  120691. */
  120692. endTimeQuery(token: _TimeToken): int;
  120693. /** @hidden */
  120694. _currentNonTimestampToken: Nullable<_TimeToken>;
  120695. /** @hidden */
  120696. _createTimeQuery(): WebGLQuery;
  120697. /** @hidden */
  120698. _deleteTimeQuery(query: WebGLQuery): void;
  120699. /** @hidden */
  120700. _getGlAlgorithmType(algorithmType: number): number;
  120701. /** @hidden */
  120702. _getTimeQueryResult(query: WebGLQuery): any;
  120703. /** @hidden */
  120704. _getTimeQueryAvailability(query: WebGLQuery): any;
  120705. }
  120706. interface AbstractMesh {
  120707. /**
  120708. * Backing filed
  120709. * @hidden
  120710. */
  120711. __occlusionDataStorage: _OcclusionDataStorage;
  120712. /**
  120713. * Access property
  120714. * @hidden
  120715. */
  120716. _occlusionDataStorage: _OcclusionDataStorage;
  120717. /**
  120718. * 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.
  120719. * The default value is -1 which means don't break the query and wait till the result
  120720. * @see http://doc.babylonjs.com/features/occlusionquery
  120721. */
  120722. occlusionRetryCount: number;
  120723. /**
  120724. * 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:
  120725. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120726. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120727. * * 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.
  120728. * @see http://doc.babylonjs.com/features/occlusionquery
  120729. */
  120730. occlusionType: number;
  120731. /**
  120732. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120733. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120734. * * 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.
  120735. * @see http://doc.babylonjs.com/features/occlusionquery
  120736. */
  120737. occlusionQueryAlgorithmType: number;
  120738. /**
  120739. * 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
  120740. * @see http://doc.babylonjs.com/features/occlusionquery
  120741. */
  120742. isOccluded: boolean;
  120743. /**
  120744. * Flag to check the progress status of the query
  120745. * @see http://doc.babylonjs.com/features/occlusionquery
  120746. */
  120747. isOcclusionQueryInProgress: boolean;
  120748. }
  120749. }
  120750. declare module BABYLON {
  120751. /** @hidden */
  120752. export var _forceTransformFeedbackToBundle: boolean;
  120753. interface Engine {
  120754. /**
  120755. * Creates a webGL transform feedback object
  120756. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120757. * @returns the webGL transform feedback object
  120758. */
  120759. createTransformFeedback(): WebGLTransformFeedback;
  120760. /**
  120761. * Delete a webGL transform feedback object
  120762. * @param value defines the webGL transform feedback object to delete
  120763. */
  120764. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120765. /**
  120766. * Bind a webGL transform feedback object to the webgl context
  120767. * @param value defines the webGL transform feedback object to bind
  120768. */
  120769. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120770. /**
  120771. * Begins a transform feedback operation
  120772. * @param usePoints defines if points or triangles must be used
  120773. */
  120774. beginTransformFeedback(usePoints: boolean): void;
  120775. /**
  120776. * Ends a transform feedback operation
  120777. */
  120778. endTransformFeedback(): void;
  120779. /**
  120780. * Specify the varyings to use with transform feedback
  120781. * @param program defines the associated webGL program
  120782. * @param value defines the list of strings representing the varying names
  120783. */
  120784. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120785. /**
  120786. * Bind a webGL buffer for a transform feedback operation
  120787. * @param value defines the webGL buffer to bind
  120788. */
  120789. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120790. }
  120791. }
  120792. declare module BABYLON {
  120793. /**
  120794. * Creation options of the multi render target texture.
  120795. */
  120796. export interface IMultiRenderTargetOptions {
  120797. /**
  120798. * Define if the texture needs to create mip maps after render.
  120799. */
  120800. generateMipMaps?: boolean;
  120801. /**
  120802. * Define the types of all the draw buffers we want to create
  120803. */
  120804. types?: number[];
  120805. /**
  120806. * Define the sampling modes of all the draw buffers we want to create
  120807. */
  120808. samplingModes?: number[];
  120809. /**
  120810. * Define if a depth buffer is required
  120811. */
  120812. generateDepthBuffer?: boolean;
  120813. /**
  120814. * Define if a stencil buffer is required
  120815. */
  120816. generateStencilBuffer?: boolean;
  120817. /**
  120818. * Define if a depth texture is required instead of a depth buffer
  120819. */
  120820. generateDepthTexture?: boolean;
  120821. /**
  120822. * Define the number of desired draw buffers
  120823. */
  120824. textureCount?: number;
  120825. /**
  120826. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120827. */
  120828. doNotChangeAspectRatio?: boolean;
  120829. /**
  120830. * Define the default type of the buffers we are creating
  120831. */
  120832. defaultType?: number;
  120833. }
  120834. /**
  120835. * A multi render target, like a render target provides the ability to render to a texture.
  120836. * Unlike the render target, it can render to several draw buffers in one draw.
  120837. * This is specially interesting in deferred rendering or for any effects requiring more than
  120838. * just one color from a single pass.
  120839. */
  120840. export class MultiRenderTarget extends RenderTargetTexture {
  120841. private _internalTextures;
  120842. private _textures;
  120843. private _multiRenderTargetOptions;
  120844. /**
  120845. * Get if draw buffers are currently supported by the used hardware and browser.
  120846. */
  120847. get isSupported(): boolean;
  120848. /**
  120849. * Get the list of textures generated by the multi render target.
  120850. */
  120851. get textures(): Texture[];
  120852. /**
  120853. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120854. */
  120855. get depthTexture(): Texture;
  120856. /**
  120857. * Set the wrapping mode on U of all the textures we are rendering to.
  120858. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120859. */
  120860. set wrapU(wrap: number);
  120861. /**
  120862. * Set the wrapping mode on V of all the textures we are rendering to.
  120863. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120864. */
  120865. set wrapV(wrap: number);
  120866. /**
  120867. * Instantiate a new multi render target texture.
  120868. * A multi render target, like a render target provides the ability to render to a texture.
  120869. * Unlike the render target, it can render to several draw buffers in one draw.
  120870. * This is specially interesting in deferred rendering or for any effects requiring more than
  120871. * just one color from a single pass.
  120872. * @param name Define the name of the texture
  120873. * @param size Define the size of the buffers to render to
  120874. * @param count Define the number of target we are rendering into
  120875. * @param scene Define the scene the texture belongs to
  120876. * @param options Define the options used to create the multi render target
  120877. */
  120878. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120879. /** @hidden */
  120880. _rebuild(): void;
  120881. private _createInternalTextures;
  120882. private _createTextures;
  120883. /**
  120884. * Define the number of samples used if MSAA is enabled.
  120885. */
  120886. get samples(): number;
  120887. set samples(value: number);
  120888. /**
  120889. * Resize all the textures in the multi render target.
  120890. * Be carrefull as it will recreate all the data in the new texture.
  120891. * @param size Define the new size
  120892. */
  120893. resize(size: any): void;
  120894. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120895. /**
  120896. * Dispose the render targets and their associated resources
  120897. */
  120898. dispose(): void;
  120899. /**
  120900. * Release all the underlying texture used as draw buffers.
  120901. */
  120902. releaseInternalTextures(): void;
  120903. }
  120904. }
  120905. declare module BABYLON {
  120906. interface ThinEngine {
  120907. /**
  120908. * Unbind a list of render target textures from the webGL context
  120909. * This is used only when drawBuffer extension or webGL2 are active
  120910. * @param textures defines the render target textures to unbind
  120911. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120912. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120913. */
  120914. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120915. /**
  120916. * Create a multi render target texture
  120917. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120918. * @param size defines the size of the texture
  120919. * @param options defines the creation options
  120920. * @returns the cube texture as an InternalTexture
  120921. */
  120922. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120923. /**
  120924. * Update the sample count for a given multiple render target texture
  120925. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120926. * @param textures defines the textures to update
  120927. * @param samples defines the sample count to set
  120928. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120929. */
  120930. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120931. }
  120932. }
  120933. declare module BABYLON {
  120934. /**
  120935. * Class used to define an additional view for the engine
  120936. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120937. */
  120938. export class EngineView {
  120939. /** Defines the canvas where to render the view */
  120940. target: HTMLCanvasElement;
  120941. /** Defines an optional camera used to render the view (will use active camera else) */
  120942. camera?: Camera;
  120943. }
  120944. interface Engine {
  120945. /**
  120946. * Gets or sets the HTML element to use for attaching events
  120947. */
  120948. inputElement: Nullable<HTMLElement>;
  120949. /**
  120950. * Gets the current engine view
  120951. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120952. */
  120953. activeView: Nullable<EngineView>;
  120954. /** Gets or sets the list of views */
  120955. views: EngineView[];
  120956. /**
  120957. * Register a new child canvas
  120958. * @param canvas defines the canvas to register
  120959. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120960. * @returns the associated view
  120961. */
  120962. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120963. /**
  120964. * Remove a registered child canvas
  120965. * @param canvas defines the canvas to remove
  120966. * @returns the current engine
  120967. */
  120968. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120969. }
  120970. }
  120971. declare module BABYLON {
  120972. interface Engine {
  120973. /** @hidden */
  120974. _excludedCompressedTextures: string[];
  120975. /** @hidden */
  120976. _textureFormatInUse: string;
  120977. /**
  120978. * Gets the list of texture formats supported
  120979. */
  120980. readonly texturesSupported: Array<string>;
  120981. /**
  120982. * Gets the texture format in use
  120983. */
  120984. readonly textureFormatInUse: Nullable<string>;
  120985. /**
  120986. * Set the compressed texture extensions or file names to skip.
  120987. *
  120988. * @param skippedFiles defines the list of those texture files you want to skip
  120989. * Example: [".dds", ".env", "myfile.png"]
  120990. */
  120991. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  120992. /**
  120993. * Set the compressed texture format to use, based on the formats you have, and the formats
  120994. * supported by the hardware / browser.
  120995. *
  120996. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  120997. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  120998. * to API arguments needed to compressed textures. This puts the burden on the container
  120999. * generator to house the arcane code for determining these for current & future formats.
  121000. *
  121001. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121002. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121003. *
  121004. * Note: The result of this call is not taken into account when a texture is base64.
  121005. *
  121006. * @param formatsAvailable defines the list of those format families you have created
  121007. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121008. *
  121009. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121010. * @returns The extension selected.
  121011. */
  121012. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121013. }
  121014. }
  121015. declare module BABYLON {
  121016. /**
  121017. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121018. */
  121019. export interface CubeMapInfo {
  121020. /**
  121021. * The pixel array for the front face.
  121022. * This is stored in format, left to right, up to down format.
  121023. */
  121024. front: Nullable<ArrayBufferView>;
  121025. /**
  121026. * The pixel array for the back face.
  121027. * This is stored in format, left to right, up to down format.
  121028. */
  121029. back: Nullable<ArrayBufferView>;
  121030. /**
  121031. * The pixel array for the left face.
  121032. * This is stored in format, left to right, up to down format.
  121033. */
  121034. left: Nullable<ArrayBufferView>;
  121035. /**
  121036. * The pixel array for the right face.
  121037. * This is stored in format, left to right, up to down format.
  121038. */
  121039. right: Nullable<ArrayBufferView>;
  121040. /**
  121041. * The pixel array for the up face.
  121042. * This is stored in format, left to right, up to down format.
  121043. */
  121044. up: Nullable<ArrayBufferView>;
  121045. /**
  121046. * The pixel array for the down face.
  121047. * This is stored in format, left to right, up to down format.
  121048. */
  121049. down: Nullable<ArrayBufferView>;
  121050. /**
  121051. * The size of the cubemap stored.
  121052. *
  121053. * Each faces will be size * size pixels.
  121054. */
  121055. size: number;
  121056. /**
  121057. * The format of the texture.
  121058. *
  121059. * RGBA, RGB.
  121060. */
  121061. format: number;
  121062. /**
  121063. * The type of the texture data.
  121064. *
  121065. * UNSIGNED_INT, FLOAT.
  121066. */
  121067. type: number;
  121068. /**
  121069. * Specifies whether the texture is in gamma space.
  121070. */
  121071. gammaSpace: boolean;
  121072. }
  121073. /**
  121074. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  121075. */
  121076. export class PanoramaToCubeMapTools {
  121077. private static FACE_FRONT;
  121078. private static FACE_BACK;
  121079. private static FACE_RIGHT;
  121080. private static FACE_LEFT;
  121081. private static FACE_DOWN;
  121082. private static FACE_UP;
  121083. /**
  121084. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  121085. *
  121086. * @param float32Array The source data.
  121087. * @param inputWidth The width of the input panorama.
  121088. * @param inputHeight The height of the input panorama.
  121089. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  121090. * @return The cubemap data
  121091. */
  121092. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  121093. private static CreateCubemapTexture;
  121094. private static CalcProjectionSpherical;
  121095. }
  121096. }
  121097. declare module BABYLON {
  121098. /**
  121099. * Helper class dealing with the extraction of spherical polynomial dataArray
  121100. * from a cube map.
  121101. */
  121102. export class CubeMapToSphericalPolynomialTools {
  121103. private static FileFaces;
  121104. /**
  121105. * Converts a texture to the according Spherical Polynomial data.
  121106. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121107. *
  121108. * @param texture The texture to extract the information from.
  121109. * @return The Spherical Polynomial data.
  121110. */
  121111. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  121112. /**
  121113. * Converts a cubemap to the according Spherical Polynomial data.
  121114. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121115. *
  121116. * @param cubeInfo The Cube map to extract the information from.
  121117. * @return The Spherical Polynomial data.
  121118. */
  121119. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  121120. }
  121121. }
  121122. declare module BABYLON {
  121123. interface BaseTexture {
  121124. /**
  121125. * Get the polynomial representation of the texture data.
  121126. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  121127. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  121128. */
  121129. sphericalPolynomial: Nullable<SphericalPolynomial>;
  121130. }
  121131. }
  121132. declare module BABYLON {
  121133. /** @hidden */
  121134. export var rgbdEncodePixelShader: {
  121135. name: string;
  121136. shader: string;
  121137. };
  121138. }
  121139. declare module BABYLON {
  121140. /** @hidden */
  121141. export var rgbdDecodePixelShader: {
  121142. name: string;
  121143. shader: string;
  121144. };
  121145. }
  121146. declare module BABYLON {
  121147. /**
  121148. * Raw texture data and descriptor sufficient for WebGL texture upload
  121149. */
  121150. export interface EnvironmentTextureInfo {
  121151. /**
  121152. * Version of the environment map
  121153. */
  121154. version: number;
  121155. /**
  121156. * Width of image
  121157. */
  121158. width: number;
  121159. /**
  121160. * Irradiance information stored in the file.
  121161. */
  121162. irradiance: any;
  121163. /**
  121164. * Specular information stored in the file.
  121165. */
  121166. specular: any;
  121167. }
  121168. /**
  121169. * Defines One Image in the file. It requires only the position in the file
  121170. * as well as the length.
  121171. */
  121172. interface BufferImageData {
  121173. /**
  121174. * Length of the image data.
  121175. */
  121176. length: number;
  121177. /**
  121178. * Position of the data from the null terminator delimiting the end of the JSON.
  121179. */
  121180. position: number;
  121181. }
  121182. /**
  121183. * Defines the specular data enclosed in the file.
  121184. * This corresponds to the version 1 of the data.
  121185. */
  121186. export interface EnvironmentTextureSpecularInfoV1 {
  121187. /**
  121188. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  121189. */
  121190. specularDataPosition?: number;
  121191. /**
  121192. * This contains all the images data needed to reconstruct the cubemap.
  121193. */
  121194. mipmaps: Array<BufferImageData>;
  121195. /**
  121196. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  121197. */
  121198. lodGenerationScale: number;
  121199. }
  121200. /**
  121201. * Sets of helpers addressing the serialization and deserialization of environment texture
  121202. * stored in a BabylonJS env file.
  121203. * Those files are usually stored as .env files.
  121204. */
  121205. export class EnvironmentTextureTools {
  121206. /**
  121207. * Magic number identifying the env file.
  121208. */
  121209. private static _MagicBytes;
  121210. /**
  121211. * Gets the environment info from an env file.
  121212. * @param data The array buffer containing the .env bytes.
  121213. * @returns the environment file info (the json header) if successfully parsed.
  121214. */
  121215. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  121216. /**
  121217. * Creates an environment texture from a loaded cube texture.
  121218. * @param texture defines the cube texture to convert in env file
  121219. * @return a promise containing the environment data if succesfull.
  121220. */
  121221. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  121222. /**
  121223. * Creates a JSON representation of the spherical data.
  121224. * @param texture defines the texture containing the polynomials
  121225. * @return the JSON representation of the spherical info
  121226. */
  121227. private static _CreateEnvTextureIrradiance;
  121228. /**
  121229. * Creates the ArrayBufferViews used for initializing environment texture image data.
  121230. * @param data the image data
  121231. * @param info parameters that determine what views will be created for accessing the underlying buffer
  121232. * @return the views described by info providing access to the underlying buffer
  121233. */
  121234. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  121235. /**
  121236. * Uploads the texture info contained in the env file to the GPU.
  121237. * @param texture defines the internal texture to upload to
  121238. * @param data defines the data to load
  121239. * @param info defines the texture info retrieved through the GetEnvInfo method
  121240. * @returns a promise
  121241. */
  121242. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  121243. private static _OnImageReadyAsync;
  121244. /**
  121245. * Uploads the levels of image data to the GPU.
  121246. * @param texture defines the internal texture to upload to
  121247. * @param imageData defines the array buffer views of image data [mipmap][face]
  121248. * @returns a promise
  121249. */
  121250. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  121251. /**
  121252. * Uploads spherical polynomials information to the texture.
  121253. * @param texture defines the texture we are trying to upload the information to
  121254. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  121255. */
  121256. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  121257. /** @hidden */
  121258. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121259. }
  121260. }
  121261. declare module BABYLON {
  121262. /**
  121263. * Contains position and normal vectors for a vertex
  121264. */
  121265. export class PositionNormalVertex {
  121266. /** the position of the vertex (defaut: 0,0,0) */
  121267. position: Vector3;
  121268. /** the normal of the vertex (defaut: 0,1,0) */
  121269. normal: Vector3;
  121270. /**
  121271. * Creates a PositionNormalVertex
  121272. * @param position the position of the vertex (defaut: 0,0,0)
  121273. * @param normal the normal of the vertex (defaut: 0,1,0)
  121274. */
  121275. constructor(
  121276. /** the position of the vertex (defaut: 0,0,0) */
  121277. position?: Vector3,
  121278. /** the normal of the vertex (defaut: 0,1,0) */
  121279. normal?: Vector3);
  121280. /**
  121281. * Clones the PositionNormalVertex
  121282. * @returns the cloned PositionNormalVertex
  121283. */
  121284. clone(): PositionNormalVertex;
  121285. }
  121286. /**
  121287. * Contains position, normal and uv vectors for a vertex
  121288. */
  121289. export class PositionNormalTextureVertex {
  121290. /** the position of the vertex (defaut: 0,0,0) */
  121291. position: Vector3;
  121292. /** the normal of the vertex (defaut: 0,1,0) */
  121293. normal: Vector3;
  121294. /** the uv of the vertex (default: 0,0) */
  121295. uv: Vector2;
  121296. /**
  121297. * Creates a PositionNormalTextureVertex
  121298. * @param position the position of the vertex (defaut: 0,0,0)
  121299. * @param normal the normal of the vertex (defaut: 0,1,0)
  121300. * @param uv the uv of the vertex (default: 0,0)
  121301. */
  121302. constructor(
  121303. /** the position of the vertex (defaut: 0,0,0) */
  121304. position?: Vector3,
  121305. /** the normal of the vertex (defaut: 0,1,0) */
  121306. normal?: Vector3,
  121307. /** the uv of the vertex (default: 0,0) */
  121308. uv?: Vector2);
  121309. /**
  121310. * Clones the PositionNormalTextureVertex
  121311. * @returns the cloned PositionNormalTextureVertex
  121312. */
  121313. clone(): PositionNormalTextureVertex;
  121314. }
  121315. }
  121316. declare module BABYLON {
  121317. /** @hidden */
  121318. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  121319. private _genericAttributeLocation;
  121320. private _varyingLocationCount;
  121321. private _varyingLocationMap;
  121322. private _replacements;
  121323. private _textureCount;
  121324. private _uniforms;
  121325. lineProcessor(line: string): string;
  121326. attributeProcessor(attribute: string): string;
  121327. varyingProcessor(varying: string, isFragment: boolean): string;
  121328. uniformProcessor(uniform: string): string;
  121329. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  121330. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  121331. }
  121332. }
  121333. declare module BABYLON {
  121334. /**
  121335. * Container for accessors for natively-stored mesh data buffers.
  121336. */
  121337. class NativeDataBuffer extends DataBuffer {
  121338. /**
  121339. * Accessor value used to identify/retrieve a natively-stored index buffer.
  121340. */
  121341. nativeIndexBuffer?: any;
  121342. /**
  121343. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  121344. */
  121345. nativeVertexBuffer?: any;
  121346. }
  121347. /** @hidden */
  121348. class NativeTexture extends InternalTexture {
  121349. getInternalTexture(): InternalTexture;
  121350. getViewCount(): number;
  121351. }
  121352. /** @hidden */
  121353. export class NativeEngine extends Engine {
  121354. private readonly _native;
  121355. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  121356. private readonly INVALID_HANDLE;
  121357. getHardwareScalingLevel(): number;
  121358. constructor();
  121359. /**
  121360. * Can be used to override the current requestAnimationFrame requester.
  121361. * @hidden
  121362. */
  121363. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121364. /**
  121365. * Override default engine behavior.
  121366. * @param color
  121367. * @param backBuffer
  121368. * @param depth
  121369. * @param stencil
  121370. */
  121371. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121372. /**
  121373. * Gets host document
  121374. * @returns the host document object
  121375. */
  121376. getHostDocument(): Nullable<Document>;
  121377. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121378. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  121379. createVertexBuffer(data: DataArray): NativeDataBuffer;
  121380. recordVertexArrayObject(vertexBuffers: {
  121381. [key: string]: VertexBuffer;
  121382. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121383. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121384. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121385. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121386. /**
  121387. * Draw a list of indexed primitives
  121388. * @param fillMode defines the primitive to use
  121389. * @param indexStart defines the starting index
  121390. * @param indexCount defines the number of index to draw
  121391. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121392. */
  121393. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121394. /**
  121395. * Draw a list of unindexed primitives
  121396. * @param fillMode defines the primitive to use
  121397. * @param verticesStart defines the index of first vertex to draw
  121398. * @param verticesCount defines the count of vertices to draw
  121399. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121400. */
  121401. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121402. createPipelineContext(): IPipelineContext;
  121403. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121404. /** @hidden */
  121405. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121406. /** @hidden */
  121407. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121408. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121409. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121410. protected _setProgram(program: WebGLProgram): void;
  121411. _releaseEffect(effect: Effect): void;
  121412. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121413. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  121414. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  121415. bindSamplers(effect: Effect): void;
  121416. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  121417. getRenderWidth(useScreen?: boolean): number;
  121418. getRenderHeight(useScreen?: boolean): number;
  121419. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  121420. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121421. /**
  121422. * Set the z offset to apply to current rendering
  121423. * @param value defines the offset to apply
  121424. */
  121425. setZOffset(value: number): void;
  121426. /**
  121427. * Gets the current value of the zOffset
  121428. * @returns the current zOffset state
  121429. */
  121430. getZOffset(): number;
  121431. /**
  121432. * Enable or disable depth buffering
  121433. * @param enable defines the state to set
  121434. */
  121435. setDepthBuffer(enable: boolean): void;
  121436. /**
  121437. * Gets a boolean indicating if depth writing is enabled
  121438. * @returns the current depth writing state
  121439. */
  121440. getDepthWrite(): boolean;
  121441. /**
  121442. * Enable or disable depth writing
  121443. * @param enable defines the state to set
  121444. */
  121445. setDepthWrite(enable: boolean): void;
  121446. /**
  121447. * Enable or disable color writing
  121448. * @param enable defines the state to set
  121449. */
  121450. setColorWrite(enable: boolean): void;
  121451. /**
  121452. * Gets a boolean indicating if color writing is enabled
  121453. * @returns the current color writing state
  121454. */
  121455. getColorWrite(): boolean;
  121456. /**
  121457. * Sets alpha constants used by some alpha blending modes
  121458. * @param r defines the red component
  121459. * @param g defines the green component
  121460. * @param b defines the blue component
  121461. * @param a defines the alpha component
  121462. */
  121463. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121464. /**
  121465. * Sets the current alpha mode
  121466. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121467. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121468. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121469. */
  121470. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121471. /**
  121472. * Gets the current alpha mode
  121473. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121474. * @returns the current alpha mode
  121475. */
  121476. getAlphaMode(): number;
  121477. setInt(uniform: WebGLUniformLocation, int: number): void;
  121478. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121479. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121480. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121481. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121482. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121483. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121484. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121485. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121486. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121487. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121488. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121489. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121490. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121491. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121492. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121493. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121494. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121495. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121496. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121497. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121498. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121499. wipeCaches(bruteForce?: boolean): void;
  121500. _createTexture(): WebGLTexture;
  121501. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121502. /**
  121503. * Usually called from Texture.ts.
  121504. * Passed information to create a WebGLTexture
  121505. * @param urlArg defines a value which contains one of the following:
  121506. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121507. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121508. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121509. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121510. * @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)
  121511. * @param scene needed for loading to the correct scene
  121512. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121513. * @param onLoad optional callback to be called upon successful completion
  121514. * @param onError optional callback to be called upon failure
  121515. * @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
  121516. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121517. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121518. * @param forcedExtension defines the extension to use to pick the right loader
  121519. * @param mimeType defines an optional mime type
  121520. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121521. */
  121522. 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;
  121523. /**
  121524. * Creates a cube texture
  121525. * @param rootUrl defines the url where the files to load is located
  121526. * @param scene defines the current scene
  121527. * @param files defines the list of files to load (1 per face)
  121528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121529. * @param onLoad defines an optional callback raised when the texture is loaded
  121530. * @param onError defines an optional callback raised if there is an issue to load the texture
  121531. * @param format defines the format of the data
  121532. * @param forcedExtension defines the extension to use to pick the right loader
  121533. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121534. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121535. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121536. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121537. * @returns the cube texture as an InternalTexture
  121538. */
  121539. 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;
  121540. private _getSamplingFilter;
  121541. private static _GetNativeTextureFormat;
  121542. createRenderTargetTexture(size: number | {
  121543. width: number;
  121544. height: number;
  121545. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121546. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121547. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121548. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121549. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121550. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121551. /**
  121552. * Updates a dynamic vertex buffer.
  121553. * @param vertexBuffer the vertex buffer to update
  121554. * @param data the data used to update the vertex buffer
  121555. * @param byteOffset the byte offset of the data (optional)
  121556. * @param byteLength the byte length of the data (optional)
  121557. */
  121558. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121559. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121560. private _updateAnisotropicLevel;
  121561. private _getAddressMode;
  121562. /** @hidden */
  121563. _bindTexture(channel: number, texture: InternalTexture): void;
  121564. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121565. releaseEffects(): void;
  121566. /** @hidden */
  121567. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121568. /** @hidden */
  121569. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121570. /** @hidden */
  121571. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121572. /** @hidden */
  121573. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121574. }
  121575. }
  121576. declare module BABYLON {
  121577. /**
  121578. * Gather the list of clipboard event types as constants.
  121579. */
  121580. export class ClipboardEventTypes {
  121581. /**
  121582. * The clipboard event is fired when a copy command is active (pressed).
  121583. */
  121584. static readonly COPY: number;
  121585. /**
  121586. * The clipboard event is fired when a cut command is active (pressed).
  121587. */
  121588. static readonly CUT: number;
  121589. /**
  121590. * The clipboard event is fired when a paste command is active (pressed).
  121591. */
  121592. static readonly PASTE: number;
  121593. }
  121594. /**
  121595. * This class is used to store clipboard related info for the onClipboardObservable event.
  121596. */
  121597. export class ClipboardInfo {
  121598. /**
  121599. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121600. */
  121601. type: number;
  121602. /**
  121603. * Defines the related dom event
  121604. */
  121605. event: ClipboardEvent;
  121606. /**
  121607. *Creates an instance of ClipboardInfo.
  121608. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121609. * @param event Defines the related dom event
  121610. */
  121611. constructor(
  121612. /**
  121613. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121614. */
  121615. type: number,
  121616. /**
  121617. * Defines the related dom event
  121618. */
  121619. event: ClipboardEvent);
  121620. /**
  121621. * Get the clipboard event's type from the keycode.
  121622. * @param keyCode Defines the keyCode for the current keyboard event.
  121623. * @return {number}
  121624. */
  121625. static GetTypeFromCharacter(keyCode: number): number;
  121626. }
  121627. }
  121628. declare module BABYLON {
  121629. /**
  121630. * Google Daydream controller
  121631. */
  121632. export class DaydreamController extends WebVRController {
  121633. /**
  121634. * Base Url for the controller model.
  121635. */
  121636. static MODEL_BASE_URL: string;
  121637. /**
  121638. * File name for the controller model.
  121639. */
  121640. static MODEL_FILENAME: string;
  121641. /**
  121642. * Gamepad Id prefix used to identify Daydream Controller.
  121643. */
  121644. static readonly GAMEPAD_ID_PREFIX: string;
  121645. /**
  121646. * Creates a new DaydreamController from a gamepad
  121647. * @param vrGamepad the gamepad that the controller should be created from
  121648. */
  121649. constructor(vrGamepad: any);
  121650. /**
  121651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121652. * @param scene scene in which to add meshes
  121653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121654. */
  121655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121656. /**
  121657. * Called once for each button that changed state since the last frame
  121658. * @param buttonIdx Which button index changed
  121659. * @param state New state of the button
  121660. * @param changes Which properties on the state changed since last frame
  121661. */
  121662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121663. }
  121664. }
  121665. declare module BABYLON {
  121666. /**
  121667. * Gear VR Controller
  121668. */
  121669. export class GearVRController extends WebVRController {
  121670. /**
  121671. * Base Url for the controller model.
  121672. */
  121673. static MODEL_BASE_URL: string;
  121674. /**
  121675. * File name for the controller model.
  121676. */
  121677. static MODEL_FILENAME: string;
  121678. /**
  121679. * Gamepad Id prefix used to identify this controller.
  121680. */
  121681. static readonly GAMEPAD_ID_PREFIX: string;
  121682. private readonly _buttonIndexToObservableNameMap;
  121683. /**
  121684. * Creates a new GearVRController from a gamepad
  121685. * @param vrGamepad the gamepad that the controller should be created from
  121686. */
  121687. constructor(vrGamepad: any);
  121688. /**
  121689. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121690. * @param scene scene in which to add meshes
  121691. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121692. */
  121693. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121694. /**
  121695. * Called once for each button that changed state since the last frame
  121696. * @param buttonIdx Which button index changed
  121697. * @param state New state of the button
  121698. * @param changes Which properties on the state changed since last frame
  121699. */
  121700. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121701. }
  121702. }
  121703. declare module BABYLON {
  121704. /**
  121705. * Generic Controller
  121706. */
  121707. export class GenericController extends WebVRController {
  121708. /**
  121709. * Base Url for the controller model.
  121710. */
  121711. static readonly MODEL_BASE_URL: string;
  121712. /**
  121713. * File name for the controller model.
  121714. */
  121715. static readonly MODEL_FILENAME: string;
  121716. /**
  121717. * Creates a new GenericController from a gamepad
  121718. * @param vrGamepad the gamepad that the controller should be created from
  121719. */
  121720. constructor(vrGamepad: any);
  121721. /**
  121722. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121723. * @param scene scene in which to add meshes
  121724. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121725. */
  121726. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121727. /**
  121728. * Called once for each button that changed state since the last frame
  121729. * @param buttonIdx Which button index changed
  121730. * @param state New state of the button
  121731. * @param changes Which properties on the state changed since last frame
  121732. */
  121733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121734. }
  121735. }
  121736. declare module BABYLON {
  121737. /**
  121738. * Oculus Touch Controller
  121739. */
  121740. export class OculusTouchController extends WebVRController {
  121741. /**
  121742. * Base Url for the controller model.
  121743. */
  121744. static MODEL_BASE_URL: string;
  121745. /**
  121746. * File name for the left controller model.
  121747. */
  121748. static MODEL_LEFT_FILENAME: string;
  121749. /**
  121750. * File name for the right controller model.
  121751. */
  121752. static MODEL_RIGHT_FILENAME: string;
  121753. /**
  121754. * Base Url for the Quest controller model.
  121755. */
  121756. static QUEST_MODEL_BASE_URL: string;
  121757. /**
  121758. * @hidden
  121759. * If the controllers are running on a device that needs the updated Quest controller models
  121760. */
  121761. static _IsQuest: boolean;
  121762. /**
  121763. * Fired when the secondary trigger on this controller is modified
  121764. */
  121765. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121766. /**
  121767. * Fired when the thumb rest on this controller is modified
  121768. */
  121769. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121770. /**
  121771. * Creates a new OculusTouchController from a gamepad
  121772. * @param vrGamepad the gamepad that the controller should be created from
  121773. */
  121774. constructor(vrGamepad: any);
  121775. /**
  121776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121777. * @param scene scene in which to add meshes
  121778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121779. */
  121780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121781. /**
  121782. * Fired when the A button on this controller is modified
  121783. */
  121784. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121785. /**
  121786. * Fired when the B button on this controller is modified
  121787. */
  121788. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121789. /**
  121790. * Fired when the X button on this controller is modified
  121791. */
  121792. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121793. /**
  121794. * Fired when the Y button on this controller is modified
  121795. */
  121796. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121797. /**
  121798. * Called once for each button that changed state since the last frame
  121799. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121800. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121801. * 2) secondary trigger (same)
  121802. * 3) A (right) X (left), touch, pressed = value
  121803. * 4) B / Y
  121804. * 5) thumb rest
  121805. * @param buttonIdx Which button index changed
  121806. * @param state New state of the button
  121807. * @param changes Which properties on the state changed since last frame
  121808. */
  121809. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121810. }
  121811. }
  121812. declare module BABYLON {
  121813. /**
  121814. * Vive Controller
  121815. */
  121816. export class ViveController extends WebVRController {
  121817. /**
  121818. * Base Url for the controller model.
  121819. */
  121820. static MODEL_BASE_URL: string;
  121821. /**
  121822. * File name for the controller model.
  121823. */
  121824. static MODEL_FILENAME: string;
  121825. /**
  121826. * Creates a new ViveController from a gamepad
  121827. * @param vrGamepad the gamepad that the controller should be created from
  121828. */
  121829. constructor(vrGamepad: any);
  121830. /**
  121831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121832. * @param scene scene in which to add meshes
  121833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121834. */
  121835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121836. /**
  121837. * Fired when the left button on this controller is modified
  121838. */
  121839. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121840. /**
  121841. * Fired when the right button on this controller is modified
  121842. */
  121843. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121844. /**
  121845. * Fired when the menu button on this controller is modified
  121846. */
  121847. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121848. /**
  121849. * Called once for each button that changed state since the last frame
  121850. * Vive mapping:
  121851. * 0: touchpad
  121852. * 1: trigger
  121853. * 2: left AND right buttons
  121854. * 3: menu button
  121855. * @param buttonIdx Which button index changed
  121856. * @param state New state of the button
  121857. * @param changes Which properties on the state changed since last frame
  121858. */
  121859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121860. }
  121861. }
  121862. declare module BABYLON {
  121863. /**
  121864. * Defines the WindowsMotionController object that the state of the windows motion controller
  121865. */
  121866. export class WindowsMotionController extends WebVRController {
  121867. /**
  121868. * The base url used to load the left and right controller models
  121869. */
  121870. static MODEL_BASE_URL: string;
  121871. /**
  121872. * The name of the left controller model file
  121873. */
  121874. static MODEL_LEFT_FILENAME: string;
  121875. /**
  121876. * The name of the right controller model file
  121877. */
  121878. static MODEL_RIGHT_FILENAME: string;
  121879. /**
  121880. * The controller name prefix for this controller type
  121881. */
  121882. static readonly GAMEPAD_ID_PREFIX: string;
  121883. /**
  121884. * The controller id pattern for this controller type
  121885. */
  121886. private static readonly GAMEPAD_ID_PATTERN;
  121887. private _loadedMeshInfo;
  121888. protected readonly _mapping: {
  121889. buttons: string[];
  121890. buttonMeshNames: {
  121891. 'trigger': string;
  121892. 'menu': string;
  121893. 'grip': string;
  121894. 'thumbstick': string;
  121895. 'trackpad': string;
  121896. };
  121897. buttonObservableNames: {
  121898. 'trigger': string;
  121899. 'menu': string;
  121900. 'grip': string;
  121901. 'thumbstick': string;
  121902. 'trackpad': string;
  121903. };
  121904. axisMeshNames: string[];
  121905. pointingPoseMeshName: string;
  121906. };
  121907. /**
  121908. * Fired when the trackpad on this controller is clicked
  121909. */
  121910. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121911. /**
  121912. * Fired when the trackpad on this controller is modified
  121913. */
  121914. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121915. /**
  121916. * The current x and y values of this controller's trackpad
  121917. */
  121918. trackpad: StickValues;
  121919. /**
  121920. * Creates a new WindowsMotionController from a gamepad
  121921. * @param vrGamepad the gamepad that the controller should be created from
  121922. */
  121923. constructor(vrGamepad: any);
  121924. /**
  121925. * Fired when the trigger on this controller is modified
  121926. */
  121927. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121928. /**
  121929. * Fired when the menu button on this controller is modified
  121930. */
  121931. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121932. /**
  121933. * Fired when the grip button on this controller is modified
  121934. */
  121935. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121936. /**
  121937. * Fired when the thumbstick button on this controller is modified
  121938. */
  121939. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121940. /**
  121941. * Fired when the touchpad button on this controller is modified
  121942. */
  121943. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121944. /**
  121945. * Fired when the touchpad values on this controller are modified
  121946. */
  121947. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121948. protected _updateTrackpad(): void;
  121949. /**
  121950. * Called once per frame by the engine.
  121951. */
  121952. update(): void;
  121953. /**
  121954. * Called once for each button that changed state since the last frame
  121955. * @param buttonIdx Which button index changed
  121956. * @param state New state of the button
  121957. * @param changes Which properties on the state changed since last frame
  121958. */
  121959. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121960. /**
  121961. * Moves the buttons on the controller mesh based on their current state
  121962. * @param buttonName the name of the button to move
  121963. * @param buttonValue the value of the button which determines the buttons new position
  121964. */
  121965. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121966. /**
  121967. * Moves the axis on the controller mesh based on its current state
  121968. * @param axis the index of the axis
  121969. * @param axisValue the value of the axis which determines the meshes new position
  121970. * @hidden
  121971. */
  121972. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121973. /**
  121974. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121975. * @param scene scene in which to add meshes
  121976. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121977. */
  121978. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121979. /**
  121980. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121981. * can be transformed by button presses and axes values, based on this._mapping.
  121982. *
  121983. * @param scene scene in which the meshes exist
  121984. * @param meshes list of meshes that make up the controller model to process
  121985. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121986. */
  121987. private processModel;
  121988. private createMeshInfo;
  121989. /**
  121990. * Gets the ray of the controller in the direction the controller is pointing
  121991. * @param length the length the resulting ray should be
  121992. * @returns a ray in the direction the controller is pointing
  121993. */
  121994. getForwardRay(length?: number): Ray;
  121995. /**
  121996. * Disposes of the controller
  121997. */
  121998. dispose(): void;
  121999. }
  122000. /**
  122001. * This class represents a new windows motion controller in XR.
  122002. */
  122003. export class XRWindowsMotionController extends WindowsMotionController {
  122004. /**
  122005. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122006. */
  122007. protected readonly _mapping: {
  122008. buttons: string[];
  122009. buttonMeshNames: {
  122010. 'trigger': string;
  122011. 'menu': string;
  122012. 'grip': string;
  122013. 'thumbstick': string;
  122014. 'trackpad': string;
  122015. };
  122016. buttonObservableNames: {
  122017. 'trigger': string;
  122018. 'menu': string;
  122019. 'grip': string;
  122020. 'thumbstick': string;
  122021. 'trackpad': string;
  122022. };
  122023. axisMeshNames: string[];
  122024. pointingPoseMeshName: string;
  122025. };
  122026. /**
  122027. * Construct a new XR-Based windows motion controller
  122028. *
  122029. * @param gamepadInfo the gamepad object from the browser
  122030. */
  122031. constructor(gamepadInfo: any);
  122032. /**
  122033. * holds the thumbstick values (X,Y)
  122034. */
  122035. thumbstickValues: StickValues;
  122036. /**
  122037. * Fired when the thumbstick on this controller is clicked
  122038. */
  122039. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122040. /**
  122041. * Fired when the thumbstick on this controller is modified
  122042. */
  122043. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122044. /**
  122045. * Fired when the touchpad button on this controller is modified
  122046. */
  122047. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122048. /**
  122049. * Fired when the touchpad values on this controller are modified
  122050. */
  122051. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122052. /**
  122053. * Fired when the thumbstick button on this controller is modified
  122054. * here to prevent breaking changes
  122055. */
  122056. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122057. /**
  122058. * updating the thumbstick(!) and not the trackpad.
  122059. * This is named this way due to the difference between WebVR and XR and to avoid
  122060. * changing the parent class.
  122061. */
  122062. protected _updateTrackpad(): void;
  122063. /**
  122064. * Disposes the class with joy
  122065. */
  122066. dispose(): void;
  122067. }
  122068. }
  122069. declare module BABYLON {
  122070. /**
  122071. * Class containing static functions to help procedurally build meshes
  122072. */
  122073. export class PolyhedronBuilder {
  122074. /**
  122075. * Creates a polyhedron mesh
  122076. * * 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
  122077. * * The parameter `size` (positive float, default 1) sets the polygon size
  122078. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122079. * * 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`
  122080. * * 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
  122081. * * 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)`)
  122082. * * 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
  122083. * * 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
  122084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122087. * @param name defines the name of the mesh
  122088. * @param options defines the options used to create the mesh
  122089. * @param scene defines the hosting scene
  122090. * @returns the polyhedron mesh
  122091. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122092. */
  122093. static CreatePolyhedron(name: string, options: {
  122094. type?: number;
  122095. size?: number;
  122096. sizeX?: number;
  122097. sizeY?: number;
  122098. sizeZ?: number;
  122099. custom?: any;
  122100. faceUV?: Vector4[];
  122101. faceColors?: Color4[];
  122102. flat?: boolean;
  122103. updatable?: boolean;
  122104. sideOrientation?: number;
  122105. frontUVs?: Vector4;
  122106. backUVs?: Vector4;
  122107. }, scene?: Nullable<Scene>): Mesh;
  122108. }
  122109. }
  122110. declare module BABYLON {
  122111. /**
  122112. * Gizmo that enables scaling a mesh along 3 axis
  122113. */
  122114. export class ScaleGizmo extends Gizmo {
  122115. /**
  122116. * Internal gizmo used for interactions on the x axis
  122117. */
  122118. xGizmo: AxisScaleGizmo;
  122119. /**
  122120. * Internal gizmo used for interactions on the y axis
  122121. */
  122122. yGizmo: AxisScaleGizmo;
  122123. /**
  122124. * Internal gizmo used for interactions on the z axis
  122125. */
  122126. zGizmo: AxisScaleGizmo;
  122127. /**
  122128. * Internal gizmo used to scale all axis equally
  122129. */
  122130. uniformScaleGizmo: AxisScaleGizmo;
  122131. private _meshAttached;
  122132. private _updateGizmoRotationToMatchAttachedMesh;
  122133. private _snapDistance;
  122134. private _scaleRatio;
  122135. private _uniformScalingMesh;
  122136. private _octahedron;
  122137. private _sensitivity;
  122138. /** Fires an event when any of it's sub gizmos are dragged */
  122139. onDragStartObservable: Observable<unknown>;
  122140. /** Fires an event when any of it's sub gizmos are released from dragging */
  122141. onDragEndObservable: Observable<unknown>;
  122142. get attachedMesh(): Nullable<AbstractMesh>;
  122143. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122144. /**
  122145. * Creates a ScaleGizmo
  122146. * @param gizmoLayer The utility layer the gizmo will be added to
  122147. */
  122148. constructor(gizmoLayer?: UtilityLayerRenderer);
  122149. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122150. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122151. /**
  122152. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122153. */
  122154. set snapDistance(value: number);
  122155. get snapDistance(): number;
  122156. /**
  122157. * Ratio for the scale of the gizmo (Default: 1)
  122158. */
  122159. set scaleRatio(value: number);
  122160. get scaleRatio(): number;
  122161. /**
  122162. * Sensitivity factor for dragging (Default: 1)
  122163. */
  122164. set sensitivity(value: number);
  122165. get sensitivity(): number;
  122166. /**
  122167. * Disposes of the gizmo
  122168. */
  122169. dispose(): void;
  122170. }
  122171. }
  122172. declare module BABYLON {
  122173. /**
  122174. * Single axis scale gizmo
  122175. */
  122176. export class AxisScaleGizmo extends Gizmo {
  122177. /**
  122178. * Drag behavior responsible for the gizmos dragging interactions
  122179. */
  122180. dragBehavior: PointerDragBehavior;
  122181. private _pointerObserver;
  122182. /**
  122183. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122184. */
  122185. snapDistance: number;
  122186. /**
  122187. * Event that fires each time the gizmo snaps to a new location.
  122188. * * snapDistance is the the change in distance
  122189. */
  122190. onSnapObservable: Observable<{
  122191. snapDistance: number;
  122192. }>;
  122193. /**
  122194. * If the scaling operation should be done on all axis (default: false)
  122195. */
  122196. uniformScaling: boolean;
  122197. /**
  122198. * Custom sensitivity value for the drag strength
  122199. */
  122200. sensitivity: number;
  122201. private _isEnabled;
  122202. private _parent;
  122203. private _arrow;
  122204. private _coloredMaterial;
  122205. private _hoverMaterial;
  122206. /**
  122207. * Creates an AxisScaleGizmo
  122208. * @param gizmoLayer The utility layer the gizmo will be added to
  122209. * @param dragAxis The axis which the gizmo will be able to scale on
  122210. * @param color The color of the gizmo
  122211. */
  122212. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  122213. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122214. /**
  122215. * If the gizmo is enabled
  122216. */
  122217. set isEnabled(value: boolean);
  122218. get isEnabled(): boolean;
  122219. /**
  122220. * Disposes of the gizmo
  122221. */
  122222. dispose(): void;
  122223. /**
  122224. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122225. * @param mesh The mesh to replace the default mesh of the gizmo
  122226. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  122227. */
  122228. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  122229. }
  122230. }
  122231. declare module BABYLON {
  122232. /**
  122233. * Bounding box gizmo
  122234. */
  122235. export class BoundingBoxGizmo extends Gizmo {
  122236. private _lineBoundingBox;
  122237. private _rotateSpheresParent;
  122238. private _scaleBoxesParent;
  122239. private _boundingDimensions;
  122240. private _renderObserver;
  122241. private _pointerObserver;
  122242. private _scaleDragSpeed;
  122243. private _tmpQuaternion;
  122244. private _tmpVector;
  122245. private _tmpRotationMatrix;
  122246. /**
  122247. * 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)
  122248. */
  122249. ignoreChildren: boolean;
  122250. /**
  122251. * 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)
  122252. */
  122253. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  122254. /**
  122255. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  122256. */
  122257. rotationSphereSize: number;
  122258. /**
  122259. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  122260. */
  122261. scaleBoxSize: number;
  122262. /**
  122263. * 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)
  122264. */
  122265. fixedDragMeshScreenSize: boolean;
  122266. /**
  122267. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  122268. */
  122269. fixedDragMeshScreenSizeDistanceFactor: number;
  122270. /**
  122271. * Fired when a rotation sphere or scale box is dragged
  122272. */
  122273. onDragStartObservable: Observable<{}>;
  122274. /**
  122275. * Fired when a scale box is dragged
  122276. */
  122277. onScaleBoxDragObservable: Observable<{}>;
  122278. /**
  122279. * Fired when a scale box drag is ended
  122280. */
  122281. onScaleBoxDragEndObservable: Observable<{}>;
  122282. /**
  122283. * Fired when a rotation sphere is dragged
  122284. */
  122285. onRotationSphereDragObservable: Observable<{}>;
  122286. /**
  122287. * Fired when a rotation sphere drag is ended
  122288. */
  122289. onRotationSphereDragEndObservable: Observable<{}>;
  122290. /**
  122291. * 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)
  122292. */
  122293. scalePivot: Nullable<Vector3>;
  122294. /**
  122295. * Mesh used as a pivot to rotate the attached mesh
  122296. */
  122297. private _anchorMesh;
  122298. private _existingMeshScale;
  122299. private _dragMesh;
  122300. private pointerDragBehavior;
  122301. private coloredMaterial;
  122302. private hoverColoredMaterial;
  122303. /**
  122304. * Sets the color of the bounding box gizmo
  122305. * @param color the color to set
  122306. */
  122307. setColor(color: Color3): void;
  122308. /**
  122309. * Creates an BoundingBoxGizmo
  122310. * @param gizmoLayer The utility layer the gizmo will be added to
  122311. * @param color The color of the gizmo
  122312. */
  122313. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  122314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122315. private _selectNode;
  122316. /**
  122317. * Updates the bounding box information for the Gizmo
  122318. */
  122319. updateBoundingBox(): void;
  122320. private _updateRotationSpheres;
  122321. private _updateScaleBoxes;
  122322. /**
  122323. * Enables rotation on the specified axis and disables rotation on the others
  122324. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  122325. */
  122326. setEnabledRotationAxis(axis: string): void;
  122327. /**
  122328. * Enables/disables scaling
  122329. * @param enable if scaling should be enabled
  122330. */
  122331. setEnabledScaling(enable: boolean): void;
  122332. private _updateDummy;
  122333. /**
  122334. * Enables a pointer drag behavior on the bounding box of the gizmo
  122335. */
  122336. enableDragBehavior(): void;
  122337. /**
  122338. * Disposes of the gizmo
  122339. */
  122340. dispose(): void;
  122341. /**
  122342. * 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)
  122343. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  122344. * @returns the bounding box mesh with the passed in mesh as a child
  122345. */
  122346. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  122347. /**
  122348. * CustomMeshes are not supported by this gizmo
  122349. * @param mesh The mesh to replace the default mesh of the gizmo
  122350. */
  122351. setCustomMesh(mesh: Mesh): void;
  122352. }
  122353. }
  122354. declare module BABYLON {
  122355. /**
  122356. * Single plane rotation gizmo
  122357. */
  122358. export class PlaneRotationGizmo extends Gizmo {
  122359. /**
  122360. * Drag behavior responsible for the gizmos dragging interactions
  122361. */
  122362. dragBehavior: PointerDragBehavior;
  122363. private _pointerObserver;
  122364. /**
  122365. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  122366. */
  122367. snapDistance: number;
  122368. /**
  122369. * Event that fires each time the gizmo snaps to a new location.
  122370. * * snapDistance is the the change in distance
  122371. */
  122372. onSnapObservable: Observable<{
  122373. snapDistance: number;
  122374. }>;
  122375. private _isEnabled;
  122376. private _parent;
  122377. /**
  122378. * Creates a PlaneRotationGizmo
  122379. * @param gizmoLayer The utility layer the gizmo will be added to
  122380. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  122381. * @param color The color of the gizmo
  122382. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122383. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122384. */
  122385. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  122386. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122387. /**
  122388. * If the gizmo is enabled
  122389. */
  122390. set isEnabled(value: boolean);
  122391. get isEnabled(): boolean;
  122392. /**
  122393. * Disposes of the gizmo
  122394. */
  122395. dispose(): void;
  122396. }
  122397. }
  122398. declare module BABYLON {
  122399. /**
  122400. * Gizmo that enables rotating a mesh along 3 axis
  122401. */
  122402. export class RotationGizmo extends Gizmo {
  122403. /**
  122404. * Internal gizmo used for interactions on the x axis
  122405. */
  122406. xGizmo: PlaneRotationGizmo;
  122407. /**
  122408. * Internal gizmo used for interactions on the y axis
  122409. */
  122410. yGizmo: PlaneRotationGizmo;
  122411. /**
  122412. * Internal gizmo used for interactions on the z axis
  122413. */
  122414. zGizmo: PlaneRotationGizmo;
  122415. /** Fires an event when any of it's sub gizmos are dragged */
  122416. onDragStartObservable: Observable<unknown>;
  122417. /** Fires an event when any of it's sub gizmos are released from dragging */
  122418. onDragEndObservable: Observable<unknown>;
  122419. private _meshAttached;
  122420. get attachedMesh(): Nullable<AbstractMesh>;
  122421. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122422. /**
  122423. * Creates a RotationGizmo
  122424. * @param gizmoLayer The utility layer the gizmo will be added to
  122425. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122426. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122427. */
  122428. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  122429. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122430. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122431. /**
  122432. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122433. */
  122434. set snapDistance(value: number);
  122435. get snapDistance(): number;
  122436. /**
  122437. * Ratio for the scale of the gizmo (Default: 1)
  122438. */
  122439. set scaleRatio(value: number);
  122440. get scaleRatio(): number;
  122441. /**
  122442. * Disposes of the gizmo
  122443. */
  122444. dispose(): void;
  122445. /**
  122446. * CustomMeshes are not supported by this gizmo
  122447. * @param mesh The mesh to replace the default mesh of the gizmo
  122448. */
  122449. setCustomMesh(mesh: Mesh): void;
  122450. }
  122451. }
  122452. declare module BABYLON {
  122453. /**
  122454. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122455. */
  122456. export class GizmoManager implements IDisposable {
  122457. private scene;
  122458. /**
  122459. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122460. */
  122461. gizmos: {
  122462. positionGizmo: Nullable<PositionGizmo>;
  122463. rotationGizmo: Nullable<RotationGizmo>;
  122464. scaleGizmo: Nullable<ScaleGizmo>;
  122465. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122466. };
  122467. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122468. clearGizmoOnEmptyPointerEvent: boolean;
  122469. /** Fires an event when the manager is attached to a mesh */
  122470. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122471. private _gizmosEnabled;
  122472. private _pointerObserver;
  122473. private _attachedMesh;
  122474. private _boundingBoxColor;
  122475. private _defaultUtilityLayer;
  122476. private _defaultKeepDepthUtilityLayer;
  122477. /**
  122478. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122479. */
  122480. boundingBoxDragBehavior: SixDofDragBehavior;
  122481. /**
  122482. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122483. */
  122484. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122485. /**
  122486. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122487. */
  122488. usePointerToAttachGizmos: boolean;
  122489. /**
  122490. * Utility layer that the bounding box gizmo belongs to
  122491. */
  122492. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122493. /**
  122494. * Utility layer that all gizmos besides bounding box belong to
  122495. */
  122496. get utilityLayer(): UtilityLayerRenderer;
  122497. /**
  122498. * Instatiates a gizmo manager
  122499. * @param scene the scene to overlay the gizmos on top of
  122500. */
  122501. constructor(scene: Scene);
  122502. /**
  122503. * Attaches a set of gizmos to the specified mesh
  122504. * @param mesh The mesh the gizmo's should be attached to
  122505. */
  122506. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122507. /**
  122508. * If the position gizmo is enabled
  122509. */
  122510. set positionGizmoEnabled(value: boolean);
  122511. get positionGizmoEnabled(): boolean;
  122512. /**
  122513. * If the rotation gizmo is enabled
  122514. */
  122515. set rotationGizmoEnabled(value: boolean);
  122516. get rotationGizmoEnabled(): boolean;
  122517. /**
  122518. * If the scale gizmo is enabled
  122519. */
  122520. set scaleGizmoEnabled(value: boolean);
  122521. get scaleGizmoEnabled(): boolean;
  122522. /**
  122523. * If the boundingBox gizmo is enabled
  122524. */
  122525. set boundingBoxGizmoEnabled(value: boolean);
  122526. get boundingBoxGizmoEnabled(): boolean;
  122527. /**
  122528. * Disposes of the gizmo manager
  122529. */
  122530. dispose(): void;
  122531. }
  122532. }
  122533. declare module BABYLON {
  122534. /**
  122535. * A directional light is defined by a direction (what a surprise!).
  122536. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122537. * 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.
  122538. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122539. */
  122540. export class DirectionalLight extends ShadowLight {
  122541. private _shadowFrustumSize;
  122542. /**
  122543. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122544. */
  122545. get shadowFrustumSize(): number;
  122546. /**
  122547. * Specifies a fix frustum size for the shadow generation.
  122548. */
  122549. set shadowFrustumSize(value: number);
  122550. private _shadowOrthoScale;
  122551. /**
  122552. * Gets the shadow projection scale against the optimal computed one.
  122553. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122554. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122555. */
  122556. get shadowOrthoScale(): number;
  122557. /**
  122558. * Sets the shadow projection scale against the optimal computed one.
  122559. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122560. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122561. */
  122562. set shadowOrthoScale(value: number);
  122563. /**
  122564. * Automatically compute the projection matrix to best fit (including all the casters)
  122565. * on each frame.
  122566. */
  122567. autoUpdateExtends: boolean;
  122568. /**
  122569. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122570. * on each frame. autoUpdateExtends must be set to true for this to work
  122571. */
  122572. autoCalcShadowZBounds: boolean;
  122573. private _orthoLeft;
  122574. private _orthoRight;
  122575. private _orthoTop;
  122576. private _orthoBottom;
  122577. /**
  122578. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122579. * The directional light is emitted from everywhere in the given direction.
  122580. * It can cast shadows.
  122581. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122582. * @param name The friendly name of the light
  122583. * @param direction The direction of the light
  122584. * @param scene The scene the light belongs to
  122585. */
  122586. constructor(name: string, direction: Vector3, scene: Scene);
  122587. /**
  122588. * Returns the string "DirectionalLight".
  122589. * @return The class name
  122590. */
  122591. getClassName(): string;
  122592. /**
  122593. * Returns the integer 1.
  122594. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122595. */
  122596. getTypeID(): number;
  122597. /**
  122598. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122599. * Returns the DirectionalLight Shadow projection matrix.
  122600. */
  122601. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122602. /**
  122603. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122604. * Returns the DirectionalLight Shadow projection matrix.
  122605. */
  122606. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122607. /**
  122608. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122609. * Returns the DirectionalLight Shadow projection matrix.
  122610. */
  122611. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122612. protected _buildUniformLayout(): void;
  122613. /**
  122614. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122615. * @param effect The effect to update
  122616. * @param lightIndex The index of the light in the effect to update
  122617. * @returns The directional light
  122618. */
  122619. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122620. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122621. /**
  122622. * Gets the minZ used for shadow according to both the scene and the light.
  122623. *
  122624. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122625. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122626. * @param activeCamera The camera we are returning the min for
  122627. * @returns the depth min z
  122628. */
  122629. getDepthMinZ(activeCamera: Camera): number;
  122630. /**
  122631. * Gets the maxZ used for shadow according to both the scene and the light.
  122632. *
  122633. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122634. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122635. * @param activeCamera The camera we are returning the max for
  122636. * @returns the depth max z
  122637. */
  122638. getDepthMaxZ(activeCamera: Camera): number;
  122639. /**
  122640. * Prepares the list of defines specific to the light type.
  122641. * @param defines the list of defines
  122642. * @param lightIndex defines the index of the light for the effect
  122643. */
  122644. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122645. }
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * Class containing static functions to help procedurally build meshes
  122650. */
  122651. export class HemisphereBuilder {
  122652. /**
  122653. * Creates a hemisphere mesh
  122654. * @param name defines the name of the mesh
  122655. * @param options defines the options used to create the mesh
  122656. * @param scene defines the hosting scene
  122657. * @returns the hemisphere mesh
  122658. */
  122659. static CreateHemisphere(name: string, options: {
  122660. segments?: number;
  122661. diameter?: number;
  122662. sideOrientation?: number;
  122663. }, scene: any): Mesh;
  122664. }
  122665. }
  122666. declare module BABYLON {
  122667. /**
  122668. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122669. * These values define a cone of light starting from the position, emitting toward the direction.
  122670. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122671. * and the exponent defines the speed of the decay of the light with distance (reach).
  122672. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122673. */
  122674. export class SpotLight extends ShadowLight {
  122675. private _angle;
  122676. private _innerAngle;
  122677. private _cosHalfAngle;
  122678. private _lightAngleScale;
  122679. private _lightAngleOffset;
  122680. /**
  122681. * Gets the cone angle of the spot light in Radians.
  122682. */
  122683. get angle(): number;
  122684. /**
  122685. * Sets the cone angle of the spot light in Radians.
  122686. */
  122687. set angle(value: number);
  122688. /**
  122689. * Only used in gltf falloff mode, this defines the angle where
  122690. * the directional falloff will start before cutting at angle which could be seen
  122691. * as outer angle.
  122692. */
  122693. get innerAngle(): number;
  122694. /**
  122695. * Only used in gltf falloff mode, this defines the angle where
  122696. * the directional falloff will start before cutting at angle which could be seen
  122697. * as outer angle.
  122698. */
  122699. set innerAngle(value: number);
  122700. private _shadowAngleScale;
  122701. /**
  122702. * Allows scaling the angle of the light for shadow generation only.
  122703. */
  122704. get shadowAngleScale(): number;
  122705. /**
  122706. * Allows scaling the angle of the light for shadow generation only.
  122707. */
  122708. set shadowAngleScale(value: number);
  122709. /**
  122710. * The light decay speed with the distance from the emission spot.
  122711. */
  122712. exponent: number;
  122713. private _projectionTextureMatrix;
  122714. /**
  122715. * Allows reading the projecton texture
  122716. */
  122717. get projectionTextureMatrix(): Matrix;
  122718. protected _projectionTextureLightNear: number;
  122719. /**
  122720. * Gets the near clip of the Spotlight for texture projection.
  122721. */
  122722. get projectionTextureLightNear(): number;
  122723. /**
  122724. * Sets the near clip of the Spotlight for texture projection.
  122725. */
  122726. set projectionTextureLightNear(value: number);
  122727. protected _projectionTextureLightFar: number;
  122728. /**
  122729. * Gets the far clip of the Spotlight for texture projection.
  122730. */
  122731. get projectionTextureLightFar(): number;
  122732. /**
  122733. * Sets the far clip of the Spotlight for texture projection.
  122734. */
  122735. set projectionTextureLightFar(value: number);
  122736. protected _projectionTextureUpDirection: Vector3;
  122737. /**
  122738. * Gets the Up vector of the Spotlight for texture projection.
  122739. */
  122740. get projectionTextureUpDirection(): Vector3;
  122741. /**
  122742. * Sets the Up vector of the Spotlight for texture projection.
  122743. */
  122744. set projectionTextureUpDirection(value: Vector3);
  122745. private _projectionTexture;
  122746. /**
  122747. * Gets the projection texture of the light.
  122748. */
  122749. get projectionTexture(): Nullable<BaseTexture>;
  122750. /**
  122751. * Sets the projection texture of the light.
  122752. */
  122753. set projectionTexture(value: Nullable<BaseTexture>);
  122754. private _projectionTextureViewLightDirty;
  122755. private _projectionTextureProjectionLightDirty;
  122756. private _projectionTextureDirty;
  122757. private _projectionTextureViewTargetVector;
  122758. private _projectionTextureViewLightMatrix;
  122759. private _projectionTextureProjectionLightMatrix;
  122760. private _projectionTextureScalingMatrix;
  122761. /**
  122762. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122763. * It can cast shadows.
  122764. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122765. * @param name The light friendly name
  122766. * @param position The position of the spot light in the scene
  122767. * @param direction The direction of the light in the scene
  122768. * @param angle The cone angle of the light in Radians
  122769. * @param exponent The light decay speed with the distance from the emission spot
  122770. * @param scene The scene the lights belongs to
  122771. */
  122772. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122773. /**
  122774. * Returns the string "SpotLight".
  122775. * @returns the class name
  122776. */
  122777. getClassName(): string;
  122778. /**
  122779. * Returns the integer 2.
  122780. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122781. */
  122782. getTypeID(): number;
  122783. /**
  122784. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122785. */
  122786. protected _setDirection(value: Vector3): void;
  122787. /**
  122788. * Overrides the position setter to recompute the projection texture view light Matrix.
  122789. */
  122790. protected _setPosition(value: Vector3): void;
  122791. /**
  122792. * 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.
  122793. * Returns the SpotLight.
  122794. */
  122795. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122796. protected _computeProjectionTextureViewLightMatrix(): void;
  122797. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122798. /**
  122799. * Main function for light texture projection matrix computing.
  122800. */
  122801. protected _computeProjectionTextureMatrix(): void;
  122802. protected _buildUniformLayout(): void;
  122803. private _computeAngleValues;
  122804. /**
  122805. * Sets the passed Effect "effect" with the Light textures.
  122806. * @param effect The effect to update
  122807. * @param lightIndex The index of the light in the effect to update
  122808. * @returns The light
  122809. */
  122810. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122811. /**
  122812. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122813. * @param effect The effect to update
  122814. * @param lightIndex The index of the light in the effect to update
  122815. * @returns The spot light
  122816. */
  122817. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122818. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122819. /**
  122820. * Disposes the light and the associated resources.
  122821. */
  122822. dispose(): void;
  122823. /**
  122824. * Prepares the list of defines specific to the light type.
  122825. * @param defines the list of defines
  122826. * @param lightIndex defines the index of the light for the effect
  122827. */
  122828. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122829. }
  122830. }
  122831. declare module BABYLON {
  122832. /**
  122833. * Gizmo that enables viewing a light
  122834. */
  122835. export class LightGizmo extends Gizmo {
  122836. private _lightMesh;
  122837. private _material;
  122838. private _cachedPosition;
  122839. private _cachedForward;
  122840. private _attachedMeshParent;
  122841. /**
  122842. * Creates a LightGizmo
  122843. * @param gizmoLayer The utility layer the gizmo will be added to
  122844. */
  122845. constructor(gizmoLayer?: UtilityLayerRenderer);
  122846. private _light;
  122847. /**
  122848. * The light that the gizmo is attached to
  122849. */
  122850. set light(light: Nullable<Light>);
  122851. get light(): Nullable<Light>;
  122852. /**
  122853. * Gets the material used to render the light gizmo
  122854. */
  122855. get material(): StandardMaterial;
  122856. /**
  122857. * @hidden
  122858. * Updates the gizmo to match the attached mesh's position/rotation
  122859. */
  122860. protected _update(): void;
  122861. private static _Scale;
  122862. /**
  122863. * Creates the lines for a light mesh
  122864. */
  122865. private static _CreateLightLines;
  122866. /**
  122867. * Disposes of the light gizmo
  122868. */
  122869. dispose(): void;
  122870. private static _CreateHemisphericLightMesh;
  122871. private static _CreatePointLightMesh;
  122872. private static _CreateSpotLightMesh;
  122873. private static _CreateDirectionalLightMesh;
  122874. }
  122875. }
  122876. declare module BABYLON {
  122877. /** @hidden */
  122878. export var backgroundFragmentDeclaration: {
  122879. name: string;
  122880. shader: string;
  122881. };
  122882. }
  122883. declare module BABYLON {
  122884. /** @hidden */
  122885. export var backgroundUboDeclaration: {
  122886. name: string;
  122887. shader: string;
  122888. };
  122889. }
  122890. declare module BABYLON {
  122891. /** @hidden */
  122892. export var backgroundPixelShader: {
  122893. name: string;
  122894. shader: string;
  122895. };
  122896. }
  122897. declare module BABYLON {
  122898. /** @hidden */
  122899. export var backgroundVertexDeclaration: {
  122900. name: string;
  122901. shader: string;
  122902. };
  122903. }
  122904. declare module BABYLON {
  122905. /** @hidden */
  122906. export var backgroundVertexShader: {
  122907. name: string;
  122908. shader: string;
  122909. };
  122910. }
  122911. declare module BABYLON {
  122912. /**
  122913. * Background material used to create an efficient environement around your scene.
  122914. */
  122915. export class BackgroundMaterial extends PushMaterial {
  122916. /**
  122917. * Standard reflectance value at parallel view angle.
  122918. */
  122919. static StandardReflectance0: number;
  122920. /**
  122921. * Standard reflectance value at grazing angle.
  122922. */
  122923. static StandardReflectance90: number;
  122924. protected _primaryColor: Color3;
  122925. /**
  122926. * Key light Color (multiply against the environement texture)
  122927. */
  122928. primaryColor: Color3;
  122929. protected __perceptualColor: Nullable<Color3>;
  122930. /**
  122931. * Experimental Internal Use Only.
  122932. *
  122933. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122934. * This acts as a helper to set the primary color to a more "human friendly" value.
  122935. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122936. * output color as close as possible from the chosen value.
  122937. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122938. * part of lighting setup.)
  122939. */
  122940. get _perceptualColor(): Nullable<Color3>;
  122941. set _perceptualColor(value: Nullable<Color3>);
  122942. protected _primaryColorShadowLevel: float;
  122943. /**
  122944. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122945. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122946. */
  122947. get primaryColorShadowLevel(): float;
  122948. set primaryColorShadowLevel(value: float);
  122949. protected _primaryColorHighlightLevel: float;
  122950. /**
  122951. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122952. * The primary color is used at the level chosen to define what the white area would look.
  122953. */
  122954. get primaryColorHighlightLevel(): float;
  122955. set primaryColorHighlightLevel(value: float);
  122956. protected _reflectionTexture: Nullable<BaseTexture>;
  122957. /**
  122958. * Reflection Texture used in the material.
  122959. * Should be author in a specific way for the best result (refer to the documentation).
  122960. */
  122961. reflectionTexture: Nullable<BaseTexture>;
  122962. protected _reflectionBlur: float;
  122963. /**
  122964. * Reflection Texture level of blur.
  122965. *
  122966. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122967. * texture twice.
  122968. */
  122969. reflectionBlur: float;
  122970. protected _diffuseTexture: Nullable<BaseTexture>;
  122971. /**
  122972. * Diffuse Texture used in the material.
  122973. * Should be author in a specific way for the best result (refer to the documentation).
  122974. */
  122975. diffuseTexture: Nullable<BaseTexture>;
  122976. protected _shadowLights: Nullable<IShadowLight[]>;
  122977. /**
  122978. * Specify the list of lights casting shadow on the material.
  122979. * All scene shadow lights will be included if null.
  122980. */
  122981. shadowLights: Nullable<IShadowLight[]>;
  122982. protected _shadowLevel: float;
  122983. /**
  122984. * Helps adjusting the shadow to a softer level if required.
  122985. * 0 means black shadows and 1 means no shadows.
  122986. */
  122987. shadowLevel: float;
  122988. protected _sceneCenter: Vector3;
  122989. /**
  122990. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122991. * It is usually zero but might be interesting to modify according to your setup.
  122992. */
  122993. sceneCenter: Vector3;
  122994. protected _opacityFresnel: boolean;
  122995. /**
  122996. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122997. * This helps ensuring a nice transition when the camera goes under the ground.
  122998. */
  122999. opacityFresnel: boolean;
  123000. protected _reflectionFresnel: boolean;
  123001. /**
  123002. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123003. * This helps adding a mirror texture on the ground.
  123004. */
  123005. reflectionFresnel: boolean;
  123006. protected _reflectionFalloffDistance: number;
  123007. /**
  123008. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123009. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123010. */
  123011. reflectionFalloffDistance: number;
  123012. protected _reflectionAmount: number;
  123013. /**
  123014. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123015. */
  123016. reflectionAmount: number;
  123017. protected _reflectionReflectance0: number;
  123018. /**
  123019. * This specifies the weight of the reflection at grazing angle.
  123020. */
  123021. reflectionReflectance0: number;
  123022. protected _reflectionReflectance90: number;
  123023. /**
  123024. * This specifies the weight of the reflection at a perpendicular point of view.
  123025. */
  123026. reflectionReflectance90: number;
  123027. /**
  123028. * Sets the reflection reflectance fresnel values according to the default standard
  123029. * empirically know to work well :-)
  123030. */
  123031. set reflectionStandardFresnelWeight(value: number);
  123032. protected _useRGBColor: boolean;
  123033. /**
  123034. * Helps to directly use the maps channels instead of their level.
  123035. */
  123036. useRGBColor: boolean;
  123037. protected _enableNoise: boolean;
  123038. /**
  123039. * This helps reducing the banding effect that could occur on the background.
  123040. */
  123041. enableNoise: boolean;
  123042. /**
  123043. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123044. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123045. * Recommended to be keep at 1.0 except for special cases.
  123046. */
  123047. get fovMultiplier(): number;
  123048. set fovMultiplier(value: number);
  123049. private _fovMultiplier;
  123050. /**
  123051. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123052. */
  123053. useEquirectangularFOV: boolean;
  123054. private _maxSimultaneousLights;
  123055. /**
  123056. * Number of Simultaneous lights allowed on the material.
  123057. */
  123058. maxSimultaneousLights: int;
  123059. /**
  123060. * Default configuration related to image processing available in the Background Material.
  123061. */
  123062. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123063. /**
  123064. * Keep track of the image processing observer to allow dispose and replace.
  123065. */
  123066. private _imageProcessingObserver;
  123067. /**
  123068. * Attaches a new image processing configuration to the PBR Material.
  123069. * @param configuration (if null the scene configuration will be use)
  123070. */
  123071. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123072. /**
  123073. * Gets the image processing configuration used either in this material.
  123074. */
  123075. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  123076. /**
  123077. * Sets the Default image processing configuration used either in the this material.
  123078. *
  123079. * If sets to null, the scene one is in use.
  123080. */
  123081. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  123082. /**
  123083. * Gets wether the color curves effect is enabled.
  123084. */
  123085. get cameraColorCurvesEnabled(): boolean;
  123086. /**
  123087. * Sets wether the color curves effect is enabled.
  123088. */
  123089. set cameraColorCurvesEnabled(value: boolean);
  123090. /**
  123091. * Gets wether the color grading effect is enabled.
  123092. */
  123093. get cameraColorGradingEnabled(): boolean;
  123094. /**
  123095. * Gets wether the color grading effect is enabled.
  123096. */
  123097. set cameraColorGradingEnabled(value: boolean);
  123098. /**
  123099. * Gets wether tonemapping is enabled or not.
  123100. */
  123101. get cameraToneMappingEnabled(): boolean;
  123102. /**
  123103. * Sets wether tonemapping is enabled or not
  123104. */
  123105. set cameraToneMappingEnabled(value: boolean);
  123106. /**
  123107. * The camera exposure used on this material.
  123108. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123109. * This corresponds to a photographic exposure.
  123110. */
  123111. get cameraExposure(): float;
  123112. /**
  123113. * The camera exposure used on this material.
  123114. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123115. * This corresponds to a photographic exposure.
  123116. */
  123117. set cameraExposure(value: float);
  123118. /**
  123119. * Gets The camera contrast used on this material.
  123120. */
  123121. get cameraContrast(): float;
  123122. /**
  123123. * Sets The camera contrast used on this material.
  123124. */
  123125. set cameraContrast(value: float);
  123126. /**
  123127. * Gets the Color Grading 2D Lookup Texture.
  123128. */
  123129. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  123130. /**
  123131. * Sets the Color Grading 2D Lookup Texture.
  123132. */
  123133. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  123134. /**
  123135. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123136. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123137. * 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;
  123138. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123139. */
  123140. get cameraColorCurves(): Nullable<ColorCurves>;
  123141. /**
  123142. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123143. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123144. * 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;
  123145. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123146. */
  123147. set cameraColorCurves(value: Nullable<ColorCurves>);
  123148. /**
  123149. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  123150. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  123151. */
  123152. switchToBGR: boolean;
  123153. private _renderTargets;
  123154. private _reflectionControls;
  123155. private _white;
  123156. private _primaryShadowColor;
  123157. private _primaryHighlightColor;
  123158. /**
  123159. * Instantiates a Background Material in the given scene
  123160. * @param name The friendly name of the material
  123161. * @param scene The scene to add the material to
  123162. */
  123163. constructor(name: string, scene: Scene);
  123164. /**
  123165. * Gets a boolean indicating that current material needs to register RTT
  123166. */
  123167. get hasRenderTargetTextures(): boolean;
  123168. /**
  123169. * The entire material has been created in order to prevent overdraw.
  123170. * @returns false
  123171. */
  123172. needAlphaTesting(): boolean;
  123173. /**
  123174. * The entire material has been created in order to prevent overdraw.
  123175. * @returns true if blending is enable
  123176. */
  123177. needAlphaBlending(): boolean;
  123178. /**
  123179. * Checks wether the material is ready to be rendered for a given mesh.
  123180. * @param mesh The mesh to render
  123181. * @param subMesh The submesh to check against
  123182. * @param useInstances Specify wether or not the material is used with instances
  123183. * @returns true if all the dependencies are ready (Textures, Effects...)
  123184. */
  123185. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123186. /**
  123187. * Compute the primary color according to the chosen perceptual color.
  123188. */
  123189. private _computePrimaryColorFromPerceptualColor;
  123190. /**
  123191. * Compute the highlights and shadow colors according to their chosen levels.
  123192. */
  123193. private _computePrimaryColors;
  123194. /**
  123195. * Build the uniform buffer used in the material.
  123196. */
  123197. buildUniformLayout(): void;
  123198. /**
  123199. * Unbind the material.
  123200. */
  123201. unbind(): void;
  123202. /**
  123203. * Bind only the world matrix to the material.
  123204. * @param world The world matrix to bind.
  123205. */
  123206. bindOnlyWorldMatrix(world: Matrix): void;
  123207. /**
  123208. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  123209. * @param world The world matrix to bind.
  123210. * @param subMesh The submesh to bind for.
  123211. */
  123212. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123213. /**
  123214. * Checks to see if a texture is used in the material.
  123215. * @param texture - Base texture to use.
  123216. * @returns - Boolean specifying if a texture is used in the material.
  123217. */
  123218. hasTexture(texture: BaseTexture): boolean;
  123219. /**
  123220. * Dispose the material.
  123221. * @param forceDisposeEffect Force disposal of the associated effect.
  123222. * @param forceDisposeTextures Force disposal of the associated textures.
  123223. */
  123224. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  123225. /**
  123226. * Clones the material.
  123227. * @param name The cloned name.
  123228. * @returns The cloned material.
  123229. */
  123230. clone(name: string): BackgroundMaterial;
  123231. /**
  123232. * Serializes the current material to its JSON representation.
  123233. * @returns The JSON representation.
  123234. */
  123235. serialize(): any;
  123236. /**
  123237. * Gets the class name of the material
  123238. * @returns "BackgroundMaterial"
  123239. */
  123240. getClassName(): string;
  123241. /**
  123242. * Parse a JSON input to create back a background material.
  123243. * @param source The JSON data to parse
  123244. * @param scene The scene to create the parsed material in
  123245. * @param rootUrl The root url of the assets the material depends upon
  123246. * @returns the instantiated BackgroundMaterial.
  123247. */
  123248. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  123249. }
  123250. }
  123251. declare module BABYLON {
  123252. /**
  123253. * Represents the different options available during the creation of
  123254. * a Environment helper.
  123255. *
  123256. * This can control the default ground, skybox and image processing setup of your scene.
  123257. */
  123258. export interface IEnvironmentHelperOptions {
  123259. /**
  123260. * Specifies whether or not to create a ground.
  123261. * True by default.
  123262. */
  123263. createGround: boolean;
  123264. /**
  123265. * Specifies the ground size.
  123266. * 15 by default.
  123267. */
  123268. groundSize: number;
  123269. /**
  123270. * The texture used on the ground for the main color.
  123271. * Comes from the BabylonJS CDN by default.
  123272. *
  123273. * Remarks: Can be either a texture or a url.
  123274. */
  123275. groundTexture: string | BaseTexture;
  123276. /**
  123277. * The color mixed in the ground texture by default.
  123278. * BabylonJS clearColor by default.
  123279. */
  123280. groundColor: Color3;
  123281. /**
  123282. * Specifies the ground opacity.
  123283. * 1 by default.
  123284. */
  123285. groundOpacity: number;
  123286. /**
  123287. * Enables the ground to receive shadows.
  123288. * True by default.
  123289. */
  123290. enableGroundShadow: boolean;
  123291. /**
  123292. * Helps preventing the shadow to be fully black on the ground.
  123293. * 0.5 by default.
  123294. */
  123295. groundShadowLevel: number;
  123296. /**
  123297. * Creates a mirror texture attach to the ground.
  123298. * false by default.
  123299. */
  123300. enableGroundMirror: boolean;
  123301. /**
  123302. * Specifies the ground mirror size ratio.
  123303. * 0.3 by default as the default kernel is 64.
  123304. */
  123305. groundMirrorSizeRatio: number;
  123306. /**
  123307. * Specifies the ground mirror blur kernel size.
  123308. * 64 by default.
  123309. */
  123310. groundMirrorBlurKernel: number;
  123311. /**
  123312. * Specifies the ground mirror visibility amount.
  123313. * 1 by default
  123314. */
  123315. groundMirrorAmount: number;
  123316. /**
  123317. * Specifies the ground mirror reflectance weight.
  123318. * This uses the standard weight of the background material to setup the fresnel effect
  123319. * of the mirror.
  123320. * 1 by default.
  123321. */
  123322. groundMirrorFresnelWeight: number;
  123323. /**
  123324. * Specifies the ground mirror Falloff distance.
  123325. * This can helps reducing the size of the reflection.
  123326. * 0 by Default.
  123327. */
  123328. groundMirrorFallOffDistance: number;
  123329. /**
  123330. * Specifies the ground mirror texture type.
  123331. * Unsigned Int by Default.
  123332. */
  123333. groundMirrorTextureType: number;
  123334. /**
  123335. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  123336. * the shown objects.
  123337. */
  123338. groundYBias: number;
  123339. /**
  123340. * Specifies whether or not to create a skybox.
  123341. * True by default.
  123342. */
  123343. createSkybox: boolean;
  123344. /**
  123345. * Specifies the skybox size.
  123346. * 20 by default.
  123347. */
  123348. skyboxSize: number;
  123349. /**
  123350. * The texture used on the skybox for the main color.
  123351. * Comes from the BabylonJS CDN by default.
  123352. *
  123353. * Remarks: Can be either a texture or a url.
  123354. */
  123355. skyboxTexture: string | BaseTexture;
  123356. /**
  123357. * The color mixed in the skybox texture by default.
  123358. * BabylonJS clearColor by default.
  123359. */
  123360. skyboxColor: Color3;
  123361. /**
  123362. * The background rotation around the Y axis of the scene.
  123363. * This helps aligning the key lights of your scene with the background.
  123364. * 0 by default.
  123365. */
  123366. backgroundYRotation: number;
  123367. /**
  123368. * Compute automatically the size of the elements to best fit with the scene.
  123369. */
  123370. sizeAuto: boolean;
  123371. /**
  123372. * Default position of the rootMesh if autoSize is not true.
  123373. */
  123374. rootPosition: Vector3;
  123375. /**
  123376. * Sets up the image processing in the scene.
  123377. * true by default.
  123378. */
  123379. setupImageProcessing: boolean;
  123380. /**
  123381. * The texture used as your environment texture in the scene.
  123382. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  123383. *
  123384. * Remarks: Can be either a texture or a url.
  123385. */
  123386. environmentTexture: string | BaseTexture;
  123387. /**
  123388. * The value of the exposure to apply to the scene.
  123389. * 0.6 by default if setupImageProcessing is true.
  123390. */
  123391. cameraExposure: number;
  123392. /**
  123393. * The value of the contrast to apply to the scene.
  123394. * 1.6 by default if setupImageProcessing is true.
  123395. */
  123396. cameraContrast: number;
  123397. /**
  123398. * Specifies whether or not tonemapping should be enabled in the scene.
  123399. * true by default if setupImageProcessing is true.
  123400. */
  123401. toneMappingEnabled: boolean;
  123402. }
  123403. /**
  123404. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  123405. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  123406. * It also helps with the default setup of your imageProcessing configuration.
  123407. */
  123408. export class EnvironmentHelper {
  123409. /**
  123410. * Default ground texture URL.
  123411. */
  123412. private static _groundTextureCDNUrl;
  123413. /**
  123414. * Default skybox texture URL.
  123415. */
  123416. private static _skyboxTextureCDNUrl;
  123417. /**
  123418. * Default environment texture URL.
  123419. */
  123420. private static _environmentTextureCDNUrl;
  123421. /**
  123422. * Creates the default options for the helper.
  123423. */
  123424. private static _getDefaultOptions;
  123425. private _rootMesh;
  123426. /**
  123427. * Gets the root mesh created by the helper.
  123428. */
  123429. get rootMesh(): Mesh;
  123430. private _skybox;
  123431. /**
  123432. * Gets the skybox created by the helper.
  123433. */
  123434. get skybox(): Nullable<Mesh>;
  123435. private _skyboxTexture;
  123436. /**
  123437. * Gets the skybox texture created by the helper.
  123438. */
  123439. get skyboxTexture(): Nullable<BaseTexture>;
  123440. private _skyboxMaterial;
  123441. /**
  123442. * Gets the skybox material created by the helper.
  123443. */
  123444. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  123445. private _ground;
  123446. /**
  123447. * Gets the ground mesh created by the helper.
  123448. */
  123449. get ground(): Nullable<Mesh>;
  123450. private _groundTexture;
  123451. /**
  123452. * Gets the ground texture created by the helper.
  123453. */
  123454. get groundTexture(): Nullable<BaseTexture>;
  123455. private _groundMirror;
  123456. /**
  123457. * Gets the ground mirror created by the helper.
  123458. */
  123459. get groundMirror(): Nullable<MirrorTexture>;
  123460. /**
  123461. * Gets the ground mirror render list to helps pushing the meshes
  123462. * you wish in the ground reflection.
  123463. */
  123464. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123465. private _groundMaterial;
  123466. /**
  123467. * Gets the ground material created by the helper.
  123468. */
  123469. get groundMaterial(): Nullable<BackgroundMaterial>;
  123470. /**
  123471. * Stores the creation options.
  123472. */
  123473. private readonly _scene;
  123474. private _options;
  123475. /**
  123476. * This observable will be notified with any error during the creation of the environment,
  123477. * mainly texture creation errors.
  123478. */
  123479. onErrorObservable: Observable<{
  123480. message?: string;
  123481. exception?: any;
  123482. }>;
  123483. /**
  123484. * constructor
  123485. * @param options Defines the options we want to customize the helper
  123486. * @param scene The scene to add the material to
  123487. */
  123488. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123489. /**
  123490. * Updates the background according to the new options
  123491. * @param options
  123492. */
  123493. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123494. /**
  123495. * Sets the primary color of all the available elements.
  123496. * @param color the main color to affect to the ground and the background
  123497. */
  123498. setMainColor(color: Color3): void;
  123499. /**
  123500. * Setup the image processing according to the specified options.
  123501. */
  123502. private _setupImageProcessing;
  123503. /**
  123504. * Setup the environment texture according to the specified options.
  123505. */
  123506. private _setupEnvironmentTexture;
  123507. /**
  123508. * Setup the background according to the specified options.
  123509. */
  123510. private _setupBackground;
  123511. /**
  123512. * Get the scene sizes according to the setup.
  123513. */
  123514. private _getSceneSize;
  123515. /**
  123516. * Setup the ground according to the specified options.
  123517. */
  123518. private _setupGround;
  123519. /**
  123520. * Setup the ground material according to the specified options.
  123521. */
  123522. private _setupGroundMaterial;
  123523. /**
  123524. * Setup the ground diffuse texture according to the specified options.
  123525. */
  123526. private _setupGroundDiffuseTexture;
  123527. /**
  123528. * Setup the ground mirror texture according to the specified options.
  123529. */
  123530. private _setupGroundMirrorTexture;
  123531. /**
  123532. * Setup the ground to receive the mirror texture.
  123533. */
  123534. private _setupMirrorInGroundMaterial;
  123535. /**
  123536. * Setup the skybox according to the specified options.
  123537. */
  123538. private _setupSkybox;
  123539. /**
  123540. * Setup the skybox material according to the specified options.
  123541. */
  123542. private _setupSkyboxMaterial;
  123543. /**
  123544. * Setup the skybox reflection texture according to the specified options.
  123545. */
  123546. private _setupSkyboxReflectionTexture;
  123547. private _errorHandler;
  123548. /**
  123549. * Dispose all the elements created by the Helper.
  123550. */
  123551. dispose(): void;
  123552. }
  123553. }
  123554. declare module BABYLON {
  123555. /**
  123556. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123557. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123558. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123559. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123560. */
  123561. export class PhotoDome extends TransformNode {
  123562. /**
  123563. * Define the image as a Monoscopic panoramic 360 image.
  123564. */
  123565. static readonly MODE_MONOSCOPIC: number;
  123566. /**
  123567. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123568. */
  123569. static readonly MODE_TOPBOTTOM: number;
  123570. /**
  123571. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123572. */
  123573. static readonly MODE_SIDEBYSIDE: number;
  123574. private _useDirectMapping;
  123575. /**
  123576. * The texture being displayed on the sphere
  123577. */
  123578. protected _photoTexture: Texture;
  123579. /**
  123580. * Gets or sets the texture being displayed on the sphere
  123581. */
  123582. get photoTexture(): Texture;
  123583. set photoTexture(value: Texture);
  123584. /**
  123585. * Observable raised when an error occured while loading the 360 image
  123586. */
  123587. onLoadErrorObservable: Observable<string>;
  123588. /**
  123589. * The skybox material
  123590. */
  123591. protected _material: BackgroundMaterial;
  123592. /**
  123593. * The surface used for the skybox
  123594. */
  123595. protected _mesh: Mesh;
  123596. /**
  123597. * Gets the mesh used for the skybox.
  123598. */
  123599. get mesh(): Mesh;
  123600. /**
  123601. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123602. * Also see the options.resolution property.
  123603. */
  123604. get fovMultiplier(): number;
  123605. set fovMultiplier(value: number);
  123606. private _imageMode;
  123607. /**
  123608. * Gets or set the current video mode for the video. It can be:
  123609. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123610. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123611. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123612. */
  123613. get imageMode(): number;
  123614. set imageMode(value: number);
  123615. /**
  123616. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123617. * @param name Element's name, child elements will append suffixes for their own names.
  123618. * @param urlsOfPhoto defines the url of the photo to display
  123619. * @param options defines an object containing optional or exposed sub element properties
  123620. * @param onError defines a callback called when an error occured while loading the texture
  123621. */
  123622. constructor(name: string, urlOfPhoto: string, options: {
  123623. resolution?: number;
  123624. size?: number;
  123625. useDirectMapping?: boolean;
  123626. faceForward?: boolean;
  123627. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123628. private _onBeforeCameraRenderObserver;
  123629. private _changeImageMode;
  123630. /**
  123631. * Releases resources associated with this node.
  123632. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123633. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123634. */
  123635. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123636. }
  123637. }
  123638. declare module BABYLON {
  123639. /**
  123640. * Class used to host RGBD texture specific utilities
  123641. */
  123642. export class RGBDTextureTools {
  123643. /**
  123644. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123645. * @param texture the texture to expand.
  123646. */
  123647. static ExpandRGBDTexture(texture: Texture): void;
  123648. }
  123649. }
  123650. declare module BABYLON {
  123651. /**
  123652. * Class used to host texture specific utilities
  123653. */
  123654. export class BRDFTextureTools {
  123655. /**
  123656. * Prevents texture cache collision
  123657. */
  123658. private static _instanceNumber;
  123659. /**
  123660. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123661. * @param scene defines the hosting scene
  123662. * @returns the environment BRDF texture
  123663. */
  123664. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123665. private static _environmentBRDFBase64Texture;
  123666. }
  123667. }
  123668. declare module BABYLON {
  123669. /**
  123670. * @hidden
  123671. */
  123672. export interface IMaterialClearCoatDefines {
  123673. CLEARCOAT: boolean;
  123674. CLEARCOAT_DEFAULTIOR: boolean;
  123675. CLEARCOAT_TEXTURE: boolean;
  123676. CLEARCOAT_TEXTUREDIRECTUV: number;
  123677. CLEARCOAT_BUMP: boolean;
  123678. CLEARCOAT_BUMPDIRECTUV: number;
  123679. CLEARCOAT_TINT: boolean;
  123680. CLEARCOAT_TINT_TEXTURE: boolean;
  123681. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123682. /** @hidden */
  123683. _areTexturesDirty: boolean;
  123684. }
  123685. /**
  123686. * Define the code related to the clear coat parameters of the pbr material.
  123687. */
  123688. export class PBRClearCoatConfiguration {
  123689. /**
  123690. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123691. * The default fits with a polyurethane material.
  123692. */
  123693. private static readonly _DefaultIndexOfRefraction;
  123694. private _isEnabled;
  123695. /**
  123696. * Defines if the clear coat is enabled in the material.
  123697. */
  123698. isEnabled: boolean;
  123699. /**
  123700. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123701. */
  123702. intensity: number;
  123703. /**
  123704. * Defines the clear coat layer roughness.
  123705. */
  123706. roughness: number;
  123707. private _indexOfRefraction;
  123708. /**
  123709. * Defines the index of refraction of the clear coat.
  123710. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123711. * The default fits with a polyurethane material.
  123712. * Changing the default value is more performance intensive.
  123713. */
  123714. indexOfRefraction: number;
  123715. private _texture;
  123716. /**
  123717. * Stores the clear coat values in a texture.
  123718. */
  123719. texture: Nullable<BaseTexture>;
  123720. private _bumpTexture;
  123721. /**
  123722. * Define the clear coat specific bump texture.
  123723. */
  123724. bumpTexture: Nullable<BaseTexture>;
  123725. private _isTintEnabled;
  123726. /**
  123727. * Defines if the clear coat tint is enabled in the material.
  123728. */
  123729. isTintEnabled: boolean;
  123730. /**
  123731. * Defines the clear coat tint of the material.
  123732. * This is only use if tint is enabled
  123733. */
  123734. tintColor: Color3;
  123735. /**
  123736. * Defines the distance at which the tint color should be found in the
  123737. * clear coat media.
  123738. * This is only use if tint is enabled
  123739. */
  123740. tintColorAtDistance: number;
  123741. /**
  123742. * Defines the clear coat layer thickness.
  123743. * This is only use if tint is enabled
  123744. */
  123745. tintThickness: number;
  123746. private _tintTexture;
  123747. /**
  123748. * Stores the clear tint values in a texture.
  123749. * rgb is tint
  123750. * a is a thickness factor
  123751. */
  123752. tintTexture: Nullable<BaseTexture>;
  123753. /** @hidden */
  123754. private _internalMarkAllSubMeshesAsTexturesDirty;
  123755. /** @hidden */
  123756. _markAllSubMeshesAsTexturesDirty(): void;
  123757. /**
  123758. * Instantiate a new istance of clear coat configuration.
  123759. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123760. */
  123761. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123762. /**
  123763. * Gets wehter the submesh is ready to be used or not.
  123764. * @param defines the list of "defines" to update.
  123765. * @param scene defines the scene the material belongs to.
  123766. * @param engine defines the engine the material belongs to.
  123767. * @param disableBumpMap defines wether the material disables bump or not.
  123768. * @returns - boolean indicating that the submesh is ready or not.
  123769. */
  123770. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123771. /**
  123772. * Checks to see if a texture is used in the material.
  123773. * @param defines the list of "defines" to update.
  123774. * @param scene defines the scene to the material belongs to.
  123775. */
  123776. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123777. /**
  123778. * Binds the material data.
  123779. * @param uniformBuffer defines the Uniform buffer to fill in.
  123780. * @param scene defines the scene the material belongs to.
  123781. * @param engine defines the engine the material belongs to.
  123782. * @param disableBumpMap defines wether the material disables bump or not.
  123783. * @param isFrozen defines wether the material is frozen or not.
  123784. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123785. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123786. */
  123787. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123788. /**
  123789. * Checks to see if a texture is used in the material.
  123790. * @param texture - Base texture to use.
  123791. * @returns - Boolean specifying if a texture is used in the material.
  123792. */
  123793. hasTexture(texture: BaseTexture): boolean;
  123794. /**
  123795. * Returns an array of the actively used textures.
  123796. * @param activeTextures Array of BaseTextures
  123797. */
  123798. getActiveTextures(activeTextures: BaseTexture[]): void;
  123799. /**
  123800. * Returns the animatable textures.
  123801. * @param animatables Array of animatable textures.
  123802. */
  123803. getAnimatables(animatables: IAnimatable[]): void;
  123804. /**
  123805. * Disposes the resources of the material.
  123806. * @param forceDisposeTextures - Forces the disposal of all textures.
  123807. */
  123808. dispose(forceDisposeTextures?: boolean): void;
  123809. /**
  123810. * Get the current class name of the texture useful for serialization or dynamic coding.
  123811. * @returns "PBRClearCoatConfiguration"
  123812. */
  123813. getClassName(): string;
  123814. /**
  123815. * Add fallbacks to the effect fallbacks list.
  123816. * @param defines defines the Base texture to use.
  123817. * @param fallbacks defines the current fallback list.
  123818. * @param currentRank defines the current fallback rank.
  123819. * @returns the new fallback rank.
  123820. */
  123821. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123822. /**
  123823. * Add the required uniforms to the current list.
  123824. * @param uniforms defines the current uniform list.
  123825. */
  123826. static AddUniforms(uniforms: string[]): void;
  123827. /**
  123828. * Add the required samplers to the current list.
  123829. * @param samplers defines the current sampler list.
  123830. */
  123831. static AddSamplers(samplers: string[]): void;
  123832. /**
  123833. * Add the required uniforms to the current buffer.
  123834. * @param uniformBuffer defines the current uniform buffer.
  123835. */
  123836. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123837. /**
  123838. * Makes a duplicate of the current configuration into another one.
  123839. * @param clearCoatConfiguration define the config where to copy the info
  123840. */
  123841. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123842. /**
  123843. * Serializes this clear coat configuration.
  123844. * @returns - An object with the serialized config.
  123845. */
  123846. serialize(): any;
  123847. /**
  123848. * Parses a anisotropy Configuration from a serialized object.
  123849. * @param source - Serialized object.
  123850. * @param scene Defines the scene we are parsing for
  123851. * @param rootUrl Defines the rootUrl to load from
  123852. */
  123853. parse(source: any, scene: Scene, rootUrl: string): void;
  123854. }
  123855. }
  123856. declare module BABYLON {
  123857. /**
  123858. * @hidden
  123859. */
  123860. export interface IMaterialAnisotropicDefines {
  123861. ANISOTROPIC: boolean;
  123862. ANISOTROPIC_TEXTURE: boolean;
  123863. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123864. MAINUV1: boolean;
  123865. _areTexturesDirty: boolean;
  123866. _needUVs: boolean;
  123867. }
  123868. /**
  123869. * Define the code related to the anisotropic parameters of the pbr material.
  123870. */
  123871. export class PBRAnisotropicConfiguration {
  123872. private _isEnabled;
  123873. /**
  123874. * Defines if the anisotropy is enabled in the material.
  123875. */
  123876. isEnabled: boolean;
  123877. /**
  123878. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123879. */
  123880. intensity: number;
  123881. /**
  123882. * Defines if the effect is along the tangents, bitangents or in between.
  123883. * By default, the effect is "strectching" the highlights along the tangents.
  123884. */
  123885. direction: Vector2;
  123886. private _texture;
  123887. /**
  123888. * Stores the anisotropy values in a texture.
  123889. * rg is direction (like normal from -1 to 1)
  123890. * b is a intensity
  123891. */
  123892. texture: Nullable<BaseTexture>;
  123893. /** @hidden */
  123894. private _internalMarkAllSubMeshesAsTexturesDirty;
  123895. /** @hidden */
  123896. _markAllSubMeshesAsTexturesDirty(): void;
  123897. /**
  123898. * Instantiate a new istance of anisotropy configuration.
  123899. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123900. */
  123901. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123902. /**
  123903. * Specifies that the submesh is ready to be used.
  123904. * @param defines the list of "defines" to update.
  123905. * @param scene defines the scene the material belongs to.
  123906. * @returns - boolean indicating that the submesh is ready or not.
  123907. */
  123908. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123909. /**
  123910. * Checks to see if a texture is used in the material.
  123911. * @param defines the list of "defines" to update.
  123912. * @param mesh the mesh we are preparing the defines for.
  123913. * @param scene defines the scene the material belongs to.
  123914. */
  123915. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123916. /**
  123917. * Binds the material data.
  123918. * @param uniformBuffer defines the Uniform buffer to fill in.
  123919. * @param scene defines the scene the material belongs to.
  123920. * @param isFrozen defines wether the material is frozen or not.
  123921. */
  123922. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123923. /**
  123924. * Checks to see if a texture is used in the material.
  123925. * @param texture - Base texture to use.
  123926. * @returns - Boolean specifying if a texture is used in the material.
  123927. */
  123928. hasTexture(texture: BaseTexture): boolean;
  123929. /**
  123930. * Returns an array of the actively used textures.
  123931. * @param activeTextures Array of BaseTextures
  123932. */
  123933. getActiveTextures(activeTextures: BaseTexture[]): void;
  123934. /**
  123935. * Returns the animatable textures.
  123936. * @param animatables Array of animatable textures.
  123937. */
  123938. getAnimatables(animatables: IAnimatable[]): void;
  123939. /**
  123940. * Disposes the resources of the material.
  123941. * @param forceDisposeTextures - Forces the disposal of all textures.
  123942. */
  123943. dispose(forceDisposeTextures?: boolean): void;
  123944. /**
  123945. * Get the current class name of the texture useful for serialization or dynamic coding.
  123946. * @returns "PBRAnisotropicConfiguration"
  123947. */
  123948. getClassName(): string;
  123949. /**
  123950. * Add fallbacks to the effect fallbacks list.
  123951. * @param defines defines the Base texture to use.
  123952. * @param fallbacks defines the current fallback list.
  123953. * @param currentRank defines the current fallback rank.
  123954. * @returns the new fallback rank.
  123955. */
  123956. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123957. /**
  123958. * Add the required uniforms to the current list.
  123959. * @param uniforms defines the current uniform list.
  123960. */
  123961. static AddUniforms(uniforms: string[]): void;
  123962. /**
  123963. * Add the required uniforms to the current buffer.
  123964. * @param uniformBuffer defines the current uniform buffer.
  123965. */
  123966. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123967. /**
  123968. * Add the required samplers to the current list.
  123969. * @param samplers defines the current sampler list.
  123970. */
  123971. static AddSamplers(samplers: string[]): void;
  123972. /**
  123973. * Makes a duplicate of the current configuration into another one.
  123974. * @param anisotropicConfiguration define the config where to copy the info
  123975. */
  123976. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123977. /**
  123978. * Serializes this anisotropy configuration.
  123979. * @returns - An object with the serialized config.
  123980. */
  123981. serialize(): any;
  123982. /**
  123983. * Parses a anisotropy Configuration from a serialized object.
  123984. * @param source - Serialized object.
  123985. * @param scene Defines the scene we are parsing for
  123986. * @param rootUrl Defines the rootUrl to load from
  123987. */
  123988. parse(source: any, scene: Scene, rootUrl: string): void;
  123989. }
  123990. }
  123991. declare module BABYLON {
  123992. /**
  123993. * @hidden
  123994. */
  123995. export interface IMaterialBRDFDefines {
  123996. BRDF_V_HEIGHT_CORRELATED: boolean;
  123997. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123998. SPHERICAL_HARMONICS: boolean;
  123999. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124000. /** @hidden */
  124001. _areMiscDirty: boolean;
  124002. }
  124003. /**
  124004. * Define the code related to the BRDF parameters of the pbr material.
  124005. */
  124006. export class PBRBRDFConfiguration {
  124007. /**
  124008. * Default value used for the energy conservation.
  124009. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124010. */
  124011. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124012. /**
  124013. * Default value used for the Smith Visibility Height Correlated mode.
  124014. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124015. */
  124016. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124017. /**
  124018. * Default value used for the IBL diffuse part.
  124019. * This can help switching back to the polynomials mode globally which is a tiny bit
  124020. * less GPU intensive at the drawback of a lower quality.
  124021. */
  124022. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124023. /**
  124024. * Default value used for activating energy conservation for the specular workflow.
  124025. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124026. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124027. */
  124028. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124029. private _useEnergyConservation;
  124030. /**
  124031. * Defines if the material uses energy conservation.
  124032. */
  124033. useEnergyConservation: boolean;
  124034. private _useSmithVisibilityHeightCorrelated;
  124035. /**
  124036. * LEGACY Mode set to false
  124037. * Defines if the material uses height smith correlated visibility term.
  124038. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124039. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124040. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124041. * Not relying on height correlated will also disable energy conservation.
  124042. */
  124043. useSmithVisibilityHeightCorrelated: boolean;
  124044. private _useSphericalHarmonics;
  124045. /**
  124046. * LEGACY Mode set to false
  124047. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124048. * diffuse part of the IBL.
  124049. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124050. * to the ground truth.
  124051. */
  124052. useSphericalHarmonics: boolean;
  124053. private _useSpecularGlossinessInputEnergyConservation;
  124054. /**
  124055. * Defines if the material uses energy conservation, when the specular workflow is active.
  124056. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124057. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124058. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124059. */
  124060. useSpecularGlossinessInputEnergyConservation: boolean;
  124061. /** @hidden */
  124062. private _internalMarkAllSubMeshesAsMiscDirty;
  124063. /** @hidden */
  124064. _markAllSubMeshesAsMiscDirty(): void;
  124065. /**
  124066. * Instantiate a new istance of clear coat configuration.
  124067. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  124068. */
  124069. constructor(markAllSubMeshesAsMiscDirty: () => void);
  124070. /**
  124071. * Checks to see if a texture is used in the material.
  124072. * @param defines the list of "defines" to update.
  124073. */
  124074. prepareDefines(defines: IMaterialBRDFDefines): void;
  124075. /**
  124076. * Get the current class name of the texture useful for serialization or dynamic coding.
  124077. * @returns "PBRClearCoatConfiguration"
  124078. */
  124079. getClassName(): string;
  124080. /**
  124081. * Makes a duplicate of the current configuration into another one.
  124082. * @param brdfConfiguration define the config where to copy the info
  124083. */
  124084. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  124085. /**
  124086. * Serializes this BRDF configuration.
  124087. * @returns - An object with the serialized config.
  124088. */
  124089. serialize(): any;
  124090. /**
  124091. * Parses a anisotropy Configuration from a serialized object.
  124092. * @param source - Serialized object.
  124093. * @param scene Defines the scene we are parsing for
  124094. * @param rootUrl Defines the rootUrl to load from
  124095. */
  124096. parse(source: any, scene: Scene, rootUrl: string): void;
  124097. }
  124098. }
  124099. declare module BABYLON {
  124100. /**
  124101. * @hidden
  124102. */
  124103. export interface IMaterialSheenDefines {
  124104. SHEEN: boolean;
  124105. SHEEN_TEXTURE: boolean;
  124106. SHEEN_TEXTUREDIRECTUV: number;
  124107. SHEEN_LINKWITHALBEDO: boolean;
  124108. SHEEN_ROUGHNESS: boolean;
  124109. SHEEN_ALBEDOSCALING: boolean;
  124110. /** @hidden */
  124111. _areTexturesDirty: boolean;
  124112. }
  124113. /**
  124114. * Define the code related to the Sheen parameters of the pbr material.
  124115. */
  124116. export class PBRSheenConfiguration {
  124117. private _isEnabled;
  124118. /**
  124119. * Defines if the material uses sheen.
  124120. */
  124121. isEnabled: boolean;
  124122. private _linkSheenWithAlbedo;
  124123. /**
  124124. * Defines if the sheen is linked to the sheen color.
  124125. */
  124126. linkSheenWithAlbedo: boolean;
  124127. /**
  124128. * Defines the sheen intensity.
  124129. */
  124130. intensity: number;
  124131. /**
  124132. * Defines the sheen color.
  124133. */
  124134. color: Color3;
  124135. private _texture;
  124136. /**
  124137. * Stores the sheen tint values in a texture.
  124138. * rgb is tint
  124139. * a is a intensity
  124140. */
  124141. texture: Nullable<BaseTexture>;
  124142. private _roughness;
  124143. /**
  124144. * Defines the sheen roughness.
  124145. * It is not taken into account if linkSheenWithAlbedo is true.
  124146. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  124147. */
  124148. roughness: Nullable<number>;
  124149. private _albedoScaling;
  124150. /**
  124151. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  124152. * It allows the strength of the sheen effect to not depend on the base color of the material,
  124153. * making it easier to setup and tweak the effect
  124154. */
  124155. albedoScaling: boolean;
  124156. /** @hidden */
  124157. private _internalMarkAllSubMeshesAsTexturesDirty;
  124158. /** @hidden */
  124159. _markAllSubMeshesAsTexturesDirty(): void;
  124160. /**
  124161. * Instantiate a new istance of clear coat configuration.
  124162. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124163. */
  124164. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124165. /**
  124166. * Specifies that the submesh is ready to be used.
  124167. * @param defines the list of "defines" to update.
  124168. * @param scene defines the scene the material belongs to.
  124169. * @returns - boolean indicating that the submesh is ready or not.
  124170. */
  124171. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  124172. /**
  124173. * Checks to see if a texture is used in the material.
  124174. * @param defines the list of "defines" to update.
  124175. * @param scene defines the scene the material belongs to.
  124176. */
  124177. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  124178. /**
  124179. * Binds the material data.
  124180. * @param uniformBuffer defines the Uniform buffer to fill in.
  124181. * @param scene defines the scene the material belongs to.
  124182. * @param isFrozen defines wether the material is frozen or not.
  124183. */
  124184. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124185. /**
  124186. * Checks to see if a texture is used in the material.
  124187. * @param texture - Base texture to use.
  124188. * @returns - Boolean specifying if a texture is used in the material.
  124189. */
  124190. hasTexture(texture: BaseTexture): boolean;
  124191. /**
  124192. * Returns an array of the actively used textures.
  124193. * @param activeTextures Array of BaseTextures
  124194. */
  124195. getActiveTextures(activeTextures: BaseTexture[]): void;
  124196. /**
  124197. * Returns the animatable textures.
  124198. * @param animatables Array of animatable textures.
  124199. */
  124200. getAnimatables(animatables: IAnimatable[]): void;
  124201. /**
  124202. * Disposes the resources of the material.
  124203. * @param forceDisposeTextures - Forces the disposal of all textures.
  124204. */
  124205. dispose(forceDisposeTextures?: boolean): void;
  124206. /**
  124207. * Get the current class name of the texture useful for serialization or dynamic coding.
  124208. * @returns "PBRSheenConfiguration"
  124209. */
  124210. getClassName(): string;
  124211. /**
  124212. * Add fallbacks to the effect fallbacks list.
  124213. * @param defines defines the Base texture to use.
  124214. * @param fallbacks defines the current fallback list.
  124215. * @param currentRank defines the current fallback rank.
  124216. * @returns the new fallback rank.
  124217. */
  124218. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124219. /**
  124220. * Add the required uniforms to the current list.
  124221. * @param uniforms defines the current uniform list.
  124222. */
  124223. static AddUniforms(uniforms: string[]): void;
  124224. /**
  124225. * Add the required uniforms to the current buffer.
  124226. * @param uniformBuffer defines the current uniform buffer.
  124227. */
  124228. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124229. /**
  124230. * Add the required samplers to the current list.
  124231. * @param samplers defines the current sampler list.
  124232. */
  124233. static AddSamplers(samplers: string[]): void;
  124234. /**
  124235. * Makes a duplicate of the current configuration into another one.
  124236. * @param sheenConfiguration define the config where to copy the info
  124237. */
  124238. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  124239. /**
  124240. * Serializes this BRDF configuration.
  124241. * @returns - An object with the serialized config.
  124242. */
  124243. serialize(): any;
  124244. /**
  124245. * Parses a anisotropy Configuration from a serialized object.
  124246. * @param source - Serialized object.
  124247. * @param scene Defines the scene we are parsing for
  124248. * @param rootUrl Defines the rootUrl to load from
  124249. */
  124250. parse(source: any, scene: Scene, rootUrl: string): void;
  124251. }
  124252. }
  124253. declare module BABYLON {
  124254. /**
  124255. * @hidden
  124256. */
  124257. export interface IMaterialSubSurfaceDefines {
  124258. SUBSURFACE: boolean;
  124259. SS_REFRACTION: boolean;
  124260. SS_TRANSLUCENCY: boolean;
  124261. SS_SCATERRING: boolean;
  124262. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124263. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124264. SS_REFRACTIONMAP_3D: boolean;
  124265. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124266. SS_LODINREFRACTIONALPHA: boolean;
  124267. SS_GAMMAREFRACTION: boolean;
  124268. SS_RGBDREFRACTION: boolean;
  124269. SS_LINEARSPECULARREFRACTION: boolean;
  124270. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124271. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124272. /** @hidden */
  124273. _areTexturesDirty: boolean;
  124274. }
  124275. /**
  124276. * Define the code related to the sub surface parameters of the pbr material.
  124277. */
  124278. export class PBRSubSurfaceConfiguration {
  124279. private _isRefractionEnabled;
  124280. /**
  124281. * Defines if the refraction is enabled in the material.
  124282. */
  124283. isRefractionEnabled: boolean;
  124284. private _isTranslucencyEnabled;
  124285. /**
  124286. * Defines if the translucency is enabled in the material.
  124287. */
  124288. isTranslucencyEnabled: boolean;
  124289. private _isScatteringEnabled;
  124290. /**
  124291. * Defines the refraction intensity of the material.
  124292. * The refraction when enabled replaces the Diffuse part of the material.
  124293. * The intensity helps transitionning between diffuse and refraction.
  124294. */
  124295. refractionIntensity: number;
  124296. /**
  124297. * Defines the translucency intensity of the material.
  124298. * When translucency has been enabled, this defines how much of the "translucency"
  124299. * is addded to the diffuse part of the material.
  124300. */
  124301. translucencyIntensity: number;
  124302. /**
  124303. * Defines the scattering intensity of the material.
  124304. * When scattering has been enabled, this defines how much of the "scattered light"
  124305. * is addded to the diffuse part of the material.
  124306. */
  124307. scatteringIntensity: number;
  124308. private _thicknessTexture;
  124309. /**
  124310. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  124311. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  124312. * 0 would mean minimumThickness
  124313. * 1 would mean maximumThickness
  124314. * The other channels might be use as a mask to vary the different effects intensity.
  124315. */
  124316. thicknessTexture: Nullable<BaseTexture>;
  124317. private _refractionTexture;
  124318. /**
  124319. * Defines the texture to use for refraction.
  124320. */
  124321. refractionTexture: Nullable<BaseTexture>;
  124322. private _indexOfRefraction;
  124323. /**
  124324. * Defines the index of refraction used in the material.
  124325. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  124326. */
  124327. indexOfRefraction: number;
  124328. private _invertRefractionY;
  124329. /**
  124330. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124331. */
  124332. invertRefractionY: boolean;
  124333. private _linkRefractionWithTransparency;
  124334. /**
  124335. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124336. * Materials half opaque for instance using refraction could benefit from this control.
  124337. */
  124338. linkRefractionWithTransparency: boolean;
  124339. /**
  124340. * Defines the minimum thickness stored in the thickness map.
  124341. * If no thickness map is defined, this value will be used to simulate thickness.
  124342. */
  124343. minimumThickness: number;
  124344. /**
  124345. * Defines the maximum thickness stored in the thickness map.
  124346. */
  124347. maximumThickness: number;
  124348. /**
  124349. * Defines the volume tint of the material.
  124350. * This is used for both translucency and scattering.
  124351. */
  124352. tintColor: Color3;
  124353. /**
  124354. * Defines the distance at which the tint color should be found in the media.
  124355. * This is used for refraction only.
  124356. */
  124357. tintColorAtDistance: number;
  124358. /**
  124359. * Defines how far each channel transmit through the media.
  124360. * It is defined as a color to simplify it selection.
  124361. */
  124362. diffusionDistance: Color3;
  124363. private _useMaskFromThicknessTexture;
  124364. /**
  124365. * Stores the intensity of the different subsurface effects in the thickness texture.
  124366. * * the green channel is the translucency intensity.
  124367. * * the blue channel is the scattering intensity.
  124368. * * the alpha channel is the refraction intensity.
  124369. */
  124370. useMaskFromThicknessTexture: boolean;
  124371. /** @hidden */
  124372. private _internalMarkAllSubMeshesAsTexturesDirty;
  124373. /** @hidden */
  124374. _markAllSubMeshesAsTexturesDirty(): void;
  124375. /**
  124376. * Instantiate a new istance of sub surface configuration.
  124377. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124378. */
  124379. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124380. /**
  124381. * Gets wehter the submesh is ready to be used or not.
  124382. * @param defines the list of "defines" to update.
  124383. * @param scene defines the scene the material belongs to.
  124384. * @returns - boolean indicating that the submesh is ready or not.
  124385. */
  124386. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  124387. /**
  124388. * Checks to see if a texture is used in the material.
  124389. * @param defines the list of "defines" to update.
  124390. * @param scene defines the scene to the material belongs to.
  124391. */
  124392. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  124393. /**
  124394. * Binds the material data.
  124395. * @param uniformBuffer defines the Uniform buffer to fill in.
  124396. * @param scene defines the scene the material belongs to.
  124397. * @param engine defines the engine the material belongs to.
  124398. * @param isFrozen defines wether the material is frozen or not.
  124399. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  124400. */
  124401. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  124402. /**
  124403. * Unbinds the material from the mesh.
  124404. * @param activeEffect defines the effect that should be unbound from.
  124405. * @returns true if unbound, otherwise false
  124406. */
  124407. unbind(activeEffect: Effect): boolean;
  124408. /**
  124409. * Returns the texture used for refraction or null if none is used.
  124410. * @param scene defines the scene the material belongs to.
  124411. * @returns - Refraction texture if present. If no refraction texture and refraction
  124412. * is linked with transparency, returns environment texture. Otherwise, returns null.
  124413. */
  124414. private _getRefractionTexture;
  124415. /**
  124416. * Returns true if alpha blending should be disabled.
  124417. */
  124418. get disableAlphaBlending(): boolean;
  124419. /**
  124420. * Fills the list of render target textures.
  124421. * @param renderTargets the list of render targets to update
  124422. */
  124423. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  124424. /**
  124425. * Checks to see if a texture is used in the material.
  124426. * @param texture - Base texture to use.
  124427. * @returns - Boolean specifying if a texture is used in the material.
  124428. */
  124429. hasTexture(texture: BaseTexture): boolean;
  124430. /**
  124431. * Gets a boolean indicating that current material needs to register RTT
  124432. * @returns true if this uses a render target otherwise false.
  124433. */
  124434. hasRenderTargetTextures(): boolean;
  124435. /**
  124436. * Returns an array of the actively used textures.
  124437. * @param activeTextures Array of BaseTextures
  124438. */
  124439. getActiveTextures(activeTextures: BaseTexture[]): void;
  124440. /**
  124441. * Returns the animatable textures.
  124442. * @param animatables Array of animatable textures.
  124443. */
  124444. getAnimatables(animatables: IAnimatable[]): void;
  124445. /**
  124446. * Disposes the resources of the material.
  124447. * @param forceDisposeTextures - Forces the disposal of all textures.
  124448. */
  124449. dispose(forceDisposeTextures?: boolean): void;
  124450. /**
  124451. * Get the current class name of the texture useful for serialization or dynamic coding.
  124452. * @returns "PBRSubSurfaceConfiguration"
  124453. */
  124454. getClassName(): string;
  124455. /**
  124456. * Add fallbacks to the effect fallbacks list.
  124457. * @param defines defines the Base texture to use.
  124458. * @param fallbacks defines the current fallback list.
  124459. * @param currentRank defines the current fallback rank.
  124460. * @returns the new fallback rank.
  124461. */
  124462. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124463. /**
  124464. * Add the required uniforms to the current list.
  124465. * @param uniforms defines the current uniform list.
  124466. */
  124467. static AddUniforms(uniforms: string[]): void;
  124468. /**
  124469. * Add the required samplers to the current list.
  124470. * @param samplers defines the current sampler list.
  124471. */
  124472. static AddSamplers(samplers: string[]): void;
  124473. /**
  124474. * Add the required uniforms to the current buffer.
  124475. * @param uniformBuffer defines the current uniform buffer.
  124476. */
  124477. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124478. /**
  124479. * Makes a duplicate of the current configuration into another one.
  124480. * @param configuration define the config where to copy the info
  124481. */
  124482. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124483. /**
  124484. * Serializes this Sub Surface configuration.
  124485. * @returns - An object with the serialized config.
  124486. */
  124487. serialize(): any;
  124488. /**
  124489. * Parses a anisotropy Configuration from a serialized object.
  124490. * @param source - Serialized object.
  124491. * @param scene Defines the scene we are parsing for
  124492. * @param rootUrl Defines the rootUrl to load from
  124493. */
  124494. parse(source: any, scene: Scene, rootUrl: string): void;
  124495. }
  124496. }
  124497. declare module BABYLON {
  124498. /** @hidden */
  124499. export var pbrFragmentDeclaration: {
  124500. name: string;
  124501. shader: string;
  124502. };
  124503. }
  124504. declare module BABYLON {
  124505. /** @hidden */
  124506. export var pbrUboDeclaration: {
  124507. name: string;
  124508. shader: string;
  124509. };
  124510. }
  124511. declare module BABYLON {
  124512. /** @hidden */
  124513. export var pbrFragmentExtraDeclaration: {
  124514. name: string;
  124515. shader: string;
  124516. };
  124517. }
  124518. declare module BABYLON {
  124519. /** @hidden */
  124520. export var pbrFragmentSamplersDeclaration: {
  124521. name: string;
  124522. shader: string;
  124523. };
  124524. }
  124525. declare module BABYLON {
  124526. /** @hidden */
  124527. export var pbrHelperFunctions: {
  124528. name: string;
  124529. shader: string;
  124530. };
  124531. }
  124532. declare module BABYLON {
  124533. /** @hidden */
  124534. export var harmonicsFunctions: {
  124535. name: string;
  124536. shader: string;
  124537. };
  124538. }
  124539. declare module BABYLON {
  124540. /** @hidden */
  124541. export var pbrDirectLightingSetupFunctions: {
  124542. name: string;
  124543. shader: string;
  124544. };
  124545. }
  124546. declare module BABYLON {
  124547. /** @hidden */
  124548. export var pbrDirectLightingFalloffFunctions: {
  124549. name: string;
  124550. shader: string;
  124551. };
  124552. }
  124553. declare module BABYLON {
  124554. /** @hidden */
  124555. export var pbrBRDFFunctions: {
  124556. name: string;
  124557. shader: string;
  124558. };
  124559. }
  124560. declare module BABYLON {
  124561. /** @hidden */
  124562. export var pbrDirectLightingFunctions: {
  124563. name: string;
  124564. shader: string;
  124565. };
  124566. }
  124567. declare module BABYLON {
  124568. /** @hidden */
  124569. export var pbrIBLFunctions: {
  124570. name: string;
  124571. shader: string;
  124572. };
  124573. }
  124574. declare module BABYLON {
  124575. /** @hidden */
  124576. export var pbrDebug: {
  124577. name: string;
  124578. shader: string;
  124579. };
  124580. }
  124581. declare module BABYLON {
  124582. /** @hidden */
  124583. export var pbrPixelShader: {
  124584. name: string;
  124585. shader: string;
  124586. };
  124587. }
  124588. declare module BABYLON {
  124589. /** @hidden */
  124590. export var pbrVertexDeclaration: {
  124591. name: string;
  124592. shader: string;
  124593. };
  124594. }
  124595. declare module BABYLON {
  124596. /** @hidden */
  124597. export var pbrVertexShader: {
  124598. name: string;
  124599. shader: string;
  124600. };
  124601. }
  124602. declare module BABYLON {
  124603. /**
  124604. * Manages the defines for the PBR Material.
  124605. * @hidden
  124606. */
  124607. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124608. PBR: boolean;
  124609. MAINUV1: boolean;
  124610. MAINUV2: boolean;
  124611. UV1: boolean;
  124612. UV2: boolean;
  124613. ALBEDO: boolean;
  124614. GAMMAALBEDO: boolean;
  124615. ALBEDODIRECTUV: number;
  124616. VERTEXCOLOR: boolean;
  124617. AMBIENT: boolean;
  124618. AMBIENTDIRECTUV: number;
  124619. AMBIENTINGRAYSCALE: boolean;
  124620. OPACITY: boolean;
  124621. VERTEXALPHA: boolean;
  124622. OPACITYDIRECTUV: number;
  124623. OPACITYRGB: boolean;
  124624. ALPHATEST: boolean;
  124625. DEPTHPREPASS: boolean;
  124626. ALPHABLEND: boolean;
  124627. ALPHAFROMALBEDO: boolean;
  124628. ALPHATESTVALUE: string;
  124629. SPECULAROVERALPHA: boolean;
  124630. RADIANCEOVERALPHA: boolean;
  124631. ALPHAFRESNEL: boolean;
  124632. LINEARALPHAFRESNEL: boolean;
  124633. PREMULTIPLYALPHA: boolean;
  124634. EMISSIVE: boolean;
  124635. EMISSIVEDIRECTUV: number;
  124636. REFLECTIVITY: boolean;
  124637. REFLECTIVITYDIRECTUV: number;
  124638. SPECULARTERM: boolean;
  124639. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124640. MICROSURFACEAUTOMATIC: boolean;
  124641. LODBASEDMICROSFURACE: boolean;
  124642. MICROSURFACEMAP: boolean;
  124643. MICROSURFACEMAPDIRECTUV: number;
  124644. METALLICWORKFLOW: boolean;
  124645. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124646. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124647. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124648. AOSTOREINMETALMAPRED: boolean;
  124649. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124650. ENVIRONMENTBRDF: boolean;
  124651. ENVIRONMENTBRDF_RGBD: boolean;
  124652. NORMAL: boolean;
  124653. TANGENT: boolean;
  124654. BUMP: boolean;
  124655. BUMPDIRECTUV: number;
  124656. OBJECTSPACE_NORMALMAP: boolean;
  124657. PARALLAX: boolean;
  124658. PARALLAXOCCLUSION: boolean;
  124659. NORMALXYSCALE: boolean;
  124660. LIGHTMAP: boolean;
  124661. LIGHTMAPDIRECTUV: number;
  124662. USELIGHTMAPASSHADOWMAP: boolean;
  124663. GAMMALIGHTMAP: boolean;
  124664. RGBDLIGHTMAP: boolean;
  124665. REFLECTION: boolean;
  124666. REFLECTIONMAP_3D: boolean;
  124667. REFLECTIONMAP_SPHERICAL: boolean;
  124668. REFLECTIONMAP_PLANAR: boolean;
  124669. REFLECTIONMAP_CUBIC: boolean;
  124670. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124671. REFLECTIONMAP_PROJECTION: boolean;
  124672. REFLECTIONMAP_SKYBOX: boolean;
  124673. REFLECTIONMAP_EXPLICIT: boolean;
  124674. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124675. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124676. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124677. INVERTCUBICMAP: boolean;
  124678. USESPHERICALFROMREFLECTIONMAP: boolean;
  124679. USEIRRADIANCEMAP: boolean;
  124680. SPHERICAL_HARMONICS: boolean;
  124681. USESPHERICALINVERTEX: boolean;
  124682. REFLECTIONMAP_OPPOSITEZ: boolean;
  124683. LODINREFLECTIONALPHA: boolean;
  124684. GAMMAREFLECTION: boolean;
  124685. RGBDREFLECTION: boolean;
  124686. LINEARSPECULARREFLECTION: boolean;
  124687. RADIANCEOCCLUSION: boolean;
  124688. HORIZONOCCLUSION: boolean;
  124689. INSTANCES: boolean;
  124690. NUM_BONE_INFLUENCERS: number;
  124691. BonesPerMesh: number;
  124692. BONETEXTURE: boolean;
  124693. NONUNIFORMSCALING: boolean;
  124694. MORPHTARGETS: boolean;
  124695. MORPHTARGETS_NORMAL: boolean;
  124696. MORPHTARGETS_TANGENT: boolean;
  124697. MORPHTARGETS_UV: boolean;
  124698. NUM_MORPH_INFLUENCERS: number;
  124699. IMAGEPROCESSING: boolean;
  124700. VIGNETTE: boolean;
  124701. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124702. VIGNETTEBLENDMODEOPAQUE: boolean;
  124703. TONEMAPPING: boolean;
  124704. TONEMAPPING_ACES: boolean;
  124705. CONTRAST: boolean;
  124706. COLORCURVES: boolean;
  124707. COLORGRADING: boolean;
  124708. COLORGRADING3D: boolean;
  124709. SAMPLER3DGREENDEPTH: boolean;
  124710. SAMPLER3DBGRMAP: boolean;
  124711. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124712. EXPOSURE: boolean;
  124713. MULTIVIEW: boolean;
  124714. USEPHYSICALLIGHTFALLOFF: boolean;
  124715. USEGLTFLIGHTFALLOFF: boolean;
  124716. TWOSIDEDLIGHTING: boolean;
  124717. SHADOWFLOAT: boolean;
  124718. CLIPPLANE: boolean;
  124719. CLIPPLANE2: boolean;
  124720. CLIPPLANE3: boolean;
  124721. CLIPPLANE4: boolean;
  124722. CLIPPLANE5: boolean;
  124723. CLIPPLANE6: boolean;
  124724. POINTSIZE: boolean;
  124725. FOG: boolean;
  124726. LOGARITHMICDEPTH: boolean;
  124727. FORCENORMALFORWARD: boolean;
  124728. SPECULARAA: boolean;
  124729. CLEARCOAT: boolean;
  124730. CLEARCOAT_DEFAULTIOR: boolean;
  124731. CLEARCOAT_TEXTURE: boolean;
  124732. CLEARCOAT_TEXTUREDIRECTUV: number;
  124733. CLEARCOAT_BUMP: boolean;
  124734. CLEARCOAT_BUMPDIRECTUV: number;
  124735. CLEARCOAT_TINT: boolean;
  124736. CLEARCOAT_TINT_TEXTURE: boolean;
  124737. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124738. ANISOTROPIC: boolean;
  124739. ANISOTROPIC_TEXTURE: boolean;
  124740. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124741. BRDF_V_HEIGHT_CORRELATED: boolean;
  124742. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124743. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124744. SHEEN: boolean;
  124745. SHEEN_TEXTURE: boolean;
  124746. SHEEN_TEXTUREDIRECTUV: number;
  124747. SHEEN_LINKWITHALBEDO: boolean;
  124748. SHEEN_ROUGHNESS: boolean;
  124749. SHEEN_ALBEDOSCALING: boolean;
  124750. SUBSURFACE: boolean;
  124751. SS_REFRACTION: boolean;
  124752. SS_TRANSLUCENCY: boolean;
  124753. SS_SCATERRING: boolean;
  124754. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124755. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124756. SS_REFRACTIONMAP_3D: boolean;
  124757. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124758. SS_LODINREFRACTIONALPHA: boolean;
  124759. SS_GAMMAREFRACTION: boolean;
  124760. SS_RGBDREFRACTION: boolean;
  124761. SS_LINEARSPECULARREFRACTION: boolean;
  124762. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124763. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124764. UNLIT: boolean;
  124765. DEBUGMODE: number;
  124766. /**
  124767. * Initializes the PBR Material defines.
  124768. */
  124769. constructor();
  124770. /**
  124771. * Resets the PBR Material defines.
  124772. */
  124773. reset(): void;
  124774. }
  124775. /**
  124776. * The Physically based material base class of BJS.
  124777. *
  124778. * This offers the main features of a standard PBR material.
  124779. * For more information, please refer to the documentation :
  124780. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124781. */
  124782. export abstract class PBRBaseMaterial extends PushMaterial {
  124783. /**
  124784. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124785. */
  124786. static readonly PBRMATERIAL_OPAQUE: number;
  124787. /**
  124788. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124789. */
  124790. static readonly PBRMATERIAL_ALPHATEST: number;
  124791. /**
  124792. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124793. */
  124794. static readonly PBRMATERIAL_ALPHABLEND: number;
  124795. /**
  124796. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124797. * They are also discarded below the alpha cutoff threshold to improve performances.
  124798. */
  124799. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124800. /**
  124801. * Defines the default value of how much AO map is occluding the analytical lights
  124802. * (point spot...).
  124803. */
  124804. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124805. /**
  124806. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124807. */
  124808. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124809. /**
  124810. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124811. * to enhance interoperability with other engines.
  124812. */
  124813. static readonly LIGHTFALLOFF_GLTF: number;
  124814. /**
  124815. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124816. * to enhance interoperability with other materials.
  124817. */
  124818. static readonly LIGHTFALLOFF_STANDARD: number;
  124819. /**
  124820. * Intensity of the direct lights e.g. the four lights available in your scene.
  124821. * This impacts both the direct diffuse and specular highlights.
  124822. */
  124823. protected _directIntensity: number;
  124824. /**
  124825. * Intensity of the emissive part of the material.
  124826. * This helps controlling the emissive effect without modifying the emissive color.
  124827. */
  124828. protected _emissiveIntensity: number;
  124829. /**
  124830. * Intensity of the environment e.g. how much the environment will light the object
  124831. * either through harmonics for rough material or through the refelction for shiny ones.
  124832. */
  124833. protected _environmentIntensity: number;
  124834. /**
  124835. * This is a special control allowing the reduction of the specular highlights coming from the
  124836. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124837. */
  124838. protected _specularIntensity: number;
  124839. /**
  124840. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124841. */
  124842. private _lightingInfos;
  124843. /**
  124844. * Debug Control allowing disabling the bump map on this material.
  124845. */
  124846. protected _disableBumpMap: boolean;
  124847. /**
  124848. * AKA Diffuse Texture in standard nomenclature.
  124849. */
  124850. protected _albedoTexture: Nullable<BaseTexture>;
  124851. /**
  124852. * AKA Occlusion Texture in other nomenclature.
  124853. */
  124854. protected _ambientTexture: Nullable<BaseTexture>;
  124855. /**
  124856. * AKA Occlusion Texture Intensity in other nomenclature.
  124857. */
  124858. protected _ambientTextureStrength: number;
  124859. /**
  124860. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124861. * 1 means it completely occludes it
  124862. * 0 mean it has no impact
  124863. */
  124864. protected _ambientTextureImpactOnAnalyticalLights: number;
  124865. /**
  124866. * Stores the alpha values in a texture.
  124867. */
  124868. protected _opacityTexture: Nullable<BaseTexture>;
  124869. /**
  124870. * Stores the reflection values in a texture.
  124871. */
  124872. protected _reflectionTexture: Nullable<BaseTexture>;
  124873. /**
  124874. * Stores the emissive values in a texture.
  124875. */
  124876. protected _emissiveTexture: Nullable<BaseTexture>;
  124877. /**
  124878. * AKA Specular texture in other nomenclature.
  124879. */
  124880. protected _reflectivityTexture: Nullable<BaseTexture>;
  124881. /**
  124882. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124883. */
  124884. protected _metallicTexture: Nullable<BaseTexture>;
  124885. /**
  124886. * Specifies the metallic scalar of the metallic/roughness workflow.
  124887. * Can also be used to scale the metalness values of the metallic texture.
  124888. */
  124889. protected _metallic: Nullable<number>;
  124890. /**
  124891. * Specifies the roughness scalar of the metallic/roughness workflow.
  124892. * Can also be used to scale the roughness values of the metallic texture.
  124893. */
  124894. protected _roughness: Nullable<number>;
  124895. /**
  124896. * Specifies the an F0 factor to help configuring the material F0.
  124897. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124898. * to 0.5 the previously hard coded value stays the same.
  124899. * Can also be used to scale the F0 values of the metallic texture.
  124900. */
  124901. protected _metallicF0Factor: number;
  124902. /**
  124903. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124904. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124905. * your expectation as it multiplies with the texture data.
  124906. */
  124907. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124908. /**
  124909. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124910. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124911. */
  124912. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124913. /**
  124914. * Stores surface normal data used to displace a mesh in a texture.
  124915. */
  124916. protected _bumpTexture: Nullable<BaseTexture>;
  124917. /**
  124918. * Stores the pre-calculated light information of a mesh in a texture.
  124919. */
  124920. protected _lightmapTexture: Nullable<BaseTexture>;
  124921. /**
  124922. * The color of a material in ambient lighting.
  124923. */
  124924. protected _ambientColor: Color3;
  124925. /**
  124926. * AKA Diffuse Color in other nomenclature.
  124927. */
  124928. protected _albedoColor: Color3;
  124929. /**
  124930. * AKA Specular Color in other nomenclature.
  124931. */
  124932. protected _reflectivityColor: Color3;
  124933. /**
  124934. * The color applied when light is reflected from a material.
  124935. */
  124936. protected _reflectionColor: Color3;
  124937. /**
  124938. * The color applied when light is emitted from a material.
  124939. */
  124940. protected _emissiveColor: Color3;
  124941. /**
  124942. * AKA Glossiness in other nomenclature.
  124943. */
  124944. protected _microSurface: number;
  124945. /**
  124946. * Specifies that the material will use the light map as a show map.
  124947. */
  124948. protected _useLightmapAsShadowmap: boolean;
  124949. /**
  124950. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124951. * makes the reflect vector face the model (under horizon).
  124952. */
  124953. protected _useHorizonOcclusion: boolean;
  124954. /**
  124955. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124956. * too much the area relying on ambient texture to define their ambient occlusion.
  124957. */
  124958. protected _useRadianceOcclusion: boolean;
  124959. /**
  124960. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124961. */
  124962. protected _useAlphaFromAlbedoTexture: boolean;
  124963. /**
  124964. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124965. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124966. */
  124967. protected _useSpecularOverAlpha: boolean;
  124968. /**
  124969. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124970. */
  124971. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124972. /**
  124973. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124974. */
  124975. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124976. /**
  124977. * Specifies if the metallic texture contains the roughness information in its green channel.
  124978. */
  124979. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124980. /**
  124981. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124982. */
  124983. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124984. /**
  124985. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124986. */
  124987. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124988. /**
  124989. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124990. */
  124991. protected _useAmbientInGrayScale: boolean;
  124992. /**
  124993. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124994. * The material will try to infer what glossiness each pixel should be.
  124995. */
  124996. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124997. /**
  124998. * Defines the falloff type used in this material.
  124999. * It by default is Physical.
  125000. */
  125001. protected _lightFalloff: number;
  125002. /**
  125003. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125004. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125005. */
  125006. protected _useRadianceOverAlpha: boolean;
  125007. /**
  125008. * Allows using an object space normal map (instead of tangent space).
  125009. */
  125010. protected _useObjectSpaceNormalMap: boolean;
  125011. /**
  125012. * Allows using the bump map in parallax mode.
  125013. */
  125014. protected _useParallax: boolean;
  125015. /**
  125016. * Allows using the bump map in parallax occlusion mode.
  125017. */
  125018. protected _useParallaxOcclusion: boolean;
  125019. /**
  125020. * Controls the scale bias of the parallax mode.
  125021. */
  125022. protected _parallaxScaleBias: number;
  125023. /**
  125024. * If sets to true, disables all the lights affecting the material.
  125025. */
  125026. protected _disableLighting: boolean;
  125027. /**
  125028. * Number of Simultaneous lights allowed on the material.
  125029. */
  125030. protected _maxSimultaneousLights: number;
  125031. /**
  125032. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  125033. */
  125034. protected _invertNormalMapX: boolean;
  125035. /**
  125036. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  125037. */
  125038. protected _invertNormalMapY: boolean;
  125039. /**
  125040. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125041. */
  125042. protected _twoSidedLighting: boolean;
  125043. /**
  125044. * Defines the alpha limits in alpha test mode.
  125045. */
  125046. protected _alphaCutOff: number;
  125047. /**
  125048. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125049. */
  125050. protected _forceAlphaTest: boolean;
  125051. /**
  125052. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125053. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125054. */
  125055. protected _useAlphaFresnel: boolean;
  125056. /**
  125057. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125058. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125059. */
  125060. protected _useLinearAlphaFresnel: boolean;
  125061. /**
  125062. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  125063. * from cos thetav and roughness:
  125064. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  125065. */
  125066. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  125067. /**
  125068. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125069. */
  125070. protected _forceIrradianceInFragment: boolean;
  125071. /**
  125072. * Force normal to face away from face.
  125073. */
  125074. protected _forceNormalForward: boolean;
  125075. /**
  125076. * Enables specular anti aliasing in the PBR shader.
  125077. * It will both interacts on the Geometry for analytical and IBL lighting.
  125078. * It also prefilter the roughness map based on the bump values.
  125079. */
  125080. protected _enableSpecularAntiAliasing: boolean;
  125081. /**
  125082. * Default configuration related to image processing available in the PBR Material.
  125083. */
  125084. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125085. /**
  125086. * Keep track of the image processing observer to allow dispose and replace.
  125087. */
  125088. private _imageProcessingObserver;
  125089. /**
  125090. * Attaches a new image processing configuration to the PBR Material.
  125091. * @param configuration
  125092. */
  125093. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125094. /**
  125095. * Stores the available render targets.
  125096. */
  125097. private _renderTargets;
  125098. /**
  125099. * Sets the global ambient color for the material used in lighting calculations.
  125100. */
  125101. private _globalAmbientColor;
  125102. /**
  125103. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  125104. */
  125105. private _useLogarithmicDepth;
  125106. /**
  125107. * If set to true, no lighting calculations will be applied.
  125108. */
  125109. private _unlit;
  125110. private _debugMode;
  125111. /**
  125112. * @hidden
  125113. * This is reserved for the inspector.
  125114. * Defines the material debug mode.
  125115. * It helps seeing only some components of the material while troubleshooting.
  125116. */
  125117. debugMode: number;
  125118. /**
  125119. * @hidden
  125120. * This is reserved for the inspector.
  125121. * Specify from where on screen the debug mode should start.
  125122. * The value goes from -1 (full screen) to 1 (not visible)
  125123. * It helps with side by side comparison against the final render
  125124. * This defaults to -1
  125125. */
  125126. private debugLimit;
  125127. /**
  125128. * @hidden
  125129. * This is reserved for the inspector.
  125130. * As the default viewing range might not be enough (if the ambient is really small for instance)
  125131. * You can use the factor to better multiply the final value.
  125132. */
  125133. private debugFactor;
  125134. /**
  125135. * Defines the clear coat layer parameters for the material.
  125136. */
  125137. readonly clearCoat: PBRClearCoatConfiguration;
  125138. /**
  125139. * Defines the anisotropic parameters for the material.
  125140. */
  125141. readonly anisotropy: PBRAnisotropicConfiguration;
  125142. /**
  125143. * Defines the BRDF parameters for the material.
  125144. */
  125145. readonly brdf: PBRBRDFConfiguration;
  125146. /**
  125147. * Defines the Sheen parameters for the material.
  125148. */
  125149. readonly sheen: PBRSheenConfiguration;
  125150. /**
  125151. * Defines the SubSurface parameters for the material.
  125152. */
  125153. readonly subSurface: PBRSubSurfaceConfiguration;
  125154. /**
  125155. * Custom callback helping to override the default shader used in the material.
  125156. */
  125157. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  125158. protected _rebuildInParallel: boolean;
  125159. /**
  125160. * Instantiates a new PBRMaterial instance.
  125161. *
  125162. * @param name The material name
  125163. * @param scene The scene the material will be use in.
  125164. */
  125165. constructor(name: string, scene: Scene);
  125166. /**
  125167. * Gets a boolean indicating that current material needs to register RTT
  125168. */
  125169. get hasRenderTargetTextures(): boolean;
  125170. /**
  125171. * Gets the name of the material class.
  125172. */
  125173. getClassName(): string;
  125174. /**
  125175. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125176. */
  125177. get useLogarithmicDepth(): boolean;
  125178. /**
  125179. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125180. */
  125181. set useLogarithmicDepth(value: boolean);
  125182. /**
  125183. * Returns true if alpha blending should be disabled.
  125184. */
  125185. protected get _disableAlphaBlending(): boolean;
  125186. /**
  125187. * Specifies whether or not this material should be rendered in alpha blend mode.
  125188. */
  125189. needAlphaBlending(): boolean;
  125190. /**
  125191. * Specifies whether or not this material should be rendered in alpha test mode.
  125192. */
  125193. needAlphaTesting(): boolean;
  125194. /**
  125195. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  125196. */
  125197. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  125198. /**
  125199. * Gets the texture used for the alpha test.
  125200. */
  125201. getAlphaTestTexture(): Nullable<BaseTexture>;
  125202. /**
  125203. * Specifies that the submesh is ready to be used.
  125204. * @param mesh - BJS mesh.
  125205. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  125206. * @param useInstances - Specifies that instances should be used.
  125207. * @returns - boolean indicating that the submesh is ready or not.
  125208. */
  125209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125210. /**
  125211. * Specifies if the material uses metallic roughness workflow.
  125212. * @returns boolean specifiying if the material uses metallic roughness workflow.
  125213. */
  125214. isMetallicWorkflow(): boolean;
  125215. private _prepareEffect;
  125216. private _prepareDefines;
  125217. /**
  125218. * Force shader compilation
  125219. */
  125220. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  125221. /**
  125222. * Initializes the uniform buffer layout for the shader.
  125223. */
  125224. buildUniformLayout(): void;
  125225. /**
  125226. * Unbinds the material from the mesh
  125227. */
  125228. unbind(): void;
  125229. /**
  125230. * Binds the submesh data.
  125231. * @param world - The world matrix.
  125232. * @param mesh - The BJS mesh.
  125233. * @param subMesh - A submesh of the BJS mesh.
  125234. */
  125235. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  125236. /**
  125237. * Returns the animatable textures.
  125238. * @returns - Array of animatable textures.
  125239. */
  125240. getAnimatables(): IAnimatable[];
  125241. /**
  125242. * Returns the texture used for reflections.
  125243. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  125244. */
  125245. private _getReflectionTexture;
  125246. /**
  125247. * Returns an array of the actively used textures.
  125248. * @returns - Array of BaseTextures
  125249. */
  125250. getActiveTextures(): BaseTexture[];
  125251. /**
  125252. * Checks to see if a texture is used in the material.
  125253. * @param texture - Base texture to use.
  125254. * @returns - Boolean specifying if a texture is used in the material.
  125255. */
  125256. hasTexture(texture: BaseTexture): boolean;
  125257. /**
  125258. * Disposes the resources of the material.
  125259. * @param forceDisposeEffect - Forces the disposal of effects.
  125260. * @param forceDisposeTextures - Forces the disposal of all textures.
  125261. */
  125262. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  125263. }
  125264. }
  125265. declare module BABYLON {
  125266. /**
  125267. * The Physically based material of BJS.
  125268. *
  125269. * This offers the main features of a standard PBR material.
  125270. * For more information, please refer to the documentation :
  125271. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125272. */
  125273. export class PBRMaterial extends PBRBaseMaterial {
  125274. /**
  125275. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125276. */
  125277. static readonly PBRMATERIAL_OPAQUE: number;
  125278. /**
  125279. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125280. */
  125281. static readonly PBRMATERIAL_ALPHATEST: number;
  125282. /**
  125283. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125284. */
  125285. static readonly PBRMATERIAL_ALPHABLEND: number;
  125286. /**
  125287. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125288. * They are also discarded below the alpha cutoff threshold to improve performances.
  125289. */
  125290. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125291. /**
  125292. * Defines the default value of how much AO map is occluding the analytical lights
  125293. * (point spot...).
  125294. */
  125295. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125296. /**
  125297. * Intensity of the direct lights e.g. the four lights available in your scene.
  125298. * This impacts both the direct diffuse and specular highlights.
  125299. */
  125300. directIntensity: number;
  125301. /**
  125302. * Intensity of the emissive part of the material.
  125303. * This helps controlling the emissive effect without modifying the emissive color.
  125304. */
  125305. emissiveIntensity: number;
  125306. /**
  125307. * Intensity of the environment e.g. how much the environment will light the object
  125308. * either through harmonics for rough material or through the refelction for shiny ones.
  125309. */
  125310. environmentIntensity: number;
  125311. /**
  125312. * This is a special control allowing the reduction of the specular highlights coming from the
  125313. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125314. */
  125315. specularIntensity: number;
  125316. /**
  125317. * Debug Control allowing disabling the bump map on this material.
  125318. */
  125319. disableBumpMap: boolean;
  125320. /**
  125321. * AKA Diffuse Texture in standard nomenclature.
  125322. */
  125323. albedoTexture: BaseTexture;
  125324. /**
  125325. * AKA Occlusion Texture in other nomenclature.
  125326. */
  125327. ambientTexture: BaseTexture;
  125328. /**
  125329. * AKA Occlusion Texture Intensity in other nomenclature.
  125330. */
  125331. ambientTextureStrength: number;
  125332. /**
  125333. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125334. * 1 means it completely occludes it
  125335. * 0 mean it has no impact
  125336. */
  125337. ambientTextureImpactOnAnalyticalLights: number;
  125338. /**
  125339. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  125340. */
  125341. opacityTexture: BaseTexture;
  125342. /**
  125343. * Stores the reflection values in a texture.
  125344. */
  125345. reflectionTexture: Nullable<BaseTexture>;
  125346. /**
  125347. * Stores the emissive values in a texture.
  125348. */
  125349. emissiveTexture: BaseTexture;
  125350. /**
  125351. * AKA Specular texture in other nomenclature.
  125352. */
  125353. reflectivityTexture: BaseTexture;
  125354. /**
  125355. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125356. */
  125357. metallicTexture: BaseTexture;
  125358. /**
  125359. * Specifies the metallic scalar of the metallic/roughness workflow.
  125360. * Can also be used to scale the metalness values of the metallic texture.
  125361. */
  125362. metallic: Nullable<number>;
  125363. /**
  125364. * Specifies the roughness scalar of the metallic/roughness workflow.
  125365. * Can also be used to scale the roughness values of the metallic texture.
  125366. */
  125367. roughness: Nullable<number>;
  125368. /**
  125369. * Specifies the an F0 factor to help configuring the material F0.
  125370. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125371. * to 0.5 the previously hard coded value stays the same.
  125372. * Can also be used to scale the F0 values of the metallic texture.
  125373. */
  125374. metallicF0Factor: number;
  125375. /**
  125376. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125377. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125378. * your expectation as it multiplies with the texture data.
  125379. */
  125380. useMetallicF0FactorFromMetallicTexture: boolean;
  125381. /**
  125382. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125383. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125384. */
  125385. microSurfaceTexture: BaseTexture;
  125386. /**
  125387. * Stores surface normal data used to displace a mesh in a texture.
  125388. */
  125389. bumpTexture: BaseTexture;
  125390. /**
  125391. * Stores the pre-calculated light information of a mesh in a texture.
  125392. */
  125393. lightmapTexture: BaseTexture;
  125394. /**
  125395. * Stores the refracted light information in a texture.
  125396. */
  125397. get refractionTexture(): Nullable<BaseTexture>;
  125398. set refractionTexture(value: Nullable<BaseTexture>);
  125399. /**
  125400. * The color of a material in ambient lighting.
  125401. */
  125402. ambientColor: Color3;
  125403. /**
  125404. * AKA Diffuse Color in other nomenclature.
  125405. */
  125406. albedoColor: Color3;
  125407. /**
  125408. * AKA Specular Color in other nomenclature.
  125409. */
  125410. reflectivityColor: Color3;
  125411. /**
  125412. * The color reflected from the material.
  125413. */
  125414. reflectionColor: Color3;
  125415. /**
  125416. * The color emitted from the material.
  125417. */
  125418. emissiveColor: Color3;
  125419. /**
  125420. * AKA Glossiness in other nomenclature.
  125421. */
  125422. microSurface: number;
  125423. /**
  125424. * source material index of refraction (IOR)' / 'destination material IOR.
  125425. */
  125426. get indexOfRefraction(): number;
  125427. set indexOfRefraction(value: number);
  125428. /**
  125429. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125430. */
  125431. get invertRefractionY(): boolean;
  125432. set invertRefractionY(value: boolean);
  125433. /**
  125434. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125435. * Materials half opaque for instance using refraction could benefit from this control.
  125436. */
  125437. get linkRefractionWithTransparency(): boolean;
  125438. set linkRefractionWithTransparency(value: boolean);
  125439. /**
  125440. * If true, the light map contains occlusion information instead of lighting info.
  125441. */
  125442. useLightmapAsShadowmap: boolean;
  125443. /**
  125444. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125445. */
  125446. useAlphaFromAlbedoTexture: boolean;
  125447. /**
  125448. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125449. */
  125450. forceAlphaTest: boolean;
  125451. /**
  125452. * Defines the alpha limits in alpha test mode.
  125453. */
  125454. alphaCutOff: number;
  125455. /**
  125456. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125457. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125458. */
  125459. useSpecularOverAlpha: boolean;
  125460. /**
  125461. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125462. */
  125463. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125464. /**
  125465. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125466. */
  125467. useRoughnessFromMetallicTextureAlpha: boolean;
  125468. /**
  125469. * Specifies if the metallic texture contains the roughness information in its green channel.
  125470. */
  125471. useRoughnessFromMetallicTextureGreen: boolean;
  125472. /**
  125473. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125474. */
  125475. useMetallnessFromMetallicTextureBlue: boolean;
  125476. /**
  125477. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125478. */
  125479. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125480. /**
  125481. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125482. */
  125483. useAmbientInGrayScale: boolean;
  125484. /**
  125485. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125486. * The material will try to infer what glossiness each pixel should be.
  125487. */
  125488. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125489. /**
  125490. * BJS is using an harcoded light falloff based on a manually sets up range.
  125491. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125492. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125493. */
  125494. get usePhysicalLightFalloff(): boolean;
  125495. /**
  125496. * BJS is using an harcoded light falloff based on a manually sets up range.
  125497. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125498. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125499. */
  125500. set usePhysicalLightFalloff(value: boolean);
  125501. /**
  125502. * In order to support the falloff compatibility with gltf, a special mode has been added
  125503. * to reproduce the gltf light falloff.
  125504. */
  125505. get useGLTFLightFalloff(): boolean;
  125506. /**
  125507. * In order to support the falloff compatibility with gltf, a special mode has been added
  125508. * to reproduce the gltf light falloff.
  125509. */
  125510. set useGLTFLightFalloff(value: boolean);
  125511. /**
  125512. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125513. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125514. */
  125515. useRadianceOverAlpha: boolean;
  125516. /**
  125517. * Allows using an object space normal map (instead of tangent space).
  125518. */
  125519. useObjectSpaceNormalMap: boolean;
  125520. /**
  125521. * Allows using the bump map in parallax mode.
  125522. */
  125523. useParallax: boolean;
  125524. /**
  125525. * Allows using the bump map in parallax occlusion mode.
  125526. */
  125527. useParallaxOcclusion: boolean;
  125528. /**
  125529. * Controls the scale bias of the parallax mode.
  125530. */
  125531. parallaxScaleBias: number;
  125532. /**
  125533. * If sets to true, disables all the lights affecting the material.
  125534. */
  125535. disableLighting: boolean;
  125536. /**
  125537. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125538. */
  125539. forceIrradianceInFragment: boolean;
  125540. /**
  125541. * Number of Simultaneous lights allowed on the material.
  125542. */
  125543. maxSimultaneousLights: number;
  125544. /**
  125545. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125546. */
  125547. invertNormalMapX: boolean;
  125548. /**
  125549. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125550. */
  125551. invertNormalMapY: boolean;
  125552. /**
  125553. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125554. */
  125555. twoSidedLighting: boolean;
  125556. /**
  125557. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125558. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125559. */
  125560. useAlphaFresnel: boolean;
  125561. /**
  125562. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125563. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125564. */
  125565. useLinearAlphaFresnel: boolean;
  125566. /**
  125567. * Let user defines the brdf lookup texture used for IBL.
  125568. * A default 8bit version is embedded but you could point at :
  125569. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125570. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125571. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125572. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125573. */
  125574. environmentBRDFTexture: Nullable<BaseTexture>;
  125575. /**
  125576. * Force normal to face away from face.
  125577. */
  125578. forceNormalForward: boolean;
  125579. /**
  125580. * Enables specular anti aliasing in the PBR shader.
  125581. * It will both interacts on the Geometry for analytical and IBL lighting.
  125582. * It also prefilter the roughness map based on the bump values.
  125583. */
  125584. enableSpecularAntiAliasing: boolean;
  125585. /**
  125586. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125587. * makes the reflect vector face the model (under horizon).
  125588. */
  125589. useHorizonOcclusion: boolean;
  125590. /**
  125591. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125592. * too much the area relying on ambient texture to define their ambient occlusion.
  125593. */
  125594. useRadianceOcclusion: boolean;
  125595. /**
  125596. * If set to true, no lighting calculations will be applied.
  125597. */
  125598. unlit: boolean;
  125599. /**
  125600. * Gets the image processing configuration used either in this material.
  125601. */
  125602. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125603. /**
  125604. * Sets the Default image processing configuration used either in the this material.
  125605. *
  125606. * If sets to null, the scene one is in use.
  125607. */
  125608. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125609. /**
  125610. * Gets wether the color curves effect is enabled.
  125611. */
  125612. get cameraColorCurvesEnabled(): boolean;
  125613. /**
  125614. * Sets wether the color curves effect is enabled.
  125615. */
  125616. set cameraColorCurvesEnabled(value: boolean);
  125617. /**
  125618. * Gets wether the color grading effect is enabled.
  125619. */
  125620. get cameraColorGradingEnabled(): boolean;
  125621. /**
  125622. * Gets wether the color grading effect is enabled.
  125623. */
  125624. set cameraColorGradingEnabled(value: boolean);
  125625. /**
  125626. * Gets wether tonemapping is enabled or not.
  125627. */
  125628. get cameraToneMappingEnabled(): boolean;
  125629. /**
  125630. * Sets wether tonemapping is enabled or not
  125631. */
  125632. set cameraToneMappingEnabled(value: boolean);
  125633. /**
  125634. * The camera exposure used on this material.
  125635. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125636. * This corresponds to a photographic exposure.
  125637. */
  125638. get cameraExposure(): number;
  125639. /**
  125640. * The camera exposure used on this material.
  125641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125642. * This corresponds to a photographic exposure.
  125643. */
  125644. set cameraExposure(value: number);
  125645. /**
  125646. * Gets The camera contrast used on this material.
  125647. */
  125648. get cameraContrast(): number;
  125649. /**
  125650. * Sets The camera contrast used on this material.
  125651. */
  125652. set cameraContrast(value: number);
  125653. /**
  125654. * Gets the Color Grading 2D Lookup Texture.
  125655. */
  125656. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125657. /**
  125658. * Sets the Color Grading 2D Lookup Texture.
  125659. */
  125660. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125661. /**
  125662. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125663. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125664. * 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;
  125665. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125666. */
  125667. get cameraColorCurves(): Nullable<ColorCurves>;
  125668. /**
  125669. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125670. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125671. * 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;
  125672. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125673. */
  125674. set cameraColorCurves(value: Nullable<ColorCurves>);
  125675. /**
  125676. * Instantiates a new PBRMaterial instance.
  125677. *
  125678. * @param name The material name
  125679. * @param scene The scene the material will be use in.
  125680. */
  125681. constructor(name: string, scene: Scene);
  125682. /**
  125683. * Returns the name of this material class.
  125684. */
  125685. getClassName(): string;
  125686. /**
  125687. * Makes a duplicate of the current material.
  125688. * @param name - name to use for the new material.
  125689. */
  125690. clone(name: string): PBRMaterial;
  125691. /**
  125692. * Serializes this PBR Material.
  125693. * @returns - An object with the serialized material.
  125694. */
  125695. serialize(): any;
  125696. /**
  125697. * Parses a PBR Material from a serialized object.
  125698. * @param source - Serialized object.
  125699. * @param scene - BJS scene instance.
  125700. * @param rootUrl - url for the scene object
  125701. * @returns - PBRMaterial
  125702. */
  125703. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125704. }
  125705. }
  125706. declare module BABYLON {
  125707. /**
  125708. * Direct draw surface info
  125709. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125710. */
  125711. export interface DDSInfo {
  125712. /**
  125713. * Width of the texture
  125714. */
  125715. width: number;
  125716. /**
  125717. * Width of the texture
  125718. */
  125719. height: number;
  125720. /**
  125721. * Number of Mipmaps for the texture
  125722. * @see https://en.wikipedia.org/wiki/Mipmap
  125723. */
  125724. mipmapCount: number;
  125725. /**
  125726. * If the textures format is a known fourCC format
  125727. * @see https://www.fourcc.org/
  125728. */
  125729. isFourCC: boolean;
  125730. /**
  125731. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125732. */
  125733. isRGB: boolean;
  125734. /**
  125735. * If the texture is a lumincance format
  125736. */
  125737. isLuminance: boolean;
  125738. /**
  125739. * If this is a cube texture
  125740. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125741. */
  125742. isCube: boolean;
  125743. /**
  125744. * If the texture is a compressed format eg. FOURCC_DXT1
  125745. */
  125746. isCompressed: boolean;
  125747. /**
  125748. * The dxgiFormat of the texture
  125749. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125750. */
  125751. dxgiFormat: number;
  125752. /**
  125753. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125754. */
  125755. textureType: number;
  125756. /**
  125757. * Sphericle polynomial created for the dds texture
  125758. */
  125759. sphericalPolynomial?: SphericalPolynomial;
  125760. }
  125761. /**
  125762. * Class used to provide DDS decompression tools
  125763. */
  125764. export class DDSTools {
  125765. /**
  125766. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125767. */
  125768. static StoreLODInAlphaChannel: boolean;
  125769. /**
  125770. * Gets DDS information from an array buffer
  125771. * @param data defines the array buffer view to read data from
  125772. * @returns the DDS information
  125773. */
  125774. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125775. private static _FloatView;
  125776. private static _Int32View;
  125777. private static _ToHalfFloat;
  125778. private static _FromHalfFloat;
  125779. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125780. private static _GetHalfFloatRGBAArrayBuffer;
  125781. private static _GetFloatRGBAArrayBuffer;
  125782. private static _GetFloatAsUIntRGBAArrayBuffer;
  125783. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125784. private static _GetRGBAArrayBuffer;
  125785. private static _ExtractLongWordOrder;
  125786. private static _GetRGBArrayBuffer;
  125787. private static _GetLuminanceArrayBuffer;
  125788. /**
  125789. * Uploads DDS Levels to a Babylon Texture
  125790. * @hidden
  125791. */
  125792. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125793. }
  125794. interface ThinEngine {
  125795. /**
  125796. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125797. * @param rootUrl defines the url where the file to load is located
  125798. * @param scene defines the current scene
  125799. * @param lodScale defines scale to apply to the mip map selection
  125800. * @param lodOffset defines offset to apply to the mip map selection
  125801. * @param onLoad defines an optional callback raised when the texture is loaded
  125802. * @param onError defines an optional callback raised if there is an issue to load the texture
  125803. * @param format defines the format of the data
  125804. * @param forcedExtension defines the extension to use to pick the right loader
  125805. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125806. * @returns the cube texture as an InternalTexture
  125807. */
  125808. 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;
  125809. }
  125810. }
  125811. declare module BABYLON {
  125812. /**
  125813. * Implementation of the DDS Texture Loader.
  125814. * @hidden
  125815. */
  125816. export class _DDSTextureLoader implements IInternalTextureLoader {
  125817. /**
  125818. * Defines wether the loader supports cascade loading the different faces.
  125819. */
  125820. readonly supportCascades: boolean;
  125821. /**
  125822. * This returns if the loader support the current file information.
  125823. * @param extension defines the file extension of the file being loaded
  125824. * @returns true if the loader can load the specified file
  125825. */
  125826. canLoad(extension: string): boolean;
  125827. /**
  125828. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125829. * @param data contains the texture data
  125830. * @param texture defines the BabylonJS internal texture
  125831. * @param createPolynomials will be true if polynomials have been requested
  125832. * @param onLoad defines the callback to trigger once the texture is ready
  125833. * @param onError defines the callback to trigger in case of error
  125834. */
  125835. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125836. /**
  125837. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125838. * @param data contains the texture data
  125839. * @param texture defines the BabylonJS internal texture
  125840. * @param callback defines the method to call once ready to upload
  125841. */
  125842. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125843. }
  125844. }
  125845. declare module BABYLON {
  125846. /**
  125847. * Implementation of the ENV Texture Loader.
  125848. * @hidden
  125849. */
  125850. export class _ENVTextureLoader implements IInternalTextureLoader {
  125851. /**
  125852. * Defines wether the loader supports cascade loading the different faces.
  125853. */
  125854. readonly supportCascades: boolean;
  125855. /**
  125856. * This returns if the loader support the current file information.
  125857. * @param extension defines the file extension of the file being loaded
  125858. * @returns true if the loader can load the specified file
  125859. */
  125860. canLoad(extension: string): boolean;
  125861. /**
  125862. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125863. * @param data contains the texture data
  125864. * @param texture defines the BabylonJS internal texture
  125865. * @param createPolynomials will be true if polynomials have been requested
  125866. * @param onLoad defines the callback to trigger once the texture is ready
  125867. * @param onError defines the callback to trigger in case of error
  125868. */
  125869. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125870. /**
  125871. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125872. * @param data contains the texture data
  125873. * @param texture defines the BabylonJS internal texture
  125874. * @param callback defines the method to call once ready to upload
  125875. */
  125876. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125877. }
  125878. }
  125879. declare module BABYLON {
  125880. /**
  125881. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125882. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125883. */
  125884. export class KhronosTextureContainer {
  125885. /** contents of the KTX container file */
  125886. data: ArrayBufferView;
  125887. private static HEADER_LEN;
  125888. private static COMPRESSED_2D;
  125889. private static COMPRESSED_3D;
  125890. private static TEX_2D;
  125891. private static TEX_3D;
  125892. /**
  125893. * Gets the openGL type
  125894. */
  125895. glType: number;
  125896. /**
  125897. * Gets the openGL type size
  125898. */
  125899. glTypeSize: number;
  125900. /**
  125901. * Gets the openGL format
  125902. */
  125903. glFormat: number;
  125904. /**
  125905. * Gets the openGL internal format
  125906. */
  125907. glInternalFormat: number;
  125908. /**
  125909. * Gets the base internal format
  125910. */
  125911. glBaseInternalFormat: number;
  125912. /**
  125913. * Gets image width in pixel
  125914. */
  125915. pixelWidth: number;
  125916. /**
  125917. * Gets image height in pixel
  125918. */
  125919. pixelHeight: number;
  125920. /**
  125921. * Gets image depth in pixels
  125922. */
  125923. pixelDepth: number;
  125924. /**
  125925. * Gets the number of array elements
  125926. */
  125927. numberOfArrayElements: number;
  125928. /**
  125929. * Gets the number of faces
  125930. */
  125931. numberOfFaces: number;
  125932. /**
  125933. * Gets the number of mipmap levels
  125934. */
  125935. numberOfMipmapLevels: number;
  125936. /**
  125937. * Gets the bytes of key value data
  125938. */
  125939. bytesOfKeyValueData: number;
  125940. /**
  125941. * Gets the load type
  125942. */
  125943. loadType: number;
  125944. /**
  125945. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125946. */
  125947. isInvalid: boolean;
  125948. /**
  125949. * Creates a new KhronosTextureContainer
  125950. * @param data contents of the KTX container file
  125951. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125952. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125953. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125954. */
  125955. constructor(
  125956. /** contents of the KTX container file */
  125957. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125958. /**
  125959. * Uploads KTX content to a Babylon Texture.
  125960. * It is assumed that the texture has already been created & is currently bound
  125961. * @hidden
  125962. */
  125963. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125964. private _upload2DCompressedLevels;
  125965. /**
  125966. * Checks if the given data starts with a KTX file identifier.
  125967. * @param data the data to check
  125968. * @returns true if the data is a KTX file or false otherwise
  125969. */
  125970. static IsValid(data: ArrayBufferView): boolean;
  125971. }
  125972. }
  125973. declare module BABYLON {
  125974. /**
  125975. * Class for loading KTX2 files
  125976. * !!! Experimental Extension Subject to Changes !!!
  125977. * @hidden
  125978. */
  125979. export class KhronosTextureContainer2 {
  125980. private static _ModulePromise;
  125981. private static _TranscodeFormat;
  125982. constructor(engine: ThinEngine);
  125983. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125984. private _determineTranscodeFormat;
  125985. /**
  125986. * Checks if the given data starts with a KTX2 file identifier.
  125987. * @param data the data to check
  125988. * @returns true if the data is a KTX2 file or false otherwise
  125989. */
  125990. static IsValid(data: ArrayBufferView): boolean;
  125991. }
  125992. }
  125993. declare module BABYLON {
  125994. /**
  125995. * Implementation of the KTX Texture Loader.
  125996. * @hidden
  125997. */
  125998. export class _KTXTextureLoader implements IInternalTextureLoader {
  125999. /**
  126000. * Defines wether the loader supports cascade loading the different faces.
  126001. */
  126002. readonly supportCascades: boolean;
  126003. /**
  126004. * This returns if the loader support the current file information.
  126005. * @param extension defines the file extension of the file being loaded
  126006. * @returns true if the loader can load the specified file
  126007. */
  126008. canLoad(extension: string): boolean;
  126009. /**
  126010. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126011. * @param data contains the texture data
  126012. * @param texture defines the BabylonJS internal texture
  126013. * @param createPolynomials will be true if polynomials have been requested
  126014. * @param onLoad defines the callback to trigger once the texture is ready
  126015. * @param onError defines the callback to trigger in case of error
  126016. */
  126017. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126018. /**
  126019. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126020. * @param data contains the texture data
  126021. * @param texture defines the BabylonJS internal texture
  126022. * @param callback defines the method to call once ready to upload
  126023. */
  126024. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  126025. }
  126026. }
  126027. declare module BABYLON {
  126028. /** @hidden */
  126029. export var _forceSceneHelpersToBundle: boolean;
  126030. interface Scene {
  126031. /**
  126032. * Creates a default light for the scene.
  126033. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  126034. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  126035. */
  126036. createDefaultLight(replace?: boolean): void;
  126037. /**
  126038. * Creates a default camera for the scene.
  126039. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  126040. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  126041. * @param replace has default false, when true replaces the active camera in the scene
  126042. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  126043. */
  126044. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  126045. /**
  126046. * Creates a default camera and a default light.
  126047. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  126048. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  126049. * @param replace has the default false, when true replaces the active camera/light in the scene
  126050. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  126051. */
  126052. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  126053. /**
  126054. * Creates a new sky box
  126055. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  126056. * @param environmentTexture defines the texture to use as environment texture
  126057. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  126058. * @param scale defines the overall scale of the skybox
  126059. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  126060. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  126061. * @returns a new mesh holding the sky box
  126062. */
  126063. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  126064. /**
  126065. * Creates a new environment
  126066. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  126067. * @param options defines the options you can use to configure the environment
  126068. * @returns the new EnvironmentHelper
  126069. */
  126070. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  126071. /**
  126072. * Creates a new VREXperienceHelper
  126073. * @see http://doc.babylonjs.com/how_to/webvr_helper
  126074. * @param webVROptions defines the options used to create the new VREXperienceHelper
  126075. * @returns a new VREXperienceHelper
  126076. */
  126077. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  126078. /**
  126079. * Creates a new WebXRDefaultExperience
  126080. * @see http://doc.babylonjs.com/how_to/webxr
  126081. * @param options experience options
  126082. * @returns a promise for a new WebXRDefaultExperience
  126083. */
  126084. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126085. }
  126086. }
  126087. declare module BABYLON {
  126088. /**
  126089. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  126090. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  126091. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  126092. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126093. */
  126094. export class VideoDome extends TransformNode {
  126095. /**
  126096. * Define the video source as a Monoscopic panoramic 360 video.
  126097. */
  126098. static readonly MODE_MONOSCOPIC: number;
  126099. /**
  126100. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126101. */
  126102. static readonly MODE_TOPBOTTOM: number;
  126103. /**
  126104. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126105. */
  126106. static readonly MODE_SIDEBYSIDE: number;
  126107. private _halfDome;
  126108. private _useDirectMapping;
  126109. /**
  126110. * The video texture being displayed on the sphere
  126111. */
  126112. protected _videoTexture: VideoTexture;
  126113. /**
  126114. * Gets the video texture being displayed on the sphere
  126115. */
  126116. get videoTexture(): VideoTexture;
  126117. /**
  126118. * The skybox material
  126119. */
  126120. protected _material: BackgroundMaterial;
  126121. /**
  126122. * The surface used for the skybox
  126123. */
  126124. protected _mesh: Mesh;
  126125. /**
  126126. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  126127. */
  126128. private _halfDomeMask;
  126129. /**
  126130. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126131. * Also see the options.resolution property.
  126132. */
  126133. get fovMultiplier(): number;
  126134. set fovMultiplier(value: number);
  126135. private _videoMode;
  126136. /**
  126137. * Gets or set the current video mode for the video. It can be:
  126138. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  126139. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126140. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126141. */
  126142. get videoMode(): number;
  126143. set videoMode(value: number);
  126144. /**
  126145. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  126146. *
  126147. */
  126148. get halfDome(): boolean;
  126149. /**
  126150. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  126151. */
  126152. set halfDome(enabled: boolean);
  126153. /**
  126154. * Oberserver used in Stereoscopic VR Mode.
  126155. */
  126156. private _onBeforeCameraRenderObserver;
  126157. /**
  126158. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  126159. * @param name Element's name, child elements will append suffixes for their own names.
  126160. * @param urlsOrVideo defines the url(s) or the video element to use
  126161. * @param options An object containing optional or exposed sub element properties
  126162. */
  126163. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  126164. resolution?: number;
  126165. clickToPlay?: boolean;
  126166. autoPlay?: boolean;
  126167. loop?: boolean;
  126168. size?: number;
  126169. poster?: string;
  126170. faceForward?: boolean;
  126171. useDirectMapping?: boolean;
  126172. halfDomeMode?: boolean;
  126173. }, scene: Scene);
  126174. private _changeVideoMode;
  126175. /**
  126176. * Releases resources associated with this node.
  126177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126179. */
  126180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126181. }
  126182. }
  126183. declare module BABYLON {
  126184. /**
  126185. * This class can be used to get instrumentation data from a Babylon engine
  126186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126187. */
  126188. export class EngineInstrumentation implements IDisposable {
  126189. /**
  126190. * Define the instrumented engine.
  126191. */
  126192. engine: Engine;
  126193. private _captureGPUFrameTime;
  126194. private _gpuFrameTimeToken;
  126195. private _gpuFrameTime;
  126196. private _captureShaderCompilationTime;
  126197. private _shaderCompilationTime;
  126198. private _onBeginFrameObserver;
  126199. private _onEndFrameObserver;
  126200. private _onBeforeShaderCompilationObserver;
  126201. private _onAfterShaderCompilationObserver;
  126202. /**
  126203. * Gets the perf counter used for GPU frame time
  126204. */
  126205. get gpuFrameTimeCounter(): PerfCounter;
  126206. /**
  126207. * Gets the GPU frame time capture status
  126208. */
  126209. get captureGPUFrameTime(): boolean;
  126210. /**
  126211. * Enable or disable the GPU frame time capture
  126212. */
  126213. set captureGPUFrameTime(value: boolean);
  126214. /**
  126215. * Gets the perf counter used for shader compilation time
  126216. */
  126217. get shaderCompilationTimeCounter(): PerfCounter;
  126218. /**
  126219. * Gets the shader compilation time capture status
  126220. */
  126221. get captureShaderCompilationTime(): boolean;
  126222. /**
  126223. * Enable or disable the shader compilation time capture
  126224. */
  126225. set captureShaderCompilationTime(value: boolean);
  126226. /**
  126227. * Instantiates a new engine instrumentation.
  126228. * This class can be used to get instrumentation data from a Babylon engine
  126229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126230. * @param engine Defines the engine to instrument
  126231. */
  126232. constructor(
  126233. /**
  126234. * Define the instrumented engine.
  126235. */
  126236. engine: Engine);
  126237. /**
  126238. * Dispose and release associated resources.
  126239. */
  126240. dispose(): void;
  126241. }
  126242. }
  126243. declare module BABYLON {
  126244. /**
  126245. * This class can be used to get instrumentation data from a Babylon engine
  126246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126247. */
  126248. export class SceneInstrumentation implements IDisposable {
  126249. /**
  126250. * Defines the scene to instrument
  126251. */
  126252. scene: Scene;
  126253. private _captureActiveMeshesEvaluationTime;
  126254. private _activeMeshesEvaluationTime;
  126255. private _captureRenderTargetsRenderTime;
  126256. private _renderTargetsRenderTime;
  126257. private _captureFrameTime;
  126258. private _frameTime;
  126259. private _captureRenderTime;
  126260. private _renderTime;
  126261. private _captureInterFrameTime;
  126262. private _interFrameTime;
  126263. private _captureParticlesRenderTime;
  126264. private _particlesRenderTime;
  126265. private _captureSpritesRenderTime;
  126266. private _spritesRenderTime;
  126267. private _capturePhysicsTime;
  126268. private _physicsTime;
  126269. private _captureAnimationsTime;
  126270. private _animationsTime;
  126271. private _captureCameraRenderTime;
  126272. private _cameraRenderTime;
  126273. private _onBeforeActiveMeshesEvaluationObserver;
  126274. private _onAfterActiveMeshesEvaluationObserver;
  126275. private _onBeforeRenderTargetsRenderObserver;
  126276. private _onAfterRenderTargetsRenderObserver;
  126277. private _onAfterRenderObserver;
  126278. private _onBeforeDrawPhaseObserver;
  126279. private _onAfterDrawPhaseObserver;
  126280. private _onBeforeAnimationsObserver;
  126281. private _onBeforeParticlesRenderingObserver;
  126282. private _onAfterParticlesRenderingObserver;
  126283. private _onBeforeSpritesRenderingObserver;
  126284. private _onAfterSpritesRenderingObserver;
  126285. private _onBeforePhysicsObserver;
  126286. private _onAfterPhysicsObserver;
  126287. private _onAfterAnimationsObserver;
  126288. private _onBeforeCameraRenderObserver;
  126289. private _onAfterCameraRenderObserver;
  126290. /**
  126291. * Gets the perf counter used for active meshes evaluation time
  126292. */
  126293. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  126294. /**
  126295. * Gets the active meshes evaluation time capture status
  126296. */
  126297. get captureActiveMeshesEvaluationTime(): boolean;
  126298. /**
  126299. * Enable or disable the active meshes evaluation time capture
  126300. */
  126301. set captureActiveMeshesEvaluationTime(value: boolean);
  126302. /**
  126303. * Gets the perf counter used for render targets render time
  126304. */
  126305. get renderTargetsRenderTimeCounter(): PerfCounter;
  126306. /**
  126307. * Gets the render targets render time capture status
  126308. */
  126309. get captureRenderTargetsRenderTime(): boolean;
  126310. /**
  126311. * Enable or disable the render targets render time capture
  126312. */
  126313. set captureRenderTargetsRenderTime(value: boolean);
  126314. /**
  126315. * Gets the perf counter used for particles render time
  126316. */
  126317. get particlesRenderTimeCounter(): PerfCounter;
  126318. /**
  126319. * Gets the particles render time capture status
  126320. */
  126321. get captureParticlesRenderTime(): boolean;
  126322. /**
  126323. * Enable or disable the particles render time capture
  126324. */
  126325. set captureParticlesRenderTime(value: boolean);
  126326. /**
  126327. * Gets the perf counter used for sprites render time
  126328. */
  126329. get spritesRenderTimeCounter(): PerfCounter;
  126330. /**
  126331. * Gets the sprites render time capture status
  126332. */
  126333. get captureSpritesRenderTime(): boolean;
  126334. /**
  126335. * Enable or disable the sprites render time capture
  126336. */
  126337. set captureSpritesRenderTime(value: boolean);
  126338. /**
  126339. * Gets the perf counter used for physics time
  126340. */
  126341. get physicsTimeCounter(): PerfCounter;
  126342. /**
  126343. * Gets the physics time capture status
  126344. */
  126345. get capturePhysicsTime(): boolean;
  126346. /**
  126347. * Enable or disable the physics time capture
  126348. */
  126349. set capturePhysicsTime(value: boolean);
  126350. /**
  126351. * Gets the perf counter used for animations time
  126352. */
  126353. get animationsTimeCounter(): PerfCounter;
  126354. /**
  126355. * Gets the animations time capture status
  126356. */
  126357. get captureAnimationsTime(): boolean;
  126358. /**
  126359. * Enable or disable the animations time capture
  126360. */
  126361. set captureAnimationsTime(value: boolean);
  126362. /**
  126363. * Gets the perf counter used for frame time capture
  126364. */
  126365. get frameTimeCounter(): PerfCounter;
  126366. /**
  126367. * Gets the frame time capture status
  126368. */
  126369. get captureFrameTime(): boolean;
  126370. /**
  126371. * Enable or disable the frame time capture
  126372. */
  126373. set captureFrameTime(value: boolean);
  126374. /**
  126375. * Gets the perf counter used for inter-frames time capture
  126376. */
  126377. get interFrameTimeCounter(): PerfCounter;
  126378. /**
  126379. * Gets the inter-frames time capture status
  126380. */
  126381. get captureInterFrameTime(): boolean;
  126382. /**
  126383. * Enable or disable the inter-frames time capture
  126384. */
  126385. set captureInterFrameTime(value: boolean);
  126386. /**
  126387. * Gets the perf counter used for render time capture
  126388. */
  126389. get renderTimeCounter(): PerfCounter;
  126390. /**
  126391. * Gets the render time capture status
  126392. */
  126393. get captureRenderTime(): boolean;
  126394. /**
  126395. * Enable or disable the render time capture
  126396. */
  126397. set captureRenderTime(value: boolean);
  126398. /**
  126399. * Gets the perf counter used for camera render time capture
  126400. */
  126401. get cameraRenderTimeCounter(): PerfCounter;
  126402. /**
  126403. * Gets the camera render time capture status
  126404. */
  126405. get captureCameraRenderTime(): boolean;
  126406. /**
  126407. * Enable or disable the camera render time capture
  126408. */
  126409. set captureCameraRenderTime(value: boolean);
  126410. /**
  126411. * Gets the perf counter used for draw calls
  126412. */
  126413. get drawCallsCounter(): PerfCounter;
  126414. /**
  126415. * Instantiates a new scene instrumentation.
  126416. * This class can be used to get instrumentation data from a Babylon engine
  126417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126418. * @param scene Defines the scene to instrument
  126419. */
  126420. constructor(
  126421. /**
  126422. * Defines the scene to instrument
  126423. */
  126424. scene: Scene);
  126425. /**
  126426. * Dispose and release associated resources.
  126427. */
  126428. dispose(): void;
  126429. }
  126430. }
  126431. declare module BABYLON {
  126432. /** @hidden */
  126433. export var glowMapGenerationPixelShader: {
  126434. name: string;
  126435. shader: string;
  126436. };
  126437. }
  126438. declare module BABYLON {
  126439. /** @hidden */
  126440. export var glowMapGenerationVertexShader: {
  126441. name: string;
  126442. shader: string;
  126443. };
  126444. }
  126445. declare module BABYLON {
  126446. /**
  126447. * Effect layer options. This helps customizing the behaviour
  126448. * of the effect layer.
  126449. */
  126450. export interface IEffectLayerOptions {
  126451. /**
  126452. * Multiplication factor apply to the canvas size to compute the render target size
  126453. * used to generated the objects (the smaller the faster).
  126454. */
  126455. mainTextureRatio: number;
  126456. /**
  126457. * Enforces a fixed size texture to ensure effect stability across devices.
  126458. */
  126459. mainTextureFixedSize?: number;
  126460. /**
  126461. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126462. */
  126463. alphaBlendingMode: number;
  126464. /**
  126465. * The camera attached to the layer.
  126466. */
  126467. camera: Nullable<Camera>;
  126468. /**
  126469. * The rendering group to draw the layer in.
  126470. */
  126471. renderingGroupId: number;
  126472. }
  126473. /**
  126474. * The effect layer Helps adding post process effect blended with the main pass.
  126475. *
  126476. * This can be for instance use to generate glow or higlight effects on the scene.
  126477. *
  126478. * The effect layer class can not be used directly and is intented to inherited from to be
  126479. * customized per effects.
  126480. */
  126481. export abstract class EffectLayer {
  126482. private _vertexBuffers;
  126483. private _indexBuffer;
  126484. private _cachedDefines;
  126485. private _effectLayerMapGenerationEffect;
  126486. private _effectLayerOptions;
  126487. private _mergeEffect;
  126488. protected _scene: Scene;
  126489. protected _engine: Engine;
  126490. protected _maxSize: number;
  126491. protected _mainTextureDesiredSize: ISize;
  126492. protected _mainTexture: RenderTargetTexture;
  126493. protected _shouldRender: boolean;
  126494. protected _postProcesses: PostProcess[];
  126495. protected _textures: BaseTexture[];
  126496. protected _emissiveTextureAndColor: {
  126497. texture: Nullable<BaseTexture>;
  126498. color: Color4;
  126499. };
  126500. /**
  126501. * The name of the layer
  126502. */
  126503. name: string;
  126504. /**
  126505. * The clear color of the texture used to generate the glow map.
  126506. */
  126507. neutralColor: Color4;
  126508. /**
  126509. * Specifies whether the highlight layer is enabled or not.
  126510. */
  126511. isEnabled: boolean;
  126512. /**
  126513. * Gets the camera attached to the layer.
  126514. */
  126515. get camera(): Nullable<Camera>;
  126516. /**
  126517. * Gets the rendering group id the layer should render in.
  126518. */
  126519. get renderingGroupId(): number;
  126520. set renderingGroupId(renderingGroupId: number);
  126521. /**
  126522. * An event triggered when the effect layer has been disposed.
  126523. */
  126524. onDisposeObservable: Observable<EffectLayer>;
  126525. /**
  126526. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126527. */
  126528. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126529. /**
  126530. * An event triggered when the generated texture is being merged in the scene.
  126531. */
  126532. onBeforeComposeObservable: Observable<EffectLayer>;
  126533. /**
  126534. * An event triggered when the mesh is rendered into the effect render target.
  126535. */
  126536. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126537. /**
  126538. * An event triggered after the mesh has been rendered into the effect render target.
  126539. */
  126540. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126541. /**
  126542. * An event triggered when the generated texture has been merged in the scene.
  126543. */
  126544. onAfterComposeObservable: Observable<EffectLayer>;
  126545. /**
  126546. * An event triggered when the efffect layer changes its size.
  126547. */
  126548. onSizeChangedObservable: Observable<EffectLayer>;
  126549. /** @hidden */
  126550. static _SceneComponentInitialization: (scene: Scene) => void;
  126551. /**
  126552. * Instantiates a new effect Layer and references it in the scene.
  126553. * @param name The name of the layer
  126554. * @param scene The scene to use the layer in
  126555. */
  126556. constructor(
  126557. /** The Friendly of the effect in the scene */
  126558. name: string, scene: Scene);
  126559. /**
  126560. * Get the effect name of the layer.
  126561. * @return The effect name
  126562. */
  126563. abstract getEffectName(): string;
  126564. /**
  126565. * Checks for the readiness of the element composing the layer.
  126566. * @param subMesh the mesh to check for
  126567. * @param useInstances specify whether or not to use instances to render the mesh
  126568. * @return true if ready otherwise, false
  126569. */
  126570. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126571. /**
  126572. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126573. * @returns true if the effect requires stencil during the main canvas render pass.
  126574. */
  126575. abstract needStencil(): boolean;
  126576. /**
  126577. * Create the merge effect. This is the shader use to blit the information back
  126578. * to the main canvas at the end of the scene rendering.
  126579. * @returns The effect containing the shader used to merge the effect on the main canvas
  126580. */
  126581. protected abstract _createMergeEffect(): Effect;
  126582. /**
  126583. * Creates the render target textures and post processes used in the effect layer.
  126584. */
  126585. protected abstract _createTextureAndPostProcesses(): void;
  126586. /**
  126587. * Implementation specific of rendering the generating effect on the main canvas.
  126588. * @param effect The effect used to render through
  126589. */
  126590. protected abstract _internalRender(effect: Effect): void;
  126591. /**
  126592. * Sets the required values for both the emissive texture and and the main color.
  126593. */
  126594. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126595. /**
  126596. * Free any resources and references associated to a mesh.
  126597. * Internal use
  126598. * @param mesh The mesh to free.
  126599. */
  126600. abstract _disposeMesh(mesh: Mesh): void;
  126601. /**
  126602. * Serializes this layer (Glow or Highlight for example)
  126603. * @returns a serialized layer object
  126604. */
  126605. abstract serialize?(): any;
  126606. /**
  126607. * Initializes the effect layer with the required options.
  126608. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126609. */
  126610. protected _init(options: Partial<IEffectLayerOptions>): void;
  126611. /**
  126612. * Generates the index buffer of the full screen quad blending to the main canvas.
  126613. */
  126614. private _generateIndexBuffer;
  126615. /**
  126616. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126617. */
  126618. private _generateVertexBuffer;
  126619. /**
  126620. * Sets the main texture desired size which is the closest power of two
  126621. * of the engine canvas size.
  126622. */
  126623. private _setMainTextureSize;
  126624. /**
  126625. * Creates the main texture for the effect layer.
  126626. */
  126627. protected _createMainTexture(): void;
  126628. /**
  126629. * Adds specific effects defines.
  126630. * @param defines The defines to add specifics to.
  126631. */
  126632. protected _addCustomEffectDefines(defines: string[]): void;
  126633. /**
  126634. * Checks for the readiness of the element composing the layer.
  126635. * @param subMesh the mesh to check for
  126636. * @param useInstances specify whether or not to use instances to render the mesh
  126637. * @param emissiveTexture the associated emissive texture used to generate the glow
  126638. * @return true if ready otherwise, false
  126639. */
  126640. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126641. /**
  126642. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126643. */
  126644. render(): void;
  126645. /**
  126646. * Determine if a given mesh will be used in the current effect.
  126647. * @param mesh mesh to test
  126648. * @returns true if the mesh will be used
  126649. */
  126650. hasMesh(mesh: AbstractMesh): boolean;
  126651. /**
  126652. * Returns true if the layer contains information to display, otherwise false.
  126653. * @returns true if the glow layer should be rendered
  126654. */
  126655. shouldRender(): boolean;
  126656. /**
  126657. * Returns true if the mesh should render, otherwise false.
  126658. * @param mesh The mesh to render
  126659. * @returns true if it should render otherwise false
  126660. */
  126661. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126662. /**
  126663. * Returns true if the mesh can be rendered, otherwise false.
  126664. * @param mesh The mesh to render
  126665. * @param material The material used on the mesh
  126666. * @returns true if it can be rendered otherwise false
  126667. */
  126668. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126669. /**
  126670. * Returns true if the mesh should render, otherwise false.
  126671. * @param mesh The mesh to render
  126672. * @returns true if it should render otherwise false
  126673. */
  126674. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126675. /**
  126676. * Renders the submesh passed in parameter to the generation map.
  126677. */
  126678. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126679. /**
  126680. * Defines whether the current material of the mesh should be use to render the effect.
  126681. * @param mesh defines the current mesh to render
  126682. */
  126683. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126684. /**
  126685. * Rebuild the required buffers.
  126686. * @hidden Internal use only.
  126687. */
  126688. _rebuild(): void;
  126689. /**
  126690. * Dispose only the render target textures and post process.
  126691. */
  126692. private _disposeTextureAndPostProcesses;
  126693. /**
  126694. * Dispose the highlight layer and free resources.
  126695. */
  126696. dispose(): void;
  126697. /**
  126698. * Gets the class name of the effect layer
  126699. * @returns the string with the class name of the effect layer
  126700. */
  126701. getClassName(): string;
  126702. /**
  126703. * Creates an effect layer from parsed effect layer data
  126704. * @param parsedEffectLayer defines effect layer data
  126705. * @param scene defines the current scene
  126706. * @param rootUrl defines the root URL containing the effect layer information
  126707. * @returns a parsed effect Layer
  126708. */
  126709. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126710. }
  126711. }
  126712. declare module BABYLON {
  126713. interface AbstractScene {
  126714. /**
  126715. * The list of effect layers (highlights/glow) added to the scene
  126716. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126717. * @see http://doc.babylonjs.com/how_to/glow_layer
  126718. */
  126719. effectLayers: Array<EffectLayer>;
  126720. /**
  126721. * Removes the given effect layer from this scene.
  126722. * @param toRemove defines the effect layer to remove
  126723. * @returns the index of the removed effect layer
  126724. */
  126725. removeEffectLayer(toRemove: EffectLayer): number;
  126726. /**
  126727. * Adds the given effect layer to this scene
  126728. * @param newEffectLayer defines the effect layer to add
  126729. */
  126730. addEffectLayer(newEffectLayer: EffectLayer): void;
  126731. }
  126732. /**
  126733. * Defines the layer scene component responsible to manage any effect layers
  126734. * in a given scene.
  126735. */
  126736. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126737. /**
  126738. * The component name helpfull to identify the component in the list of scene components.
  126739. */
  126740. readonly name: string;
  126741. /**
  126742. * The scene the component belongs to.
  126743. */
  126744. scene: Scene;
  126745. private _engine;
  126746. private _renderEffects;
  126747. private _needStencil;
  126748. private _previousStencilState;
  126749. /**
  126750. * Creates a new instance of the component for the given scene
  126751. * @param scene Defines the scene to register the component in
  126752. */
  126753. constructor(scene: Scene);
  126754. /**
  126755. * Registers the component in a given scene
  126756. */
  126757. register(): void;
  126758. /**
  126759. * Rebuilds the elements related to this component in case of
  126760. * context lost for instance.
  126761. */
  126762. rebuild(): void;
  126763. /**
  126764. * Serializes the component data to the specified json object
  126765. * @param serializationObject The object to serialize to
  126766. */
  126767. serialize(serializationObject: any): void;
  126768. /**
  126769. * Adds all the elements from the container to the scene
  126770. * @param container the container holding the elements
  126771. */
  126772. addFromContainer(container: AbstractScene): void;
  126773. /**
  126774. * Removes all the elements in the container from the scene
  126775. * @param container contains the elements to remove
  126776. * @param dispose if the removed element should be disposed (default: false)
  126777. */
  126778. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126779. /**
  126780. * Disposes the component and the associated ressources.
  126781. */
  126782. dispose(): void;
  126783. private _isReadyForMesh;
  126784. private _renderMainTexture;
  126785. private _setStencil;
  126786. private _setStencilBack;
  126787. private _draw;
  126788. private _drawCamera;
  126789. private _drawRenderingGroup;
  126790. }
  126791. }
  126792. declare module BABYLON {
  126793. /** @hidden */
  126794. export var glowMapMergePixelShader: {
  126795. name: string;
  126796. shader: string;
  126797. };
  126798. }
  126799. declare module BABYLON {
  126800. /** @hidden */
  126801. export var glowMapMergeVertexShader: {
  126802. name: string;
  126803. shader: string;
  126804. };
  126805. }
  126806. declare module BABYLON {
  126807. interface AbstractScene {
  126808. /**
  126809. * Return a the first highlight layer of the scene with a given name.
  126810. * @param name The name of the highlight layer to look for.
  126811. * @return The highlight layer if found otherwise null.
  126812. */
  126813. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126814. }
  126815. /**
  126816. * Glow layer options. This helps customizing the behaviour
  126817. * of the glow layer.
  126818. */
  126819. export interface IGlowLayerOptions {
  126820. /**
  126821. * Multiplication factor apply to the canvas size to compute the render target size
  126822. * used to generated the glowing objects (the smaller the faster).
  126823. */
  126824. mainTextureRatio: number;
  126825. /**
  126826. * Enforces a fixed size texture to ensure resize independant blur.
  126827. */
  126828. mainTextureFixedSize?: number;
  126829. /**
  126830. * How big is the kernel of the blur texture.
  126831. */
  126832. blurKernelSize: number;
  126833. /**
  126834. * The camera attached to the layer.
  126835. */
  126836. camera: Nullable<Camera>;
  126837. /**
  126838. * Enable MSAA by chosing the number of samples.
  126839. */
  126840. mainTextureSamples?: number;
  126841. /**
  126842. * The rendering group to draw the layer in.
  126843. */
  126844. renderingGroupId: number;
  126845. }
  126846. /**
  126847. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126848. *
  126849. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126850. *
  126851. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126852. */
  126853. export class GlowLayer extends EffectLayer {
  126854. /**
  126855. * Effect Name of the layer.
  126856. */
  126857. static readonly EffectName: string;
  126858. /**
  126859. * The default blur kernel size used for the glow.
  126860. */
  126861. static DefaultBlurKernelSize: number;
  126862. /**
  126863. * The default texture size ratio used for the glow.
  126864. */
  126865. static DefaultTextureRatio: number;
  126866. /**
  126867. * Sets the kernel size of the blur.
  126868. */
  126869. set blurKernelSize(value: number);
  126870. /**
  126871. * Gets the kernel size of the blur.
  126872. */
  126873. get blurKernelSize(): number;
  126874. /**
  126875. * Sets the glow intensity.
  126876. */
  126877. set intensity(value: number);
  126878. /**
  126879. * Gets the glow intensity.
  126880. */
  126881. get intensity(): number;
  126882. private _options;
  126883. private _intensity;
  126884. private _horizontalBlurPostprocess1;
  126885. private _verticalBlurPostprocess1;
  126886. private _horizontalBlurPostprocess2;
  126887. private _verticalBlurPostprocess2;
  126888. private _blurTexture1;
  126889. private _blurTexture2;
  126890. private _postProcesses1;
  126891. private _postProcesses2;
  126892. private _includedOnlyMeshes;
  126893. private _excludedMeshes;
  126894. private _meshesUsingTheirOwnMaterials;
  126895. /**
  126896. * Callback used to let the user override the color selection on a per mesh basis
  126897. */
  126898. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126899. /**
  126900. * Callback used to let the user override the texture selection on a per mesh basis
  126901. */
  126902. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126903. /**
  126904. * Instantiates a new glow Layer and references it to the scene.
  126905. * @param name The name of the layer
  126906. * @param scene The scene to use the layer in
  126907. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126908. */
  126909. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126910. /**
  126911. * Get the effect name of the layer.
  126912. * @return The effect name
  126913. */
  126914. getEffectName(): string;
  126915. /**
  126916. * Create the merge effect. This is the shader use to blit the information back
  126917. * to the main canvas at the end of the scene rendering.
  126918. */
  126919. protected _createMergeEffect(): Effect;
  126920. /**
  126921. * Creates the render target textures and post processes used in the glow layer.
  126922. */
  126923. protected _createTextureAndPostProcesses(): void;
  126924. /**
  126925. * Checks for the readiness of the element composing the layer.
  126926. * @param subMesh the mesh to check for
  126927. * @param useInstances specify wether or not to use instances to render the mesh
  126928. * @param emissiveTexture the associated emissive texture used to generate the glow
  126929. * @return true if ready otherwise, false
  126930. */
  126931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126932. /**
  126933. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126934. */
  126935. needStencil(): boolean;
  126936. /**
  126937. * Returns true if the mesh can be rendered, otherwise false.
  126938. * @param mesh The mesh to render
  126939. * @param material The material used on the mesh
  126940. * @returns true if it can be rendered otherwise false
  126941. */
  126942. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126943. /**
  126944. * Implementation specific of rendering the generating effect on the main canvas.
  126945. * @param effect The effect used to render through
  126946. */
  126947. protected _internalRender(effect: Effect): void;
  126948. /**
  126949. * Sets the required values for both the emissive texture and and the main color.
  126950. */
  126951. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126952. /**
  126953. * Returns true if the mesh should render, otherwise false.
  126954. * @param mesh The mesh to render
  126955. * @returns true if it should render otherwise false
  126956. */
  126957. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126958. /**
  126959. * Adds specific effects defines.
  126960. * @param defines The defines to add specifics to.
  126961. */
  126962. protected _addCustomEffectDefines(defines: string[]): void;
  126963. /**
  126964. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126965. * @param mesh The mesh to exclude from the glow layer
  126966. */
  126967. addExcludedMesh(mesh: Mesh): void;
  126968. /**
  126969. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126970. * @param mesh The mesh to remove
  126971. */
  126972. removeExcludedMesh(mesh: Mesh): void;
  126973. /**
  126974. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126975. * @param mesh The mesh to include in the glow layer
  126976. */
  126977. addIncludedOnlyMesh(mesh: Mesh): void;
  126978. /**
  126979. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126980. * @param mesh The mesh to remove
  126981. */
  126982. removeIncludedOnlyMesh(mesh: Mesh): void;
  126983. /**
  126984. * Determine if a given mesh will be used in the glow layer
  126985. * @param mesh The mesh to test
  126986. * @returns true if the mesh will be highlighted by the current glow layer
  126987. */
  126988. hasMesh(mesh: AbstractMesh): boolean;
  126989. /**
  126990. * Defines whether the current material of the mesh should be use to render the effect.
  126991. * @param mesh defines the current mesh to render
  126992. */
  126993. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126994. /**
  126995. * Add a mesh to be rendered through its own material and not with emissive only.
  126996. * @param mesh The mesh for which we need to use its material
  126997. */
  126998. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126999. /**
  127000. * Remove a mesh from being rendered through its own material and not with emissive only.
  127001. * @param mesh The mesh for which we need to not use its material
  127002. */
  127003. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  127004. /**
  127005. * Free any resources and references associated to a mesh.
  127006. * Internal use
  127007. * @param mesh The mesh to free.
  127008. * @hidden
  127009. */
  127010. _disposeMesh(mesh: Mesh): void;
  127011. /**
  127012. * Gets the class name of the effect layer
  127013. * @returns the string with the class name of the effect layer
  127014. */
  127015. getClassName(): string;
  127016. /**
  127017. * Serializes this glow layer
  127018. * @returns a serialized glow layer object
  127019. */
  127020. serialize(): any;
  127021. /**
  127022. * Creates a Glow Layer from parsed glow layer data
  127023. * @param parsedGlowLayer defines glow layer data
  127024. * @param scene defines the current scene
  127025. * @param rootUrl defines the root URL containing the glow layer information
  127026. * @returns a parsed Glow Layer
  127027. */
  127028. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  127029. }
  127030. }
  127031. declare module BABYLON {
  127032. /** @hidden */
  127033. export var glowBlurPostProcessPixelShader: {
  127034. name: string;
  127035. shader: string;
  127036. };
  127037. }
  127038. declare module BABYLON {
  127039. interface AbstractScene {
  127040. /**
  127041. * Return a the first highlight layer of the scene with a given name.
  127042. * @param name The name of the highlight layer to look for.
  127043. * @return The highlight layer if found otherwise null.
  127044. */
  127045. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  127046. }
  127047. /**
  127048. * Highlight layer options. This helps customizing the behaviour
  127049. * of the highlight layer.
  127050. */
  127051. export interface IHighlightLayerOptions {
  127052. /**
  127053. * Multiplication factor apply to the canvas size to compute the render target size
  127054. * used to generated the glowing objects (the smaller the faster).
  127055. */
  127056. mainTextureRatio: number;
  127057. /**
  127058. * Enforces a fixed size texture to ensure resize independant blur.
  127059. */
  127060. mainTextureFixedSize?: number;
  127061. /**
  127062. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  127063. * of the picture to blur (the smaller the faster).
  127064. */
  127065. blurTextureSizeRatio: number;
  127066. /**
  127067. * How big in texel of the blur texture is the vertical blur.
  127068. */
  127069. blurVerticalSize: number;
  127070. /**
  127071. * How big in texel of the blur texture is the horizontal blur.
  127072. */
  127073. blurHorizontalSize: number;
  127074. /**
  127075. * Alpha blending mode used to apply the blur. Default is combine.
  127076. */
  127077. alphaBlendingMode: number;
  127078. /**
  127079. * The camera attached to the layer.
  127080. */
  127081. camera: Nullable<Camera>;
  127082. /**
  127083. * Should we display highlight as a solid stroke?
  127084. */
  127085. isStroke?: boolean;
  127086. /**
  127087. * The rendering group to draw the layer in.
  127088. */
  127089. renderingGroupId: number;
  127090. }
  127091. /**
  127092. * The highlight layer Helps adding a glow effect around a mesh.
  127093. *
  127094. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  127095. * glowy meshes to your scene.
  127096. *
  127097. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  127098. */
  127099. export class HighlightLayer extends EffectLayer {
  127100. name: string;
  127101. /**
  127102. * Effect Name of the highlight layer.
  127103. */
  127104. static readonly EffectName: string;
  127105. /**
  127106. * The neutral color used during the preparation of the glow effect.
  127107. * This is black by default as the blend operation is a blend operation.
  127108. */
  127109. static NeutralColor: Color4;
  127110. /**
  127111. * Stencil value used for glowing meshes.
  127112. */
  127113. static GlowingMeshStencilReference: number;
  127114. /**
  127115. * Stencil value used for the other meshes in the scene.
  127116. */
  127117. static NormalMeshStencilReference: number;
  127118. /**
  127119. * Specifies whether or not the inner glow is ACTIVE in the layer.
  127120. */
  127121. innerGlow: boolean;
  127122. /**
  127123. * Specifies whether or not the outer glow is ACTIVE in the layer.
  127124. */
  127125. outerGlow: boolean;
  127126. /**
  127127. * Specifies the horizontal size of the blur.
  127128. */
  127129. set blurHorizontalSize(value: number);
  127130. /**
  127131. * Specifies the vertical size of the blur.
  127132. */
  127133. set blurVerticalSize(value: number);
  127134. /**
  127135. * Gets the horizontal size of the blur.
  127136. */
  127137. get blurHorizontalSize(): number;
  127138. /**
  127139. * Gets the vertical size of the blur.
  127140. */
  127141. get blurVerticalSize(): number;
  127142. /**
  127143. * An event triggered when the highlight layer is being blurred.
  127144. */
  127145. onBeforeBlurObservable: Observable<HighlightLayer>;
  127146. /**
  127147. * An event triggered when the highlight layer has been blurred.
  127148. */
  127149. onAfterBlurObservable: Observable<HighlightLayer>;
  127150. private _instanceGlowingMeshStencilReference;
  127151. private _options;
  127152. private _downSamplePostprocess;
  127153. private _horizontalBlurPostprocess;
  127154. private _verticalBlurPostprocess;
  127155. private _blurTexture;
  127156. private _meshes;
  127157. private _excludedMeshes;
  127158. /**
  127159. * Instantiates a new highlight Layer and references it to the scene..
  127160. * @param name The name of the layer
  127161. * @param scene The scene to use the layer in
  127162. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  127163. */
  127164. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  127165. /**
  127166. * Get the effect name of the layer.
  127167. * @return The effect name
  127168. */
  127169. getEffectName(): string;
  127170. /**
  127171. * Create the merge effect. This is the shader use to blit the information back
  127172. * to the main canvas at the end of the scene rendering.
  127173. */
  127174. protected _createMergeEffect(): Effect;
  127175. /**
  127176. * Creates the render target textures and post processes used in the highlight layer.
  127177. */
  127178. protected _createTextureAndPostProcesses(): void;
  127179. /**
  127180. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  127181. */
  127182. needStencil(): boolean;
  127183. /**
  127184. * Checks for the readiness of the element composing the layer.
  127185. * @param subMesh the mesh to check for
  127186. * @param useInstances specify wether or not to use instances to render the mesh
  127187. * @param emissiveTexture the associated emissive texture used to generate the glow
  127188. * @return true if ready otherwise, false
  127189. */
  127190. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127191. /**
  127192. * Implementation specific of rendering the generating effect on the main canvas.
  127193. * @param effect The effect used to render through
  127194. */
  127195. protected _internalRender(effect: Effect): void;
  127196. /**
  127197. * Returns true if the layer contains information to display, otherwise false.
  127198. */
  127199. shouldRender(): boolean;
  127200. /**
  127201. * Returns true if the mesh should render, otherwise false.
  127202. * @param mesh The mesh to render
  127203. * @returns true if it should render otherwise false
  127204. */
  127205. protected _shouldRenderMesh(mesh: Mesh): boolean;
  127206. /**
  127207. * Sets the required values for both the emissive texture and and the main color.
  127208. */
  127209. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127210. /**
  127211. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  127212. * @param mesh The mesh to exclude from the highlight layer
  127213. */
  127214. addExcludedMesh(mesh: Mesh): void;
  127215. /**
  127216. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  127217. * @param mesh The mesh to highlight
  127218. */
  127219. removeExcludedMesh(mesh: Mesh): void;
  127220. /**
  127221. * Determine if a given mesh will be highlighted by the current HighlightLayer
  127222. * @param mesh mesh to test
  127223. * @returns true if the mesh will be highlighted by the current HighlightLayer
  127224. */
  127225. hasMesh(mesh: AbstractMesh): boolean;
  127226. /**
  127227. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  127228. * @param mesh The mesh to highlight
  127229. * @param color The color of the highlight
  127230. * @param glowEmissiveOnly Extract the glow from the emissive texture
  127231. */
  127232. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  127233. /**
  127234. * Remove a mesh from the highlight layer in order to make it stop glowing.
  127235. * @param mesh The mesh to highlight
  127236. */
  127237. removeMesh(mesh: Mesh): void;
  127238. /**
  127239. * Remove all the meshes currently referenced in the highlight layer
  127240. */
  127241. removeAllMeshes(): void;
  127242. /**
  127243. * Force the stencil to the normal expected value for none glowing parts
  127244. */
  127245. private _defaultStencilReference;
  127246. /**
  127247. * Free any resources and references associated to a mesh.
  127248. * Internal use
  127249. * @param mesh The mesh to free.
  127250. * @hidden
  127251. */
  127252. _disposeMesh(mesh: Mesh): void;
  127253. /**
  127254. * Dispose the highlight layer and free resources.
  127255. */
  127256. dispose(): void;
  127257. /**
  127258. * Gets the class name of the effect layer
  127259. * @returns the string with the class name of the effect layer
  127260. */
  127261. getClassName(): string;
  127262. /**
  127263. * Serializes this Highlight layer
  127264. * @returns a serialized Highlight layer object
  127265. */
  127266. serialize(): any;
  127267. /**
  127268. * Creates a Highlight layer from parsed Highlight layer data
  127269. * @param parsedHightlightLayer defines the Highlight layer data
  127270. * @param scene defines the current scene
  127271. * @param rootUrl defines the root URL containing the Highlight layer information
  127272. * @returns a parsed Highlight layer
  127273. */
  127274. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  127275. }
  127276. }
  127277. declare module BABYLON {
  127278. interface AbstractScene {
  127279. /**
  127280. * The list of layers (background and foreground) of the scene
  127281. */
  127282. layers: Array<Layer>;
  127283. }
  127284. /**
  127285. * Defines the layer scene component responsible to manage any layers
  127286. * in a given scene.
  127287. */
  127288. export class LayerSceneComponent implements ISceneComponent {
  127289. /**
  127290. * The component name helpfull to identify the component in the list of scene components.
  127291. */
  127292. readonly name: string;
  127293. /**
  127294. * The scene the component belongs to.
  127295. */
  127296. scene: Scene;
  127297. private _engine;
  127298. /**
  127299. * Creates a new instance of the component for the given scene
  127300. * @param scene Defines the scene to register the component in
  127301. */
  127302. constructor(scene: Scene);
  127303. /**
  127304. * Registers the component in a given scene
  127305. */
  127306. register(): void;
  127307. /**
  127308. * Rebuilds the elements related to this component in case of
  127309. * context lost for instance.
  127310. */
  127311. rebuild(): void;
  127312. /**
  127313. * Disposes the component and the associated ressources.
  127314. */
  127315. dispose(): void;
  127316. private _draw;
  127317. private _drawCameraPredicate;
  127318. private _drawCameraBackground;
  127319. private _drawCameraForeground;
  127320. private _drawRenderTargetPredicate;
  127321. private _drawRenderTargetBackground;
  127322. private _drawRenderTargetForeground;
  127323. /**
  127324. * Adds all the elements from the container to the scene
  127325. * @param container the container holding the elements
  127326. */
  127327. addFromContainer(container: AbstractScene): void;
  127328. /**
  127329. * Removes all the elements in the container from the scene
  127330. * @param container contains the elements to remove
  127331. * @param dispose if the removed element should be disposed (default: false)
  127332. */
  127333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127334. }
  127335. }
  127336. declare module BABYLON {
  127337. /** @hidden */
  127338. export var layerPixelShader: {
  127339. name: string;
  127340. shader: string;
  127341. };
  127342. }
  127343. declare module BABYLON {
  127344. /** @hidden */
  127345. export var layerVertexShader: {
  127346. name: string;
  127347. shader: string;
  127348. };
  127349. }
  127350. declare module BABYLON {
  127351. /**
  127352. * This represents a full screen 2d layer.
  127353. * This can be useful to display a picture in the background of your scene for instance.
  127354. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127355. */
  127356. export class Layer {
  127357. /**
  127358. * Define the name of the layer.
  127359. */
  127360. name: string;
  127361. /**
  127362. * Define the texture the layer should display.
  127363. */
  127364. texture: Nullable<Texture>;
  127365. /**
  127366. * Is the layer in background or foreground.
  127367. */
  127368. isBackground: boolean;
  127369. /**
  127370. * Define the color of the layer (instead of texture).
  127371. */
  127372. color: Color4;
  127373. /**
  127374. * Define the scale of the layer in order to zoom in out of the texture.
  127375. */
  127376. scale: Vector2;
  127377. /**
  127378. * Define an offset for the layer in order to shift the texture.
  127379. */
  127380. offset: Vector2;
  127381. /**
  127382. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  127383. */
  127384. alphaBlendingMode: number;
  127385. /**
  127386. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  127387. * Alpha test will not mix with the background color in case of transparency.
  127388. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  127389. */
  127390. alphaTest: boolean;
  127391. /**
  127392. * Define a mask to restrict the layer to only some of the scene cameras.
  127393. */
  127394. layerMask: number;
  127395. /**
  127396. * Define the list of render target the layer is visible into.
  127397. */
  127398. renderTargetTextures: RenderTargetTexture[];
  127399. /**
  127400. * Define if the layer is only used in renderTarget or if it also
  127401. * renders in the main frame buffer of the canvas.
  127402. */
  127403. renderOnlyInRenderTargetTextures: boolean;
  127404. private _scene;
  127405. private _vertexBuffers;
  127406. private _indexBuffer;
  127407. private _effect;
  127408. private _previousDefines;
  127409. /**
  127410. * An event triggered when the layer is disposed.
  127411. */
  127412. onDisposeObservable: Observable<Layer>;
  127413. private _onDisposeObserver;
  127414. /**
  127415. * Back compatibility with callback before the onDisposeObservable existed.
  127416. * The set callback will be triggered when the layer has been disposed.
  127417. */
  127418. set onDispose(callback: () => void);
  127419. /**
  127420. * An event triggered before rendering the scene
  127421. */
  127422. onBeforeRenderObservable: Observable<Layer>;
  127423. private _onBeforeRenderObserver;
  127424. /**
  127425. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127426. * The set callback will be triggered just before rendering the layer.
  127427. */
  127428. set onBeforeRender(callback: () => void);
  127429. /**
  127430. * An event triggered after rendering the scene
  127431. */
  127432. onAfterRenderObservable: Observable<Layer>;
  127433. private _onAfterRenderObserver;
  127434. /**
  127435. * Back compatibility with callback before the onAfterRenderObservable existed.
  127436. * The set callback will be triggered just after rendering the layer.
  127437. */
  127438. set onAfterRender(callback: () => void);
  127439. /**
  127440. * Instantiates a new layer.
  127441. * This represents a full screen 2d layer.
  127442. * This can be useful to display a picture in the background of your scene for instance.
  127443. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127444. * @param name Define the name of the layer in the scene
  127445. * @param imgUrl Define the url of the texture to display in the layer
  127446. * @param scene Define the scene the layer belongs to
  127447. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127448. * @param color Defines a color for the layer
  127449. */
  127450. constructor(
  127451. /**
  127452. * Define the name of the layer.
  127453. */
  127454. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127455. private _createIndexBuffer;
  127456. /** @hidden */
  127457. _rebuild(): void;
  127458. /**
  127459. * Renders the layer in the scene.
  127460. */
  127461. render(): void;
  127462. /**
  127463. * Disposes and releases the associated ressources.
  127464. */
  127465. dispose(): void;
  127466. }
  127467. }
  127468. declare module BABYLON {
  127469. /** @hidden */
  127470. export var lensFlarePixelShader: {
  127471. name: string;
  127472. shader: string;
  127473. };
  127474. }
  127475. declare module BABYLON {
  127476. /** @hidden */
  127477. export var lensFlareVertexShader: {
  127478. name: string;
  127479. shader: string;
  127480. };
  127481. }
  127482. declare module BABYLON {
  127483. /**
  127484. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127485. * It is usually composed of several `lensFlare`.
  127486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127487. */
  127488. export class LensFlareSystem {
  127489. /**
  127490. * Define the name of the lens flare system
  127491. */
  127492. name: string;
  127493. /**
  127494. * List of lens flares used in this system.
  127495. */
  127496. lensFlares: LensFlare[];
  127497. /**
  127498. * Define a limit from the border the lens flare can be visible.
  127499. */
  127500. borderLimit: number;
  127501. /**
  127502. * Define a viewport border we do not want to see the lens flare in.
  127503. */
  127504. viewportBorder: number;
  127505. /**
  127506. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127507. */
  127508. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127509. /**
  127510. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127511. */
  127512. layerMask: number;
  127513. /**
  127514. * Define the id of the lens flare system in the scene.
  127515. * (equal to name by default)
  127516. */
  127517. id: string;
  127518. private _scene;
  127519. private _emitter;
  127520. private _vertexBuffers;
  127521. private _indexBuffer;
  127522. private _effect;
  127523. private _positionX;
  127524. private _positionY;
  127525. private _isEnabled;
  127526. /** @hidden */
  127527. static _SceneComponentInitialization: (scene: Scene) => void;
  127528. /**
  127529. * Instantiates a lens flare system.
  127530. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127531. * It is usually composed of several `lensFlare`.
  127532. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127533. * @param name Define the name of the lens flare system in the scene
  127534. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127535. * @param scene Define the scene the lens flare system belongs to
  127536. */
  127537. constructor(
  127538. /**
  127539. * Define the name of the lens flare system
  127540. */
  127541. name: string, emitter: any, scene: Scene);
  127542. /**
  127543. * Define if the lens flare system is enabled.
  127544. */
  127545. get isEnabled(): boolean;
  127546. set isEnabled(value: boolean);
  127547. /**
  127548. * Get the scene the effects belongs to.
  127549. * @returns the scene holding the lens flare system
  127550. */
  127551. getScene(): Scene;
  127552. /**
  127553. * Get the emitter of the lens flare system.
  127554. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127555. * @returns the emitter of the lens flare system
  127556. */
  127557. getEmitter(): any;
  127558. /**
  127559. * Set the emitter of the lens flare system.
  127560. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127561. * @param newEmitter Define the new emitter of the system
  127562. */
  127563. setEmitter(newEmitter: any): void;
  127564. /**
  127565. * Get the lens flare system emitter position.
  127566. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127567. * @returns the position
  127568. */
  127569. getEmitterPosition(): Vector3;
  127570. /**
  127571. * @hidden
  127572. */
  127573. computeEffectivePosition(globalViewport: Viewport): boolean;
  127574. /** @hidden */
  127575. _isVisible(): boolean;
  127576. /**
  127577. * @hidden
  127578. */
  127579. render(): boolean;
  127580. /**
  127581. * Dispose and release the lens flare with its associated resources.
  127582. */
  127583. dispose(): void;
  127584. /**
  127585. * Parse a lens flare system from a JSON repressentation
  127586. * @param parsedLensFlareSystem Define the JSON to parse
  127587. * @param scene Define the scene the parsed system should be instantiated in
  127588. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127589. * @returns the parsed system
  127590. */
  127591. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127592. /**
  127593. * Serialize the current Lens Flare System into a JSON representation.
  127594. * @returns the serialized JSON
  127595. */
  127596. serialize(): any;
  127597. }
  127598. }
  127599. declare module BABYLON {
  127600. /**
  127601. * This represents one of the lens effect in a `lensFlareSystem`.
  127602. * It controls one of the indiviual texture used in the effect.
  127603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127604. */
  127605. export class LensFlare {
  127606. /**
  127607. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127608. */
  127609. size: number;
  127610. /**
  127611. * 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.
  127612. */
  127613. position: number;
  127614. /**
  127615. * Define the lens color.
  127616. */
  127617. color: Color3;
  127618. /**
  127619. * Define the lens texture.
  127620. */
  127621. texture: Nullable<Texture>;
  127622. /**
  127623. * Define the alpha mode to render this particular lens.
  127624. */
  127625. alphaMode: number;
  127626. private _system;
  127627. /**
  127628. * Creates a new Lens Flare.
  127629. * This represents one of the lens effect in a `lensFlareSystem`.
  127630. * It controls one of the indiviual texture used in the effect.
  127631. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127632. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127633. * @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.
  127634. * @param color Define the lens color
  127635. * @param imgUrl Define the lens texture url
  127636. * @param system Define the `lensFlareSystem` this flare is part of
  127637. * @returns The newly created Lens Flare
  127638. */
  127639. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127640. /**
  127641. * Instantiates a new Lens Flare.
  127642. * This represents one of the lens effect in a `lensFlareSystem`.
  127643. * It controls one of the indiviual texture used in the effect.
  127644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127645. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127646. * @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.
  127647. * @param color Define the lens color
  127648. * @param imgUrl Define the lens texture url
  127649. * @param system Define the `lensFlareSystem` this flare is part of
  127650. */
  127651. constructor(
  127652. /**
  127653. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127654. */
  127655. size: number,
  127656. /**
  127657. * 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.
  127658. */
  127659. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127660. /**
  127661. * Dispose and release the lens flare with its associated resources.
  127662. */
  127663. dispose(): void;
  127664. }
  127665. }
  127666. declare module BABYLON {
  127667. interface AbstractScene {
  127668. /**
  127669. * The list of lens flare system added to the scene
  127670. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127671. */
  127672. lensFlareSystems: Array<LensFlareSystem>;
  127673. /**
  127674. * Removes the given lens flare system from this scene.
  127675. * @param toRemove The lens flare system to remove
  127676. * @returns The index of the removed lens flare system
  127677. */
  127678. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127679. /**
  127680. * Adds the given lens flare system to this scene
  127681. * @param newLensFlareSystem The lens flare system to add
  127682. */
  127683. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127684. /**
  127685. * Gets a lens flare system using its name
  127686. * @param name defines the name to look for
  127687. * @returns the lens flare system or null if not found
  127688. */
  127689. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127690. /**
  127691. * Gets a lens flare system using its id
  127692. * @param id defines the id to look for
  127693. * @returns the lens flare system or null if not found
  127694. */
  127695. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127696. }
  127697. /**
  127698. * Defines the lens flare scene component responsible to manage any lens flares
  127699. * in a given scene.
  127700. */
  127701. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127702. /**
  127703. * The component name helpfull to identify the component in the list of scene components.
  127704. */
  127705. readonly name: string;
  127706. /**
  127707. * The scene the component belongs to.
  127708. */
  127709. scene: Scene;
  127710. /**
  127711. * Creates a new instance of the component for the given scene
  127712. * @param scene Defines the scene to register the component in
  127713. */
  127714. constructor(scene: Scene);
  127715. /**
  127716. * Registers the component in a given scene
  127717. */
  127718. register(): void;
  127719. /**
  127720. * Rebuilds the elements related to this component in case of
  127721. * context lost for instance.
  127722. */
  127723. rebuild(): void;
  127724. /**
  127725. * Adds all the elements from the container to the scene
  127726. * @param container the container holding the elements
  127727. */
  127728. addFromContainer(container: AbstractScene): void;
  127729. /**
  127730. * Removes all the elements in the container from the scene
  127731. * @param container contains the elements to remove
  127732. * @param dispose if the removed element should be disposed (default: false)
  127733. */
  127734. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127735. /**
  127736. * Serializes the component data to the specified json object
  127737. * @param serializationObject The object to serialize to
  127738. */
  127739. serialize(serializationObject: any): void;
  127740. /**
  127741. * Disposes the component and the associated ressources.
  127742. */
  127743. dispose(): void;
  127744. private _draw;
  127745. }
  127746. }
  127747. declare module BABYLON {
  127748. /** @hidden */
  127749. export var depthPixelShader: {
  127750. name: string;
  127751. shader: string;
  127752. };
  127753. }
  127754. declare module BABYLON {
  127755. /** @hidden */
  127756. export var depthVertexShader: {
  127757. name: string;
  127758. shader: string;
  127759. };
  127760. }
  127761. declare module BABYLON {
  127762. /**
  127763. * This represents a depth renderer in Babylon.
  127764. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127765. */
  127766. export class DepthRenderer {
  127767. private _scene;
  127768. private _depthMap;
  127769. private _effect;
  127770. private readonly _storeNonLinearDepth;
  127771. private readonly _clearColor;
  127772. /** Get if the depth renderer is using packed depth or not */
  127773. readonly isPacked: boolean;
  127774. private _cachedDefines;
  127775. private _camera;
  127776. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127777. enabled: boolean;
  127778. /**
  127779. * Specifiess that the depth renderer will only be used within
  127780. * the camera it is created for.
  127781. * This can help forcing its rendering during the camera processing.
  127782. */
  127783. useOnlyInActiveCamera: boolean;
  127784. /** @hidden */
  127785. static _SceneComponentInitialization: (scene: Scene) => void;
  127786. /**
  127787. * Instantiates a depth renderer
  127788. * @param scene The scene the renderer belongs to
  127789. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127790. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127791. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127792. */
  127793. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127794. /**
  127795. * Creates the depth rendering effect and checks if the effect is ready.
  127796. * @param subMesh The submesh to be used to render the depth map of
  127797. * @param useInstances If multiple world instances should be used
  127798. * @returns if the depth renderer is ready to render the depth map
  127799. */
  127800. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127801. /**
  127802. * Gets the texture which the depth map will be written to.
  127803. * @returns The depth map texture
  127804. */
  127805. getDepthMap(): RenderTargetTexture;
  127806. /**
  127807. * Disposes of the depth renderer.
  127808. */
  127809. dispose(): void;
  127810. }
  127811. }
  127812. declare module BABYLON {
  127813. /** @hidden */
  127814. export var minmaxReduxPixelShader: {
  127815. name: string;
  127816. shader: string;
  127817. };
  127818. }
  127819. declare module BABYLON {
  127820. /**
  127821. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127822. * and maximum values from all values of the texture.
  127823. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127824. * The source values are read from the red channel of the texture.
  127825. */
  127826. export class MinMaxReducer {
  127827. /**
  127828. * Observable triggered when the computation has been performed
  127829. */
  127830. onAfterReductionPerformed: Observable<{
  127831. min: number;
  127832. max: number;
  127833. }>;
  127834. protected _camera: Camera;
  127835. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127836. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127837. protected _postProcessManager: PostProcessManager;
  127838. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127839. protected _forceFullscreenViewport: boolean;
  127840. /**
  127841. * Creates a min/max reducer
  127842. * @param camera The camera to use for the post processes
  127843. */
  127844. constructor(camera: Camera);
  127845. /**
  127846. * Gets the texture used to read the values from.
  127847. */
  127848. get sourceTexture(): Nullable<RenderTargetTexture>;
  127849. /**
  127850. * Sets the source texture to read the values from.
  127851. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127852. * because in such textures '1' value must not be taken into account to compute the maximum
  127853. * as this value is used to clear the texture.
  127854. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127855. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127856. * @param depthRedux Indicates if the texture is a depth texture or not
  127857. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127858. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127859. */
  127860. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127861. /**
  127862. * Defines the refresh rate of the computation.
  127863. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127864. */
  127865. get refreshRate(): number;
  127866. set refreshRate(value: number);
  127867. protected _activated: boolean;
  127868. /**
  127869. * Gets the activation status of the reducer
  127870. */
  127871. get activated(): boolean;
  127872. /**
  127873. * Activates the reduction computation.
  127874. * When activated, the observers registered in onAfterReductionPerformed are
  127875. * called after the compuation is performed
  127876. */
  127877. activate(): void;
  127878. /**
  127879. * Deactivates the reduction computation.
  127880. */
  127881. deactivate(): void;
  127882. /**
  127883. * Disposes the min/max reducer
  127884. * @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.
  127885. */
  127886. dispose(disposeAll?: boolean): void;
  127887. }
  127888. }
  127889. declare module BABYLON {
  127890. /**
  127891. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127892. */
  127893. export class DepthReducer extends MinMaxReducer {
  127894. private _depthRenderer;
  127895. private _depthRendererId;
  127896. /**
  127897. * Gets the depth renderer used for the computation.
  127898. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127899. */
  127900. get depthRenderer(): Nullable<DepthRenderer>;
  127901. /**
  127902. * Creates a depth reducer
  127903. * @param camera The camera used to render the depth texture
  127904. */
  127905. constructor(camera: Camera);
  127906. /**
  127907. * Sets the depth renderer to use to generate the depth map
  127908. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127909. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127910. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127911. */
  127912. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127913. /** @hidden */
  127914. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127915. /**
  127916. * Activates the reduction computation.
  127917. * When activated, the observers registered in onAfterReductionPerformed are
  127918. * called after the compuation is performed
  127919. */
  127920. activate(): void;
  127921. /**
  127922. * Deactivates the reduction computation.
  127923. */
  127924. deactivate(): void;
  127925. /**
  127926. * Disposes the depth reducer
  127927. * @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.
  127928. */
  127929. dispose(disposeAll?: boolean): void;
  127930. }
  127931. }
  127932. declare module BABYLON {
  127933. /**
  127934. * A CSM implementation allowing casting shadows on large scenes.
  127935. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127936. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127937. */
  127938. export class CascadedShadowGenerator extends ShadowGenerator {
  127939. private static readonly frustumCornersNDCSpace;
  127940. /**
  127941. * Name of the CSM class
  127942. */
  127943. static CLASSNAME: string;
  127944. /**
  127945. * Defines the default number of cascades used by the CSM.
  127946. */
  127947. static readonly DEFAULT_CASCADES_COUNT: number;
  127948. /**
  127949. * Defines the minimum number of cascades used by the CSM.
  127950. */
  127951. static readonly MIN_CASCADES_COUNT: number;
  127952. /**
  127953. * Defines the maximum number of cascades used by the CSM.
  127954. */
  127955. static readonly MAX_CASCADES_COUNT: number;
  127956. protected _validateFilter(filter: number): number;
  127957. /**
  127958. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127959. */
  127960. penumbraDarkness: number;
  127961. private _numCascades;
  127962. /**
  127963. * Gets or set the number of cascades used by the CSM.
  127964. */
  127965. get numCascades(): number;
  127966. set numCascades(value: number);
  127967. /**
  127968. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127969. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127970. */
  127971. stabilizeCascades: boolean;
  127972. private _freezeShadowCastersBoundingInfo;
  127973. private _freezeShadowCastersBoundingInfoObservable;
  127974. /**
  127975. * Enables or disables the shadow casters bounding info computation.
  127976. * If your shadow casters don't move, you can disable this feature.
  127977. * If it is enabled, the bounding box computation is done every frame.
  127978. */
  127979. get freezeShadowCastersBoundingInfo(): boolean;
  127980. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127981. private _scbiMin;
  127982. private _scbiMax;
  127983. protected _computeShadowCastersBoundingInfo(): void;
  127984. protected _shadowCastersBoundingInfo: BoundingInfo;
  127985. /**
  127986. * Gets or sets the shadow casters bounding info.
  127987. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127988. * so that the system won't overwrite the bounds you provide
  127989. */
  127990. get shadowCastersBoundingInfo(): BoundingInfo;
  127991. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127992. protected _breaksAreDirty: boolean;
  127993. protected _minDistance: number;
  127994. protected _maxDistance: number;
  127995. /**
  127996. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127997. *
  127998. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127999. * If you don't know these values, simply leave them to their defaults and don't call this function.
  128000. * @param min minimal distance for the breaks (default to 0.)
  128001. * @param max maximal distance for the breaks (default to 1.)
  128002. */
  128003. setMinMaxDistance(min: number, max: number): void;
  128004. /** Gets the minimal distance used in the cascade break computation */
  128005. get minDistance(): number;
  128006. /** Gets the maximal distance used in the cascade break computation */
  128007. get maxDistance(): number;
  128008. /**
  128009. * Gets the class name of that object
  128010. * @returns "CascadedShadowGenerator"
  128011. */
  128012. getClassName(): string;
  128013. private _cascadeMinExtents;
  128014. private _cascadeMaxExtents;
  128015. /**
  128016. * Gets a cascade minimum extents
  128017. * @param cascadeIndex index of the cascade
  128018. * @returns the minimum cascade extents
  128019. */
  128020. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  128021. /**
  128022. * Gets a cascade maximum extents
  128023. * @param cascadeIndex index of the cascade
  128024. * @returns the maximum cascade extents
  128025. */
  128026. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  128027. private _cascades;
  128028. private _currentLayer;
  128029. private _viewSpaceFrustumsZ;
  128030. private _viewMatrices;
  128031. private _projectionMatrices;
  128032. private _transformMatrices;
  128033. private _transformMatricesAsArray;
  128034. private _frustumLengths;
  128035. private _lightSizeUVCorrection;
  128036. private _depthCorrection;
  128037. private _frustumCornersWorldSpace;
  128038. private _frustumCenter;
  128039. private _shadowCameraPos;
  128040. private _shadowMaxZ;
  128041. /**
  128042. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  128043. * It defaults to camera.maxZ
  128044. */
  128045. get shadowMaxZ(): number;
  128046. /**
  128047. * Sets the shadow max z distance.
  128048. */
  128049. set shadowMaxZ(value: number);
  128050. protected _debug: boolean;
  128051. /**
  128052. * Gets or sets the debug flag.
  128053. * When enabled, the cascades are materialized by different colors on the screen.
  128054. */
  128055. get debug(): boolean;
  128056. set debug(dbg: boolean);
  128057. private _depthClamp;
  128058. /**
  128059. * Gets or sets the depth clamping value.
  128060. *
  128061. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  128062. * to account for the shadow casters far away.
  128063. *
  128064. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  128065. */
  128066. get depthClamp(): boolean;
  128067. set depthClamp(value: boolean);
  128068. private _cascadeBlendPercentage;
  128069. /**
  128070. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  128071. * It defaults to 0.1 (10% blending).
  128072. */
  128073. get cascadeBlendPercentage(): number;
  128074. set cascadeBlendPercentage(value: number);
  128075. private _lambda;
  128076. /**
  128077. * Gets or set the lambda parameter.
  128078. * This parameter is used to split the camera frustum and create the cascades.
  128079. * 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.
  128080. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  128081. */
  128082. get lambda(): number;
  128083. set lambda(value: number);
  128084. /**
  128085. * Gets the view matrix corresponding to a given cascade
  128086. * @param cascadeNum cascade to retrieve the view matrix from
  128087. * @returns the cascade view matrix
  128088. */
  128089. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  128090. /**
  128091. * Gets the projection matrix corresponding to a given cascade
  128092. * @param cascadeNum cascade to retrieve the projection matrix from
  128093. * @returns the cascade projection matrix
  128094. */
  128095. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  128096. /**
  128097. * Gets the transformation matrix corresponding to a given cascade
  128098. * @param cascadeNum cascade to retrieve the transformation matrix from
  128099. * @returns the cascade transformation matrix
  128100. */
  128101. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  128102. private _depthRenderer;
  128103. /**
  128104. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  128105. *
  128106. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  128107. *
  128108. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  128109. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  128110. * @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
  128111. */
  128112. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  128113. private _depthReducer;
  128114. private _autoCalcDepthBounds;
  128115. /**
  128116. * Gets or sets the autoCalcDepthBounds property.
  128117. *
  128118. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  128119. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  128120. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  128121. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  128122. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  128123. */
  128124. get autoCalcDepthBounds(): boolean;
  128125. set autoCalcDepthBounds(value: boolean);
  128126. /**
  128127. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  128128. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128129. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  128130. * for setting the refresh rate on the renderer yourself!
  128131. */
  128132. get autoCalcDepthBoundsRefreshRate(): number;
  128133. set autoCalcDepthBoundsRefreshRate(value: number);
  128134. /**
  128135. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  128136. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  128137. * you change the camera near/far planes!
  128138. */
  128139. splitFrustum(): void;
  128140. private _splitFrustum;
  128141. private _computeMatrices;
  128142. private _computeFrustumInWorldSpace;
  128143. private _computeCascadeFrustum;
  128144. /** @hidden */
  128145. static _SceneComponentInitialization: (scene: Scene) => void;
  128146. /**
  128147. * Creates a Cascaded Shadow Generator object.
  128148. * A ShadowGenerator is the required tool to use the shadows.
  128149. * Each directional light casting shadows needs to use its own ShadowGenerator.
  128150. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128151. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  128152. * @param light The directional light object generating the shadows.
  128153. * @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.
  128154. */
  128155. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  128156. protected _initializeGenerator(): void;
  128157. protected _createTargetRenderTexture(): void;
  128158. protected _initializeShadowMap(): void;
  128159. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  128160. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  128161. /**
  128162. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  128163. * @param defines Defines of the material we want to update
  128164. * @param lightIndex Index of the light in the enabled light list of the material
  128165. */
  128166. prepareDefines(defines: any, lightIndex: number): void;
  128167. /**
  128168. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  128169. * defined in the generator but impacting the effect).
  128170. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  128171. * @param effect The effect we are binfing the information for
  128172. */
  128173. bindShadowLight(lightIndex: string, effect: Effect): void;
  128174. /**
  128175. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  128176. * (eq to view projection * shadow projection matrices)
  128177. * @returns The transform matrix used to create the shadow map
  128178. */
  128179. getTransformMatrix(): Matrix;
  128180. /**
  128181. * Disposes the ShadowGenerator.
  128182. * Returns nothing.
  128183. */
  128184. dispose(): void;
  128185. /**
  128186. * Serializes the shadow generator setup to a json object.
  128187. * @returns The serialized JSON object
  128188. */
  128189. serialize(): any;
  128190. /**
  128191. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  128192. * @param parsedShadowGenerator The JSON object to parse
  128193. * @param scene The scene to create the shadow map for
  128194. * @returns The parsed shadow generator
  128195. */
  128196. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  128197. }
  128198. }
  128199. declare module BABYLON {
  128200. /**
  128201. * Defines the shadow generator component responsible to manage any shadow generators
  128202. * in a given scene.
  128203. */
  128204. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  128205. /**
  128206. * The component name helpfull to identify the component in the list of scene components.
  128207. */
  128208. readonly name: string;
  128209. /**
  128210. * The scene the component belongs to.
  128211. */
  128212. scene: Scene;
  128213. /**
  128214. * Creates a new instance of the component for the given scene
  128215. * @param scene Defines the scene to register the component in
  128216. */
  128217. constructor(scene: Scene);
  128218. /**
  128219. * Registers the component in a given scene
  128220. */
  128221. register(): void;
  128222. /**
  128223. * Rebuilds the elements related to this component in case of
  128224. * context lost for instance.
  128225. */
  128226. rebuild(): void;
  128227. /**
  128228. * Serializes the component data to the specified json object
  128229. * @param serializationObject The object to serialize to
  128230. */
  128231. serialize(serializationObject: any): void;
  128232. /**
  128233. * Adds all the elements from the container to the scene
  128234. * @param container the container holding the elements
  128235. */
  128236. addFromContainer(container: AbstractScene): void;
  128237. /**
  128238. * Removes all the elements in the container from the scene
  128239. * @param container contains the elements to remove
  128240. * @param dispose if the removed element should be disposed (default: false)
  128241. */
  128242. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128243. /**
  128244. * Rebuilds the elements related to this component in case of
  128245. * context lost for instance.
  128246. */
  128247. dispose(): void;
  128248. private _gatherRenderTargets;
  128249. }
  128250. }
  128251. declare module BABYLON {
  128252. /**
  128253. * A point light is a light defined by an unique point in world space.
  128254. * The light is emitted in every direction from this point.
  128255. * A good example of a point light is a standard light bulb.
  128256. * Documentation: https://doc.babylonjs.com/babylon101/lights
  128257. */
  128258. export class PointLight extends ShadowLight {
  128259. private _shadowAngle;
  128260. /**
  128261. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128262. * This specifies what angle the shadow will use to be created.
  128263. *
  128264. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128265. */
  128266. get shadowAngle(): number;
  128267. /**
  128268. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128269. * This specifies what angle the shadow will use to be created.
  128270. *
  128271. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128272. */
  128273. set shadowAngle(value: number);
  128274. /**
  128275. * Gets the direction if it has been set.
  128276. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128277. */
  128278. get direction(): Vector3;
  128279. /**
  128280. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128281. */
  128282. set direction(value: Vector3);
  128283. /**
  128284. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  128285. * A PointLight emits the light in every direction.
  128286. * It can cast shadows.
  128287. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  128288. * ```javascript
  128289. * var pointLight = new PointLight("pl", camera.position, scene);
  128290. * ```
  128291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  128292. * @param name The light friendly name
  128293. * @param position The position of the point light in the scene
  128294. * @param scene The scene the lights belongs to
  128295. */
  128296. constructor(name: string, position: Vector3, scene: Scene);
  128297. /**
  128298. * Returns the string "PointLight"
  128299. * @returns the class name
  128300. */
  128301. getClassName(): string;
  128302. /**
  128303. * Returns the integer 0.
  128304. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  128305. */
  128306. getTypeID(): number;
  128307. /**
  128308. * Specifies wether or not the shadowmap should be a cube texture.
  128309. * @returns true if the shadowmap needs to be a cube texture.
  128310. */
  128311. needCube(): boolean;
  128312. /**
  128313. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  128314. * @param faceIndex The index of the face we are computed the direction to generate shadow
  128315. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  128316. */
  128317. getShadowDirection(faceIndex?: number): Vector3;
  128318. /**
  128319. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  128320. * - fov = PI / 2
  128321. * - aspect ratio : 1.0
  128322. * - z-near and far equal to the active camera minZ and maxZ.
  128323. * Returns the PointLight.
  128324. */
  128325. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  128326. protected _buildUniformLayout(): void;
  128327. /**
  128328. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  128329. * @param effect The effect to update
  128330. * @param lightIndex The index of the light in the effect to update
  128331. * @returns The point light
  128332. */
  128333. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  128334. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  128335. /**
  128336. * Prepares the list of defines specific to the light type.
  128337. * @param defines the list of defines
  128338. * @param lightIndex defines the index of the light for the effect
  128339. */
  128340. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  128341. }
  128342. }
  128343. declare module BABYLON {
  128344. /**
  128345. * Header information of HDR texture files.
  128346. */
  128347. export interface HDRInfo {
  128348. /**
  128349. * The height of the texture in pixels.
  128350. */
  128351. height: number;
  128352. /**
  128353. * The width of the texture in pixels.
  128354. */
  128355. width: number;
  128356. /**
  128357. * The index of the beginning of the data in the binary file.
  128358. */
  128359. dataPosition: number;
  128360. }
  128361. /**
  128362. * This groups tools to convert HDR texture to native colors array.
  128363. */
  128364. export class HDRTools {
  128365. private static Ldexp;
  128366. private static Rgbe2float;
  128367. private static readStringLine;
  128368. /**
  128369. * Reads header information from an RGBE texture stored in a native array.
  128370. * More information on this format are available here:
  128371. * https://en.wikipedia.org/wiki/RGBE_image_format
  128372. *
  128373. * @param uint8array The binary file stored in native array.
  128374. * @return The header information.
  128375. */
  128376. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  128377. /**
  128378. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  128379. * This RGBE texture needs to store the information as a panorama.
  128380. *
  128381. * More information on this format are available here:
  128382. * https://en.wikipedia.org/wiki/RGBE_image_format
  128383. *
  128384. * @param buffer The binary file stored in an array buffer.
  128385. * @param size The expected size of the extracted cubemap.
  128386. * @return The Cube Map information.
  128387. */
  128388. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  128389. /**
  128390. * Returns the pixels data extracted from an RGBE texture.
  128391. * This pixels will be stored left to right up to down in the R G B order in one array.
  128392. *
  128393. * More information on this format are available here:
  128394. * https://en.wikipedia.org/wiki/RGBE_image_format
  128395. *
  128396. * @param uint8array The binary file stored in an array buffer.
  128397. * @param hdrInfo The header information of the file.
  128398. * @return The pixels data in RGB right to left up to down order.
  128399. */
  128400. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  128401. private static RGBE_ReadPixels_RLE;
  128402. }
  128403. }
  128404. declare module BABYLON {
  128405. /**
  128406. * This represents a texture coming from an HDR input.
  128407. *
  128408. * The only supported format is currently panorama picture stored in RGBE format.
  128409. * Example of such files can be found on HDRLib: http://hdrlib.com/
  128410. */
  128411. export class HDRCubeTexture extends BaseTexture {
  128412. private static _facesMapping;
  128413. private _generateHarmonics;
  128414. private _noMipmap;
  128415. private _textureMatrix;
  128416. private _size;
  128417. private _onLoad;
  128418. private _onError;
  128419. /**
  128420. * The texture URL.
  128421. */
  128422. url: string;
  128423. /**
  128424. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128425. */
  128426. coordinatesMode: number;
  128427. protected _isBlocking: boolean;
  128428. /**
  128429. * Sets wether or not the texture is blocking during loading.
  128430. */
  128431. set isBlocking(value: boolean);
  128432. /**
  128433. * Gets wether or not the texture is blocking during loading.
  128434. */
  128435. get isBlocking(): boolean;
  128436. protected _rotationY: number;
  128437. /**
  128438. * Sets texture matrix rotation angle around Y axis in radians.
  128439. */
  128440. set rotationY(value: number);
  128441. /**
  128442. * Gets texture matrix rotation angle around Y axis radians.
  128443. */
  128444. get rotationY(): number;
  128445. /**
  128446. * Gets or sets the center of the bounding box associated with the cube texture
  128447. * It must define where the camera used to render the texture was set
  128448. */
  128449. boundingBoxPosition: Vector3;
  128450. private _boundingBoxSize;
  128451. /**
  128452. * Gets or sets the size of the bounding box associated with the cube texture
  128453. * When defined, the cubemap will switch to local mode
  128454. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128455. * @example https://www.babylonjs-playground.com/#RNASML
  128456. */
  128457. set boundingBoxSize(value: Vector3);
  128458. get boundingBoxSize(): Vector3;
  128459. /**
  128460. * Instantiates an HDRTexture from the following parameters.
  128461. *
  128462. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128463. * @param scene The scene the texture will be used in
  128464. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128465. * @param noMipmap Forces to not generate the mipmap if true
  128466. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128467. * @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)
  128468. * @param reserved Reserved flag for internal use.
  128469. */
  128470. 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>);
  128471. /**
  128472. * Get the current class name of the texture useful for serialization or dynamic coding.
  128473. * @returns "HDRCubeTexture"
  128474. */
  128475. getClassName(): string;
  128476. /**
  128477. * Occurs when the file is raw .hdr file.
  128478. */
  128479. private loadTexture;
  128480. clone(): HDRCubeTexture;
  128481. delayLoad(): void;
  128482. /**
  128483. * Get the texture reflection matrix used to rotate/transform the reflection.
  128484. * @returns the reflection matrix
  128485. */
  128486. getReflectionTextureMatrix(): Matrix;
  128487. /**
  128488. * Set the texture reflection matrix used to rotate/transform the reflection.
  128489. * @param value Define the reflection matrix to set
  128490. */
  128491. setReflectionTextureMatrix(value: Matrix): void;
  128492. /**
  128493. * Parses a JSON representation of an HDR Texture in order to create the texture
  128494. * @param parsedTexture Define the JSON representation
  128495. * @param scene Define the scene the texture should be created in
  128496. * @param rootUrl Define the root url in case we need to load relative dependencies
  128497. * @returns the newly created texture after parsing
  128498. */
  128499. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128500. serialize(): any;
  128501. }
  128502. }
  128503. declare module BABYLON {
  128504. /**
  128505. * Class used to control physics engine
  128506. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128507. */
  128508. export class PhysicsEngine implements IPhysicsEngine {
  128509. private _physicsPlugin;
  128510. /**
  128511. * Global value used to control the smallest number supported by the simulation
  128512. */
  128513. static Epsilon: number;
  128514. private _impostors;
  128515. private _joints;
  128516. private _subTimeStep;
  128517. /**
  128518. * Gets the gravity vector used by the simulation
  128519. */
  128520. gravity: Vector3;
  128521. /**
  128522. * Factory used to create the default physics plugin.
  128523. * @returns The default physics plugin
  128524. */
  128525. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128526. /**
  128527. * Creates a new Physics Engine
  128528. * @param gravity defines the gravity vector used by the simulation
  128529. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128530. */
  128531. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128532. /**
  128533. * Sets the gravity vector used by the simulation
  128534. * @param gravity defines the gravity vector to use
  128535. */
  128536. setGravity(gravity: Vector3): void;
  128537. /**
  128538. * Set the time step of the physics engine.
  128539. * Default is 1/60.
  128540. * To slow it down, enter 1/600 for example.
  128541. * To speed it up, 1/30
  128542. * @param newTimeStep defines the new timestep to apply to this world.
  128543. */
  128544. setTimeStep(newTimeStep?: number): void;
  128545. /**
  128546. * Get the time step of the physics engine.
  128547. * @returns the current time step
  128548. */
  128549. getTimeStep(): number;
  128550. /**
  128551. * Set the sub time step of the physics engine.
  128552. * Default is 0 meaning there is no sub steps
  128553. * To increase physics resolution precision, set a small value (like 1 ms)
  128554. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128555. */
  128556. setSubTimeStep(subTimeStep?: number): void;
  128557. /**
  128558. * Get the sub time step of the physics engine.
  128559. * @returns the current sub time step
  128560. */
  128561. getSubTimeStep(): number;
  128562. /**
  128563. * Release all resources
  128564. */
  128565. dispose(): void;
  128566. /**
  128567. * Gets the name of the current physics plugin
  128568. * @returns the name of the plugin
  128569. */
  128570. getPhysicsPluginName(): string;
  128571. /**
  128572. * Adding a new impostor for the impostor tracking.
  128573. * This will be done by the impostor itself.
  128574. * @param impostor the impostor to add
  128575. */
  128576. addImpostor(impostor: PhysicsImpostor): void;
  128577. /**
  128578. * Remove an impostor from the engine.
  128579. * This impostor and its mesh will not longer be updated by the physics engine.
  128580. * @param impostor the impostor to remove
  128581. */
  128582. removeImpostor(impostor: PhysicsImpostor): void;
  128583. /**
  128584. * Add a joint to the physics engine
  128585. * @param mainImpostor defines the main impostor to which the joint is added.
  128586. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128587. * @param joint defines the joint that will connect both impostors.
  128588. */
  128589. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128590. /**
  128591. * Removes a joint from the simulation
  128592. * @param mainImpostor defines the impostor used with the joint
  128593. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128594. * @param joint defines the joint to remove
  128595. */
  128596. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128597. /**
  128598. * Called by the scene. No need to call it.
  128599. * @param delta defines the timespam between frames
  128600. */
  128601. _step(delta: number): void;
  128602. /**
  128603. * Gets the current plugin used to run the simulation
  128604. * @returns current plugin
  128605. */
  128606. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128607. /**
  128608. * Gets the list of physic impostors
  128609. * @returns an array of PhysicsImpostor
  128610. */
  128611. getImpostors(): Array<PhysicsImpostor>;
  128612. /**
  128613. * Gets the impostor for a physics enabled object
  128614. * @param object defines the object impersonated by the impostor
  128615. * @returns the PhysicsImpostor or null if not found
  128616. */
  128617. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128618. /**
  128619. * Gets the impostor for a physics body object
  128620. * @param body defines physics body used by the impostor
  128621. * @returns the PhysicsImpostor or null if not found
  128622. */
  128623. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128624. /**
  128625. * Does a raycast in the physics world
  128626. * @param from when should the ray start?
  128627. * @param to when should the ray end?
  128628. * @returns PhysicsRaycastResult
  128629. */
  128630. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128631. }
  128632. }
  128633. declare module BABYLON {
  128634. /** @hidden */
  128635. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128636. private _useDeltaForWorldStep;
  128637. world: any;
  128638. name: string;
  128639. private _physicsMaterials;
  128640. private _fixedTimeStep;
  128641. private _cannonRaycastResult;
  128642. private _raycastResult;
  128643. private _physicsBodysToRemoveAfterStep;
  128644. BJSCANNON: any;
  128645. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128646. setGravity(gravity: Vector3): void;
  128647. setTimeStep(timeStep: number): void;
  128648. getTimeStep(): number;
  128649. executeStep(delta: number): void;
  128650. private _removeMarkedPhysicsBodiesFromWorld;
  128651. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128652. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128653. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128654. private _processChildMeshes;
  128655. removePhysicsBody(impostor: PhysicsImpostor): void;
  128656. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128657. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128658. private _addMaterial;
  128659. private _checkWithEpsilon;
  128660. private _createShape;
  128661. private _createHeightmap;
  128662. private _minus90X;
  128663. private _plus90X;
  128664. private _tmpPosition;
  128665. private _tmpDeltaPosition;
  128666. private _tmpUnityRotation;
  128667. private _updatePhysicsBodyTransformation;
  128668. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128669. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128670. isSupported(): boolean;
  128671. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128672. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128673. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128674. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128675. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128676. getBodyMass(impostor: PhysicsImpostor): number;
  128677. getBodyFriction(impostor: PhysicsImpostor): number;
  128678. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128679. getBodyRestitution(impostor: PhysicsImpostor): number;
  128680. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128681. sleepBody(impostor: PhysicsImpostor): void;
  128682. wakeUpBody(impostor: PhysicsImpostor): void;
  128683. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128684. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128685. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128686. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128687. getRadius(impostor: PhysicsImpostor): number;
  128688. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128689. dispose(): void;
  128690. private _extendNamespace;
  128691. /**
  128692. * Does a raycast in the physics world
  128693. * @param from when should the ray start?
  128694. * @param to when should the ray end?
  128695. * @returns PhysicsRaycastResult
  128696. */
  128697. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128698. }
  128699. }
  128700. declare module BABYLON {
  128701. /** @hidden */
  128702. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128703. world: any;
  128704. name: string;
  128705. BJSOIMO: any;
  128706. private _raycastResult;
  128707. constructor(iterations?: number, oimoInjection?: any);
  128708. setGravity(gravity: Vector3): void;
  128709. setTimeStep(timeStep: number): void;
  128710. getTimeStep(): number;
  128711. private _tmpImpostorsArray;
  128712. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128713. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128714. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128715. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128716. private _tmpPositionVector;
  128717. removePhysicsBody(impostor: PhysicsImpostor): void;
  128718. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128719. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128720. isSupported(): boolean;
  128721. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128722. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128723. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128724. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128725. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128726. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128727. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128728. getBodyMass(impostor: PhysicsImpostor): number;
  128729. getBodyFriction(impostor: PhysicsImpostor): number;
  128730. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128731. getBodyRestitution(impostor: PhysicsImpostor): number;
  128732. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128733. sleepBody(impostor: PhysicsImpostor): void;
  128734. wakeUpBody(impostor: PhysicsImpostor): void;
  128735. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128736. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128737. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128738. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128739. getRadius(impostor: PhysicsImpostor): number;
  128740. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128741. dispose(): void;
  128742. /**
  128743. * Does a raycast in the physics world
  128744. * @param from when should the ray start?
  128745. * @param to when should the ray end?
  128746. * @returns PhysicsRaycastResult
  128747. */
  128748. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128749. }
  128750. }
  128751. declare module BABYLON {
  128752. /**
  128753. * Class containing static functions to help procedurally build meshes
  128754. */
  128755. export class RibbonBuilder {
  128756. /**
  128757. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128758. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128759. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128760. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128761. * * 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
  128762. * * 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
  128763. * * 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
  128764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128767. * * 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
  128768. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128769. * * 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
  128770. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128772. * @param name defines the name of the mesh
  128773. * @param options defines the options used to create the mesh
  128774. * @param scene defines the hosting scene
  128775. * @returns the ribbon mesh
  128776. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128777. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128778. */
  128779. static CreateRibbon(name: string, options: {
  128780. pathArray: Vector3[][];
  128781. closeArray?: boolean;
  128782. closePath?: boolean;
  128783. offset?: number;
  128784. updatable?: boolean;
  128785. sideOrientation?: number;
  128786. frontUVs?: Vector4;
  128787. backUVs?: Vector4;
  128788. instance?: Mesh;
  128789. invertUV?: boolean;
  128790. uvs?: Vector2[];
  128791. colors?: Color4[];
  128792. }, scene?: Nullable<Scene>): Mesh;
  128793. }
  128794. }
  128795. declare module BABYLON {
  128796. /**
  128797. * Class containing static functions to help procedurally build meshes
  128798. */
  128799. export class ShapeBuilder {
  128800. /**
  128801. * 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.
  128802. * * 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.
  128803. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128804. * * 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.
  128805. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128806. * * 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
  128807. * * 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
  128808. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128813. * @param name defines the name of the mesh
  128814. * @param options defines the options used to create the mesh
  128815. * @param scene defines the hosting scene
  128816. * @returns the extruded shape mesh
  128817. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128819. */
  128820. static ExtrudeShape(name: string, options: {
  128821. shape: Vector3[];
  128822. path: Vector3[];
  128823. scale?: number;
  128824. rotation?: number;
  128825. cap?: number;
  128826. updatable?: boolean;
  128827. sideOrientation?: number;
  128828. frontUVs?: Vector4;
  128829. backUVs?: Vector4;
  128830. instance?: Mesh;
  128831. invertUV?: boolean;
  128832. }, scene?: Nullable<Scene>): Mesh;
  128833. /**
  128834. * Creates an custom extruded shape mesh.
  128835. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128836. * * 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.
  128837. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128838. * * 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
  128839. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128840. * * 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
  128841. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128842. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128843. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128844. * * 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
  128845. * * 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
  128846. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128851. * @param name defines the name of the mesh
  128852. * @param options defines the options used to create the mesh
  128853. * @param scene defines the hosting scene
  128854. * @returns the custom extruded shape mesh
  128855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128858. */
  128859. static ExtrudeShapeCustom(name: string, options: {
  128860. shape: Vector3[];
  128861. path: Vector3[];
  128862. scaleFunction?: any;
  128863. rotationFunction?: any;
  128864. ribbonCloseArray?: boolean;
  128865. ribbonClosePath?: boolean;
  128866. cap?: number;
  128867. updatable?: boolean;
  128868. sideOrientation?: number;
  128869. frontUVs?: Vector4;
  128870. backUVs?: Vector4;
  128871. instance?: Mesh;
  128872. invertUV?: boolean;
  128873. }, scene?: Nullable<Scene>): Mesh;
  128874. private static _ExtrudeShapeGeneric;
  128875. }
  128876. }
  128877. declare module BABYLON {
  128878. /**
  128879. * AmmoJS Physics plugin
  128880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128881. * @see https://github.com/kripken/ammo.js/
  128882. */
  128883. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128884. private _useDeltaForWorldStep;
  128885. /**
  128886. * Reference to the Ammo library
  128887. */
  128888. bjsAMMO: any;
  128889. /**
  128890. * Created ammoJS world which physics bodies are added to
  128891. */
  128892. world: any;
  128893. /**
  128894. * Name of the plugin
  128895. */
  128896. name: string;
  128897. private _timeStep;
  128898. private _fixedTimeStep;
  128899. private _maxSteps;
  128900. private _tmpQuaternion;
  128901. private _tmpAmmoTransform;
  128902. private _tmpAmmoQuaternion;
  128903. private _tmpAmmoConcreteContactResultCallback;
  128904. private _collisionConfiguration;
  128905. private _dispatcher;
  128906. private _overlappingPairCache;
  128907. private _solver;
  128908. private _softBodySolver;
  128909. private _tmpAmmoVectorA;
  128910. private _tmpAmmoVectorB;
  128911. private _tmpAmmoVectorC;
  128912. private _tmpAmmoVectorD;
  128913. private _tmpContactCallbackResult;
  128914. private _tmpAmmoVectorRCA;
  128915. private _tmpAmmoVectorRCB;
  128916. private _raycastResult;
  128917. private static readonly DISABLE_COLLISION_FLAG;
  128918. private static readonly KINEMATIC_FLAG;
  128919. private static readonly DISABLE_DEACTIVATION_FLAG;
  128920. /**
  128921. * Initializes the ammoJS plugin
  128922. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128923. * @param ammoInjection can be used to inject your own ammo reference
  128924. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128925. */
  128926. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128927. /**
  128928. * Sets the gravity of the physics world (m/(s^2))
  128929. * @param gravity Gravity to set
  128930. */
  128931. setGravity(gravity: Vector3): void;
  128932. /**
  128933. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128934. * @param timeStep timestep to use in seconds
  128935. */
  128936. setTimeStep(timeStep: number): void;
  128937. /**
  128938. * 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)
  128939. * @param fixedTimeStep fixedTimeStep to use in seconds
  128940. */
  128941. setFixedTimeStep(fixedTimeStep: number): void;
  128942. /**
  128943. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128944. * @param maxSteps the maximum number of steps by the physics engine per frame
  128945. */
  128946. setMaxSteps(maxSteps: number): void;
  128947. /**
  128948. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128949. * @returns the current timestep in seconds
  128950. */
  128951. getTimeStep(): number;
  128952. /**
  128953. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128954. */
  128955. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128956. private _isImpostorInContact;
  128957. private _isImpostorPairInContact;
  128958. private _stepSimulation;
  128959. /**
  128960. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128961. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128962. * After the step the babylon meshes are set to the position of the physics imposters
  128963. * @param delta amount of time to step forward
  128964. * @param impostors array of imposters to update before/after the step
  128965. */
  128966. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128967. /**
  128968. * Update babylon mesh to match physics world object
  128969. * @param impostor imposter to match
  128970. */
  128971. private _afterSoftStep;
  128972. /**
  128973. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128974. * @param impostor imposter to match
  128975. */
  128976. private _ropeStep;
  128977. /**
  128978. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128979. * @param impostor imposter to match
  128980. */
  128981. private _softbodyOrClothStep;
  128982. private _tmpVector;
  128983. private _tmpMatrix;
  128984. /**
  128985. * Applies an impulse on the imposter
  128986. * @param impostor imposter to apply impulse to
  128987. * @param force amount of force to be applied to the imposter
  128988. * @param contactPoint the location to apply the impulse on the imposter
  128989. */
  128990. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128991. /**
  128992. * Applies a force on the imposter
  128993. * @param impostor imposter to apply force
  128994. * @param force amount of force to be applied to the imposter
  128995. * @param contactPoint the location to apply the force on the imposter
  128996. */
  128997. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128998. /**
  128999. * Creates a physics body using the plugin
  129000. * @param impostor the imposter to create the physics body on
  129001. */
  129002. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129003. /**
  129004. * Removes the physics body from the imposter and disposes of the body's memory
  129005. * @param impostor imposter to remove the physics body from
  129006. */
  129007. removePhysicsBody(impostor: PhysicsImpostor): void;
  129008. /**
  129009. * Generates a joint
  129010. * @param impostorJoint the imposter joint to create the joint with
  129011. */
  129012. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129013. /**
  129014. * Removes a joint
  129015. * @param impostorJoint the imposter joint to remove the joint from
  129016. */
  129017. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129018. private _addMeshVerts;
  129019. /**
  129020. * Initialise the soft body vertices to match its object's (mesh) vertices
  129021. * Softbody vertices (nodes) are in world space and to match this
  129022. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  129023. * @param impostor to create the softbody for
  129024. */
  129025. private _softVertexData;
  129026. /**
  129027. * Create an impostor's soft body
  129028. * @param impostor to create the softbody for
  129029. */
  129030. private _createSoftbody;
  129031. /**
  129032. * Create cloth for an impostor
  129033. * @param impostor to create the softbody for
  129034. */
  129035. private _createCloth;
  129036. /**
  129037. * Create rope for an impostor
  129038. * @param impostor to create the softbody for
  129039. */
  129040. private _createRope;
  129041. /**
  129042. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  129043. * @param impostor to create the custom physics shape for
  129044. */
  129045. private _createCustom;
  129046. private _addHullVerts;
  129047. private _createShape;
  129048. /**
  129049. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  129050. * @param impostor imposter containing the physics body and babylon object
  129051. */
  129052. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129053. /**
  129054. * Sets the babylon object's position/rotation from the physics body's position/rotation
  129055. * @param impostor imposter containing the physics body and babylon object
  129056. * @param newPosition new position
  129057. * @param newRotation new rotation
  129058. */
  129059. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129060. /**
  129061. * If this plugin is supported
  129062. * @returns true if its supported
  129063. */
  129064. isSupported(): boolean;
  129065. /**
  129066. * Sets the linear velocity of the physics body
  129067. * @param impostor imposter to set the velocity on
  129068. * @param velocity velocity to set
  129069. */
  129070. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129071. /**
  129072. * Sets the angular velocity of the physics body
  129073. * @param impostor imposter to set the velocity on
  129074. * @param velocity velocity to set
  129075. */
  129076. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129077. /**
  129078. * gets the linear velocity
  129079. * @param impostor imposter to get linear velocity from
  129080. * @returns linear velocity
  129081. */
  129082. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129083. /**
  129084. * gets the angular velocity
  129085. * @param impostor imposter to get angular velocity from
  129086. * @returns angular velocity
  129087. */
  129088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129089. /**
  129090. * Sets the mass of physics body
  129091. * @param impostor imposter to set the mass on
  129092. * @param mass mass to set
  129093. */
  129094. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129095. /**
  129096. * Gets the mass of the physics body
  129097. * @param impostor imposter to get the mass from
  129098. * @returns mass
  129099. */
  129100. getBodyMass(impostor: PhysicsImpostor): number;
  129101. /**
  129102. * Gets friction of the impostor
  129103. * @param impostor impostor to get friction from
  129104. * @returns friction value
  129105. */
  129106. getBodyFriction(impostor: PhysicsImpostor): number;
  129107. /**
  129108. * Sets friction of the impostor
  129109. * @param impostor impostor to set friction on
  129110. * @param friction friction value
  129111. */
  129112. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129113. /**
  129114. * Gets restitution of the impostor
  129115. * @param impostor impostor to get restitution from
  129116. * @returns restitution value
  129117. */
  129118. getBodyRestitution(impostor: PhysicsImpostor): number;
  129119. /**
  129120. * Sets resitution of the impostor
  129121. * @param impostor impostor to set resitution on
  129122. * @param restitution resitution value
  129123. */
  129124. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129125. /**
  129126. * Gets pressure inside the impostor
  129127. * @param impostor impostor to get pressure from
  129128. * @returns pressure value
  129129. */
  129130. getBodyPressure(impostor: PhysicsImpostor): number;
  129131. /**
  129132. * Sets pressure inside a soft body impostor
  129133. * Cloth and rope must remain 0 pressure
  129134. * @param impostor impostor to set pressure on
  129135. * @param pressure pressure value
  129136. */
  129137. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  129138. /**
  129139. * Gets stiffness of the impostor
  129140. * @param impostor impostor to get stiffness from
  129141. * @returns pressure value
  129142. */
  129143. getBodyStiffness(impostor: PhysicsImpostor): number;
  129144. /**
  129145. * Sets stiffness of the impostor
  129146. * @param impostor impostor to set stiffness on
  129147. * @param stiffness stiffness value from 0 to 1
  129148. */
  129149. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  129150. /**
  129151. * Gets velocityIterations of the impostor
  129152. * @param impostor impostor to get velocity iterations from
  129153. * @returns velocityIterations value
  129154. */
  129155. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  129156. /**
  129157. * Sets velocityIterations of the impostor
  129158. * @param impostor impostor to set velocity iterations on
  129159. * @param velocityIterations velocityIterations value
  129160. */
  129161. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  129162. /**
  129163. * Gets positionIterations of the impostor
  129164. * @param impostor impostor to get position iterations from
  129165. * @returns positionIterations value
  129166. */
  129167. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  129168. /**
  129169. * Sets positionIterations of the impostor
  129170. * @param impostor impostor to set position on
  129171. * @param positionIterations positionIterations value
  129172. */
  129173. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  129174. /**
  129175. * Append an anchor to a cloth object
  129176. * @param impostor is the cloth impostor to add anchor to
  129177. * @param otherImpostor is the rigid impostor to anchor to
  129178. * @param width ratio across width from 0 to 1
  129179. * @param height ratio up height from 0 to 1
  129180. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  129181. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129182. */
  129183. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129184. /**
  129185. * Append an hook to a rope object
  129186. * @param impostor is the rope impostor to add hook to
  129187. * @param otherImpostor is the rigid impostor to hook to
  129188. * @param length ratio along the rope from 0 to 1
  129189. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  129190. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129191. */
  129192. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129193. /**
  129194. * Sleeps the physics body and stops it from being active
  129195. * @param impostor impostor to sleep
  129196. */
  129197. sleepBody(impostor: PhysicsImpostor): void;
  129198. /**
  129199. * Activates the physics body
  129200. * @param impostor impostor to activate
  129201. */
  129202. wakeUpBody(impostor: PhysicsImpostor): void;
  129203. /**
  129204. * Updates the distance parameters of the joint
  129205. * @param joint joint to update
  129206. * @param maxDistance maximum distance of the joint
  129207. * @param minDistance minimum distance of the joint
  129208. */
  129209. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129210. /**
  129211. * Sets a motor on the joint
  129212. * @param joint joint to set motor on
  129213. * @param speed speed of the motor
  129214. * @param maxForce maximum force of the motor
  129215. * @param motorIndex index of the motor
  129216. */
  129217. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129218. /**
  129219. * Sets the motors limit
  129220. * @param joint joint to set limit on
  129221. * @param upperLimit upper limit
  129222. * @param lowerLimit lower limit
  129223. */
  129224. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129225. /**
  129226. * Syncs the position and rotation of a mesh with the impostor
  129227. * @param mesh mesh to sync
  129228. * @param impostor impostor to update the mesh with
  129229. */
  129230. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129231. /**
  129232. * Gets the radius of the impostor
  129233. * @param impostor impostor to get radius from
  129234. * @returns the radius
  129235. */
  129236. getRadius(impostor: PhysicsImpostor): number;
  129237. /**
  129238. * Gets the box size of the impostor
  129239. * @param impostor impostor to get box size from
  129240. * @param result the resulting box size
  129241. */
  129242. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129243. /**
  129244. * Disposes of the impostor
  129245. */
  129246. dispose(): void;
  129247. /**
  129248. * Does a raycast in the physics world
  129249. * @param from when should the ray start?
  129250. * @param to when should the ray end?
  129251. * @returns PhysicsRaycastResult
  129252. */
  129253. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129254. }
  129255. }
  129256. declare module BABYLON {
  129257. interface AbstractScene {
  129258. /**
  129259. * The list of reflection probes added to the scene
  129260. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129261. */
  129262. reflectionProbes: Array<ReflectionProbe>;
  129263. /**
  129264. * Removes the given reflection probe from this scene.
  129265. * @param toRemove The reflection probe to remove
  129266. * @returns The index of the removed reflection probe
  129267. */
  129268. removeReflectionProbe(toRemove: ReflectionProbe): number;
  129269. /**
  129270. * Adds the given reflection probe to this scene.
  129271. * @param newReflectionProbe The reflection probe to add
  129272. */
  129273. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  129274. }
  129275. /**
  129276. * Class used to generate realtime reflection / refraction cube textures
  129277. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129278. */
  129279. export class ReflectionProbe {
  129280. /** defines the name of the probe */
  129281. name: string;
  129282. private _scene;
  129283. private _renderTargetTexture;
  129284. private _projectionMatrix;
  129285. private _viewMatrix;
  129286. private _target;
  129287. private _add;
  129288. private _attachedMesh;
  129289. private _invertYAxis;
  129290. /** Gets or sets probe position (center of the cube map) */
  129291. position: Vector3;
  129292. /**
  129293. * Creates a new reflection probe
  129294. * @param name defines the name of the probe
  129295. * @param size defines the texture resolution (for each face)
  129296. * @param scene defines the hosting scene
  129297. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  129298. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  129299. */
  129300. constructor(
  129301. /** defines the name of the probe */
  129302. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  129303. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  129304. get samples(): number;
  129305. set samples(value: number);
  129306. /** Gets or sets the refresh rate to use (on every frame by default) */
  129307. get refreshRate(): number;
  129308. set refreshRate(value: number);
  129309. /**
  129310. * Gets the hosting scene
  129311. * @returns a Scene
  129312. */
  129313. getScene(): Scene;
  129314. /** Gets the internal CubeTexture used to render to */
  129315. get cubeTexture(): RenderTargetTexture;
  129316. /** Gets the list of meshes to render */
  129317. get renderList(): Nullable<AbstractMesh[]>;
  129318. /**
  129319. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  129320. * @param mesh defines the mesh to attach to
  129321. */
  129322. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129323. /**
  129324. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  129325. * @param renderingGroupId The rendering group id corresponding to its index
  129326. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  129327. */
  129328. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  129329. /**
  129330. * Clean all associated resources
  129331. */
  129332. dispose(): void;
  129333. /**
  129334. * Converts the reflection probe information to a readable string for debug purpose.
  129335. * @param fullDetails Supports for multiple levels of logging within scene loading
  129336. * @returns the human readable reflection probe info
  129337. */
  129338. toString(fullDetails?: boolean): string;
  129339. /**
  129340. * Get the class name of the relfection probe.
  129341. * @returns "ReflectionProbe"
  129342. */
  129343. getClassName(): string;
  129344. /**
  129345. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  129346. * @returns The JSON representation of the texture
  129347. */
  129348. serialize(): any;
  129349. /**
  129350. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  129351. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  129352. * @param scene Define the scene the parsed reflection probe should be instantiated in
  129353. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  129354. * @returns The parsed reflection probe if successful
  129355. */
  129356. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  129357. }
  129358. }
  129359. declare module BABYLON {
  129360. /** @hidden */
  129361. export var _BabylonLoaderRegistered: boolean;
  129362. /**
  129363. * Helps setting up some configuration for the babylon file loader.
  129364. */
  129365. export class BabylonFileLoaderConfiguration {
  129366. /**
  129367. * The loader does not allow injecting custom physix engine into the plugins.
  129368. * Unfortunately in ES6, we need to manually inject them into the plugin.
  129369. * So you could set this variable to your engine import to make it work.
  129370. */
  129371. static LoaderInjectedPhysicsEngine: any;
  129372. }
  129373. }
  129374. declare module BABYLON {
  129375. /**
  129376. * The Physically based simple base material of BJS.
  129377. *
  129378. * This enables better naming and convention enforcements on top of the pbrMaterial.
  129379. * It is used as the base class for both the specGloss and metalRough conventions.
  129380. */
  129381. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  129382. /**
  129383. * Number of Simultaneous lights allowed on the material.
  129384. */
  129385. maxSimultaneousLights: number;
  129386. /**
  129387. * If sets to true, disables all the lights affecting the material.
  129388. */
  129389. disableLighting: boolean;
  129390. /**
  129391. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  129392. */
  129393. environmentTexture: BaseTexture;
  129394. /**
  129395. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  129396. */
  129397. invertNormalMapX: boolean;
  129398. /**
  129399. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  129400. */
  129401. invertNormalMapY: boolean;
  129402. /**
  129403. * Normal map used in the model.
  129404. */
  129405. normalTexture: BaseTexture;
  129406. /**
  129407. * Emissivie color used to self-illuminate the model.
  129408. */
  129409. emissiveColor: Color3;
  129410. /**
  129411. * Emissivie texture used to self-illuminate the model.
  129412. */
  129413. emissiveTexture: BaseTexture;
  129414. /**
  129415. * Occlusion Channel Strenght.
  129416. */
  129417. occlusionStrength: number;
  129418. /**
  129419. * Occlusion Texture of the material (adding extra occlusion effects).
  129420. */
  129421. occlusionTexture: BaseTexture;
  129422. /**
  129423. * Defines the alpha limits in alpha test mode.
  129424. */
  129425. alphaCutOff: number;
  129426. /**
  129427. * Gets the current double sided mode.
  129428. */
  129429. get doubleSided(): boolean;
  129430. /**
  129431. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129432. */
  129433. set doubleSided(value: boolean);
  129434. /**
  129435. * Stores the pre-calculated light information of a mesh in a texture.
  129436. */
  129437. lightmapTexture: BaseTexture;
  129438. /**
  129439. * If true, the light map contains occlusion information instead of lighting info.
  129440. */
  129441. useLightmapAsShadowmap: boolean;
  129442. /**
  129443. * Instantiates a new PBRMaterial instance.
  129444. *
  129445. * @param name The material name
  129446. * @param scene The scene the material will be use in.
  129447. */
  129448. constructor(name: string, scene: Scene);
  129449. getClassName(): string;
  129450. }
  129451. }
  129452. declare module BABYLON {
  129453. /**
  129454. * The PBR material of BJS following the metal roughness convention.
  129455. *
  129456. * This fits to the PBR convention in the GLTF definition:
  129457. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129458. */
  129459. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129460. /**
  129461. * The base color has two different interpretations depending on the value of metalness.
  129462. * When the material is a metal, the base color is the specific measured reflectance value
  129463. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129464. * of the material.
  129465. */
  129466. baseColor: Color3;
  129467. /**
  129468. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129469. * well as opacity information in the alpha channel.
  129470. */
  129471. baseTexture: BaseTexture;
  129472. /**
  129473. * Specifies the metallic scalar value of the material.
  129474. * Can also be used to scale the metalness values of the metallic texture.
  129475. */
  129476. metallic: number;
  129477. /**
  129478. * Specifies the roughness scalar value of the material.
  129479. * Can also be used to scale the roughness values of the metallic texture.
  129480. */
  129481. roughness: number;
  129482. /**
  129483. * Texture containing both the metallic value in the B channel and the
  129484. * roughness value in the G channel to keep better precision.
  129485. */
  129486. metallicRoughnessTexture: BaseTexture;
  129487. /**
  129488. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129489. *
  129490. * @param name The material name
  129491. * @param scene The scene the material will be use in.
  129492. */
  129493. constructor(name: string, scene: Scene);
  129494. /**
  129495. * Return the currrent class name of the material.
  129496. */
  129497. getClassName(): string;
  129498. /**
  129499. * Makes a duplicate of the current material.
  129500. * @param name - name to use for the new material.
  129501. */
  129502. clone(name: string): PBRMetallicRoughnessMaterial;
  129503. /**
  129504. * Serialize the material to a parsable JSON object.
  129505. */
  129506. serialize(): any;
  129507. /**
  129508. * Parses a JSON object correponding to the serialize function.
  129509. */
  129510. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129511. }
  129512. }
  129513. declare module BABYLON {
  129514. /**
  129515. * The PBR material of BJS following the specular glossiness convention.
  129516. *
  129517. * This fits to the PBR convention in the GLTF definition:
  129518. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129519. */
  129520. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129521. /**
  129522. * Specifies the diffuse color of the material.
  129523. */
  129524. diffuseColor: Color3;
  129525. /**
  129526. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129527. * channel.
  129528. */
  129529. diffuseTexture: BaseTexture;
  129530. /**
  129531. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129532. */
  129533. specularColor: Color3;
  129534. /**
  129535. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129536. */
  129537. glossiness: number;
  129538. /**
  129539. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129540. */
  129541. specularGlossinessTexture: BaseTexture;
  129542. /**
  129543. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129544. *
  129545. * @param name The material name
  129546. * @param scene The scene the material will be use in.
  129547. */
  129548. constructor(name: string, scene: Scene);
  129549. /**
  129550. * Return the currrent class name of the material.
  129551. */
  129552. getClassName(): string;
  129553. /**
  129554. * Makes a duplicate of the current material.
  129555. * @param name - name to use for the new material.
  129556. */
  129557. clone(name: string): PBRSpecularGlossinessMaterial;
  129558. /**
  129559. * Serialize the material to a parsable JSON object.
  129560. */
  129561. serialize(): any;
  129562. /**
  129563. * Parses a JSON object correponding to the serialize function.
  129564. */
  129565. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129566. }
  129567. }
  129568. declare module BABYLON {
  129569. /**
  129570. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129571. * It can help converting any input color in a desired output one. This can then be used to create effects
  129572. * from sepia, black and white to sixties or futuristic rendering...
  129573. *
  129574. * The only supported format is currently 3dl.
  129575. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129576. */
  129577. export class ColorGradingTexture extends BaseTexture {
  129578. /**
  129579. * The current texture matrix. (will always be identity in color grading texture)
  129580. */
  129581. private _textureMatrix;
  129582. /**
  129583. * The texture URL.
  129584. */
  129585. url: string;
  129586. /**
  129587. * Empty line regex stored for GC.
  129588. */
  129589. private static _noneEmptyLineRegex;
  129590. private _engine;
  129591. /**
  129592. * Instantiates a ColorGradingTexture from the following parameters.
  129593. *
  129594. * @param url The location of the color gradind data (currently only supporting 3dl)
  129595. * @param scene The scene the texture will be used in
  129596. */
  129597. constructor(url: string, scene: Scene);
  129598. /**
  129599. * Returns the texture matrix used in most of the material.
  129600. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129601. */
  129602. getTextureMatrix(): Matrix;
  129603. /**
  129604. * Occurs when the file being loaded is a .3dl LUT file.
  129605. */
  129606. private load3dlTexture;
  129607. /**
  129608. * Starts the loading process of the texture.
  129609. */
  129610. private loadTexture;
  129611. /**
  129612. * Clones the color gradind texture.
  129613. */
  129614. clone(): ColorGradingTexture;
  129615. /**
  129616. * Called during delayed load for textures.
  129617. */
  129618. delayLoad(): void;
  129619. /**
  129620. * Parses a color grading texture serialized by Babylon.
  129621. * @param parsedTexture The texture information being parsedTexture
  129622. * @param scene The scene to load the texture in
  129623. * @param rootUrl The root url of the data assets to load
  129624. * @return A color gradind texture
  129625. */
  129626. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129627. /**
  129628. * Serializes the LUT texture to json format.
  129629. */
  129630. serialize(): any;
  129631. }
  129632. }
  129633. declare module BABYLON {
  129634. /**
  129635. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129636. */
  129637. export class EquiRectangularCubeTexture extends BaseTexture {
  129638. /** The six faces of the cube. */
  129639. private static _FacesMapping;
  129640. private _noMipmap;
  129641. private _onLoad;
  129642. private _onError;
  129643. /** The size of the cubemap. */
  129644. private _size;
  129645. /** The buffer of the image. */
  129646. private _buffer;
  129647. /** The width of the input image. */
  129648. private _width;
  129649. /** The height of the input image. */
  129650. private _height;
  129651. /** The URL to the image. */
  129652. url: string;
  129653. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129654. coordinatesMode: number;
  129655. /**
  129656. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129657. * @param url The location of the image
  129658. * @param scene The scene the texture will be used in
  129659. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129660. * @param noMipmap Forces to not generate the mipmap if true
  129661. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129662. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129663. * @param onLoad — defines a callback called when texture is loaded
  129664. * @param onError — defines a callback called if there is an error
  129665. */
  129666. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129667. /**
  129668. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129669. */
  129670. private loadImage;
  129671. /**
  129672. * Convert the image buffer into a cubemap and create a CubeTexture.
  129673. */
  129674. private loadTexture;
  129675. /**
  129676. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129677. * @param buffer The ArrayBuffer that should be converted.
  129678. * @returns The buffer as Float32Array.
  129679. */
  129680. private getFloat32ArrayFromArrayBuffer;
  129681. /**
  129682. * Get the current class name of the texture useful for serialization or dynamic coding.
  129683. * @returns "EquiRectangularCubeTexture"
  129684. */
  129685. getClassName(): string;
  129686. /**
  129687. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129688. * @returns A clone of the current EquiRectangularCubeTexture.
  129689. */
  129690. clone(): EquiRectangularCubeTexture;
  129691. }
  129692. }
  129693. declare module BABYLON {
  129694. /**
  129695. * Based on jsTGALoader - Javascript loader for TGA file
  129696. * By Vincent Thibault
  129697. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129698. */
  129699. export class TGATools {
  129700. private static _TYPE_INDEXED;
  129701. private static _TYPE_RGB;
  129702. private static _TYPE_GREY;
  129703. private static _TYPE_RLE_INDEXED;
  129704. private static _TYPE_RLE_RGB;
  129705. private static _TYPE_RLE_GREY;
  129706. private static _ORIGIN_MASK;
  129707. private static _ORIGIN_SHIFT;
  129708. private static _ORIGIN_BL;
  129709. private static _ORIGIN_BR;
  129710. private static _ORIGIN_UL;
  129711. private static _ORIGIN_UR;
  129712. /**
  129713. * Gets the header of a TGA file
  129714. * @param data defines the TGA data
  129715. * @returns the header
  129716. */
  129717. static GetTGAHeader(data: Uint8Array): any;
  129718. /**
  129719. * Uploads TGA content to a Babylon Texture
  129720. * @hidden
  129721. */
  129722. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129723. /** @hidden */
  129724. 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;
  129725. /** @hidden */
  129726. 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;
  129727. /** @hidden */
  129728. 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;
  129729. /** @hidden */
  129730. 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;
  129731. /** @hidden */
  129732. 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;
  129733. /** @hidden */
  129734. 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;
  129735. }
  129736. }
  129737. declare module BABYLON {
  129738. /**
  129739. * Implementation of the TGA Texture Loader.
  129740. * @hidden
  129741. */
  129742. export class _TGATextureLoader implements IInternalTextureLoader {
  129743. /**
  129744. * Defines wether the loader supports cascade loading the different faces.
  129745. */
  129746. readonly supportCascades: boolean;
  129747. /**
  129748. * This returns if the loader support the current file information.
  129749. * @param extension defines the file extension of the file being loaded
  129750. * @returns true if the loader can load the specified file
  129751. */
  129752. canLoad(extension: string): boolean;
  129753. /**
  129754. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129755. * @param data contains the texture data
  129756. * @param texture defines the BabylonJS internal texture
  129757. * @param createPolynomials will be true if polynomials have been requested
  129758. * @param onLoad defines the callback to trigger once the texture is ready
  129759. * @param onError defines the callback to trigger in case of error
  129760. */
  129761. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129762. /**
  129763. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129764. * @param data contains the texture data
  129765. * @param texture defines the BabylonJS internal texture
  129766. * @param callback defines the method to call once ready to upload
  129767. */
  129768. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129769. }
  129770. }
  129771. declare module BABYLON {
  129772. /**
  129773. * Info about the .basis files
  129774. */
  129775. class BasisFileInfo {
  129776. /**
  129777. * If the file has alpha
  129778. */
  129779. hasAlpha: boolean;
  129780. /**
  129781. * Info about each image of the basis file
  129782. */
  129783. images: Array<{
  129784. levels: Array<{
  129785. width: number;
  129786. height: number;
  129787. transcodedPixels: ArrayBufferView;
  129788. }>;
  129789. }>;
  129790. }
  129791. /**
  129792. * Result of transcoding a basis file
  129793. */
  129794. class TranscodeResult {
  129795. /**
  129796. * Info about the .basis file
  129797. */
  129798. fileInfo: BasisFileInfo;
  129799. /**
  129800. * Format to use when loading the file
  129801. */
  129802. format: number;
  129803. }
  129804. /**
  129805. * Configuration options for the Basis transcoder
  129806. */
  129807. export class BasisTranscodeConfiguration {
  129808. /**
  129809. * Supported compression formats used to determine the supported output format of the transcoder
  129810. */
  129811. supportedCompressionFormats?: {
  129812. /**
  129813. * etc1 compression format
  129814. */
  129815. etc1?: boolean;
  129816. /**
  129817. * s3tc compression format
  129818. */
  129819. s3tc?: boolean;
  129820. /**
  129821. * pvrtc compression format
  129822. */
  129823. pvrtc?: boolean;
  129824. /**
  129825. * etc2 compression format
  129826. */
  129827. etc2?: boolean;
  129828. };
  129829. /**
  129830. * If mipmap levels should be loaded for transcoded images (Default: true)
  129831. */
  129832. loadMipmapLevels?: boolean;
  129833. /**
  129834. * Index of a single image to load (Default: all images)
  129835. */
  129836. loadSingleImage?: number;
  129837. }
  129838. /**
  129839. * Used to load .Basis files
  129840. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129841. */
  129842. export class BasisTools {
  129843. private static _IgnoreSupportedFormats;
  129844. /**
  129845. * URL to use when loading the basis transcoder
  129846. */
  129847. static JSModuleURL: string;
  129848. /**
  129849. * URL to use when loading the wasm module for the transcoder
  129850. */
  129851. static WasmModuleURL: string;
  129852. /**
  129853. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129854. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129855. * @returns internal format corresponding to the Basis format
  129856. */
  129857. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129858. private static _WorkerPromise;
  129859. private static _Worker;
  129860. private static _actionId;
  129861. private static _CreateWorkerAsync;
  129862. /**
  129863. * Transcodes a loaded image file to compressed pixel data
  129864. * @param data image data to transcode
  129865. * @param config configuration options for the transcoding
  129866. * @returns a promise resulting in the transcoded image
  129867. */
  129868. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129869. /**
  129870. * Loads a texture from the transcode result
  129871. * @param texture texture load to
  129872. * @param transcodeResult the result of transcoding the basis file to load from
  129873. */
  129874. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129875. }
  129876. }
  129877. declare module BABYLON {
  129878. /**
  129879. * Loader for .basis file format
  129880. */
  129881. export class _BasisTextureLoader implements IInternalTextureLoader {
  129882. /**
  129883. * Defines whether the loader supports cascade loading the different faces.
  129884. */
  129885. readonly supportCascades: boolean;
  129886. /**
  129887. * This returns if the loader support the current file information.
  129888. * @param extension defines the file extension of the file being loaded
  129889. * @returns true if the loader can load the specified file
  129890. */
  129891. canLoad(extension: string): boolean;
  129892. /**
  129893. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129894. * @param data contains the texture data
  129895. * @param texture defines the BabylonJS internal texture
  129896. * @param createPolynomials will be true if polynomials have been requested
  129897. * @param onLoad defines the callback to trigger once the texture is ready
  129898. * @param onError defines the callback to trigger in case of error
  129899. */
  129900. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129901. /**
  129902. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129903. * @param data contains the texture data
  129904. * @param texture defines the BabylonJS internal texture
  129905. * @param callback defines the method to call once ready to upload
  129906. */
  129907. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129908. }
  129909. }
  129910. declare module BABYLON {
  129911. /**
  129912. * 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.
  129913. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129914. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129915. */
  129916. export class CustomProceduralTexture extends ProceduralTexture {
  129917. private _animate;
  129918. private _time;
  129919. private _config;
  129920. private _texturePath;
  129921. /**
  129922. * Instantiates a new Custom Procedural Texture.
  129923. * 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.
  129924. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129925. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129926. * @param name Define the name of the texture
  129927. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129928. * @param size Define the size of the texture to create
  129929. * @param scene Define the scene the texture belongs to
  129930. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129931. * @param generateMipMaps Define if the texture should creates mip maps or not
  129932. */
  129933. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129934. private _loadJson;
  129935. /**
  129936. * Is the texture ready to be used ? (rendered at least once)
  129937. * @returns true if ready, otherwise, false.
  129938. */
  129939. isReady(): boolean;
  129940. /**
  129941. * Render the texture to its associated render target.
  129942. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129943. */
  129944. render(useCameraPostProcess?: boolean): void;
  129945. /**
  129946. * Update the list of dependant textures samplers in the shader.
  129947. */
  129948. updateTextures(): void;
  129949. /**
  129950. * Update the uniform values of the procedural texture in the shader.
  129951. */
  129952. updateShaderUniforms(): void;
  129953. /**
  129954. * Define if the texture animates or not.
  129955. */
  129956. get animate(): boolean;
  129957. set animate(value: boolean);
  129958. }
  129959. }
  129960. declare module BABYLON {
  129961. /** @hidden */
  129962. export var noisePixelShader: {
  129963. name: string;
  129964. shader: string;
  129965. };
  129966. }
  129967. declare module BABYLON {
  129968. /**
  129969. * Class used to generate noise procedural textures
  129970. */
  129971. export class NoiseProceduralTexture extends ProceduralTexture {
  129972. private _time;
  129973. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129974. brightness: number;
  129975. /** Defines the number of octaves to process */
  129976. octaves: number;
  129977. /** Defines the level of persistence (0.8 by default) */
  129978. persistence: number;
  129979. /** Gets or sets animation speed factor (default is 1) */
  129980. animationSpeedFactor: number;
  129981. /**
  129982. * Creates a new NoiseProceduralTexture
  129983. * @param name defines the name fo the texture
  129984. * @param size defines the size of the texture (default is 256)
  129985. * @param scene defines the hosting scene
  129986. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129987. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129988. */
  129989. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129990. private _updateShaderUniforms;
  129991. protected _getDefines(): string;
  129992. /** Generate the current state of the procedural texture */
  129993. render(useCameraPostProcess?: boolean): void;
  129994. /**
  129995. * Serializes this noise procedural texture
  129996. * @returns a serialized noise procedural texture object
  129997. */
  129998. serialize(): any;
  129999. /**
  130000. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  130001. * @param parsedTexture defines parsed texture data
  130002. * @param scene defines the current scene
  130003. * @param rootUrl defines the root URL containing noise procedural texture information
  130004. * @returns a parsed NoiseProceduralTexture
  130005. */
  130006. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  130007. }
  130008. }
  130009. declare module BABYLON {
  130010. /**
  130011. * Raw cube texture where the raw buffers are passed in
  130012. */
  130013. export class RawCubeTexture extends CubeTexture {
  130014. /**
  130015. * Creates a cube texture where the raw buffers are passed in.
  130016. * @param scene defines the scene the texture is attached to
  130017. * @param data defines the array of data to use to create each face
  130018. * @param size defines the size of the textures
  130019. * @param format defines the format of the data
  130020. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  130021. * @param generateMipMaps defines if the engine should generate the mip levels
  130022. * @param invertY defines if data must be stored with Y axis inverted
  130023. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130024. * @param compression defines the compression used (null by default)
  130025. */
  130026. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  130027. /**
  130028. * Updates the raw cube texture.
  130029. * @param data defines the data to store
  130030. * @param format defines the data format
  130031. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130032. * @param invertY defines if data must be stored with Y axis inverted
  130033. * @param compression defines the compression used (null by default)
  130034. * @param level defines which level of the texture to update
  130035. */
  130036. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  130037. /**
  130038. * Updates a raw cube texture with RGBD encoded data.
  130039. * @param data defines the array of data [mipmap][face] to use to create each face
  130040. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  130041. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130042. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130043. * @returns a promsie that resolves when the operation is complete
  130044. */
  130045. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  130046. /**
  130047. * Clones the raw cube texture.
  130048. * @return a new cube texture
  130049. */
  130050. clone(): CubeTexture;
  130051. /** @hidden */
  130052. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  130053. }
  130054. }
  130055. declare module BABYLON {
  130056. /**
  130057. * Class used to store 3D textures containing user data
  130058. */
  130059. export class RawTexture3D extends Texture {
  130060. /** Gets or sets the texture format to use */
  130061. format: number;
  130062. private _engine;
  130063. /**
  130064. * Create a new RawTexture3D
  130065. * @param data defines the data of the texture
  130066. * @param width defines the width of the texture
  130067. * @param height defines the height of the texture
  130068. * @param depth defines the depth of the texture
  130069. * @param format defines the texture format to use
  130070. * @param scene defines the hosting scene
  130071. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  130072. * @param invertY defines if texture must be stored with Y axis inverted
  130073. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130074. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130075. */
  130076. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  130077. /** Gets or sets the texture format to use */
  130078. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  130079. /**
  130080. * Update the texture with new data
  130081. * @param data defines the data to store in the texture
  130082. */
  130083. update(data: ArrayBufferView): void;
  130084. }
  130085. }
  130086. declare module BABYLON {
  130087. /**
  130088. * Class used to store 2D array textures containing user data
  130089. */
  130090. export class RawTexture2DArray extends Texture {
  130091. /** Gets or sets the texture format to use */
  130092. format: number;
  130093. private _engine;
  130094. /**
  130095. * Create a new RawTexture2DArray
  130096. * @param data defines the data of the texture
  130097. * @param width defines the width of the texture
  130098. * @param height defines the height of the texture
  130099. * @param depth defines the number of layers of the texture
  130100. * @param format defines the texture format to use
  130101. * @param scene defines the hosting scene
  130102. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  130103. * @param invertY defines if texture must be stored with Y axis inverted
  130104. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130105. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130106. */
  130107. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  130108. /** Gets or sets the texture format to use */
  130109. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  130110. /**
  130111. * Update the texture with new data
  130112. * @param data defines the data to store in the texture
  130113. */
  130114. update(data: ArrayBufferView): void;
  130115. }
  130116. }
  130117. declare module BABYLON {
  130118. /**
  130119. * Creates a refraction texture used by refraction channel of the standard material.
  130120. * It is like a mirror but to see through a material.
  130121. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130122. */
  130123. export class RefractionTexture extends RenderTargetTexture {
  130124. /**
  130125. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  130126. * 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.
  130127. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130128. */
  130129. refractionPlane: Plane;
  130130. /**
  130131. * Define how deep under the surface we should see.
  130132. */
  130133. depth: number;
  130134. /**
  130135. * Creates a refraction texture used by refraction channel of the standard material.
  130136. * It is like a mirror but to see through a material.
  130137. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130138. * @param name Define the texture name
  130139. * @param size Define the size of the underlying texture
  130140. * @param scene Define the scene the refraction belongs to
  130141. * @param generateMipMaps Define if we need to generate mips level for the refraction
  130142. */
  130143. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  130144. /**
  130145. * Clone the refraction texture.
  130146. * @returns the cloned texture
  130147. */
  130148. clone(): RefractionTexture;
  130149. /**
  130150. * Serialize the texture to a JSON representation you could use in Parse later on
  130151. * @returns the serialized JSON representation
  130152. */
  130153. serialize(): any;
  130154. }
  130155. }
  130156. declare module BABYLON {
  130157. /**
  130158. * Defines the options related to the creation of an HtmlElementTexture
  130159. */
  130160. export interface IHtmlElementTextureOptions {
  130161. /**
  130162. * Defines wether mip maps should be created or not.
  130163. */
  130164. generateMipMaps?: boolean;
  130165. /**
  130166. * Defines the sampling mode of the texture.
  130167. */
  130168. samplingMode?: number;
  130169. /**
  130170. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  130171. */
  130172. engine: Nullable<ThinEngine>;
  130173. /**
  130174. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  130175. */
  130176. scene: Nullable<Scene>;
  130177. }
  130178. /**
  130179. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  130180. * To be as efficient as possible depending on your constraints nothing aside the first upload
  130181. * is automatically managed.
  130182. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  130183. * in your application.
  130184. *
  130185. * As the update is not automatic, you need to call them manually.
  130186. */
  130187. export class HtmlElementTexture extends BaseTexture {
  130188. /**
  130189. * The texture URL.
  130190. */
  130191. element: HTMLVideoElement | HTMLCanvasElement;
  130192. private static readonly DefaultOptions;
  130193. private _textureMatrix;
  130194. private _engine;
  130195. private _isVideo;
  130196. private _generateMipMaps;
  130197. private _samplingMode;
  130198. /**
  130199. * Instantiates a HtmlElementTexture from the following parameters.
  130200. *
  130201. * @param name Defines the name of the texture
  130202. * @param element Defines the video or canvas the texture is filled with
  130203. * @param options Defines the other none mandatory texture creation options
  130204. */
  130205. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  130206. private _createInternalTexture;
  130207. /**
  130208. * Returns the texture matrix used in most of the material.
  130209. */
  130210. getTextureMatrix(): Matrix;
  130211. /**
  130212. * Updates the content of the texture.
  130213. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  130214. */
  130215. update(invertY?: Nullable<boolean>): void;
  130216. }
  130217. }
  130218. declare module BABYLON {
  130219. /**
  130220. * Defines the basic options interface of a TexturePacker Frame
  130221. */
  130222. export interface ITexturePackerFrame {
  130223. /**
  130224. * The frame ID
  130225. */
  130226. id: number;
  130227. /**
  130228. * The frames Scale
  130229. */
  130230. scale: Vector2;
  130231. /**
  130232. * The Frames offset
  130233. */
  130234. offset: Vector2;
  130235. }
  130236. /**
  130237. * This is a support class for frame Data on texture packer sets.
  130238. */
  130239. export class TexturePackerFrame implements ITexturePackerFrame {
  130240. /**
  130241. * The frame ID
  130242. */
  130243. id: number;
  130244. /**
  130245. * The frames Scale
  130246. */
  130247. scale: Vector2;
  130248. /**
  130249. * The Frames offset
  130250. */
  130251. offset: Vector2;
  130252. /**
  130253. * Initializes a texture package frame.
  130254. * @param id The numerical frame identifier
  130255. * @param scale Scalar Vector2 for UV frame
  130256. * @param offset Vector2 for the frame position in UV units.
  130257. * @returns TexturePackerFrame
  130258. */
  130259. constructor(id: number, scale: Vector2, offset: Vector2);
  130260. }
  130261. }
  130262. declare module BABYLON {
  130263. /**
  130264. * Defines the basic options interface of a TexturePacker
  130265. */
  130266. export interface ITexturePackerOptions {
  130267. /**
  130268. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  130269. */
  130270. map?: string[];
  130271. /**
  130272. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130273. */
  130274. uvsIn?: string;
  130275. /**
  130276. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130277. */
  130278. uvsOut?: string;
  130279. /**
  130280. * number representing the layout style. Defaults to LAYOUT_STRIP
  130281. */
  130282. layout?: number;
  130283. /**
  130284. * number of columns if using custom column count layout(2). This defaults to 4.
  130285. */
  130286. colnum?: number;
  130287. /**
  130288. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  130289. */
  130290. updateInputMeshes?: boolean;
  130291. /**
  130292. * boolean flag to dispose all the source textures. Defaults to true.
  130293. */
  130294. disposeSources?: boolean;
  130295. /**
  130296. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  130297. */
  130298. fillBlanks?: boolean;
  130299. /**
  130300. * string value representing the context fill style color. Defaults to 'black'.
  130301. */
  130302. customFillColor?: string;
  130303. /**
  130304. * Width and Height Value of each Frame in the TexturePacker Sets
  130305. */
  130306. frameSize?: number;
  130307. /**
  130308. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  130309. */
  130310. paddingRatio?: number;
  130311. /**
  130312. * Number that declares the fill method for the padding gutter.
  130313. */
  130314. paddingMode?: number;
  130315. /**
  130316. * If in SUBUV_COLOR padding mode what color to use.
  130317. */
  130318. paddingColor?: Color3 | Color4;
  130319. }
  130320. /**
  130321. * Defines the basic interface of a TexturePacker JSON File
  130322. */
  130323. export interface ITexturePackerJSON {
  130324. /**
  130325. * The frame ID
  130326. */
  130327. name: string;
  130328. /**
  130329. * The base64 channel data
  130330. */
  130331. sets: any;
  130332. /**
  130333. * The options of the Packer
  130334. */
  130335. options: ITexturePackerOptions;
  130336. /**
  130337. * The frame data of the Packer
  130338. */
  130339. frames: Array<number>;
  130340. }
  130341. /**
  130342. * This is a support class that generates a series of packed texture sets.
  130343. * @see https://doc.babylonjs.com/babylon101/materials
  130344. */
  130345. export class TexturePacker {
  130346. /** Packer Layout Constant 0 */
  130347. static readonly LAYOUT_STRIP: number;
  130348. /** Packer Layout Constant 1 */
  130349. static readonly LAYOUT_POWER2: number;
  130350. /** Packer Layout Constant 2 */
  130351. static readonly LAYOUT_COLNUM: number;
  130352. /** Packer Layout Constant 0 */
  130353. static readonly SUBUV_WRAP: number;
  130354. /** Packer Layout Constant 1 */
  130355. static readonly SUBUV_EXTEND: number;
  130356. /** Packer Layout Constant 2 */
  130357. static readonly SUBUV_COLOR: number;
  130358. /** The Name of the Texture Package */
  130359. name: string;
  130360. /** The scene scope of the TexturePacker */
  130361. scene: Scene;
  130362. /** The Meshes to target */
  130363. meshes: AbstractMesh[];
  130364. /** Arguments passed with the Constructor */
  130365. options: ITexturePackerOptions;
  130366. /** The promise that is started upon initialization */
  130367. promise: Nullable<Promise<TexturePacker | string>>;
  130368. /** The Container object for the channel sets that are generated */
  130369. sets: object;
  130370. /** The Container array for the frames that are generated */
  130371. frames: TexturePackerFrame[];
  130372. /** The expected number of textures the system is parsing. */
  130373. private _expecting;
  130374. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  130375. private _paddingValue;
  130376. /**
  130377. * Initializes a texture package series from an array of meshes or a single mesh.
  130378. * @param name The name of the package
  130379. * @param meshes The target meshes to compose the package from
  130380. * @param options The arguments that texture packer should follow while building.
  130381. * @param scene The scene which the textures are scoped to.
  130382. * @returns TexturePacker
  130383. */
  130384. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  130385. /**
  130386. * Starts the package process
  130387. * @param resolve The promises resolution function
  130388. * @returns TexturePacker
  130389. */
  130390. private _createFrames;
  130391. /**
  130392. * Calculates the Size of the Channel Sets
  130393. * @returns Vector2
  130394. */
  130395. private _calculateSize;
  130396. /**
  130397. * Calculates the UV data for the frames.
  130398. * @param baseSize the base frameSize
  130399. * @param padding the base frame padding
  130400. * @param dtSize size of the Dynamic Texture for that channel
  130401. * @param dtUnits is 1/dtSize
  130402. * @param update flag to update the input meshes
  130403. */
  130404. private _calculateMeshUVFrames;
  130405. /**
  130406. * Calculates the frames Offset.
  130407. * @param index of the frame
  130408. * @returns Vector2
  130409. */
  130410. private _getFrameOffset;
  130411. /**
  130412. * Updates a Mesh to the frame data
  130413. * @param mesh that is the target
  130414. * @param frameID or the frame index
  130415. */
  130416. private _updateMeshUV;
  130417. /**
  130418. * Updates a Meshes materials to use the texture packer channels
  130419. * @param m is the mesh to target
  130420. * @param force all channels on the packer to be set.
  130421. */
  130422. private _updateTextureReferences;
  130423. /**
  130424. * Public method to set a Mesh to a frame
  130425. * @param m that is the target
  130426. * @param frameID or the frame index
  130427. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130428. */
  130429. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130430. /**
  130431. * Starts the async promise to compile the texture packer.
  130432. * @returns Promise<void>
  130433. */
  130434. processAsync(): Promise<void>;
  130435. /**
  130436. * Disposes all textures associated with this packer
  130437. */
  130438. dispose(): void;
  130439. /**
  130440. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130441. * @param imageType is the image type to use.
  130442. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130443. */
  130444. download(imageType?: string, quality?: number): void;
  130445. /**
  130446. * Public method to load a texturePacker JSON file.
  130447. * @param data of the JSON file in string format.
  130448. */
  130449. updateFromJSON(data: string): void;
  130450. }
  130451. }
  130452. declare module BABYLON {
  130453. /**
  130454. * Enum used to define the target of a block
  130455. */
  130456. export enum NodeMaterialBlockTargets {
  130457. /** Vertex shader */
  130458. Vertex = 1,
  130459. /** Fragment shader */
  130460. Fragment = 2,
  130461. /** Neutral */
  130462. Neutral = 4,
  130463. /** Vertex and Fragment */
  130464. VertexAndFragment = 3
  130465. }
  130466. }
  130467. declare module BABYLON {
  130468. /**
  130469. * Defines the kind of connection point for node based material
  130470. */
  130471. export enum NodeMaterialBlockConnectionPointTypes {
  130472. /** Float */
  130473. Float = 1,
  130474. /** Int */
  130475. Int = 2,
  130476. /** Vector2 */
  130477. Vector2 = 4,
  130478. /** Vector3 */
  130479. Vector3 = 8,
  130480. /** Vector4 */
  130481. Vector4 = 16,
  130482. /** Color3 */
  130483. Color3 = 32,
  130484. /** Color4 */
  130485. Color4 = 64,
  130486. /** Matrix */
  130487. Matrix = 128,
  130488. /** Detect type based on connection */
  130489. AutoDetect = 1024,
  130490. /** Output type that will be defined by input type */
  130491. BasedOnInput = 2048
  130492. }
  130493. }
  130494. declare module BABYLON {
  130495. /**
  130496. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130497. */
  130498. export enum NodeMaterialBlockConnectionPointMode {
  130499. /** Value is an uniform */
  130500. Uniform = 0,
  130501. /** Value is a mesh attribute */
  130502. Attribute = 1,
  130503. /** Value is a varying between vertex and fragment shaders */
  130504. Varying = 2,
  130505. /** Mode is undefined */
  130506. Undefined = 3
  130507. }
  130508. }
  130509. declare module BABYLON {
  130510. /**
  130511. * Enum used to define system values e.g. values automatically provided by the system
  130512. */
  130513. export enum NodeMaterialSystemValues {
  130514. /** World */
  130515. World = 1,
  130516. /** View */
  130517. View = 2,
  130518. /** Projection */
  130519. Projection = 3,
  130520. /** ViewProjection */
  130521. ViewProjection = 4,
  130522. /** WorldView */
  130523. WorldView = 5,
  130524. /** WorldViewProjection */
  130525. WorldViewProjection = 6,
  130526. /** CameraPosition */
  130527. CameraPosition = 7,
  130528. /** Fog Color */
  130529. FogColor = 8,
  130530. /** Delta time */
  130531. DeltaTime = 9
  130532. }
  130533. }
  130534. declare module BABYLON {
  130535. /**
  130536. * Root class for all node material optimizers
  130537. */
  130538. export class NodeMaterialOptimizer {
  130539. /**
  130540. * Function used to optimize a NodeMaterial graph
  130541. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130542. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130543. */
  130544. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130545. }
  130546. }
  130547. declare module BABYLON {
  130548. /**
  130549. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130550. */
  130551. export class TransformBlock extends NodeMaterialBlock {
  130552. /**
  130553. * Defines the value to use to complement W value to transform it to a Vector4
  130554. */
  130555. complementW: number;
  130556. /**
  130557. * Defines the value to use to complement z value to transform it to a Vector4
  130558. */
  130559. complementZ: number;
  130560. /**
  130561. * Creates a new TransformBlock
  130562. * @param name defines the block name
  130563. */
  130564. constructor(name: string);
  130565. /**
  130566. * Gets the current class name
  130567. * @returns the class name
  130568. */
  130569. getClassName(): string;
  130570. /**
  130571. * Gets the vector input
  130572. */
  130573. get vector(): NodeMaterialConnectionPoint;
  130574. /**
  130575. * Gets the output component
  130576. */
  130577. get output(): NodeMaterialConnectionPoint;
  130578. /**
  130579. * Gets the xyz output component
  130580. */
  130581. get xyz(): NodeMaterialConnectionPoint;
  130582. /**
  130583. * Gets the matrix transform input
  130584. */
  130585. get transform(): NodeMaterialConnectionPoint;
  130586. protected _buildBlock(state: NodeMaterialBuildState): this;
  130587. serialize(): any;
  130588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130589. protected _dumpPropertiesCode(): string;
  130590. }
  130591. }
  130592. declare module BABYLON {
  130593. /**
  130594. * Block used to output the vertex position
  130595. */
  130596. export class VertexOutputBlock extends NodeMaterialBlock {
  130597. /**
  130598. * Creates a new VertexOutputBlock
  130599. * @param name defines the block name
  130600. */
  130601. constructor(name: string);
  130602. /**
  130603. * Gets the current class name
  130604. * @returns the class name
  130605. */
  130606. getClassName(): string;
  130607. /**
  130608. * Gets the vector input component
  130609. */
  130610. get vector(): NodeMaterialConnectionPoint;
  130611. protected _buildBlock(state: NodeMaterialBuildState): this;
  130612. }
  130613. }
  130614. declare module BABYLON {
  130615. /**
  130616. * Block used to output the final color
  130617. */
  130618. export class FragmentOutputBlock extends NodeMaterialBlock {
  130619. /**
  130620. * Create a new FragmentOutputBlock
  130621. * @param name defines the block name
  130622. */
  130623. constructor(name: string);
  130624. /**
  130625. * Gets the current class name
  130626. * @returns the class name
  130627. */
  130628. getClassName(): string;
  130629. /**
  130630. * Gets the rgba input component
  130631. */
  130632. get rgba(): NodeMaterialConnectionPoint;
  130633. /**
  130634. * Gets the rgb input component
  130635. */
  130636. get rgb(): NodeMaterialConnectionPoint;
  130637. /**
  130638. * Gets the a input component
  130639. */
  130640. get a(): NodeMaterialConnectionPoint;
  130641. protected _buildBlock(state: NodeMaterialBuildState): this;
  130642. }
  130643. }
  130644. declare module BABYLON {
  130645. /**
  130646. * Block used to read a reflection texture from a sampler
  130647. */
  130648. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130649. private _define3DName;
  130650. private _defineCubicName;
  130651. private _defineExplicitName;
  130652. private _defineProjectionName;
  130653. private _defineLocalCubicName;
  130654. private _defineSphericalName;
  130655. private _definePlanarName;
  130656. private _defineEquirectangularName;
  130657. private _defineMirroredEquirectangularFixedName;
  130658. private _defineEquirectangularFixedName;
  130659. private _defineSkyboxName;
  130660. private _cubeSamplerName;
  130661. private _2DSamplerName;
  130662. private _positionUVWName;
  130663. private _directionWName;
  130664. private _reflectionCoordsName;
  130665. private _reflection2DCoordsName;
  130666. private _reflectionColorName;
  130667. private _reflectionMatrixName;
  130668. /**
  130669. * Gets or sets the texture associated with the node
  130670. */
  130671. texture: Nullable<BaseTexture>;
  130672. /**
  130673. * Create a new TextureBlock
  130674. * @param name defines the block name
  130675. */
  130676. constructor(name: string);
  130677. /**
  130678. * Gets the current class name
  130679. * @returns the class name
  130680. */
  130681. getClassName(): string;
  130682. /**
  130683. * Gets the world position input component
  130684. */
  130685. get position(): NodeMaterialConnectionPoint;
  130686. /**
  130687. * Gets the world position input component
  130688. */
  130689. get worldPosition(): NodeMaterialConnectionPoint;
  130690. /**
  130691. * Gets the world normal input component
  130692. */
  130693. get worldNormal(): NodeMaterialConnectionPoint;
  130694. /**
  130695. * Gets the world input component
  130696. */
  130697. get world(): NodeMaterialConnectionPoint;
  130698. /**
  130699. * Gets the camera (or eye) position component
  130700. */
  130701. get cameraPosition(): NodeMaterialConnectionPoint;
  130702. /**
  130703. * Gets the view input component
  130704. */
  130705. get view(): NodeMaterialConnectionPoint;
  130706. /**
  130707. * Gets the rgb output component
  130708. */
  130709. get rgb(): NodeMaterialConnectionPoint;
  130710. /**
  130711. * Gets the r output component
  130712. */
  130713. get r(): NodeMaterialConnectionPoint;
  130714. /**
  130715. * Gets the g output component
  130716. */
  130717. get g(): NodeMaterialConnectionPoint;
  130718. /**
  130719. * Gets the b output component
  130720. */
  130721. get b(): NodeMaterialConnectionPoint;
  130722. autoConfigure(material: NodeMaterial): void;
  130723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130724. isReady(): boolean;
  130725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130726. private _injectVertexCode;
  130727. private _writeOutput;
  130728. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130729. protected _dumpPropertiesCode(): string;
  130730. serialize(): any;
  130731. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130732. }
  130733. }
  130734. declare module BABYLON {
  130735. /**
  130736. * Interface used to configure the node material editor
  130737. */
  130738. export interface INodeMaterialEditorOptions {
  130739. /** Define the URl to load node editor script */
  130740. editorURL?: string;
  130741. }
  130742. /** @hidden */
  130743. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130744. NORMAL: boolean;
  130745. TANGENT: boolean;
  130746. UV1: boolean;
  130747. /** BONES */
  130748. NUM_BONE_INFLUENCERS: number;
  130749. BonesPerMesh: number;
  130750. BONETEXTURE: boolean;
  130751. /** MORPH TARGETS */
  130752. MORPHTARGETS: boolean;
  130753. MORPHTARGETS_NORMAL: boolean;
  130754. MORPHTARGETS_TANGENT: boolean;
  130755. MORPHTARGETS_UV: boolean;
  130756. NUM_MORPH_INFLUENCERS: number;
  130757. /** IMAGE PROCESSING */
  130758. IMAGEPROCESSING: boolean;
  130759. VIGNETTE: boolean;
  130760. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130761. VIGNETTEBLENDMODEOPAQUE: boolean;
  130762. TONEMAPPING: boolean;
  130763. TONEMAPPING_ACES: boolean;
  130764. CONTRAST: boolean;
  130765. EXPOSURE: boolean;
  130766. COLORCURVES: boolean;
  130767. COLORGRADING: boolean;
  130768. COLORGRADING3D: boolean;
  130769. SAMPLER3DGREENDEPTH: boolean;
  130770. SAMPLER3DBGRMAP: boolean;
  130771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130772. /** MISC. */
  130773. BUMPDIRECTUV: number;
  130774. constructor();
  130775. setValue(name: string, value: boolean): void;
  130776. }
  130777. /**
  130778. * Class used to configure NodeMaterial
  130779. */
  130780. export interface INodeMaterialOptions {
  130781. /**
  130782. * Defines if blocks should emit comments
  130783. */
  130784. emitComments: boolean;
  130785. }
  130786. /**
  130787. * Class used to create a node based material built by assembling shader blocks
  130788. */
  130789. export class NodeMaterial extends PushMaterial {
  130790. private static _BuildIdGenerator;
  130791. private _options;
  130792. private _vertexCompilationState;
  130793. private _fragmentCompilationState;
  130794. private _sharedData;
  130795. private _buildId;
  130796. private _buildWasSuccessful;
  130797. private _cachedWorldViewMatrix;
  130798. private _cachedWorldViewProjectionMatrix;
  130799. private _optimizers;
  130800. private _animationFrame;
  130801. /** Define the Url to load node editor script */
  130802. static EditorURL: string;
  130803. /** Define the Url to load snippets */
  130804. static SnippetUrl: string;
  130805. private BJSNODEMATERIALEDITOR;
  130806. /** Get the inspector from bundle or global */
  130807. private _getGlobalNodeMaterialEditor;
  130808. /**
  130809. * Gets or sets data used by visual editor
  130810. * @see https://nme.babylonjs.com
  130811. */
  130812. editorData: any;
  130813. /**
  130814. * 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)
  130815. */
  130816. ignoreAlpha: boolean;
  130817. /**
  130818. * Defines the maximum number of lights that can be used in the material
  130819. */
  130820. maxSimultaneousLights: number;
  130821. /**
  130822. * Observable raised when the material is built
  130823. */
  130824. onBuildObservable: Observable<NodeMaterial>;
  130825. /**
  130826. * Gets or sets the root nodes of the material vertex shader
  130827. */
  130828. _vertexOutputNodes: NodeMaterialBlock[];
  130829. /**
  130830. * Gets or sets the root nodes of the material fragment (pixel) shader
  130831. */
  130832. _fragmentOutputNodes: NodeMaterialBlock[];
  130833. /** Gets or sets options to control the node material overall behavior */
  130834. get options(): INodeMaterialOptions;
  130835. set options(options: INodeMaterialOptions);
  130836. /**
  130837. * Default configuration related to image processing available in the standard Material.
  130838. */
  130839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130840. /**
  130841. * Gets the image processing configuration used either in this material.
  130842. */
  130843. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130844. /**
  130845. * Sets the Default image processing configuration used either in the this material.
  130846. *
  130847. * If sets to null, the scene one is in use.
  130848. */
  130849. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130850. /**
  130851. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130852. */
  130853. attachedBlocks: NodeMaterialBlock[];
  130854. /**
  130855. * Create a new node based material
  130856. * @param name defines the material name
  130857. * @param scene defines the hosting scene
  130858. * @param options defines creation option
  130859. */
  130860. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130861. /**
  130862. * Gets the current class name of the material e.g. "NodeMaterial"
  130863. * @returns the class name
  130864. */
  130865. getClassName(): string;
  130866. /**
  130867. * Keep track of the image processing observer to allow dispose and replace.
  130868. */
  130869. private _imageProcessingObserver;
  130870. /**
  130871. * Attaches a new image processing configuration to the Standard Material.
  130872. * @param configuration
  130873. */
  130874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130875. /**
  130876. * Get a block by its name
  130877. * @param name defines the name of the block to retrieve
  130878. * @returns the required block or null if not found
  130879. */
  130880. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130881. /**
  130882. * Get a block by its name
  130883. * @param predicate defines the predicate used to find the good candidate
  130884. * @returns the required block or null if not found
  130885. */
  130886. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130887. /**
  130888. * Get an input block by its name
  130889. * @param predicate defines the predicate used to find the good candidate
  130890. * @returns the required input block or null if not found
  130891. */
  130892. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130893. /**
  130894. * Gets the list of input blocks attached to this material
  130895. * @returns an array of InputBlocks
  130896. */
  130897. getInputBlocks(): InputBlock[];
  130898. /**
  130899. * Adds a new optimizer to the list of optimizers
  130900. * @param optimizer defines the optimizers to add
  130901. * @returns the current material
  130902. */
  130903. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130904. /**
  130905. * Remove an optimizer from the list of optimizers
  130906. * @param optimizer defines the optimizers to remove
  130907. * @returns the current material
  130908. */
  130909. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130910. /**
  130911. * Add a new block to the list of output nodes
  130912. * @param node defines the node to add
  130913. * @returns the current material
  130914. */
  130915. addOutputNode(node: NodeMaterialBlock): this;
  130916. /**
  130917. * Remove a block from the list of root nodes
  130918. * @param node defines the node to remove
  130919. * @returns the current material
  130920. */
  130921. removeOutputNode(node: NodeMaterialBlock): this;
  130922. private _addVertexOutputNode;
  130923. private _removeVertexOutputNode;
  130924. private _addFragmentOutputNode;
  130925. private _removeFragmentOutputNode;
  130926. /**
  130927. * Specifies if the material will require alpha blending
  130928. * @returns a boolean specifying if alpha blending is needed
  130929. */
  130930. needAlphaBlending(): boolean;
  130931. /**
  130932. * Specifies if this material should be rendered in alpha test mode
  130933. * @returns a boolean specifying if an alpha test is needed.
  130934. */
  130935. needAlphaTesting(): boolean;
  130936. private _initializeBlock;
  130937. private _resetDualBlocks;
  130938. /**
  130939. * Remove a block from the current node material
  130940. * @param block defines the block to remove
  130941. */
  130942. removeBlock(block: NodeMaterialBlock): void;
  130943. /**
  130944. * Build the material and generates the inner effect
  130945. * @param verbose defines if the build should log activity
  130946. */
  130947. build(verbose?: boolean): void;
  130948. /**
  130949. * Runs an otpimization phase to try to improve the shader code
  130950. */
  130951. optimize(): void;
  130952. private _prepareDefinesForAttributes;
  130953. /**
  130954. * Get if the submesh is ready to be used and all its information available.
  130955. * Child classes can use it to update shaders
  130956. * @param mesh defines the mesh to check
  130957. * @param subMesh defines which submesh to check
  130958. * @param useInstances specifies that instances should be used
  130959. * @returns a boolean indicating that the submesh is ready or not
  130960. */
  130961. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130962. /**
  130963. * Get a string representing the shaders built by the current node graph
  130964. */
  130965. get compiledShaders(): string;
  130966. /**
  130967. * Binds the world matrix to the material
  130968. * @param world defines the world transformation matrix
  130969. */
  130970. bindOnlyWorldMatrix(world: Matrix): void;
  130971. /**
  130972. * Binds the submesh to this material by preparing the effect and shader to draw
  130973. * @param world defines the world transformation matrix
  130974. * @param mesh defines the mesh containing the submesh
  130975. * @param subMesh defines the submesh to bind the material to
  130976. */
  130977. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130978. /**
  130979. * Gets the active textures from the material
  130980. * @returns an array of textures
  130981. */
  130982. getActiveTextures(): BaseTexture[];
  130983. /**
  130984. * Gets the list of texture blocks
  130985. * @returns an array of texture blocks
  130986. */
  130987. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130988. /**
  130989. * Specifies if the material uses a texture
  130990. * @param texture defines the texture to check against the material
  130991. * @returns a boolean specifying if the material uses the texture
  130992. */
  130993. hasTexture(texture: BaseTexture): boolean;
  130994. /**
  130995. * Disposes the material
  130996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130999. */
  131000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  131001. /** Creates the node editor window. */
  131002. private _createNodeEditor;
  131003. /**
  131004. * Launch the node material editor
  131005. * @param config Define the configuration of the editor
  131006. * @return a promise fulfilled when the node editor is visible
  131007. */
  131008. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  131009. /**
  131010. * Clear the current material
  131011. */
  131012. clear(): void;
  131013. /**
  131014. * Clear the current material and set it to a default state
  131015. */
  131016. setToDefault(): void;
  131017. /**
  131018. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  131019. * @param url defines the url to load from
  131020. * @returns a promise that will fullfil when the material is fully loaded
  131021. */
  131022. loadAsync(url: string): Promise<void>;
  131023. private _gatherBlocks;
  131024. /**
  131025. * Generate a string containing the code declaration required to create an equivalent of this material
  131026. * @returns a string
  131027. */
  131028. generateCode(): string;
  131029. /**
  131030. * Serializes this material in a JSON representation
  131031. * @returns the serialized material object
  131032. */
  131033. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  131034. private _restoreConnections;
  131035. /**
  131036. * Clear the current graph and load a new one from a serialization object
  131037. * @param source defines the JSON representation of the material
  131038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131039. */
  131040. loadFromSerialization(source: any, rootUrl?: string): void;
  131041. /**
  131042. * Creates a node material from parsed material data
  131043. * @param source defines the JSON representation of the material
  131044. * @param scene defines the hosting scene
  131045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131046. * @returns a new node material
  131047. */
  131048. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  131049. /**
  131050. * Creates a node material from a snippet saved in a remote file
  131051. * @param name defines the name of the material to create
  131052. * @param url defines the url to load from
  131053. * @param scene defines the hosting scene
  131054. * @returns a promise that will resolve to the new node material
  131055. */
  131056. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  131057. /**
  131058. * Creates a node material from a snippet saved by the node material editor
  131059. * @param snippetId defines the snippet to load
  131060. * @param scene defines the hosting scene
  131061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131062. * @returns a promise that will resolve to the new node material
  131063. */
  131064. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  131065. /**
  131066. * Creates a new node material set to default basic configuration
  131067. * @param name defines the name of the material
  131068. * @param scene defines the hosting scene
  131069. * @returns a new NodeMaterial
  131070. */
  131071. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  131072. }
  131073. }
  131074. declare module BABYLON {
  131075. /**
  131076. * Block used to read a texture from a sampler
  131077. */
  131078. export class TextureBlock extends NodeMaterialBlock {
  131079. private _defineName;
  131080. private _linearDefineName;
  131081. private _tempTextureRead;
  131082. private _samplerName;
  131083. private _transformedUVName;
  131084. private _textureTransformName;
  131085. private _textureInfoName;
  131086. private _mainUVName;
  131087. private _mainUVDefineName;
  131088. /**
  131089. * Gets or sets the texture associated with the node
  131090. */
  131091. texture: Nullable<Texture>;
  131092. /**
  131093. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  131094. */
  131095. convertToGammaSpace: boolean;
  131096. /**
  131097. * Create a new TextureBlock
  131098. * @param name defines the block name
  131099. */
  131100. constructor(name: string);
  131101. /**
  131102. * Gets the current class name
  131103. * @returns the class name
  131104. */
  131105. getClassName(): string;
  131106. /**
  131107. * Gets the uv input component
  131108. */
  131109. get uv(): NodeMaterialConnectionPoint;
  131110. /**
  131111. * Gets the rgba output component
  131112. */
  131113. get rgba(): NodeMaterialConnectionPoint;
  131114. /**
  131115. * Gets the rgb output component
  131116. */
  131117. get rgb(): NodeMaterialConnectionPoint;
  131118. /**
  131119. * Gets the r output component
  131120. */
  131121. get r(): NodeMaterialConnectionPoint;
  131122. /**
  131123. * Gets the g output component
  131124. */
  131125. get g(): NodeMaterialConnectionPoint;
  131126. /**
  131127. * Gets the b output component
  131128. */
  131129. get b(): NodeMaterialConnectionPoint;
  131130. /**
  131131. * Gets the a output component
  131132. */
  131133. get a(): NodeMaterialConnectionPoint;
  131134. get target(): NodeMaterialBlockTargets;
  131135. autoConfigure(material: NodeMaterial): void;
  131136. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131138. isReady(): boolean;
  131139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131140. private get _isMixed();
  131141. private _injectVertexCode;
  131142. private _writeTextureRead;
  131143. private _writeOutput;
  131144. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131145. protected _dumpPropertiesCode(): string;
  131146. serialize(): any;
  131147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131148. }
  131149. }
  131150. declare module BABYLON {
  131151. /**
  131152. * Class used to store shared data between 2 NodeMaterialBuildState
  131153. */
  131154. export class NodeMaterialBuildStateSharedData {
  131155. /**
  131156. * Gets the list of emitted varyings
  131157. */
  131158. temps: string[];
  131159. /**
  131160. * Gets the list of emitted varyings
  131161. */
  131162. varyings: string[];
  131163. /**
  131164. * Gets the varying declaration string
  131165. */
  131166. varyingDeclaration: string;
  131167. /**
  131168. * Input blocks
  131169. */
  131170. inputBlocks: InputBlock[];
  131171. /**
  131172. * Input blocks
  131173. */
  131174. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  131175. /**
  131176. * Bindable blocks (Blocks that need to set data to the effect)
  131177. */
  131178. bindableBlocks: NodeMaterialBlock[];
  131179. /**
  131180. * List of blocks that can provide a compilation fallback
  131181. */
  131182. blocksWithFallbacks: NodeMaterialBlock[];
  131183. /**
  131184. * List of blocks that can provide a define update
  131185. */
  131186. blocksWithDefines: NodeMaterialBlock[];
  131187. /**
  131188. * List of blocks that can provide a repeatable content
  131189. */
  131190. repeatableContentBlocks: NodeMaterialBlock[];
  131191. /**
  131192. * List of blocks that can provide a dynamic list of uniforms
  131193. */
  131194. dynamicUniformBlocks: NodeMaterialBlock[];
  131195. /**
  131196. * List of blocks that can block the isReady function for the material
  131197. */
  131198. blockingBlocks: NodeMaterialBlock[];
  131199. /**
  131200. * Gets the list of animated inputs
  131201. */
  131202. animatedInputs: InputBlock[];
  131203. /**
  131204. * Build Id used to avoid multiple recompilations
  131205. */
  131206. buildId: number;
  131207. /** List of emitted variables */
  131208. variableNames: {
  131209. [key: string]: number;
  131210. };
  131211. /** List of emitted defines */
  131212. defineNames: {
  131213. [key: string]: number;
  131214. };
  131215. /** Should emit comments? */
  131216. emitComments: boolean;
  131217. /** Emit build activity */
  131218. verbose: boolean;
  131219. /** Gets or sets the hosting scene */
  131220. scene: Scene;
  131221. /**
  131222. * Gets the compilation hints emitted at compilation time
  131223. */
  131224. hints: {
  131225. needWorldViewMatrix: boolean;
  131226. needWorldViewProjectionMatrix: boolean;
  131227. needAlphaBlending: boolean;
  131228. needAlphaTesting: boolean;
  131229. };
  131230. /**
  131231. * List of compilation checks
  131232. */
  131233. checks: {
  131234. emitVertex: boolean;
  131235. emitFragment: boolean;
  131236. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  131237. };
  131238. /** Creates a new shared data */
  131239. constructor();
  131240. /**
  131241. * Emits console errors and exceptions if there is a failing check
  131242. */
  131243. emitErrors(): void;
  131244. }
  131245. }
  131246. declare module BABYLON {
  131247. /**
  131248. * Class used to store node based material build state
  131249. */
  131250. export class NodeMaterialBuildState {
  131251. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  131252. supportUniformBuffers: boolean;
  131253. /**
  131254. * Gets the list of emitted attributes
  131255. */
  131256. attributes: string[];
  131257. /**
  131258. * Gets the list of emitted uniforms
  131259. */
  131260. uniforms: string[];
  131261. /**
  131262. * Gets the list of emitted constants
  131263. */
  131264. constants: string[];
  131265. /**
  131266. * Gets the list of emitted samplers
  131267. */
  131268. samplers: string[];
  131269. /**
  131270. * Gets the list of emitted functions
  131271. */
  131272. functions: {
  131273. [key: string]: string;
  131274. };
  131275. /**
  131276. * Gets the list of emitted extensions
  131277. */
  131278. extensions: {
  131279. [key: string]: string;
  131280. };
  131281. /**
  131282. * Gets the target of the compilation state
  131283. */
  131284. target: NodeMaterialBlockTargets;
  131285. /**
  131286. * Gets the list of emitted counters
  131287. */
  131288. counters: {
  131289. [key: string]: number;
  131290. };
  131291. /**
  131292. * Shared data between multiple NodeMaterialBuildState instances
  131293. */
  131294. sharedData: NodeMaterialBuildStateSharedData;
  131295. /** @hidden */
  131296. _vertexState: NodeMaterialBuildState;
  131297. /** @hidden */
  131298. _attributeDeclaration: string;
  131299. /** @hidden */
  131300. _uniformDeclaration: string;
  131301. /** @hidden */
  131302. _constantDeclaration: string;
  131303. /** @hidden */
  131304. _samplerDeclaration: string;
  131305. /** @hidden */
  131306. _varyingTransfer: string;
  131307. private _repeatableContentAnchorIndex;
  131308. /** @hidden */
  131309. _builtCompilationString: string;
  131310. /**
  131311. * Gets the emitted compilation strings
  131312. */
  131313. compilationString: string;
  131314. /**
  131315. * Finalize the compilation strings
  131316. * @param state defines the current compilation state
  131317. */
  131318. finalize(state: NodeMaterialBuildState): void;
  131319. /** @hidden */
  131320. get _repeatableContentAnchor(): string;
  131321. /** @hidden */
  131322. _getFreeVariableName(prefix: string): string;
  131323. /** @hidden */
  131324. _getFreeDefineName(prefix: string): string;
  131325. /** @hidden */
  131326. _excludeVariableName(name: string): void;
  131327. /** @hidden */
  131328. _emit2DSampler(name: string): void;
  131329. /** @hidden */
  131330. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  131331. /** @hidden */
  131332. _emitExtension(name: string, extension: string): void;
  131333. /** @hidden */
  131334. _emitFunction(name: string, code: string, comments: string): void;
  131335. /** @hidden */
  131336. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  131337. replaceStrings?: {
  131338. search: RegExp;
  131339. replace: string;
  131340. }[];
  131341. repeatKey?: string;
  131342. }): string;
  131343. /** @hidden */
  131344. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  131345. repeatKey?: string;
  131346. removeAttributes?: boolean;
  131347. removeUniforms?: boolean;
  131348. removeVaryings?: boolean;
  131349. removeIfDef?: boolean;
  131350. replaceStrings?: {
  131351. search: RegExp;
  131352. replace: string;
  131353. }[];
  131354. }, storeKey?: string): void;
  131355. /** @hidden */
  131356. _registerTempVariable(name: string): boolean;
  131357. /** @hidden */
  131358. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  131359. /** @hidden */
  131360. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  131361. /** @hidden */
  131362. _emitFloat(value: number): string;
  131363. }
  131364. }
  131365. declare module BABYLON {
  131366. /**
  131367. * Defines a block that can be used inside a node based material
  131368. */
  131369. export class NodeMaterialBlock {
  131370. private _buildId;
  131371. private _buildTarget;
  131372. private _target;
  131373. private _isFinalMerger;
  131374. private _isInput;
  131375. protected _isUnique: boolean;
  131376. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  131377. inputsAreExclusive: boolean;
  131378. /** @hidden */
  131379. _codeVariableName: string;
  131380. /** @hidden */
  131381. _inputs: NodeMaterialConnectionPoint[];
  131382. /** @hidden */
  131383. _outputs: NodeMaterialConnectionPoint[];
  131384. /** @hidden */
  131385. _preparationId: number;
  131386. /**
  131387. * Gets or sets the name of the block
  131388. */
  131389. name: string;
  131390. /**
  131391. * Gets or sets the unique id of the node
  131392. */
  131393. uniqueId: number;
  131394. /**
  131395. * Gets or sets the comments associated with this block
  131396. */
  131397. comments: string;
  131398. /**
  131399. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131400. */
  131401. get isUnique(): boolean;
  131402. /**
  131403. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131404. */
  131405. get isFinalMerger(): boolean;
  131406. /**
  131407. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131408. */
  131409. get isInput(): boolean;
  131410. /**
  131411. * Gets or sets the build Id
  131412. */
  131413. get buildId(): number;
  131414. set buildId(value: number);
  131415. /**
  131416. * Gets or sets the target of the block
  131417. */
  131418. get target(): NodeMaterialBlockTargets;
  131419. set target(value: NodeMaterialBlockTargets);
  131420. /**
  131421. * Gets the list of input points
  131422. */
  131423. get inputs(): NodeMaterialConnectionPoint[];
  131424. /** Gets the list of output points */
  131425. get outputs(): NodeMaterialConnectionPoint[];
  131426. /**
  131427. * Find an input by its name
  131428. * @param name defines the name of the input to look for
  131429. * @returns the input or null if not found
  131430. */
  131431. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131432. /**
  131433. * Find an output by its name
  131434. * @param name defines the name of the outputto look for
  131435. * @returns the output or null if not found
  131436. */
  131437. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131438. /**
  131439. * Creates a new NodeMaterialBlock
  131440. * @param name defines the block name
  131441. * @param target defines the target of that block (Vertex by default)
  131442. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131443. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131444. */
  131445. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131446. /**
  131447. * Initialize the block and prepare the context for build
  131448. * @param state defines the state that will be used for the build
  131449. */
  131450. initialize(state: NodeMaterialBuildState): void;
  131451. /**
  131452. * Bind data to effect. Will only be called for blocks with isBindable === true
  131453. * @param effect defines the effect to bind data to
  131454. * @param nodeMaterial defines the hosting NodeMaterial
  131455. * @param mesh defines the mesh that will be rendered
  131456. */
  131457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131458. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131459. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131460. protected _writeFloat(value: number): string;
  131461. /**
  131462. * Gets the current class name e.g. "NodeMaterialBlock"
  131463. * @returns the class name
  131464. */
  131465. getClassName(): string;
  131466. /**
  131467. * Register a new input. Must be called inside a block constructor
  131468. * @param name defines the connection point name
  131469. * @param type defines the connection point type
  131470. * @param isOptional defines a boolean indicating that this input can be omitted
  131471. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131472. * @returns the current block
  131473. */
  131474. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131475. /**
  131476. * Register a new output. Must be called inside a block constructor
  131477. * @param name defines the connection point name
  131478. * @param type defines the connection point type
  131479. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131480. * @returns the current block
  131481. */
  131482. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131483. /**
  131484. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131485. * @param forOutput defines an optional connection point to check compatibility with
  131486. * @returns the first available input or null
  131487. */
  131488. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131489. /**
  131490. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131491. * @param forBlock defines an optional block to check compatibility with
  131492. * @returns the first available input or null
  131493. */
  131494. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131495. /**
  131496. * Gets the sibling of the given output
  131497. * @param current defines the current output
  131498. * @returns the next output in the list or null
  131499. */
  131500. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131501. /**
  131502. * Connect current block with another block
  131503. * @param other defines the block to connect with
  131504. * @param options define the various options to help pick the right connections
  131505. * @returns the current block
  131506. */
  131507. connectTo(other: NodeMaterialBlock, options?: {
  131508. input?: string;
  131509. output?: string;
  131510. outputSwizzle?: string;
  131511. }): this | undefined;
  131512. protected _buildBlock(state: NodeMaterialBuildState): void;
  131513. /**
  131514. * Add uniforms, samplers and uniform buffers at compilation time
  131515. * @param state defines the state to update
  131516. * @param nodeMaterial defines the node material requesting the update
  131517. * @param defines defines the material defines to update
  131518. * @param uniformBuffers defines the list of uniform buffer names
  131519. */
  131520. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131521. /**
  131522. * Add potential fallbacks if shader compilation fails
  131523. * @param mesh defines the mesh to be rendered
  131524. * @param fallbacks defines the current prioritized list of fallbacks
  131525. */
  131526. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131527. /**
  131528. * Initialize defines for shader compilation
  131529. * @param mesh defines the mesh to be rendered
  131530. * @param nodeMaterial defines the node material requesting the update
  131531. * @param defines defines the material defines to update
  131532. * @param useInstances specifies that instances should be used
  131533. */
  131534. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131535. /**
  131536. * Update defines for shader compilation
  131537. * @param mesh defines the mesh to be rendered
  131538. * @param nodeMaterial defines the node material requesting the update
  131539. * @param defines defines the material defines to update
  131540. * @param useInstances specifies that instances should be used
  131541. */
  131542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131543. /**
  131544. * Lets the block try to connect some inputs automatically
  131545. * @param material defines the hosting NodeMaterial
  131546. */
  131547. autoConfigure(material: NodeMaterial): void;
  131548. /**
  131549. * Function called when a block is declared as repeatable content generator
  131550. * @param vertexShaderState defines the current compilation state for the vertex shader
  131551. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131552. * @param mesh defines the mesh to be rendered
  131553. * @param defines defines the material defines to update
  131554. */
  131555. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131556. /**
  131557. * Checks if the block is ready
  131558. * @param mesh defines the mesh to be rendered
  131559. * @param nodeMaterial defines the node material requesting the update
  131560. * @param defines defines the material defines to update
  131561. * @param useInstances specifies that instances should be used
  131562. * @returns true if the block is ready
  131563. */
  131564. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131565. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131566. private _processBuild;
  131567. /**
  131568. * Compile the current node and generate the shader code
  131569. * @param state defines the current compilation state (uniforms, samplers, current string)
  131570. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131571. * @returns true if already built
  131572. */
  131573. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131574. protected _inputRename(name: string): string;
  131575. protected _outputRename(name: string): string;
  131576. protected _dumpPropertiesCode(): string;
  131577. /** @hidden */
  131578. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131579. /** @hidden */
  131580. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131581. /**
  131582. * Clone the current block to a new identical block
  131583. * @param scene defines the hosting scene
  131584. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131585. * @returns a copy of the current block
  131586. */
  131587. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131588. /**
  131589. * Serializes this block in a JSON representation
  131590. * @returns the serialized block object
  131591. */
  131592. serialize(): any;
  131593. /** @hidden */
  131594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131595. /**
  131596. * Release resources
  131597. */
  131598. dispose(): void;
  131599. }
  131600. }
  131601. declare module BABYLON {
  131602. /**
  131603. * Enum defining the type of animations supported by InputBlock
  131604. */
  131605. export enum AnimatedInputBlockTypes {
  131606. /** No animation */
  131607. None = 0,
  131608. /** Time based animation. Will only work for floats */
  131609. Time = 1
  131610. }
  131611. }
  131612. declare module BABYLON {
  131613. /**
  131614. * Block used to expose an input value
  131615. */
  131616. export class InputBlock extends NodeMaterialBlock {
  131617. private _mode;
  131618. private _associatedVariableName;
  131619. private _storedValue;
  131620. private _valueCallback;
  131621. private _type;
  131622. private _animationType;
  131623. /** Gets or set a value used to limit the range of float values */
  131624. min: number;
  131625. /** Gets or set a value used to limit the range of float values */
  131626. max: number;
  131627. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131628. isBoolean: boolean;
  131629. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131630. matrixMode: number;
  131631. /** @hidden */
  131632. _systemValue: Nullable<NodeMaterialSystemValues>;
  131633. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131634. visibleInInspector: boolean;
  131635. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131636. isConstant: boolean;
  131637. /** Gets or sets the group to use to display this block in the Inspector */
  131638. groupInInspector: string;
  131639. /** Gets an observable raised when the value is changed */
  131640. onValueChangedObservable: Observable<InputBlock>;
  131641. /**
  131642. * Gets or sets the connection point type (default is float)
  131643. */
  131644. get type(): NodeMaterialBlockConnectionPointTypes;
  131645. /**
  131646. * Creates a new InputBlock
  131647. * @param name defines the block name
  131648. * @param target defines the target of that block (Vertex by default)
  131649. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131650. */
  131651. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131652. /**
  131653. * Gets the output component
  131654. */
  131655. get output(): NodeMaterialConnectionPoint;
  131656. /**
  131657. * Set the source of this connection point to a vertex attribute
  131658. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131659. * @returns the current connection point
  131660. */
  131661. setAsAttribute(attributeName?: string): InputBlock;
  131662. /**
  131663. * Set the source of this connection point to a system value
  131664. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131665. * @returns the current connection point
  131666. */
  131667. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131668. /**
  131669. * Gets or sets the value of that point.
  131670. * Please note that this value will be ignored if valueCallback is defined
  131671. */
  131672. get value(): any;
  131673. set value(value: any);
  131674. /**
  131675. * Gets or sets a callback used to get the value of that point.
  131676. * Please note that setting this value will force the connection point to ignore the value property
  131677. */
  131678. get valueCallback(): () => any;
  131679. set valueCallback(value: () => any);
  131680. /**
  131681. * Gets or sets the associated variable name in the shader
  131682. */
  131683. get associatedVariableName(): string;
  131684. set associatedVariableName(value: string);
  131685. /** Gets or sets the type of animation applied to the input */
  131686. get animationType(): AnimatedInputBlockTypes;
  131687. set animationType(value: AnimatedInputBlockTypes);
  131688. /**
  131689. * Gets a boolean indicating that this connection point not defined yet
  131690. */
  131691. get isUndefined(): boolean;
  131692. /**
  131693. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131694. * In this case the connection point name must be the name of the uniform to use.
  131695. * Can only be set on inputs
  131696. */
  131697. get isUniform(): boolean;
  131698. set isUniform(value: boolean);
  131699. /**
  131700. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131701. * In this case the connection point name must be the name of the attribute to use
  131702. * Can only be set on inputs
  131703. */
  131704. get isAttribute(): boolean;
  131705. set isAttribute(value: boolean);
  131706. /**
  131707. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131708. * Can only be set on exit points
  131709. */
  131710. get isVarying(): boolean;
  131711. set isVarying(value: boolean);
  131712. /**
  131713. * Gets a boolean indicating that the current connection point is a system value
  131714. */
  131715. get isSystemValue(): boolean;
  131716. /**
  131717. * Gets or sets the current well known value or null if not defined as a system value
  131718. */
  131719. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131720. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131721. /**
  131722. * Gets the current class name
  131723. * @returns the class name
  131724. */
  131725. getClassName(): string;
  131726. /**
  131727. * Animate the input if animationType !== None
  131728. * @param scene defines the rendering scene
  131729. */
  131730. animate(scene: Scene): void;
  131731. private _emitDefine;
  131732. initialize(state: NodeMaterialBuildState): void;
  131733. /**
  131734. * Set the input block to its default value (based on its type)
  131735. */
  131736. setDefaultValue(): void;
  131737. private _emitConstant;
  131738. private _emit;
  131739. /** @hidden */
  131740. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131741. /** @hidden */
  131742. _transmit(effect: Effect, scene: Scene): void;
  131743. protected _buildBlock(state: NodeMaterialBuildState): void;
  131744. protected _dumpPropertiesCode(): string;
  131745. dispose(): void;
  131746. serialize(): any;
  131747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131748. }
  131749. }
  131750. declare module BABYLON {
  131751. /**
  131752. * Enum used to define the compatibility state between two connection points
  131753. */
  131754. export enum NodeMaterialConnectionPointCompatibilityStates {
  131755. /** Points are compatibles */
  131756. Compatible = 0,
  131757. /** Points are incompatible because of their types */
  131758. TypeIncompatible = 1,
  131759. /** Points are incompatible because of their targets (vertex vs fragment) */
  131760. TargetIncompatible = 2
  131761. }
  131762. /**
  131763. * Defines the direction of a connection point
  131764. */
  131765. export enum NodeMaterialConnectionPointDirection {
  131766. /** Input */
  131767. Input = 0,
  131768. /** Output */
  131769. Output = 1
  131770. }
  131771. /**
  131772. * Defines a connection point for a block
  131773. */
  131774. export class NodeMaterialConnectionPoint {
  131775. /** @hidden */
  131776. _ownerBlock: NodeMaterialBlock;
  131777. /** @hidden */
  131778. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131779. private _endpoints;
  131780. private _associatedVariableName;
  131781. private _direction;
  131782. /** @hidden */
  131783. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131784. /** @hidden */
  131785. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131786. private _type;
  131787. /** @hidden */
  131788. _enforceAssociatedVariableName: boolean;
  131789. /** Gets the direction of the point */
  131790. get direction(): NodeMaterialConnectionPointDirection;
  131791. /**
  131792. * Gets or sets the additional types supported by this connection point
  131793. */
  131794. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131795. /**
  131796. * Gets or sets the additional types excluded by this connection point
  131797. */
  131798. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131799. /**
  131800. * Observable triggered when this point is connected
  131801. */
  131802. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131803. /**
  131804. * Gets or sets the associated variable name in the shader
  131805. */
  131806. get associatedVariableName(): string;
  131807. set associatedVariableName(value: string);
  131808. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131809. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131810. /**
  131811. * Gets or sets the connection point type (default is float)
  131812. */
  131813. get type(): NodeMaterialBlockConnectionPointTypes;
  131814. set type(value: NodeMaterialBlockConnectionPointTypes);
  131815. /**
  131816. * Gets or sets the connection point name
  131817. */
  131818. name: string;
  131819. /**
  131820. * Gets or sets a boolean indicating that this connection point can be omitted
  131821. */
  131822. isOptional: boolean;
  131823. /**
  131824. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131825. */
  131826. define: string;
  131827. /** @hidden */
  131828. _prioritizeVertex: boolean;
  131829. private _target;
  131830. /** Gets or sets the target of that connection point */
  131831. get target(): NodeMaterialBlockTargets;
  131832. set target(value: NodeMaterialBlockTargets);
  131833. /**
  131834. * Gets a boolean indicating that the current point is connected
  131835. */
  131836. get isConnected(): boolean;
  131837. /**
  131838. * Gets a boolean indicating that the current point is connected to an input block
  131839. */
  131840. get isConnectedToInputBlock(): boolean;
  131841. /**
  131842. * Gets a the connected input block (if any)
  131843. */
  131844. get connectInputBlock(): Nullable<InputBlock>;
  131845. /** Get the other side of the connection (if any) */
  131846. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131847. /** Get the block that owns this connection point */
  131848. get ownerBlock(): NodeMaterialBlock;
  131849. /** Get the block connected on the other side of this connection (if any) */
  131850. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131851. /** Get the block connected on the endpoints of this connection (if any) */
  131852. get connectedBlocks(): Array<NodeMaterialBlock>;
  131853. /** Gets the list of connected endpoints */
  131854. get endpoints(): NodeMaterialConnectionPoint[];
  131855. /** Gets a boolean indicating if that output point is connected to at least one input */
  131856. get hasEndpoints(): boolean;
  131857. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131858. get isConnectedInVertexShader(): boolean;
  131859. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131860. get isConnectedInFragmentShader(): boolean;
  131861. /**
  131862. * Creates a new connection point
  131863. * @param name defines the connection point name
  131864. * @param ownerBlock defines the block hosting this connection point
  131865. * @param direction defines the direction of the connection point
  131866. */
  131867. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131868. /**
  131869. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131870. * @returns the class name
  131871. */
  131872. getClassName(): string;
  131873. /**
  131874. * Gets a boolean indicating if the current point can be connected to another point
  131875. * @param connectionPoint defines the other connection point
  131876. * @returns a boolean
  131877. */
  131878. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131879. /**
  131880. * Gets a number indicating if the current point can be connected to another point
  131881. * @param connectionPoint defines the other connection point
  131882. * @returns a number defining the compatibility state
  131883. */
  131884. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131885. /**
  131886. * Connect this point to another connection point
  131887. * @param connectionPoint defines the other connection point
  131888. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131889. * @returns the current connection point
  131890. */
  131891. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131892. /**
  131893. * Disconnect this point from one of his endpoint
  131894. * @param endpoint defines the other connection point
  131895. * @returns the current connection point
  131896. */
  131897. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131898. /**
  131899. * Serializes this point in a JSON representation
  131900. * @returns the serialized point object
  131901. */
  131902. serialize(): any;
  131903. /**
  131904. * Release resources
  131905. */
  131906. dispose(): void;
  131907. }
  131908. }
  131909. declare module BABYLON {
  131910. /**
  131911. * Block used to add support for vertex skinning (bones)
  131912. */
  131913. export class BonesBlock extends NodeMaterialBlock {
  131914. /**
  131915. * Creates a new BonesBlock
  131916. * @param name defines the block name
  131917. */
  131918. constructor(name: string);
  131919. /**
  131920. * Initialize the block and prepare the context for build
  131921. * @param state defines the state that will be used for the build
  131922. */
  131923. initialize(state: NodeMaterialBuildState): void;
  131924. /**
  131925. * Gets the current class name
  131926. * @returns the class name
  131927. */
  131928. getClassName(): string;
  131929. /**
  131930. * Gets the matrix indices input component
  131931. */
  131932. get matricesIndices(): NodeMaterialConnectionPoint;
  131933. /**
  131934. * Gets the matrix weights input component
  131935. */
  131936. get matricesWeights(): NodeMaterialConnectionPoint;
  131937. /**
  131938. * Gets the extra matrix indices input component
  131939. */
  131940. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131941. /**
  131942. * Gets the extra matrix weights input component
  131943. */
  131944. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131945. /**
  131946. * Gets the world input component
  131947. */
  131948. get world(): NodeMaterialConnectionPoint;
  131949. /**
  131950. * Gets the output component
  131951. */
  131952. get output(): NodeMaterialConnectionPoint;
  131953. autoConfigure(material: NodeMaterial): void;
  131954. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131957. protected _buildBlock(state: NodeMaterialBuildState): this;
  131958. }
  131959. }
  131960. declare module BABYLON {
  131961. /**
  131962. * Block used to add support for instances
  131963. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131964. */
  131965. export class InstancesBlock extends NodeMaterialBlock {
  131966. /**
  131967. * Creates a new InstancesBlock
  131968. * @param name defines the block name
  131969. */
  131970. constructor(name: string);
  131971. /**
  131972. * Gets the current class name
  131973. * @returns the class name
  131974. */
  131975. getClassName(): string;
  131976. /**
  131977. * Gets the first world row input component
  131978. */
  131979. get world0(): NodeMaterialConnectionPoint;
  131980. /**
  131981. * Gets the second world row input component
  131982. */
  131983. get world1(): NodeMaterialConnectionPoint;
  131984. /**
  131985. * Gets the third world row input component
  131986. */
  131987. get world2(): NodeMaterialConnectionPoint;
  131988. /**
  131989. * Gets the forth world row input component
  131990. */
  131991. get world3(): NodeMaterialConnectionPoint;
  131992. /**
  131993. * Gets the world input component
  131994. */
  131995. get world(): NodeMaterialConnectionPoint;
  131996. /**
  131997. * Gets the output component
  131998. */
  131999. get output(): NodeMaterialConnectionPoint;
  132000. /**
  132001. * Gets the isntanceID component
  132002. */
  132003. get instanceID(): NodeMaterialConnectionPoint;
  132004. autoConfigure(material: NodeMaterial): void;
  132005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132006. protected _buildBlock(state: NodeMaterialBuildState): this;
  132007. }
  132008. }
  132009. declare module BABYLON {
  132010. /**
  132011. * Block used to add morph targets support to vertex shader
  132012. */
  132013. export class MorphTargetsBlock extends NodeMaterialBlock {
  132014. private _repeatableContentAnchor;
  132015. /**
  132016. * Create a new MorphTargetsBlock
  132017. * @param name defines the block name
  132018. */
  132019. constructor(name: string);
  132020. /**
  132021. * Gets the current class name
  132022. * @returns the class name
  132023. */
  132024. getClassName(): string;
  132025. /**
  132026. * Gets the position input component
  132027. */
  132028. get position(): NodeMaterialConnectionPoint;
  132029. /**
  132030. * Gets the normal input component
  132031. */
  132032. get normal(): NodeMaterialConnectionPoint;
  132033. /**
  132034. * Gets the tangent input component
  132035. */
  132036. get tangent(): NodeMaterialConnectionPoint;
  132037. /**
  132038. * Gets the tangent input component
  132039. */
  132040. get uv(): NodeMaterialConnectionPoint;
  132041. /**
  132042. * Gets the position output component
  132043. */
  132044. get positionOutput(): NodeMaterialConnectionPoint;
  132045. /**
  132046. * Gets the normal output component
  132047. */
  132048. get normalOutput(): NodeMaterialConnectionPoint;
  132049. /**
  132050. * Gets the tangent output component
  132051. */
  132052. get tangentOutput(): NodeMaterialConnectionPoint;
  132053. /**
  132054. * Gets the tangent output component
  132055. */
  132056. get uvOutput(): NodeMaterialConnectionPoint;
  132057. initialize(state: NodeMaterialBuildState): void;
  132058. autoConfigure(material: NodeMaterial): void;
  132059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132061. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132062. protected _buildBlock(state: NodeMaterialBuildState): this;
  132063. }
  132064. }
  132065. declare module BABYLON {
  132066. /**
  132067. * Block used to get data information from a light
  132068. */
  132069. export class LightInformationBlock extends NodeMaterialBlock {
  132070. private _lightDataUniformName;
  132071. private _lightColorUniformName;
  132072. private _lightTypeDefineName;
  132073. /**
  132074. * Gets or sets the light associated with this block
  132075. */
  132076. light: Nullable<Light>;
  132077. /**
  132078. * Creates a new LightInformationBlock
  132079. * @param name defines the block name
  132080. */
  132081. constructor(name: string);
  132082. /**
  132083. * Gets the current class name
  132084. * @returns the class name
  132085. */
  132086. getClassName(): string;
  132087. /**
  132088. * Gets the world position input component
  132089. */
  132090. get worldPosition(): NodeMaterialConnectionPoint;
  132091. /**
  132092. * Gets the direction output component
  132093. */
  132094. get direction(): NodeMaterialConnectionPoint;
  132095. /**
  132096. * Gets the direction output component
  132097. */
  132098. get color(): NodeMaterialConnectionPoint;
  132099. /**
  132100. * Gets the direction output component
  132101. */
  132102. get intensity(): NodeMaterialConnectionPoint;
  132103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132105. protected _buildBlock(state: NodeMaterialBuildState): this;
  132106. serialize(): any;
  132107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132108. }
  132109. }
  132110. declare module BABYLON {
  132111. /**
  132112. * Block used to add image processing support to fragment shader
  132113. */
  132114. export class ImageProcessingBlock extends NodeMaterialBlock {
  132115. /**
  132116. * Create a new ImageProcessingBlock
  132117. * @param name defines the block name
  132118. */
  132119. constructor(name: string);
  132120. /**
  132121. * Gets the current class name
  132122. * @returns the class name
  132123. */
  132124. getClassName(): string;
  132125. /**
  132126. * Gets the color input component
  132127. */
  132128. get color(): NodeMaterialConnectionPoint;
  132129. /**
  132130. * Gets the output component
  132131. */
  132132. get output(): NodeMaterialConnectionPoint;
  132133. /**
  132134. * Initialize the block and prepare the context for build
  132135. * @param state defines the state that will be used for the build
  132136. */
  132137. initialize(state: NodeMaterialBuildState): void;
  132138. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  132139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132141. protected _buildBlock(state: NodeMaterialBuildState): this;
  132142. }
  132143. }
  132144. declare module BABYLON {
  132145. /**
  132146. * Block used to pertub normals based on a normal map
  132147. */
  132148. export class PerturbNormalBlock extends NodeMaterialBlock {
  132149. private _tangentSpaceParameterName;
  132150. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132151. invertX: boolean;
  132152. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  132153. invertY: boolean;
  132154. /**
  132155. * Create a new PerturbNormalBlock
  132156. * @param name defines the block name
  132157. */
  132158. constructor(name: string);
  132159. /**
  132160. * Gets the current class name
  132161. * @returns the class name
  132162. */
  132163. getClassName(): string;
  132164. /**
  132165. * Gets the world position input component
  132166. */
  132167. get worldPosition(): NodeMaterialConnectionPoint;
  132168. /**
  132169. * Gets the world normal input component
  132170. */
  132171. get worldNormal(): NodeMaterialConnectionPoint;
  132172. /**
  132173. * Gets the world tangent input component
  132174. */
  132175. get worldTangent(): NodeMaterialConnectionPoint;
  132176. /**
  132177. * Gets the uv input component
  132178. */
  132179. get uv(): NodeMaterialConnectionPoint;
  132180. /**
  132181. * Gets the normal map color input component
  132182. */
  132183. get normalMapColor(): NodeMaterialConnectionPoint;
  132184. /**
  132185. * Gets the strength input component
  132186. */
  132187. get strength(): NodeMaterialConnectionPoint;
  132188. /**
  132189. * Gets the output component
  132190. */
  132191. get output(): NodeMaterialConnectionPoint;
  132192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132194. autoConfigure(material: NodeMaterial): void;
  132195. protected _buildBlock(state: NodeMaterialBuildState): this;
  132196. protected _dumpPropertiesCode(): string;
  132197. serialize(): any;
  132198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132199. }
  132200. }
  132201. declare module BABYLON {
  132202. /**
  132203. * Block used to discard a pixel if a value is smaller than a cutoff
  132204. */
  132205. export class DiscardBlock extends NodeMaterialBlock {
  132206. /**
  132207. * Create a new DiscardBlock
  132208. * @param name defines the block name
  132209. */
  132210. constructor(name: string);
  132211. /**
  132212. * Gets the current class name
  132213. * @returns the class name
  132214. */
  132215. getClassName(): string;
  132216. /**
  132217. * Gets the color input component
  132218. */
  132219. get value(): NodeMaterialConnectionPoint;
  132220. /**
  132221. * Gets the cutoff input component
  132222. */
  132223. get cutoff(): NodeMaterialConnectionPoint;
  132224. protected _buildBlock(state: NodeMaterialBuildState): this;
  132225. }
  132226. }
  132227. declare module BABYLON {
  132228. /**
  132229. * Block used to test if the fragment shader is front facing
  132230. */
  132231. export class FrontFacingBlock extends NodeMaterialBlock {
  132232. /**
  132233. * Creates a new FrontFacingBlock
  132234. * @param name defines the block name
  132235. */
  132236. constructor(name: string);
  132237. /**
  132238. * Gets the current class name
  132239. * @returns the class name
  132240. */
  132241. getClassName(): string;
  132242. /**
  132243. * Gets the output component
  132244. */
  132245. get output(): NodeMaterialConnectionPoint;
  132246. protected _buildBlock(state: NodeMaterialBuildState): this;
  132247. }
  132248. }
  132249. declare module BABYLON {
  132250. /**
  132251. * Block used to get the derivative value on x and y of a given input
  132252. */
  132253. export class DerivativeBlock extends NodeMaterialBlock {
  132254. /**
  132255. * Create a new DerivativeBlock
  132256. * @param name defines the block name
  132257. */
  132258. constructor(name: string);
  132259. /**
  132260. * Gets the current class name
  132261. * @returns the class name
  132262. */
  132263. getClassName(): string;
  132264. /**
  132265. * Gets the input component
  132266. */
  132267. get input(): NodeMaterialConnectionPoint;
  132268. /**
  132269. * Gets the derivative output on x
  132270. */
  132271. get dx(): NodeMaterialConnectionPoint;
  132272. /**
  132273. * Gets the derivative output on y
  132274. */
  132275. get dy(): NodeMaterialConnectionPoint;
  132276. protected _buildBlock(state: NodeMaterialBuildState): this;
  132277. }
  132278. }
  132279. declare module BABYLON {
  132280. /**
  132281. * Block used to add support for scene fog
  132282. */
  132283. export class FogBlock extends NodeMaterialBlock {
  132284. private _fogDistanceName;
  132285. private _fogParameters;
  132286. /**
  132287. * Create a new FogBlock
  132288. * @param name defines the block name
  132289. */
  132290. constructor(name: string);
  132291. /**
  132292. * Gets the current class name
  132293. * @returns the class name
  132294. */
  132295. getClassName(): string;
  132296. /**
  132297. * Gets the world position input component
  132298. */
  132299. get worldPosition(): NodeMaterialConnectionPoint;
  132300. /**
  132301. * Gets the view input component
  132302. */
  132303. get view(): NodeMaterialConnectionPoint;
  132304. /**
  132305. * Gets the color input component
  132306. */
  132307. get input(): NodeMaterialConnectionPoint;
  132308. /**
  132309. * Gets the fog color input component
  132310. */
  132311. get fogColor(): NodeMaterialConnectionPoint;
  132312. /**
  132313. * Gets the output component
  132314. */
  132315. get output(): NodeMaterialConnectionPoint;
  132316. autoConfigure(material: NodeMaterial): void;
  132317. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132318. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132319. protected _buildBlock(state: NodeMaterialBuildState): this;
  132320. }
  132321. }
  132322. declare module BABYLON {
  132323. /**
  132324. * Block used to add light in the fragment shader
  132325. */
  132326. export class LightBlock extends NodeMaterialBlock {
  132327. private _lightId;
  132328. /**
  132329. * Gets or sets the light associated with this block
  132330. */
  132331. light: Nullable<Light>;
  132332. /**
  132333. * Create a new LightBlock
  132334. * @param name defines the block name
  132335. */
  132336. constructor(name: string);
  132337. /**
  132338. * Gets the current class name
  132339. * @returns the class name
  132340. */
  132341. getClassName(): string;
  132342. /**
  132343. * Gets the world position input component
  132344. */
  132345. get worldPosition(): NodeMaterialConnectionPoint;
  132346. /**
  132347. * Gets the world normal input component
  132348. */
  132349. get worldNormal(): NodeMaterialConnectionPoint;
  132350. /**
  132351. * Gets the camera (or eye) position component
  132352. */
  132353. get cameraPosition(): NodeMaterialConnectionPoint;
  132354. /**
  132355. * Gets the glossiness component
  132356. */
  132357. get glossiness(): NodeMaterialConnectionPoint;
  132358. /**
  132359. * Gets the glossinness power component
  132360. */
  132361. get glossPower(): NodeMaterialConnectionPoint;
  132362. /**
  132363. * Gets the diffuse color component
  132364. */
  132365. get diffuseColor(): NodeMaterialConnectionPoint;
  132366. /**
  132367. * Gets the specular color component
  132368. */
  132369. get specularColor(): NodeMaterialConnectionPoint;
  132370. /**
  132371. * Gets the diffuse output component
  132372. */
  132373. get diffuseOutput(): NodeMaterialConnectionPoint;
  132374. /**
  132375. * Gets the specular output component
  132376. */
  132377. get specularOutput(): NodeMaterialConnectionPoint;
  132378. /**
  132379. * Gets the shadow output component
  132380. */
  132381. get shadow(): NodeMaterialConnectionPoint;
  132382. autoConfigure(material: NodeMaterial): void;
  132383. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132384. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132385. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132386. private _injectVertexCode;
  132387. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132388. serialize(): any;
  132389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132390. }
  132391. }
  132392. declare module BABYLON {
  132393. /**
  132394. * Block used to multiply 2 values
  132395. */
  132396. export class MultiplyBlock extends NodeMaterialBlock {
  132397. /**
  132398. * Creates a new MultiplyBlock
  132399. * @param name defines the block name
  132400. */
  132401. constructor(name: string);
  132402. /**
  132403. * Gets the current class name
  132404. * @returns the class name
  132405. */
  132406. getClassName(): string;
  132407. /**
  132408. * Gets the left operand input component
  132409. */
  132410. get left(): NodeMaterialConnectionPoint;
  132411. /**
  132412. * Gets the right operand input component
  132413. */
  132414. get right(): NodeMaterialConnectionPoint;
  132415. /**
  132416. * Gets the output component
  132417. */
  132418. get output(): NodeMaterialConnectionPoint;
  132419. protected _buildBlock(state: NodeMaterialBuildState): this;
  132420. }
  132421. }
  132422. declare module BABYLON {
  132423. /**
  132424. * Block used to add 2 vectors
  132425. */
  132426. export class AddBlock extends NodeMaterialBlock {
  132427. /**
  132428. * Creates a new AddBlock
  132429. * @param name defines the block name
  132430. */
  132431. constructor(name: string);
  132432. /**
  132433. * Gets the current class name
  132434. * @returns the class name
  132435. */
  132436. getClassName(): string;
  132437. /**
  132438. * Gets the left operand input component
  132439. */
  132440. get left(): NodeMaterialConnectionPoint;
  132441. /**
  132442. * Gets the right operand input component
  132443. */
  132444. get right(): NodeMaterialConnectionPoint;
  132445. /**
  132446. * Gets the output component
  132447. */
  132448. get output(): NodeMaterialConnectionPoint;
  132449. protected _buildBlock(state: NodeMaterialBuildState): this;
  132450. }
  132451. }
  132452. declare module BABYLON {
  132453. /**
  132454. * Block used to scale a vector by a float
  132455. */
  132456. export class ScaleBlock extends NodeMaterialBlock {
  132457. /**
  132458. * Creates a new ScaleBlock
  132459. * @param name defines the block name
  132460. */
  132461. constructor(name: string);
  132462. /**
  132463. * Gets the current class name
  132464. * @returns the class name
  132465. */
  132466. getClassName(): string;
  132467. /**
  132468. * Gets the input component
  132469. */
  132470. get input(): NodeMaterialConnectionPoint;
  132471. /**
  132472. * Gets the factor input component
  132473. */
  132474. get factor(): NodeMaterialConnectionPoint;
  132475. /**
  132476. * Gets the output component
  132477. */
  132478. get output(): NodeMaterialConnectionPoint;
  132479. protected _buildBlock(state: NodeMaterialBuildState): this;
  132480. }
  132481. }
  132482. declare module BABYLON {
  132483. /**
  132484. * Block used to clamp a float
  132485. */
  132486. export class ClampBlock extends NodeMaterialBlock {
  132487. /** Gets or sets the minimum range */
  132488. minimum: number;
  132489. /** Gets or sets the maximum range */
  132490. maximum: number;
  132491. /**
  132492. * Creates a new ClampBlock
  132493. * @param name defines the block name
  132494. */
  132495. constructor(name: string);
  132496. /**
  132497. * Gets the current class name
  132498. * @returns the class name
  132499. */
  132500. getClassName(): string;
  132501. /**
  132502. * Gets the value input component
  132503. */
  132504. get value(): NodeMaterialConnectionPoint;
  132505. /**
  132506. * Gets the output component
  132507. */
  132508. get output(): NodeMaterialConnectionPoint;
  132509. protected _buildBlock(state: NodeMaterialBuildState): this;
  132510. protected _dumpPropertiesCode(): string;
  132511. serialize(): any;
  132512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132513. }
  132514. }
  132515. declare module BABYLON {
  132516. /**
  132517. * Block used to apply a cross product between 2 vectors
  132518. */
  132519. export class CrossBlock extends NodeMaterialBlock {
  132520. /**
  132521. * Creates a new CrossBlock
  132522. * @param name defines the block name
  132523. */
  132524. constructor(name: string);
  132525. /**
  132526. * Gets the current class name
  132527. * @returns the class name
  132528. */
  132529. getClassName(): string;
  132530. /**
  132531. * Gets the left operand input component
  132532. */
  132533. get left(): NodeMaterialConnectionPoint;
  132534. /**
  132535. * Gets the right operand input component
  132536. */
  132537. get right(): NodeMaterialConnectionPoint;
  132538. /**
  132539. * Gets the output component
  132540. */
  132541. get output(): NodeMaterialConnectionPoint;
  132542. protected _buildBlock(state: NodeMaterialBuildState): this;
  132543. }
  132544. }
  132545. declare module BABYLON {
  132546. /**
  132547. * Block used to apply a dot product between 2 vectors
  132548. */
  132549. export class DotBlock extends NodeMaterialBlock {
  132550. /**
  132551. * Creates a new DotBlock
  132552. * @param name defines the block name
  132553. */
  132554. constructor(name: string);
  132555. /**
  132556. * Gets the current class name
  132557. * @returns the class name
  132558. */
  132559. getClassName(): string;
  132560. /**
  132561. * Gets the left operand input component
  132562. */
  132563. get left(): NodeMaterialConnectionPoint;
  132564. /**
  132565. * Gets the right operand input component
  132566. */
  132567. get right(): NodeMaterialConnectionPoint;
  132568. /**
  132569. * Gets the output component
  132570. */
  132571. get output(): NodeMaterialConnectionPoint;
  132572. protected _buildBlock(state: NodeMaterialBuildState): this;
  132573. }
  132574. }
  132575. declare module BABYLON {
  132576. /**
  132577. * Block used to remap a float from a range to a new one
  132578. */
  132579. export class RemapBlock extends NodeMaterialBlock {
  132580. /**
  132581. * Gets or sets the source range
  132582. */
  132583. sourceRange: Vector2;
  132584. /**
  132585. * Gets or sets the target range
  132586. */
  132587. targetRange: Vector2;
  132588. /**
  132589. * Creates a new RemapBlock
  132590. * @param name defines the block name
  132591. */
  132592. constructor(name: string);
  132593. /**
  132594. * Gets the current class name
  132595. * @returns the class name
  132596. */
  132597. getClassName(): string;
  132598. /**
  132599. * Gets the input component
  132600. */
  132601. get input(): NodeMaterialConnectionPoint;
  132602. /**
  132603. * Gets the source min input component
  132604. */
  132605. get sourceMin(): NodeMaterialConnectionPoint;
  132606. /**
  132607. * Gets the source max input component
  132608. */
  132609. get sourceMax(): NodeMaterialConnectionPoint;
  132610. /**
  132611. * Gets the target min input component
  132612. */
  132613. get targetMin(): NodeMaterialConnectionPoint;
  132614. /**
  132615. * Gets the target max input component
  132616. */
  132617. get targetMax(): NodeMaterialConnectionPoint;
  132618. /**
  132619. * Gets the output component
  132620. */
  132621. get output(): NodeMaterialConnectionPoint;
  132622. protected _buildBlock(state: NodeMaterialBuildState): this;
  132623. protected _dumpPropertiesCode(): string;
  132624. serialize(): any;
  132625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132626. }
  132627. }
  132628. declare module BABYLON {
  132629. /**
  132630. * Block used to normalize a vector
  132631. */
  132632. export class NormalizeBlock extends NodeMaterialBlock {
  132633. /**
  132634. * Creates a new NormalizeBlock
  132635. * @param name defines the block name
  132636. */
  132637. constructor(name: string);
  132638. /**
  132639. * Gets the current class name
  132640. * @returns the class name
  132641. */
  132642. getClassName(): string;
  132643. /**
  132644. * Gets the input component
  132645. */
  132646. get input(): NodeMaterialConnectionPoint;
  132647. /**
  132648. * Gets the output component
  132649. */
  132650. get output(): NodeMaterialConnectionPoint;
  132651. protected _buildBlock(state: NodeMaterialBuildState): this;
  132652. }
  132653. }
  132654. declare module BABYLON {
  132655. /**
  132656. * Operations supported by the Trigonometry block
  132657. */
  132658. export enum TrigonometryBlockOperations {
  132659. /** Cos */
  132660. Cos = 0,
  132661. /** Sin */
  132662. Sin = 1,
  132663. /** Abs */
  132664. Abs = 2,
  132665. /** Exp */
  132666. Exp = 3,
  132667. /** Exp2 */
  132668. Exp2 = 4,
  132669. /** Round */
  132670. Round = 5,
  132671. /** Floor */
  132672. Floor = 6,
  132673. /** Ceiling */
  132674. Ceiling = 7,
  132675. /** Square root */
  132676. Sqrt = 8,
  132677. /** Log */
  132678. Log = 9,
  132679. /** Tangent */
  132680. Tan = 10,
  132681. /** Arc tangent */
  132682. ArcTan = 11,
  132683. /** Arc cosinus */
  132684. ArcCos = 12,
  132685. /** Arc sinus */
  132686. ArcSin = 13,
  132687. /** Fraction */
  132688. Fract = 14,
  132689. /** Sign */
  132690. Sign = 15,
  132691. /** To radians (from degrees) */
  132692. Radians = 16,
  132693. /** To degrees (from radians) */
  132694. Degrees = 17
  132695. }
  132696. /**
  132697. * Block used to apply trigonometry operation to floats
  132698. */
  132699. export class TrigonometryBlock extends NodeMaterialBlock {
  132700. /**
  132701. * Gets or sets the operation applied by the block
  132702. */
  132703. operation: TrigonometryBlockOperations;
  132704. /**
  132705. * Creates a new TrigonometryBlock
  132706. * @param name defines the block name
  132707. */
  132708. constructor(name: string);
  132709. /**
  132710. * Gets the current class name
  132711. * @returns the class name
  132712. */
  132713. getClassName(): string;
  132714. /**
  132715. * Gets the input component
  132716. */
  132717. get input(): NodeMaterialConnectionPoint;
  132718. /**
  132719. * Gets the output component
  132720. */
  132721. get output(): NodeMaterialConnectionPoint;
  132722. protected _buildBlock(state: NodeMaterialBuildState): this;
  132723. serialize(): any;
  132724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132725. protected _dumpPropertiesCode(): string;
  132726. }
  132727. }
  132728. declare module BABYLON {
  132729. /**
  132730. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132731. */
  132732. export class ColorMergerBlock extends NodeMaterialBlock {
  132733. /**
  132734. * Create a new ColorMergerBlock
  132735. * @param name defines the block name
  132736. */
  132737. constructor(name: string);
  132738. /**
  132739. * Gets the current class name
  132740. * @returns the class name
  132741. */
  132742. getClassName(): string;
  132743. /**
  132744. * Gets the rgb component (input)
  132745. */
  132746. get rgbIn(): NodeMaterialConnectionPoint;
  132747. /**
  132748. * Gets the r component (input)
  132749. */
  132750. get r(): NodeMaterialConnectionPoint;
  132751. /**
  132752. * Gets the g component (input)
  132753. */
  132754. get g(): NodeMaterialConnectionPoint;
  132755. /**
  132756. * Gets the b component (input)
  132757. */
  132758. get b(): NodeMaterialConnectionPoint;
  132759. /**
  132760. * Gets the a component (input)
  132761. */
  132762. get a(): NodeMaterialConnectionPoint;
  132763. /**
  132764. * Gets the rgba component (output)
  132765. */
  132766. get rgba(): NodeMaterialConnectionPoint;
  132767. /**
  132768. * Gets the rgb component (output)
  132769. */
  132770. get rgbOut(): NodeMaterialConnectionPoint;
  132771. /**
  132772. * Gets the rgb component (output)
  132773. * @deprecated Please use rgbOut instead.
  132774. */
  132775. get rgb(): NodeMaterialConnectionPoint;
  132776. protected _buildBlock(state: NodeMaterialBuildState): this;
  132777. }
  132778. }
  132779. declare module BABYLON {
  132780. /**
  132781. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132782. */
  132783. export class VectorMergerBlock extends NodeMaterialBlock {
  132784. /**
  132785. * Create a new VectorMergerBlock
  132786. * @param name defines the block name
  132787. */
  132788. constructor(name: string);
  132789. /**
  132790. * Gets the current class name
  132791. * @returns the class name
  132792. */
  132793. getClassName(): string;
  132794. /**
  132795. * Gets the xyz component (input)
  132796. */
  132797. get xyzIn(): NodeMaterialConnectionPoint;
  132798. /**
  132799. * Gets the xy component (input)
  132800. */
  132801. get xyIn(): NodeMaterialConnectionPoint;
  132802. /**
  132803. * Gets the x component (input)
  132804. */
  132805. get x(): NodeMaterialConnectionPoint;
  132806. /**
  132807. * Gets the y component (input)
  132808. */
  132809. get y(): NodeMaterialConnectionPoint;
  132810. /**
  132811. * Gets the z component (input)
  132812. */
  132813. get z(): NodeMaterialConnectionPoint;
  132814. /**
  132815. * Gets the w component (input)
  132816. */
  132817. get w(): NodeMaterialConnectionPoint;
  132818. /**
  132819. * Gets the xyzw component (output)
  132820. */
  132821. get xyzw(): NodeMaterialConnectionPoint;
  132822. /**
  132823. * Gets the xyz component (output)
  132824. */
  132825. get xyzOut(): NodeMaterialConnectionPoint;
  132826. /**
  132827. * Gets the xy component (output)
  132828. */
  132829. get xyOut(): NodeMaterialConnectionPoint;
  132830. /**
  132831. * Gets the xy component (output)
  132832. * @deprecated Please use xyOut instead.
  132833. */
  132834. get xy(): NodeMaterialConnectionPoint;
  132835. /**
  132836. * Gets the xyz component (output)
  132837. * @deprecated Please use xyzOut instead.
  132838. */
  132839. get xyz(): NodeMaterialConnectionPoint;
  132840. protected _buildBlock(state: NodeMaterialBuildState): this;
  132841. }
  132842. }
  132843. declare module BABYLON {
  132844. /**
  132845. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132846. */
  132847. export class ColorSplitterBlock extends NodeMaterialBlock {
  132848. /**
  132849. * Create a new ColorSplitterBlock
  132850. * @param name defines the block name
  132851. */
  132852. constructor(name: string);
  132853. /**
  132854. * Gets the current class name
  132855. * @returns the class name
  132856. */
  132857. getClassName(): string;
  132858. /**
  132859. * Gets the rgba component (input)
  132860. */
  132861. get rgba(): NodeMaterialConnectionPoint;
  132862. /**
  132863. * Gets the rgb component (input)
  132864. */
  132865. get rgbIn(): NodeMaterialConnectionPoint;
  132866. /**
  132867. * Gets the rgb component (output)
  132868. */
  132869. get rgbOut(): NodeMaterialConnectionPoint;
  132870. /**
  132871. * Gets the r component (output)
  132872. */
  132873. get r(): NodeMaterialConnectionPoint;
  132874. /**
  132875. * Gets the g component (output)
  132876. */
  132877. get g(): NodeMaterialConnectionPoint;
  132878. /**
  132879. * Gets the b component (output)
  132880. */
  132881. get b(): NodeMaterialConnectionPoint;
  132882. /**
  132883. * Gets the a component (output)
  132884. */
  132885. get a(): NodeMaterialConnectionPoint;
  132886. protected _inputRename(name: string): string;
  132887. protected _outputRename(name: string): string;
  132888. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132889. }
  132890. }
  132891. declare module BABYLON {
  132892. /**
  132893. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132894. */
  132895. export class VectorSplitterBlock extends NodeMaterialBlock {
  132896. /**
  132897. * Create a new VectorSplitterBlock
  132898. * @param name defines the block name
  132899. */
  132900. constructor(name: string);
  132901. /**
  132902. * Gets the current class name
  132903. * @returns the class name
  132904. */
  132905. getClassName(): string;
  132906. /**
  132907. * Gets the xyzw component (input)
  132908. */
  132909. get xyzw(): NodeMaterialConnectionPoint;
  132910. /**
  132911. * Gets the xyz component (input)
  132912. */
  132913. get xyzIn(): NodeMaterialConnectionPoint;
  132914. /**
  132915. * Gets the xy component (input)
  132916. */
  132917. get xyIn(): NodeMaterialConnectionPoint;
  132918. /**
  132919. * Gets the xyz component (output)
  132920. */
  132921. get xyzOut(): NodeMaterialConnectionPoint;
  132922. /**
  132923. * Gets the xy component (output)
  132924. */
  132925. get xyOut(): NodeMaterialConnectionPoint;
  132926. /**
  132927. * Gets the x component (output)
  132928. */
  132929. get x(): NodeMaterialConnectionPoint;
  132930. /**
  132931. * Gets the y component (output)
  132932. */
  132933. get y(): NodeMaterialConnectionPoint;
  132934. /**
  132935. * Gets the z component (output)
  132936. */
  132937. get z(): NodeMaterialConnectionPoint;
  132938. /**
  132939. * Gets the w component (output)
  132940. */
  132941. get w(): NodeMaterialConnectionPoint;
  132942. protected _inputRename(name: string): string;
  132943. protected _outputRename(name: string): string;
  132944. protected _buildBlock(state: NodeMaterialBuildState): this;
  132945. }
  132946. }
  132947. declare module BABYLON {
  132948. /**
  132949. * Block used to lerp between 2 values
  132950. */
  132951. export class LerpBlock extends NodeMaterialBlock {
  132952. /**
  132953. * Creates a new LerpBlock
  132954. * @param name defines the block name
  132955. */
  132956. constructor(name: string);
  132957. /**
  132958. * Gets the current class name
  132959. * @returns the class name
  132960. */
  132961. getClassName(): string;
  132962. /**
  132963. * Gets the left operand input component
  132964. */
  132965. get left(): NodeMaterialConnectionPoint;
  132966. /**
  132967. * Gets the right operand input component
  132968. */
  132969. get right(): NodeMaterialConnectionPoint;
  132970. /**
  132971. * Gets the gradient operand input component
  132972. */
  132973. get gradient(): NodeMaterialConnectionPoint;
  132974. /**
  132975. * Gets the output component
  132976. */
  132977. get output(): NodeMaterialConnectionPoint;
  132978. protected _buildBlock(state: NodeMaterialBuildState): this;
  132979. }
  132980. }
  132981. declare module BABYLON {
  132982. /**
  132983. * Block used to divide 2 vectors
  132984. */
  132985. export class DivideBlock extends NodeMaterialBlock {
  132986. /**
  132987. * Creates a new DivideBlock
  132988. * @param name defines the block name
  132989. */
  132990. constructor(name: string);
  132991. /**
  132992. * Gets the current class name
  132993. * @returns the class name
  132994. */
  132995. getClassName(): string;
  132996. /**
  132997. * Gets the left operand input component
  132998. */
  132999. get left(): NodeMaterialConnectionPoint;
  133000. /**
  133001. * Gets the right operand input component
  133002. */
  133003. get right(): NodeMaterialConnectionPoint;
  133004. /**
  133005. * Gets the output component
  133006. */
  133007. get output(): NodeMaterialConnectionPoint;
  133008. protected _buildBlock(state: NodeMaterialBuildState): this;
  133009. }
  133010. }
  133011. declare module BABYLON {
  133012. /**
  133013. * Block used to subtract 2 vectors
  133014. */
  133015. export class SubtractBlock extends NodeMaterialBlock {
  133016. /**
  133017. * Creates a new SubtractBlock
  133018. * @param name defines the block name
  133019. */
  133020. constructor(name: string);
  133021. /**
  133022. * Gets the current class name
  133023. * @returns the class name
  133024. */
  133025. getClassName(): string;
  133026. /**
  133027. * Gets the left operand input component
  133028. */
  133029. get left(): NodeMaterialConnectionPoint;
  133030. /**
  133031. * Gets the right operand input component
  133032. */
  133033. get right(): NodeMaterialConnectionPoint;
  133034. /**
  133035. * Gets the output component
  133036. */
  133037. get output(): NodeMaterialConnectionPoint;
  133038. protected _buildBlock(state: NodeMaterialBuildState): this;
  133039. }
  133040. }
  133041. declare module BABYLON {
  133042. /**
  133043. * Block used to step a value
  133044. */
  133045. export class StepBlock extends NodeMaterialBlock {
  133046. /**
  133047. * Creates a new StepBlock
  133048. * @param name defines the block name
  133049. */
  133050. constructor(name: string);
  133051. /**
  133052. * Gets the current class name
  133053. * @returns the class name
  133054. */
  133055. getClassName(): string;
  133056. /**
  133057. * Gets the value operand input component
  133058. */
  133059. get value(): NodeMaterialConnectionPoint;
  133060. /**
  133061. * Gets the edge operand input component
  133062. */
  133063. get edge(): NodeMaterialConnectionPoint;
  133064. /**
  133065. * Gets the output component
  133066. */
  133067. get output(): NodeMaterialConnectionPoint;
  133068. protected _buildBlock(state: NodeMaterialBuildState): this;
  133069. }
  133070. }
  133071. declare module BABYLON {
  133072. /**
  133073. * Block used to get the opposite (1 - x) of a value
  133074. */
  133075. export class OneMinusBlock extends NodeMaterialBlock {
  133076. /**
  133077. * Creates a new OneMinusBlock
  133078. * @param name defines the block name
  133079. */
  133080. constructor(name: string);
  133081. /**
  133082. * Gets the current class name
  133083. * @returns the class name
  133084. */
  133085. getClassName(): string;
  133086. /**
  133087. * Gets the input component
  133088. */
  133089. get input(): NodeMaterialConnectionPoint;
  133090. /**
  133091. * Gets the output component
  133092. */
  133093. get output(): NodeMaterialConnectionPoint;
  133094. protected _buildBlock(state: NodeMaterialBuildState): this;
  133095. }
  133096. }
  133097. declare module BABYLON {
  133098. /**
  133099. * Block used to get the view direction
  133100. */
  133101. export class ViewDirectionBlock extends NodeMaterialBlock {
  133102. /**
  133103. * Creates a new ViewDirectionBlock
  133104. * @param name defines the block name
  133105. */
  133106. constructor(name: string);
  133107. /**
  133108. * Gets the current class name
  133109. * @returns the class name
  133110. */
  133111. getClassName(): string;
  133112. /**
  133113. * Gets the world position component
  133114. */
  133115. get worldPosition(): NodeMaterialConnectionPoint;
  133116. /**
  133117. * Gets the camera position component
  133118. */
  133119. get cameraPosition(): NodeMaterialConnectionPoint;
  133120. /**
  133121. * Gets the output component
  133122. */
  133123. get output(): NodeMaterialConnectionPoint;
  133124. autoConfigure(material: NodeMaterial): void;
  133125. protected _buildBlock(state: NodeMaterialBuildState): this;
  133126. }
  133127. }
  133128. declare module BABYLON {
  133129. /**
  133130. * Block used to compute fresnel value
  133131. */
  133132. export class FresnelBlock extends NodeMaterialBlock {
  133133. /**
  133134. * Create a new FresnelBlock
  133135. * @param name defines the block name
  133136. */
  133137. constructor(name: string);
  133138. /**
  133139. * Gets the current class name
  133140. * @returns the class name
  133141. */
  133142. getClassName(): string;
  133143. /**
  133144. * Gets the world normal input component
  133145. */
  133146. get worldNormal(): NodeMaterialConnectionPoint;
  133147. /**
  133148. * Gets the view direction input component
  133149. */
  133150. get viewDirection(): NodeMaterialConnectionPoint;
  133151. /**
  133152. * Gets the bias input component
  133153. */
  133154. get bias(): NodeMaterialConnectionPoint;
  133155. /**
  133156. * Gets the camera (or eye) position component
  133157. */
  133158. get power(): NodeMaterialConnectionPoint;
  133159. /**
  133160. * Gets the fresnel output component
  133161. */
  133162. get fresnel(): NodeMaterialConnectionPoint;
  133163. autoConfigure(material: NodeMaterial): void;
  133164. protected _buildBlock(state: NodeMaterialBuildState): this;
  133165. }
  133166. }
  133167. declare module BABYLON {
  133168. /**
  133169. * Block used to get the max of 2 values
  133170. */
  133171. export class MaxBlock extends NodeMaterialBlock {
  133172. /**
  133173. * Creates a new MaxBlock
  133174. * @param name defines the block name
  133175. */
  133176. constructor(name: string);
  133177. /**
  133178. * Gets the current class name
  133179. * @returns the class name
  133180. */
  133181. getClassName(): string;
  133182. /**
  133183. * Gets the left operand input component
  133184. */
  133185. get left(): NodeMaterialConnectionPoint;
  133186. /**
  133187. * Gets the right operand input component
  133188. */
  133189. get right(): NodeMaterialConnectionPoint;
  133190. /**
  133191. * Gets the output component
  133192. */
  133193. get output(): NodeMaterialConnectionPoint;
  133194. protected _buildBlock(state: NodeMaterialBuildState): this;
  133195. }
  133196. }
  133197. declare module BABYLON {
  133198. /**
  133199. * Block used to get the min of 2 values
  133200. */
  133201. export class MinBlock extends NodeMaterialBlock {
  133202. /**
  133203. * Creates a new MinBlock
  133204. * @param name defines the block name
  133205. */
  133206. constructor(name: string);
  133207. /**
  133208. * Gets the current class name
  133209. * @returns the class name
  133210. */
  133211. getClassName(): string;
  133212. /**
  133213. * Gets the left operand input component
  133214. */
  133215. get left(): NodeMaterialConnectionPoint;
  133216. /**
  133217. * Gets the right operand input component
  133218. */
  133219. get right(): NodeMaterialConnectionPoint;
  133220. /**
  133221. * Gets the output component
  133222. */
  133223. get output(): NodeMaterialConnectionPoint;
  133224. protected _buildBlock(state: NodeMaterialBuildState): this;
  133225. }
  133226. }
  133227. declare module BABYLON {
  133228. /**
  133229. * Block used to get the distance between 2 values
  133230. */
  133231. export class DistanceBlock extends NodeMaterialBlock {
  133232. /**
  133233. * Creates a new DistanceBlock
  133234. * @param name defines the block name
  133235. */
  133236. constructor(name: string);
  133237. /**
  133238. * Gets the current class name
  133239. * @returns the class name
  133240. */
  133241. getClassName(): string;
  133242. /**
  133243. * Gets the left operand input component
  133244. */
  133245. get left(): NodeMaterialConnectionPoint;
  133246. /**
  133247. * Gets the right operand input component
  133248. */
  133249. get right(): NodeMaterialConnectionPoint;
  133250. /**
  133251. * Gets the output component
  133252. */
  133253. get output(): NodeMaterialConnectionPoint;
  133254. protected _buildBlock(state: NodeMaterialBuildState): this;
  133255. }
  133256. }
  133257. declare module BABYLON {
  133258. /**
  133259. * Block used to get the length of a vector
  133260. */
  133261. export class LengthBlock extends NodeMaterialBlock {
  133262. /**
  133263. * Creates a new LengthBlock
  133264. * @param name defines the block name
  133265. */
  133266. constructor(name: string);
  133267. /**
  133268. * Gets the current class name
  133269. * @returns the class name
  133270. */
  133271. getClassName(): string;
  133272. /**
  133273. * Gets the value input component
  133274. */
  133275. get value(): NodeMaterialConnectionPoint;
  133276. /**
  133277. * Gets the output component
  133278. */
  133279. get output(): NodeMaterialConnectionPoint;
  133280. protected _buildBlock(state: NodeMaterialBuildState): this;
  133281. }
  133282. }
  133283. declare module BABYLON {
  133284. /**
  133285. * Block used to get negative version of a value (i.e. x * -1)
  133286. */
  133287. export class NegateBlock extends NodeMaterialBlock {
  133288. /**
  133289. * Creates a new NegateBlock
  133290. * @param name defines the block name
  133291. */
  133292. constructor(name: string);
  133293. /**
  133294. * Gets the current class name
  133295. * @returns the class name
  133296. */
  133297. getClassName(): string;
  133298. /**
  133299. * Gets the value input component
  133300. */
  133301. get value(): NodeMaterialConnectionPoint;
  133302. /**
  133303. * Gets the output component
  133304. */
  133305. get output(): NodeMaterialConnectionPoint;
  133306. protected _buildBlock(state: NodeMaterialBuildState): this;
  133307. }
  133308. }
  133309. declare module BABYLON {
  133310. /**
  133311. * Block used to get the value of the first parameter raised to the power of the second
  133312. */
  133313. export class PowBlock extends NodeMaterialBlock {
  133314. /**
  133315. * Creates a new PowBlock
  133316. * @param name defines the block name
  133317. */
  133318. constructor(name: string);
  133319. /**
  133320. * Gets the current class name
  133321. * @returns the class name
  133322. */
  133323. getClassName(): string;
  133324. /**
  133325. * Gets the value operand input component
  133326. */
  133327. get value(): NodeMaterialConnectionPoint;
  133328. /**
  133329. * Gets the power operand input component
  133330. */
  133331. get power(): NodeMaterialConnectionPoint;
  133332. /**
  133333. * Gets the output component
  133334. */
  133335. get output(): NodeMaterialConnectionPoint;
  133336. protected _buildBlock(state: NodeMaterialBuildState): this;
  133337. }
  133338. }
  133339. declare module BABYLON {
  133340. /**
  133341. * Block used to get a random number
  133342. */
  133343. export class RandomNumberBlock extends NodeMaterialBlock {
  133344. /**
  133345. * Creates a new RandomNumberBlock
  133346. * @param name defines the block name
  133347. */
  133348. constructor(name: string);
  133349. /**
  133350. * Gets the current class name
  133351. * @returns the class name
  133352. */
  133353. getClassName(): string;
  133354. /**
  133355. * Gets the seed input component
  133356. */
  133357. get seed(): NodeMaterialConnectionPoint;
  133358. /**
  133359. * Gets the output component
  133360. */
  133361. get output(): NodeMaterialConnectionPoint;
  133362. protected _buildBlock(state: NodeMaterialBuildState): this;
  133363. }
  133364. }
  133365. declare module BABYLON {
  133366. /**
  133367. * Block used to compute arc tangent of 2 values
  133368. */
  133369. export class ArcTan2Block extends NodeMaterialBlock {
  133370. /**
  133371. * Creates a new ArcTan2Block
  133372. * @param name defines the block name
  133373. */
  133374. constructor(name: string);
  133375. /**
  133376. * Gets the current class name
  133377. * @returns the class name
  133378. */
  133379. getClassName(): string;
  133380. /**
  133381. * Gets the x operand input component
  133382. */
  133383. get x(): NodeMaterialConnectionPoint;
  133384. /**
  133385. * Gets the y operand input component
  133386. */
  133387. get y(): NodeMaterialConnectionPoint;
  133388. /**
  133389. * Gets the output component
  133390. */
  133391. get output(): NodeMaterialConnectionPoint;
  133392. protected _buildBlock(state: NodeMaterialBuildState): this;
  133393. }
  133394. }
  133395. declare module BABYLON {
  133396. /**
  133397. * Block used to smooth step a value
  133398. */
  133399. export class SmoothStepBlock extends NodeMaterialBlock {
  133400. /**
  133401. * Creates a new SmoothStepBlock
  133402. * @param name defines the block name
  133403. */
  133404. constructor(name: string);
  133405. /**
  133406. * Gets the current class name
  133407. * @returns the class name
  133408. */
  133409. getClassName(): string;
  133410. /**
  133411. * Gets the value operand input component
  133412. */
  133413. get value(): NodeMaterialConnectionPoint;
  133414. /**
  133415. * Gets the first edge operand input component
  133416. */
  133417. get edge0(): NodeMaterialConnectionPoint;
  133418. /**
  133419. * Gets the second edge operand input component
  133420. */
  133421. get edge1(): NodeMaterialConnectionPoint;
  133422. /**
  133423. * Gets the output component
  133424. */
  133425. get output(): NodeMaterialConnectionPoint;
  133426. protected _buildBlock(state: NodeMaterialBuildState): this;
  133427. }
  133428. }
  133429. declare module BABYLON {
  133430. /**
  133431. * Block used to get the reciprocal (1 / x) of a value
  133432. */
  133433. export class ReciprocalBlock extends NodeMaterialBlock {
  133434. /**
  133435. * Creates a new ReciprocalBlock
  133436. * @param name defines the block name
  133437. */
  133438. constructor(name: string);
  133439. /**
  133440. * Gets the current class name
  133441. * @returns the class name
  133442. */
  133443. getClassName(): string;
  133444. /**
  133445. * Gets the input component
  133446. */
  133447. get input(): NodeMaterialConnectionPoint;
  133448. /**
  133449. * Gets the output component
  133450. */
  133451. get output(): NodeMaterialConnectionPoint;
  133452. protected _buildBlock(state: NodeMaterialBuildState): this;
  133453. }
  133454. }
  133455. declare module BABYLON {
  133456. /**
  133457. * Block used to replace a color by another one
  133458. */
  133459. export class ReplaceColorBlock extends NodeMaterialBlock {
  133460. /**
  133461. * Creates a new ReplaceColorBlock
  133462. * @param name defines the block name
  133463. */
  133464. constructor(name: string);
  133465. /**
  133466. * Gets the current class name
  133467. * @returns the class name
  133468. */
  133469. getClassName(): string;
  133470. /**
  133471. * Gets the value input component
  133472. */
  133473. get value(): NodeMaterialConnectionPoint;
  133474. /**
  133475. * Gets the reference input component
  133476. */
  133477. get reference(): NodeMaterialConnectionPoint;
  133478. /**
  133479. * Gets the distance input component
  133480. */
  133481. get distance(): NodeMaterialConnectionPoint;
  133482. /**
  133483. * Gets the replacement input component
  133484. */
  133485. get replacement(): NodeMaterialConnectionPoint;
  133486. /**
  133487. * Gets the output component
  133488. */
  133489. get output(): NodeMaterialConnectionPoint;
  133490. protected _buildBlock(state: NodeMaterialBuildState): this;
  133491. }
  133492. }
  133493. declare module BABYLON {
  133494. /**
  133495. * Block used to posterize a value
  133496. * @see https://en.wikipedia.org/wiki/Posterization
  133497. */
  133498. export class PosterizeBlock extends NodeMaterialBlock {
  133499. /**
  133500. * Creates a new PosterizeBlock
  133501. * @param name defines the block name
  133502. */
  133503. constructor(name: string);
  133504. /**
  133505. * Gets the current class name
  133506. * @returns the class name
  133507. */
  133508. getClassName(): string;
  133509. /**
  133510. * Gets the value input component
  133511. */
  133512. get value(): NodeMaterialConnectionPoint;
  133513. /**
  133514. * Gets the steps input component
  133515. */
  133516. get steps(): NodeMaterialConnectionPoint;
  133517. /**
  133518. * Gets the output component
  133519. */
  133520. get output(): NodeMaterialConnectionPoint;
  133521. protected _buildBlock(state: NodeMaterialBuildState): this;
  133522. }
  133523. }
  133524. declare module BABYLON {
  133525. /**
  133526. * Operations supported by the Wave block
  133527. */
  133528. export enum WaveBlockKind {
  133529. /** SawTooth */
  133530. SawTooth = 0,
  133531. /** Square */
  133532. Square = 1,
  133533. /** Triangle */
  133534. Triangle = 2
  133535. }
  133536. /**
  133537. * Block used to apply wave operation to floats
  133538. */
  133539. export class WaveBlock extends NodeMaterialBlock {
  133540. /**
  133541. * Gets or sets the kibnd of wave to be applied by the block
  133542. */
  133543. kind: WaveBlockKind;
  133544. /**
  133545. * Creates a new WaveBlock
  133546. * @param name defines the block name
  133547. */
  133548. constructor(name: string);
  133549. /**
  133550. * Gets the current class name
  133551. * @returns the class name
  133552. */
  133553. getClassName(): string;
  133554. /**
  133555. * Gets the input component
  133556. */
  133557. get input(): NodeMaterialConnectionPoint;
  133558. /**
  133559. * Gets the output component
  133560. */
  133561. get output(): NodeMaterialConnectionPoint;
  133562. protected _buildBlock(state: NodeMaterialBuildState): this;
  133563. serialize(): any;
  133564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133565. }
  133566. }
  133567. declare module BABYLON {
  133568. /**
  133569. * Class used to store a color step for the GradientBlock
  133570. */
  133571. export class GradientBlockColorStep {
  133572. /**
  133573. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133574. */
  133575. step: number;
  133576. /**
  133577. * Gets or sets the color associated with this step
  133578. */
  133579. color: Color3;
  133580. /**
  133581. * Creates a new GradientBlockColorStep
  133582. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133583. * @param color defines the color associated with this step
  133584. */
  133585. constructor(
  133586. /**
  133587. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133588. */
  133589. step: number,
  133590. /**
  133591. * Gets or sets the color associated with this step
  133592. */
  133593. color: Color3);
  133594. }
  133595. /**
  133596. * Block used to return a color from a gradient based on an input value between 0 and 1
  133597. */
  133598. export class GradientBlock extends NodeMaterialBlock {
  133599. /**
  133600. * Gets or sets the list of color steps
  133601. */
  133602. colorSteps: GradientBlockColorStep[];
  133603. /**
  133604. * Creates a new GradientBlock
  133605. * @param name defines the block name
  133606. */
  133607. constructor(name: string);
  133608. /**
  133609. * Gets the current class name
  133610. * @returns the class name
  133611. */
  133612. getClassName(): string;
  133613. /**
  133614. * Gets the gradient input component
  133615. */
  133616. get gradient(): NodeMaterialConnectionPoint;
  133617. /**
  133618. * Gets the output component
  133619. */
  133620. get output(): NodeMaterialConnectionPoint;
  133621. private _writeColorConstant;
  133622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133623. serialize(): any;
  133624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133625. protected _dumpPropertiesCode(): string;
  133626. }
  133627. }
  133628. declare module BABYLON {
  133629. /**
  133630. * Block used to normalize lerp between 2 values
  133631. */
  133632. export class NLerpBlock extends NodeMaterialBlock {
  133633. /**
  133634. * Creates a new NLerpBlock
  133635. * @param name defines the block name
  133636. */
  133637. constructor(name: string);
  133638. /**
  133639. * Gets the current class name
  133640. * @returns the class name
  133641. */
  133642. getClassName(): string;
  133643. /**
  133644. * Gets the left operand input component
  133645. */
  133646. get left(): NodeMaterialConnectionPoint;
  133647. /**
  133648. * Gets the right operand input component
  133649. */
  133650. get right(): NodeMaterialConnectionPoint;
  133651. /**
  133652. * Gets the gradient operand input component
  133653. */
  133654. get gradient(): NodeMaterialConnectionPoint;
  133655. /**
  133656. * Gets the output component
  133657. */
  133658. get output(): NodeMaterialConnectionPoint;
  133659. protected _buildBlock(state: NodeMaterialBuildState): this;
  133660. }
  133661. }
  133662. declare module BABYLON {
  133663. /**
  133664. * block used to Generate a Worley Noise 3D Noise Pattern
  133665. */
  133666. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133667. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133668. manhattanDistance: boolean;
  133669. /**
  133670. * Creates a new WorleyNoise3DBlock
  133671. * @param name defines the block name
  133672. */
  133673. constructor(name: string);
  133674. /**
  133675. * Gets the current class name
  133676. * @returns the class name
  133677. */
  133678. getClassName(): string;
  133679. /**
  133680. * Gets the seed input component
  133681. */
  133682. get seed(): NodeMaterialConnectionPoint;
  133683. /**
  133684. * Gets the jitter input component
  133685. */
  133686. get jitter(): NodeMaterialConnectionPoint;
  133687. /**
  133688. * Gets the output component
  133689. */
  133690. get output(): NodeMaterialConnectionPoint;
  133691. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133692. /**
  133693. * Exposes the properties to the UI?
  133694. */
  133695. protected _dumpPropertiesCode(): string;
  133696. /**
  133697. * Exposes the properties to the Seralize?
  133698. */
  133699. serialize(): any;
  133700. /**
  133701. * Exposes the properties to the deseralize?
  133702. */
  133703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133704. }
  133705. }
  133706. declare module BABYLON {
  133707. /**
  133708. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133709. */
  133710. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133711. /**
  133712. * Creates a new SimplexPerlin3DBlock
  133713. * @param name defines the block name
  133714. */
  133715. constructor(name: string);
  133716. /**
  133717. * Gets the current class name
  133718. * @returns the class name
  133719. */
  133720. getClassName(): string;
  133721. /**
  133722. * Gets the seed operand input component
  133723. */
  133724. get seed(): NodeMaterialConnectionPoint;
  133725. /**
  133726. * Gets the output component
  133727. */
  133728. get output(): NodeMaterialConnectionPoint;
  133729. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133730. }
  133731. }
  133732. declare module BABYLON {
  133733. /**
  133734. * Block used to blend normals
  133735. */
  133736. export class NormalBlendBlock extends NodeMaterialBlock {
  133737. /**
  133738. * Creates a new NormalBlendBlock
  133739. * @param name defines the block name
  133740. */
  133741. constructor(name: string);
  133742. /**
  133743. * Gets the current class name
  133744. * @returns the class name
  133745. */
  133746. getClassName(): string;
  133747. /**
  133748. * Gets the first input component
  133749. */
  133750. get normalMap0(): NodeMaterialConnectionPoint;
  133751. /**
  133752. * Gets the second input component
  133753. */
  133754. get normalMap1(): NodeMaterialConnectionPoint;
  133755. /**
  133756. * Gets the output component
  133757. */
  133758. get output(): NodeMaterialConnectionPoint;
  133759. protected _buildBlock(state: NodeMaterialBuildState): this;
  133760. }
  133761. }
  133762. declare module BABYLON {
  133763. /**
  133764. * Block used to rotate a 2d vector by a given angle
  133765. */
  133766. export class Rotate2dBlock extends NodeMaterialBlock {
  133767. /**
  133768. * Creates a new Rotate2dBlock
  133769. * @param name defines the block name
  133770. */
  133771. constructor(name: string);
  133772. /**
  133773. * Gets the current class name
  133774. * @returns the class name
  133775. */
  133776. getClassName(): string;
  133777. /**
  133778. * Gets the input vector
  133779. */
  133780. get input(): NodeMaterialConnectionPoint;
  133781. /**
  133782. * Gets the input angle
  133783. */
  133784. get angle(): NodeMaterialConnectionPoint;
  133785. /**
  133786. * Gets the output component
  133787. */
  133788. get output(): NodeMaterialConnectionPoint;
  133789. autoConfigure(material: NodeMaterial): void;
  133790. protected _buildBlock(state: NodeMaterialBuildState): this;
  133791. }
  133792. }
  133793. declare module BABYLON {
  133794. /**
  133795. * Block used to get the reflected vector from a direction and a normal
  133796. */
  133797. export class ReflectBlock extends NodeMaterialBlock {
  133798. /**
  133799. * Creates a new ReflectBlock
  133800. * @param name defines the block name
  133801. */
  133802. constructor(name: string);
  133803. /**
  133804. * Gets the current class name
  133805. * @returns the class name
  133806. */
  133807. getClassName(): string;
  133808. /**
  133809. * Gets the incident component
  133810. */
  133811. get incident(): NodeMaterialConnectionPoint;
  133812. /**
  133813. * Gets the normal component
  133814. */
  133815. get normal(): NodeMaterialConnectionPoint;
  133816. /**
  133817. * Gets the output component
  133818. */
  133819. get output(): NodeMaterialConnectionPoint;
  133820. protected _buildBlock(state: NodeMaterialBuildState): this;
  133821. }
  133822. }
  133823. declare module BABYLON {
  133824. /**
  133825. * Block used to get the refracted vector from a direction and a normal
  133826. */
  133827. export class RefractBlock extends NodeMaterialBlock {
  133828. /**
  133829. * Creates a new RefractBlock
  133830. * @param name defines the block name
  133831. */
  133832. constructor(name: string);
  133833. /**
  133834. * Gets the current class name
  133835. * @returns the class name
  133836. */
  133837. getClassName(): string;
  133838. /**
  133839. * Gets the incident component
  133840. */
  133841. get incident(): NodeMaterialConnectionPoint;
  133842. /**
  133843. * Gets the normal component
  133844. */
  133845. get normal(): NodeMaterialConnectionPoint;
  133846. /**
  133847. * Gets the index of refraction component
  133848. */
  133849. get ior(): NodeMaterialConnectionPoint;
  133850. /**
  133851. * Gets the output component
  133852. */
  133853. get output(): NodeMaterialConnectionPoint;
  133854. protected _buildBlock(state: NodeMaterialBuildState): this;
  133855. }
  133856. }
  133857. declare module BABYLON {
  133858. /**
  133859. * Block used to desaturate a color
  133860. */
  133861. export class DesaturateBlock extends NodeMaterialBlock {
  133862. /**
  133863. * Creates a new DesaturateBlock
  133864. * @param name defines the block name
  133865. */
  133866. constructor(name: string);
  133867. /**
  133868. * Gets the current class name
  133869. * @returns the class name
  133870. */
  133871. getClassName(): string;
  133872. /**
  133873. * Gets the color operand input component
  133874. */
  133875. get color(): NodeMaterialConnectionPoint;
  133876. /**
  133877. * Gets the level operand input component
  133878. */
  133879. get level(): NodeMaterialConnectionPoint;
  133880. /**
  133881. * Gets the output component
  133882. */
  133883. get output(): NodeMaterialConnectionPoint;
  133884. protected _buildBlock(state: NodeMaterialBuildState): this;
  133885. }
  133886. }
  133887. declare module BABYLON {
  133888. /**
  133889. * Effect Render Options
  133890. */
  133891. export interface IEffectRendererOptions {
  133892. /**
  133893. * Defines the vertices positions.
  133894. */
  133895. positions?: number[];
  133896. /**
  133897. * Defines the indices.
  133898. */
  133899. indices?: number[];
  133900. }
  133901. /**
  133902. * Helper class to render one or more effects
  133903. */
  133904. export class EffectRenderer {
  133905. private engine;
  133906. private static _DefaultOptions;
  133907. private _vertexBuffers;
  133908. private _indexBuffer;
  133909. private _ringBufferIndex;
  133910. private _ringScreenBuffer;
  133911. private _fullscreenViewport;
  133912. private _getNextFrameBuffer;
  133913. /**
  133914. * Creates an effect renderer
  133915. * @param engine the engine to use for rendering
  133916. * @param options defines the options of the effect renderer
  133917. */
  133918. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133919. /**
  133920. * Sets the current viewport in normalized coordinates 0-1
  133921. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133922. */
  133923. setViewport(viewport?: Viewport): void;
  133924. /**
  133925. * Binds the embedded attributes buffer to the effect.
  133926. * @param effect Defines the effect to bind the attributes for
  133927. */
  133928. bindBuffers(effect: Effect): void;
  133929. /**
  133930. * Sets the current effect wrapper to use during draw.
  133931. * The effect needs to be ready before calling this api.
  133932. * This also sets the default full screen position attribute.
  133933. * @param effectWrapper Defines the effect to draw with
  133934. */
  133935. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133936. /**
  133937. * Draws a full screen quad.
  133938. */
  133939. draw(): void;
  133940. /**
  133941. * renders one or more effects to a specified texture
  133942. * @param effectWrappers list of effects to renderer
  133943. * @param outputTexture texture to draw to, if null it will render to the screen
  133944. */
  133945. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133946. /**
  133947. * Disposes of the effect renderer
  133948. */
  133949. dispose(): void;
  133950. }
  133951. /**
  133952. * Options to create an EffectWrapper
  133953. */
  133954. interface EffectWrapperCreationOptions {
  133955. /**
  133956. * Engine to use to create the effect
  133957. */
  133958. engine: ThinEngine;
  133959. /**
  133960. * Fragment shader for the effect
  133961. */
  133962. fragmentShader: string;
  133963. /**
  133964. * Vertex shader for the effect
  133965. */
  133966. vertexShader?: string;
  133967. /**
  133968. * Attributes to use in the shader
  133969. */
  133970. attributeNames?: Array<string>;
  133971. /**
  133972. * Uniforms to use in the shader
  133973. */
  133974. uniformNames?: Array<string>;
  133975. /**
  133976. * Texture sampler names to use in the shader
  133977. */
  133978. samplerNames?: Array<string>;
  133979. /**
  133980. * The friendly name of the effect displayed in Spector.
  133981. */
  133982. name?: string;
  133983. }
  133984. /**
  133985. * Wraps an effect to be used for rendering
  133986. */
  133987. export class EffectWrapper {
  133988. /**
  133989. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133990. */
  133991. onApplyObservable: Observable<{}>;
  133992. /**
  133993. * The underlying effect
  133994. */
  133995. effect: Effect;
  133996. /**
  133997. * Creates an effect to be renderer
  133998. * @param creationOptions options to create the effect
  133999. */
  134000. constructor(creationOptions: EffectWrapperCreationOptions);
  134001. /**
  134002. * Disposes of the effect wrapper
  134003. */
  134004. dispose(): void;
  134005. }
  134006. }
  134007. declare module BABYLON {
  134008. /**
  134009. * Helper class to push actions to a pool of workers.
  134010. */
  134011. export class WorkerPool implements IDisposable {
  134012. private _workerInfos;
  134013. private _pendingActions;
  134014. /**
  134015. * Constructor
  134016. * @param workers Array of workers to use for actions
  134017. */
  134018. constructor(workers: Array<Worker>);
  134019. /**
  134020. * Terminates all workers and clears any pending actions.
  134021. */
  134022. dispose(): void;
  134023. /**
  134024. * Pushes an action to the worker pool. If all the workers are active, the action will be
  134025. * pended until a worker has completed its action.
  134026. * @param action The action to perform. Call onComplete when the action is complete.
  134027. */
  134028. push(action: (worker: Worker, onComplete: () => void) => void): void;
  134029. private _execute;
  134030. }
  134031. }
  134032. declare module BABYLON {
  134033. /**
  134034. * Configuration for Draco compression
  134035. */
  134036. export interface IDracoCompressionConfiguration {
  134037. /**
  134038. * Configuration for the decoder.
  134039. */
  134040. decoder: {
  134041. /**
  134042. * The url to the WebAssembly module.
  134043. */
  134044. wasmUrl?: string;
  134045. /**
  134046. * The url to the WebAssembly binary.
  134047. */
  134048. wasmBinaryUrl?: string;
  134049. /**
  134050. * The url to the fallback JavaScript module.
  134051. */
  134052. fallbackUrl?: string;
  134053. };
  134054. }
  134055. /**
  134056. * Draco compression (https://google.github.io/draco/)
  134057. *
  134058. * This class wraps the Draco module.
  134059. *
  134060. * **Encoder**
  134061. *
  134062. * The encoder is not currently implemented.
  134063. *
  134064. * **Decoder**
  134065. *
  134066. * 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.
  134067. *
  134068. * To update the configuration, use the following code:
  134069. * ```javascript
  134070. * DracoCompression.Configuration = {
  134071. * decoder: {
  134072. * wasmUrl: "<url to the WebAssembly library>",
  134073. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  134074. * fallbackUrl: "<url to the fallback JavaScript library>",
  134075. * }
  134076. * };
  134077. * ```
  134078. *
  134079. * 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.
  134080. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  134081. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  134082. *
  134083. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  134084. * ```javascript
  134085. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  134086. * ```
  134087. *
  134088. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  134089. */
  134090. export class DracoCompression implements IDisposable {
  134091. private _workerPoolPromise?;
  134092. private _decoderModulePromise?;
  134093. /**
  134094. * The configuration. Defaults to the following urls:
  134095. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  134096. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  134097. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  134098. */
  134099. static Configuration: IDracoCompressionConfiguration;
  134100. /**
  134101. * Returns true if the decoder configuration is available.
  134102. */
  134103. static get DecoderAvailable(): boolean;
  134104. /**
  134105. * Default number of workers to create when creating the draco compression object.
  134106. */
  134107. static DefaultNumWorkers: number;
  134108. private static GetDefaultNumWorkers;
  134109. private static _Default;
  134110. /**
  134111. * Default instance for the draco compression object.
  134112. */
  134113. static get Default(): DracoCompression;
  134114. /**
  134115. * Constructor
  134116. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  134117. */
  134118. constructor(numWorkers?: number);
  134119. /**
  134120. * Stop all async operations and release resources.
  134121. */
  134122. dispose(): void;
  134123. /**
  134124. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  134125. * @returns a promise that resolves when ready
  134126. */
  134127. whenReadyAsync(): Promise<void>;
  134128. /**
  134129. * Decode Draco compressed mesh data to vertex data.
  134130. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  134131. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  134132. * @returns A promise that resolves with the decoded vertex data
  134133. */
  134134. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  134135. [kind: string]: number;
  134136. }): Promise<VertexData>;
  134137. }
  134138. }
  134139. declare module BABYLON {
  134140. /**
  134141. * Class for building Constructive Solid Geometry
  134142. */
  134143. export class CSG {
  134144. private polygons;
  134145. /**
  134146. * The world matrix
  134147. */
  134148. matrix: Matrix;
  134149. /**
  134150. * Stores the position
  134151. */
  134152. position: Vector3;
  134153. /**
  134154. * Stores the rotation
  134155. */
  134156. rotation: Vector3;
  134157. /**
  134158. * Stores the rotation quaternion
  134159. */
  134160. rotationQuaternion: Nullable<Quaternion>;
  134161. /**
  134162. * Stores the scaling vector
  134163. */
  134164. scaling: Vector3;
  134165. /**
  134166. * Convert the Mesh to CSG
  134167. * @param mesh The Mesh to convert to CSG
  134168. * @returns A new CSG from the Mesh
  134169. */
  134170. static FromMesh(mesh: Mesh): CSG;
  134171. /**
  134172. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  134173. * @param polygons Polygons used to construct a CSG solid
  134174. */
  134175. private static FromPolygons;
  134176. /**
  134177. * Clones, or makes a deep copy, of the CSG
  134178. * @returns A new CSG
  134179. */
  134180. clone(): CSG;
  134181. /**
  134182. * Unions this CSG with another CSG
  134183. * @param csg The CSG to union against this CSG
  134184. * @returns The unioned CSG
  134185. */
  134186. union(csg: CSG): CSG;
  134187. /**
  134188. * Unions this CSG with another CSG in place
  134189. * @param csg The CSG to union against this CSG
  134190. */
  134191. unionInPlace(csg: CSG): void;
  134192. /**
  134193. * Subtracts this CSG with another CSG
  134194. * @param csg The CSG to subtract against this CSG
  134195. * @returns A new CSG
  134196. */
  134197. subtract(csg: CSG): CSG;
  134198. /**
  134199. * Subtracts this CSG with another CSG in place
  134200. * @param csg The CSG to subtact against this CSG
  134201. */
  134202. subtractInPlace(csg: CSG): void;
  134203. /**
  134204. * Intersect this CSG with another CSG
  134205. * @param csg The CSG to intersect against this CSG
  134206. * @returns A new CSG
  134207. */
  134208. intersect(csg: CSG): CSG;
  134209. /**
  134210. * Intersects this CSG with another CSG in place
  134211. * @param csg The CSG to intersect against this CSG
  134212. */
  134213. intersectInPlace(csg: CSG): void;
  134214. /**
  134215. * Return a new CSG solid with solid and empty space switched. This solid is
  134216. * not modified.
  134217. * @returns A new CSG solid with solid and empty space switched
  134218. */
  134219. inverse(): CSG;
  134220. /**
  134221. * Inverses the CSG in place
  134222. */
  134223. inverseInPlace(): void;
  134224. /**
  134225. * This is used to keep meshes transformations so they can be restored
  134226. * when we build back a Babylon Mesh
  134227. * NB : All CSG operations are performed in world coordinates
  134228. * @param csg The CSG to copy the transform attributes from
  134229. * @returns This CSG
  134230. */
  134231. copyTransformAttributes(csg: CSG): CSG;
  134232. /**
  134233. * Build Raw mesh from CSG
  134234. * Coordinates here are in world space
  134235. * @param name The name of the mesh geometry
  134236. * @param scene The Scene
  134237. * @param keepSubMeshes Specifies if the submeshes should be kept
  134238. * @returns A new Mesh
  134239. */
  134240. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134241. /**
  134242. * Build Mesh from CSG taking material and transforms into account
  134243. * @param name The name of the Mesh
  134244. * @param material The material of the Mesh
  134245. * @param scene The Scene
  134246. * @param keepSubMeshes Specifies if submeshes should be kept
  134247. * @returns The new Mesh
  134248. */
  134249. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134250. }
  134251. }
  134252. declare module BABYLON {
  134253. /**
  134254. * Class used to create a trail following a mesh
  134255. */
  134256. export class TrailMesh extends Mesh {
  134257. private _generator;
  134258. private _autoStart;
  134259. private _running;
  134260. private _diameter;
  134261. private _length;
  134262. private _sectionPolygonPointsCount;
  134263. private _sectionVectors;
  134264. private _sectionNormalVectors;
  134265. private _beforeRenderObserver;
  134266. /**
  134267. * @constructor
  134268. * @param name The value used by scene.getMeshByName() to do a lookup.
  134269. * @param generator The mesh or transform node to generate a trail.
  134270. * @param scene The scene to add this mesh to.
  134271. * @param diameter Diameter of trailing mesh. Default is 1.
  134272. * @param length Length of trailing mesh. Default is 60.
  134273. * @param autoStart Automatically start trailing mesh. Default true.
  134274. */
  134275. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  134276. /**
  134277. * "TrailMesh"
  134278. * @returns "TrailMesh"
  134279. */
  134280. getClassName(): string;
  134281. private _createMesh;
  134282. /**
  134283. * Start trailing mesh.
  134284. */
  134285. start(): void;
  134286. /**
  134287. * Stop trailing mesh.
  134288. */
  134289. stop(): void;
  134290. /**
  134291. * Update trailing mesh geometry.
  134292. */
  134293. update(): void;
  134294. /**
  134295. * Returns a new TrailMesh object.
  134296. * @param name is a string, the name given to the new mesh
  134297. * @param newGenerator use new generator object for cloned trail mesh
  134298. * @returns a new mesh
  134299. */
  134300. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  134301. /**
  134302. * Serializes this trail mesh
  134303. * @param serializationObject object to write serialization to
  134304. */
  134305. serialize(serializationObject: any): void;
  134306. /**
  134307. * Parses a serialized trail mesh
  134308. * @param parsedMesh the serialized mesh
  134309. * @param scene the scene to create the trail mesh in
  134310. * @returns the created trail mesh
  134311. */
  134312. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  134313. }
  134314. }
  134315. declare module BABYLON {
  134316. /**
  134317. * Class containing static functions to help procedurally build meshes
  134318. */
  134319. export class TiledBoxBuilder {
  134320. /**
  134321. * Creates a box mesh
  134322. * 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)
  134323. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134327. * @param name defines the name of the mesh
  134328. * @param options defines the options used to create the mesh
  134329. * @param scene defines the hosting scene
  134330. * @returns the box mesh
  134331. */
  134332. static CreateTiledBox(name: string, options: {
  134333. pattern?: number;
  134334. width?: number;
  134335. height?: number;
  134336. depth?: number;
  134337. tileSize?: number;
  134338. tileWidth?: number;
  134339. tileHeight?: number;
  134340. alignHorizontal?: number;
  134341. alignVertical?: number;
  134342. faceUV?: Vector4[];
  134343. faceColors?: Color4[];
  134344. sideOrientation?: number;
  134345. updatable?: boolean;
  134346. }, scene?: Nullable<Scene>): Mesh;
  134347. }
  134348. }
  134349. declare module BABYLON {
  134350. /**
  134351. * Class containing static functions to help procedurally build meshes
  134352. */
  134353. export class TorusKnotBuilder {
  134354. /**
  134355. * Creates a torus knot mesh
  134356. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134357. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134358. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134359. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134363. * @param name defines the name of the mesh
  134364. * @param options defines the options used to create the mesh
  134365. * @param scene defines the hosting scene
  134366. * @returns the torus knot mesh
  134367. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134368. */
  134369. static CreateTorusKnot(name: string, options: {
  134370. radius?: number;
  134371. tube?: number;
  134372. radialSegments?: number;
  134373. tubularSegments?: number;
  134374. p?: number;
  134375. q?: number;
  134376. updatable?: boolean;
  134377. sideOrientation?: number;
  134378. frontUVs?: Vector4;
  134379. backUVs?: Vector4;
  134380. }, scene: any): Mesh;
  134381. }
  134382. }
  134383. declare module BABYLON {
  134384. /**
  134385. * Polygon
  134386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  134387. */
  134388. export class Polygon {
  134389. /**
  134390. * Creates a rectangle
  134391. * @param xmin bottom X coord
  134392. * @param ymin bottom Y coord
  134393. * @param xmax top X coord
  134394. * @param ymax top Y coord
  134395. * @returns points that make the resulting rectation
  134396. */
  134397. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134398. /**
  134399. * Creates a circle
  134400. * @param radius radius of circle
  134401. * @param cx scale in x
  134402. * @param cy scale in y
  134403. * @param numberOfSides number of sides that make up the circle
  134404. * @returns points that make the resulting circle
  134405. */
  134406. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134407. /**
  134408. * Creates a polygon from input string
  134409. * @param input Input polygon data
  134410. * @returns the parsed points
  134411. */
  134412. static Parse(input: string): Vector2[];
  134413. /**
  134414. * Starts building a polygon from x and y coordinates
  134415. * @param x x coordinate
  134416. * @param y y coordinate
  134417. * @returns the started path2
  134418. */
  134419. static StartingAt(x: number, y: number): Path2;
  134420. }
  134421. /**
  134422. * Builds a polygon
  134423. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134424. */
  134425. export class PolygonMeshBuilder {
  134426. private _points;
  134427. private _outlinepoints;
  134428. private _holes;
  134429. private _name;
  134430. private _scene;
  134431. private _epoints;
  134432. private _eholes;
  134433. private _addToepoint;
  134434. /**
  134435. * Babylon reference to the earcut plugin.
  134436. */
  134437. bjsEarcut: any;
  134438. /**
  134439. * Creates a PolygonMeshBuilder
  134440. * @param name name of the builder
  134441. * @param contours Path of the polygon
  134442. * @param scene scene to add to when creating the mesh
  134443. * @param earcutInjection can be used to inject your own earcut reference
  134444. */
  134445. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134446. /**
  134447. * Adds a whole within the polygon
  134448. * @param hole Array of points defining the hole
  134449. * @returns this
  134450. */
  134451. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134452. /**
  134453. * Creates the polygon
  134454. * @param updatable If the mesh should be updatable
  134455. * @param depth The depth of the mesh created
  134456. * @returns the created mesh
  134457. */
  134458. build(updatable?: boolean, depth?: number): Mesh;
  134459. /**
  134460. * Creates the polygon
  134461. * @param depth The depth of the mesh created
  134462. * @returns the created VertexData
  134463. */
  134464. buildVertexData(depth?: number): VertexData;
  134465. /**
  134466. * Adds a side to the polygon
  134467. * @param positions points that make the polygon
  134468. * @param normals normals of the polygon
  134469. * @param uvs uvs of the polygon
  134470. * @param indices indices of the polygon
  134471. * @param bounds bounds of the polygon
  134472. * @param points points of the polygon
  134473. * @param depth depth of the polygon
  134474. * @param flip flip of the polygon
  134475. */
  134476. private addSide;
  134477. }
  134478. }
  134479. declare module BABYLON {
  134480. /**
  134481. * Class containing static functions to help procedurally build meshes
  134482. */
  134483. export class PolygonBuilder {
  134484. /**
  134485. * Creates a polygon mesh
  134486. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134487. * * 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
  134488. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134491. * * Remember you can only change the shape positions, not their number when updating a polygon
  134492. * @param name defines the name of the mesh
  134493. * @param options defines the options used to create the mesh
  134494. * @param scene defines the hosting scene
  134495. * @param earcutInjection can be used to inject your own earcut reference
  134496. * @returns the polygon mesh
  134497. */
  134498. static CreatePolygon(name: string, options: {
  134499. shape: Vector3[];
  134500. holes?: Vector3[][];
  134501. depth?: number;
  134502. faceUV?: Vector4[];
  134503. faceColors?: Color4[];
  134504. updatable?: boolean;
  134505. sideOrientation?: number;
  134506. frontUVs?: Vector4;
  134507. backUVs?: Vector4;
  134508. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134509. /**
  134510. * Creates an extruded polygon mesh, with depth in the Y direction.
  134511. * * 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)
  134512. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134513. * @param name defines the name of the mesh
  134514. * @param options defines the options used to create the mesh
  134515. * @param scene defines the hosting scene
  134516. * @param earcutInjection can be used to inject your own earcut reference
  134517. * @returns the polygon mesh
  134518. */
  134519. static ExtrudePolygon(name: string, options: {
  134520. shape: Vector3[];
  134521. holes?: Vector3[][];
  134522. depth?: number;
  134523. faceUV?: Vector4[];
  134524. faceColors?: Color4[];
  134525. updatable?: boolean;
  134526. sideOrientation?: number;
  134527. frontUVs?: Vector4;
  134528. backUVs?: Vector4;
  134529. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134530. }
  134531. }
  134532. declare module BABYLON {
  134533. /**
  134534. * Class containing static functions to help procedurally build meshes
  134535. */
  134536. export class LatheBuilder {
  134537. /**
  134538. * Creates lathe mesh.
  134539. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134540. * * 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
  134541. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134542. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134543. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134544. * * 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
  134545. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134546. * * 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
  134547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134551. * @param name defines the name of the mesh
  134552. * @param options defines the options used to create the mesh
  134553. * @param scene defines the hosting scene
  134554. * @returns the lathe mesh
  134555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134556. */
  134557. static CreateLathe(name: string, options: {
  134558. shape: Vector3[];
  134559. radius?: number;
  134560. tessellation?: number;
  134561. clip?: number;
  134562. arc?: number;
  134563. closed?: boolean;
  134564. updatable?: boolean;
  134565. sideOrientation?: number;
  134566. frontUVs?: Vector4;
  134567. backUVs?: Vector4;
  134568. cap?: number;
  134569. invertUV?: boolean;
  134570. }, scene?: Nullable<Scene>): Mesh;
  134571. }
  134572. }
  134573. declare module BABYLON {
  134574. /**
  134575. * Class containing static functions to help procedurally build meshes
  134576. */
  134577. export class TiledPlaneBuilder {
  134578. /**
  134579. * Creates a tiled plane mesh
  134580. * * The parameter `pattern` will, depending on value, do nothing or
  134581. * * * flip (reflect about central vertical) alternate tiles across and up
  134582. * * * flip every tile on alternate rows
  134583. * * * rotate (180 degs) alternate tiles across and up
  134584. * * * rotate every tile on alternate rows
  134585. * * * flip and rotate alternate tiles across and up
  134586. * * * flip and rotate every tile on alternate rows
  134587. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134588. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134591. * * 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)
  134592. * * 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)
  134593. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134594. * @param name defines the name of the mesh
  134595. * @param options defines the options used to create the mesh
  134596. * @param scene defines the hosting scene
  134597. * @returns the box mesh
  134598. */
  134599. static CreateTiledPlane(name: string, options: {
  134600. pattern?: number;
  134601. tileSize?: number;
  134602. tileWidth?: number;
  134603. tileHeight?: number;
  134604. size?: number;
  134605. width?: number;
  134606. height?: number;
  134607. alignHorizontal?: number;
  134608. alignVertical?: number;
  134609. sideOrientation?: number;
  134610. frontUVs?: Vector4;
  134611. backUVs?: Vector4;
  134612. updatable?: boolean;
  134613. }, scene?: Nullable<Scene>): Mesh;
  134614. }
  134615. }
  134616. declare module BABYLON {
  134617. /**
  134618. * Class containing static functions to help procedurally build meshes
  134619. */
  134620. export class TubeBuilder {
  134621. /**
  134622. * Creates a tube mesh.
  134623. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134624. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134625. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134626. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134627. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134628. * * 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)
  134629. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134630. * * 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
  134631. * * 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
  134632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134636. * @param name defines the name of the mesh
  134637. * @param options defines the options used to create the mesh
  134638. * @param scene defines the hosting scene
  134639. * @returns the tube mesh
  134640. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134641. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134642. */
  134643. static CreateTube(name: string, options: {
  134644. path: Vector3[];
  134645. radius?: number;
  134646. tessellation?: number;
  134647. radiusFunction?: {
  134648. (i: number, distance: number): number;
  134649. };
  134650. cap?: number;
  134651. arc?: number;
  134652. updatable?: boolean;
  134653. sideOrientation?: number;
  134654. frontUVs?: Vector4;
  134655. backUVs?: Vector4;
  134656. instance?: Mesh;
  134657. invertUV?: boolean;
  134658. }, scene?: Nullable<Scene>): Mesh;
  134659. }
  134660. }
  134661. declare module BABYLON {
  134662. /**
  134663. * Class containing static functions to help procedurally build meshes
  134664. */
  134665. export class IcoSphereBuilder {
  134666. /**
  134667. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134668. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134669. * * 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`)
  134670. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134671. * * 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
  134672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134675. * @param name defines the name of the mesh
  134676. * @param options defines the options used to create the mesh
  134677. * @param scene defines the hosting scene
  134678. * @returns the icosahedron mesh
  134679. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134680. */
  134681. static CreateIcoSphere(name: string, options: {
  134682. radius?: number;
  134683. radiusX?: number;
  134684. radiusY?: number;
  134685. radiusZ?: number;
  134686. flat?: boolean;
  134687. subdivisions?: number;
  134688. sideOrientation?: number;
  134689. frontUVs?: Vector4;
  134690. backUVs?: Vector4;
  134691. updatable?: boolean;
  134692. }, scene?: Nullable<Scene>): Mesh;
  134693. }
  134694. }
  134695. declare module BABYLON {
  134696. /**
  134697. * Class containing static functions to help procedurally build meshes
  134698. */
  134699. export class DecalBuilder {
  134700. /**
  134701. * Creates a decal mesh.
  134702. * 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
  134703. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134704. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134705. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134706. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134707. * @param name defines the name of the mesh
  134708. * @param sourceMesh defines the mesh where the decal must be applied
  134709. * @param options defines the options used to create the mesh
  134710. * @param scene defines the hosting scene
  134711. * @returns the decal mesh
  134712. * @see https://doc.babylonjs.com/how_to/decals
  134713. */
  134714. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134715. position?: Vector3;
  134716. normal?: Vector3;
  134717. size?: Vector3;
  134718. angle?: number;
  134719. }): Mesh;
  134720. }
  134721. }
  134722. declare module BABYLON {
  134723. /**
  134724. * Class containing static functions to help procedurally build meshes
  134725. */
  134726. export class MeshBuilder {
  134727. /**
  134728. * Creates a box mesh
  134729. * * The parameter `size` sets the size (float) of each box side (default 1)
  134730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134731. * * 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)
  134732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134737. * @param name defines the name of the mesh
  134738. * @param options defines the options used to create the mesh
  134739. * @param scene defines the hosting scene
  134740. * @returns the box mesh
  134741. */
  134742. static CreateBox(name: string, options: {
  134743. size?: number;
  134744. width?: number;
  134745. height?: number;
  134746. depth?: number;
  134747. faceUV?: Vector4[];
  134748. faceColors?: Color4[];
  134749. sideOrientation?: number;
  134750. frontUVs?: Vector4;
  134751. backUVs?: Vector4;
  134752. updatable?: boolean;
  134753. }, scene?: Nullable<Scene>): Mesh;
  134754. /**
  134755. * Creates a tiled box mesh
  134756. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134758. * @param name defines the name of the mesh
  134759. * @param options defines the options used to create the mesh
  134760. * @param scene defines the hosting scene
  134761. * @returns the tiled box mesh
  134762. */
  134763. static CreateTiledBox(name: string, options: {
  134764. pattern?: number;
  134765. size?: number;
  134766. width?: number;
  134767. height?: number;
  134768. depth: number;
  134769. tileSize?: number;
  134770. tileWidth?: number;
  134771. tileHeight?: number;
  134772. faceUV?: Vector4[];
  134773. faceColors?: Color4[];
  134774. alignHorizontal?: number;
  134775. alignVertical?: number;
  134776. sideOrientation?: number;
  134777. updatable?: boolean;
  134778. }, scene?: Nullable<Scene>): Mesh;
  134779. /**
  134780. * Creates a sphere mesh
  134781. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134782. * * 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`)
  134783. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134784. * * 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
  134785. * * 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)
  134786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134789. * @param name defines the name of the mesh
  134790. * @param options defines the options used to create the mesh
  134791. * @param scene defines the hosting scene
  134792. * @returns the sphere mesh
  134793. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134794. */
  134795. static CreateSphere(name: string, options: {
  134796. segments?: number;
  134797. diameter?: number;
  134798. diameterX?: number;
  134799. diameterY?: number;
  134800. diameterZ?: number;
  134801. arc?: number;
  134802. slice?: number;
  134803. sideOrientation?: number;
  134804. frontUVs?: Vector4;
  134805. backUVs?: Vector4;
  134806. updatable?: boolean;
  134807. }, scene?: Nullable<Scene>): Mesh;
  134808. /**
  134809. * Creates a plane polygonal mesh. By default, this is a disc
  134810. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134811. * * 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
  134812. * * 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
  134813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134816. * @param name defines the name of the mesh
  134817. * @param options defines the options used to create the mesh
  134818. * @param scene defines the hosting scene
  134819. * @returns the plane polygonal mesh
  134820. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134821. */
  134822. static CreateDisc(name: string, options: {
  134823. radius?: number;
  134824. tessellation?: number;
  134825. arc?: number;
  134826. updatable?: boolean;
  134827. sideOrientation?: number;
  134828. frontUVs?: Vector4;
  134829. backUVs?: Vector4;
  134830. }, scene?: Nullable<Scene>): Mesh;
  134831. /**
  134832. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134833. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134834. * * 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`)
  134835. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134836. * * 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
  134837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134840. * @param name defines the name of the mesh
  134841. * @param options defines the options used to create the mesh
  134842. * @param scene defines the hosting scene
  134843. * @returns the icosahedron mesh
  134844. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134845. */
  134846. static CreateIcoSphere(name: string, options: {
  134847. radius?: number;
  134848. radiusX?: number;
  134849. radiusY?: number;
  134850. radiusZ?: number;
  134851. flat?: boolean;
  134852. subdivisions?: number;
  134853. sideOrientation?: number;
  134854. frontUVs?: Vector4;
  134855. backUVs?: Vector4;
  134856. updatable?: boolean;
  134857. }, scene?: Nullable<Scene>): Mesh;
  134858. /**
  134859. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134860. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134861. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134862. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134863. * * 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
  134864. * * 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
  134865. * * 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
  134866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134868. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134869. * * 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
  134870. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134871. * * 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
  134872. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134874. * @param name defines the name of the mesh
  134875. * @param options defines the options used to create the mesh
  134876. * @param scene defines the hosting scene
  134877. * @returns the ribbon mesh
  134878. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134879. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134880. */
  134881. static CreateRibbon(name: string, options: {
  134882. pathArray: Vector3[][];
  134883. closeArray?: boolean;
  134884. closePath?: boolean;
  134885. offset?: number;
  134886. updatable?: boolean;
  134887. sideOrientation?: number;
  134888. frontUVs?: Vector4;
  134889. backUVs?: Vector4;
  134890. instance?: Mesh;
  134891. invertUV?: boolean;
  134892. uvs?: Vector2[];
  134893. colors?: Color4[];
  134894. }, scene?: Nullable<Scene>): Mesh;
  134895. /**
  134896. * Creates a cylinder or a cone mesh
  134897. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134898. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134899. * * 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.
  134900. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134901. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134902. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134903. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134904. * * 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).
  134905. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134906. * * 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).
  134907. * * 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
  134908. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134909. * * 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
  134910. * * 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.
  134911. * * If `enclose` is false, a ring surface is one element.
  134912. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134913. * * 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
  134914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134917. * @param name defines the name of the mesh
  134918. * @param options defines the options used to create the mesh
  134919. * @param scene defines the hosting scene
  134920. * @returns the cylinder mesh
  134921. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134922. */
  134923. static CreateCylinder(name: string, options: {
  134924. height?: number;
  134925. diameterTop?: number;
  134926. diameterBottom?: number;
  134927. diameter?: number;
  134928. tessellation?: number;
  134929. subdivisions?: number;
  134930. arc?: number;
  134931. faceColors?: Color4[];
  134932. faceUV?: Vector4[];
  134933. updatable?: boolean;
  134934. hasRings?: boolean;
  134935. enclose?: boolean;
  134936. cap?: number;
  134937. sideOrientation?: number;
  134938. frontUVs?: Vector4;
  134939. backUVs?: Vector4;
  134940. }, scene?: Nullable<Scene>): Mesh;
  134941. /**
  134942. * Creates a torus mesh
  134943. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134944. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134945. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134949. * @param name defines the name of the mesh
  134950. * @param options defines the options used to create the mesh
  134951. * @param scene defines the hosting scene
  134952. * @returns the torus mesh
  134953. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134954. */
  134955. static CreateTorus(name: string, options: {
  134956. diameter?: number;
  134957. thickness?: number;
  134958. tessellation?: number;
  134959. updatable?: boolean;
  134960. sideOrientation?: number;
  134961. frontUVs?: Vector4;
  134962. backUVs?: Vector4;
  134963. }, scene?: Nullable<Scene>): Mesh;
  134964. /**
  134965. * Creates a torus knot mesh
  134966. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134967. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134968. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134969. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134973. * @param name defines the name of the mesh
  134974. * @param options defines the options used to create the mesh
  134975. * @param scene defines the hosting scene
  134976. * @returns the torus knot mesh
  134977. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134978. */
  134979. static CreateTorusKnot(name: string, options: {
  134980. radius?: number;
  134981. tube?: number;
  134982. radialSegments?: number;
  134983. tubularSegments?: number;
  134984. p?: number;
  134985. q?: number;
  134986. updatable?: boolean;
  134987. sideOrientation?: number;
  134988. frontUVs?: Vector4;
  134989. backUVs?: Vector4;
  134990. }, scene?: Nullable<Scene>): Mesh;
  134991. /**
  134992. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134993. * * 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
  134994. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134995. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134996. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134997. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134998. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134999. * * 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
  135000. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  135001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  135003. * @param name defines the name of the new line system
  135004. * @param options defines the options used to create the line system
  135005. * @param scene defines the hosting scene
  135006. * @returns a new line system mesh
  135007. */
  135008. static CreateLineSystem(name: string, options: {
  135009. lines: Vector3[][];
  135010. updatable?: boolean;
  135011. instance?: Nullable<LinesMesh>;
  135012. colors?: Nullable<Color4[][]>;
  135013. useVertexAlpha?: boolean;
  135014. }, scene: Nullable<Scene>): LinesMesh;
  135015. /**
  135016. * Creates a line mesh
  135017. * 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
  135018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  135019. * * The parameter `points` is an array successive Vector3
  135020. * * 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
  135021. * * The optional parameter `colors` is an array of successive Color4, one per line point
  135022. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  135023. * * When updating an instance, remember that only point positions can change, not the number of points
  135024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  135026. * @param name defines the name of the new line system
  135027. * @param options defines the options used to create the line system
  135028. * @param scene defines the hosting scene
  135029. * @returns a new line mesh
  135030. */
  135031. static CreateLines(name: string, options: {
  135032. points: Vector3[];
  135033. updatable?: boolean;
  135034. instance?: Nullable<LinesMesh>;
  135035. colors?: Color4[];
  135036. useVertexAlpha?: boolean;
  135037. }, scene?: Nullable<Scene>): LinesMesh;
  135038. /**
  135039. * Creates a dashed line mesh
  135040. * * 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
  135041. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  135042. * * The parameter `points` is an array successive Vector3
  135043. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  135044. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  135045. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  135046. * * 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
  135047. * * When updating an instance, remember that only point positions can change, not the number of points
  135048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135049. * @param name defines the name of the mesh
  135050. * @param options defines the options used to create the mesh
  135051. * @param scene defines the hosting scene
  135052. * @returns the dashed line mesh
  135053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  135054. */
  135055. static CreateDashedLines(name: string, options: {
  135056. points: Vector3[];
  135057. dashSize?: number;
  135058. gapSize?: number;
  135059. dashNb?: number;
  135060. updatable?: boolean;
  135061. instance?: LinesMesh;
  135062. }, scene?: Nullable<Scene>): LinesMesh;
  135063. /**
  135064. * 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.
  135065. * * 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.
  135066. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135067. * * 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.
  135068. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135069. * * 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
  135070. * * 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
  135071. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135076. * @param name defines the name of the mesh
  135077. * @param options defines the options used to create the mesh
  135078. * @param scene defines the hosting scene
  135079. * @returns the extruded shape mesh
  135080. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135082. */
  135083. static ExtrudeShape(name: string, options: {
  135084. shape: Vector3[];
  135085. path: Vector3[];
  135086. scale?: number;
  135087. rotation?: number;
  135088. cap?: number;
  135089. updatable?: boolean;
  135090. sideOrientation?: number;
  135091. frontUVs?: Vector4;
  135092. backUVs?: Vector4;
  135093. instance?: Mesh;
  135094. invertUV?: boolean;
  135095. }, scene?: Nullable<Scene>): Mesh;
  135096. /**
  135097. * Creates an custom extruded shape mesh.
  135098. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135099. * * 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.
  135100. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135101. * * 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
  135102. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135103. * * 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
  135104. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135105. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135106. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135107. * * 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
  135108. * * 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
  135109. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135114. * @param name defines the name of the mesh
  135115. * @param options defines the options used to create the mesh
  135116. * @param scene defines the hosting scene
  135117. * @returns the custom extruded shape mesh
  135118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135119. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135121. */
  135122. static ExtrudeShapeCustom(name: string, options: {
  135123. shape: Vector3[];
  135124. path: Vector3[];
  135125. scaleFunction?: any;
  135126. rotationFunction?: any;
  135127. ribbonCloseArray?: boolean;
  135128. ribbonClosePath?: boolean;
  135129. cap?: number;
  135130. updatable?: boolean;
  135131. sideOrientation?: number;
  135132. frontUVs?: Vector4;
  135133. backUVs?: Vector4;
  135134. instance?: Mesh;
  135135. invertUV?: boolean;
  135136. }, scene?: Nullable<Scene>): Mesh;
  135137. /**
  135138. * Creates lathe mesh.
  135139. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135140. * * 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
  135141. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135142. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135143. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135144. * * 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
  135145. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135146. * * 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
  135147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135149. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135151. * @param name defines the name of the mesh
  135152. * @param options defines the options used to create the mesh
  135153. * @param scene defines the hosting scene
  135154. * @returns the lathe mesh
  135155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135156. */
  135157. static CreateLathe(name: string, options: {
  135158. shape: Vector3[];
  135159. radius?: number;
  135160. tessellation?: number;
  135161. clip?: number;
  135162. arc?: number;
  135163. closed?: boolean;
  135164. updatable?: boolean;
  135165. sideOrientation?: number;
  135166. frontUVs?: Vector4;
  135167. backUVs?: Vector4;
  135168. cap?: number;
  135169. invertUV?: boolean;
  135170. }, scene?: Nullable<Scene>): Mesh;
  135171. /**
  135172. * Creates a tiled plane mesh
  135173. * * You can set a limited pattern arrangement with the tiles
  135174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135177. * @param name defines the name of the mesh
  135178. * @param options defines the options used to create the mesh
  135179. * @param scene defines the hosting scene
  135180. * @returns the plane mesh
  135181. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135182. */
  135183. static CreateTiledPlane(name: string, options: {
  135184. pattern?: number;
  135185. tileSize?: number;
  135186. tileWidth?: number;
  135187. tileHeight?: number;
  135188. size?: number;
  135189. width?: number;
  135190. height?: number;
  135191. alignHorizontal?: number;
  135192. alignVertical?: number;
  135193. sideOrientation?: number;
  135194. frontUVs?: Vector4;
  135195. backUVs?: Vector4;
  135196. updatable?: boolean;
  135197. }, scene?: Nullable<Scene>): Mesh;
  135198. /**
  135199. * Creates a plane mesh
  135200. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  135201. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  135202. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  135203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135206. * @param name defines the name of the mesh
  135207. * @param options defines the options used to create the mesh
  135208. * @param scene defines the hosting scene
  135209. * @returns the plane mesh
  135210. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135211. */
  135212. static CreatePlane(name: string, options: {
  135213. size?: number;
  135214. width?: number;
  135215. height?: number;
  135216. sideOrientation?: number;
  135217. frontUVs?: Vector4;
  135218. backUVs?: Vector4;
  135219. updatable?: boolean;
  135220. sourcePlane?: Plane;
  135221. }, scene?: Nullable<Scene>): Mesh;
  135222. /**
  135223. * Creates a ground mesh
  135224. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  135225. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  135226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135227. * @param name defines the name of the mesh
  135228. * @param options defines the options used to create the mesh
  135229. * @param scene defines the hosting scene
  135230. * @returns the ground mesh
  135231. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  135232. */
  135233. static CreateGround(name: string, options: {
  135234. width?: number;
  135235. height?: number;
  135236. subdivisions?: number;
  135237. subdivisionsX?: number;
  135238. subdivisionsY?: number;
  135239. updatable?: boolean;
  135240. }, scene?: Nullable<Scene>): Mesh;
  135241. /**
  135242. * Creates a tiled ground mesh
  135243. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  135244. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  135245. * * 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
  135246. * * 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
  135247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135248. * @param name defines the name of the mesh
  135249. * @param options defines the options used to create the mesh
  135250. * @param scene defines the hosting scene
  135251. * @returns the tiled ground mesh
  135252. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  135253. */
  135254. static CreateTiledGround(name: string, options: {
  135255. xmin: number;
  135256. zmin: number;
  135257. xmax: number;
  135258. zmax: number;
  135259. subdivisions?: {
  135260. w: number;
  135261. h: number;
  135262. };
  135263. precision?: {
  135264. w: number;
  135265. h: number;
  135266. };
  135267. updatable?: boolean;
  135268. }, scene?: Nullable<Scene>): Mesh;
  135269. /**
  135270. * Creates a ground mesh from a height map
  135271. * * The parameter `url` sets the URL of the height map image resource.
  135272. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  135273. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  135274. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  135275. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  135276. * * 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.
  135277. * * 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).
  135278. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  135279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135280. * @param name defines the name of the mesh
  135281. * @param url defines the url to the height map
  135282. * @param options defines the options used to create the mesh
  135283. * @param scene defines the hosting scene
  135284. * @returns the ground mesh
  135285. * @see https://doc.babylonjs.com/babylon101/height_map
  135286. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  135287. */
  135288. static CreateGroundFromHeightMap(name: string, url: string, options: {
  135289. width?: number;
  135290. height?: number;
  135291. subdivisions?: number;
  135292. minHeight?: number;
  135293. maxHeight?: number;
  135294. colorFilter?: Color3;
  135295. alphaFilter?: number;
  135296. updatable?: boolean;
  135297. onReady?: (mesh: GroundMesh) => void;
  135298. }, scene?: Nullable<Scene>): GroundMesh;
  135299. /**
  135300. * Creates a polygon mesh
  135301. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135302. * * 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
  135303. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135306. * * Remember you can only change the shape positions, not their number when updating a polygon
  135307. * @param name defines the name of the mesh
  135308. * @param options defines the options used to create the mesh
  135309. * @param scene defines the hosting scene
  135310. * @param earcutInjection can be used to inject your own earcut reference
  135311. * @returns the polygon mesh
  135312. */
  135313. static CreatePolygon(name: string, options: {
  135314. shape: Vector3[];
  135315. holes?: Vector3[][];
  135316. depth?: number;
  135317. faceUV?: Vector4[];
  135318. faceColors?: Color4[];
  135319. updatable?: boolean;
  135320. sideOrientation?: number;
  135321. frontUVs?: Vector4;
  135322. backUVs?: Vector4;
  135323. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135324. /**
  135325. * Creates an extruded polygon mesh, with depth in the Y direction.
  135326. * * 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)
  135327. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135328. * @param name defines the name of the mesh
  135329. * @param options defines the options used to create the mesh
  135330. * @param scene defines the hosting scene
  135331. * @param earcutInjection can be used to inject your own earcut reference
  135332. * @returns the polygon mesh
  135333. */
  135334. static ExtrudePolygon(name: string, options: {
  135335. shape: Vector3[];
  135336. holes?: Vector3[][];
  135337. depth?: number;
  135338. faceUV?: Vector4[];
  135339. faceColors?: Color4[];
  135340. updatable?: boolean;
  135341. sideOrientation?: number;
  135342. frontUVs?: Vector4;
  135343. backUVs?: Vector4;
  135344. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135345. /**
  135346. * Creates a tube mesh.
  135347. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135348. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135349. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135350. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135351. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135352. * * 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)
  135353. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135354. * * 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
  135355. * * 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
  135356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135360. * @param name defines the name of the mesh
  135361. * @param options defines the options used to create the mesh
  135362. * @param scene defines the hosting scene
  135363. * @returns the tube mesh
  135364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135365. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135366. */
  135367. static CreateTube(name: string, options: {
  135368. path: Vector3[];
  135369. radius?: number;
  135370. tessellation?: number;
  135371. radiusFunction?: {
  135372. (i: number, distance: number): number;
  135373. };
  135374. cap?: number;
  135375. arc?: number;
  135376. updatable?: boolean;
  135377. sideOrientation?: number;
  135378. frontUVs?: Vector4;
  135379. backUVs?: Vector4;
  135380. instance?: Mesh;
  135381. invertUV?: boolean;
  135382. }, scene?: Nullable<Scene>): Mesh;
  135383. /**
  135384. * Creates a polyhedron mesh
  135385. * * 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
  135386. * * The parameter `size` (positive float, default 1) sets the polygon size
  135387. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135388. * * 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`
  135389. * * 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
  135390. * * 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)`)
  135391. * * 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
  135392. * * 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
  135393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135396. * @param name defines the name of the mesh
  135397. * @param options defines the options used to create the mesh
  135398. * @param scene defines the hosting scene
  135399. * @returns the polyhedron mesh
  135400. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135401. */
  135402. static CreatePolyhedron(name: string, options: {
  135403. type?: number;
  135404. size?: number;
  135405. sizeX?: number;
  135406. sizeY?: number;
  135407. sizeZ?: number;
  135408. custom?: any;
  135409. faceUV?: Vector4[];
  135410. faceColors?: Color4[];
  135411. flat?: boolean;
  135412. updatable?: boolean;
  135413. sideOrientation?: number;
  135414. frontUVs?: Vector4;
  135415. backUVs?: Vector4;
  135416. }, scene?: Nullable<Scene>): Mesh;
  135417. /**
  135418. * Creates a decal mesh.
  135419. * 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
  135420. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135421. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135422. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135423. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135424. * @param name defines the name of the mesh
  135425. * @param sourceMesh defines the mesh where the decal must be applied
  135426. * @param options defines the options used to create the mesh
  135427. * @param scene defines the hosting scene
  135428. * @returns the decal mesh
  135429. * @see https://doc.babylonjs.com/how_to/decals
  135430. */
  135431. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135432. position?: Vector3;
  135433. normal?: Vector3;
  135434. size?: Vector3;
  135435. angle?: number;
  135436. }): Mesh;
  135437. }
  135438. }
  135439. declare module BABYLON {
  135440. /**
  135441. * A simplifier interface for future simplification implementations
  135442. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135443. */
  135444. export interface ISimplifier {
  135445. /**
  135446. * Simplification of a given mesh according to the given settings.
  135447. * Since this requires computation, it is assumed that the function runs async.
  135448. * @param settings The settings of the simplification, including quality and distance
  135449. * @param successCallback A callback that will be called after the mesh was simplified.
  135450. * @param errorCallback in case of an error, this callback will be called. optional.
  135451. */
  135452. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135453. }
  135454. /**
  135455. * Expected simplification settings.
  135456. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135457. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135458. */
  135459. export interface ISimplificationSettings {
  135460. /**
  135461. * Gets or sets the expected quality
  135462. */
  135463. quality: number;
  135464. /**
  135465. * Gets or sets the distance when this optimized version should be used
  135466. */
  135467. distance: number;
  135468. /**
  135469. * Gets an already optimized mesh
  135470. */
  135471. optimizeMesh?: boolean;
  135472. }
  135473. /**
  135474. * Class used to specify simplification options
  135475. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135476. */
  135477. export class SimplificationSettings implements ISimplificationSettings {
  135478. /** expected quality */
  135479. quality: number;
  135480. /** distance when this optimized version should be used */
  135481. distance: number;
  135482. /** already optimized mesh */
  135483. optimizeMesh?: boolean | undefined;
  135484. /**
  135485. * Creates a SimplificationSettings
  135486. * @param quality expected quality
  135487. * @param distance distance when this optimized version should be used
  135488. * @param optimizeMesh already optimized mesh
  135489. */
  135490. constructor(
  135491. /** expected quality */
  135492. quality: number,
  135493. /** distance when this optimized version should be used */
  135494. distance: number,
  135495. /** already optimized mesh */
  135496. optimizeMesh?: boolean | undefined);
  135497. }
  135498. /**
  135499. * Interface used to define a simplification task
  135500. */
  135501. export interface ISimplificationTask {
  135502. /**
  135503. * Array of settings
  135504. */
  135505. settings: Array<ISimplificationSettings>;
  135506. /**
  135507. * Simplification type
  135508. */
  135509. simplificationType: SimplificationType;
  135510. /**
  135511. * Mesh to simplify
  135512. */
  135513. mesh: Mesh;
  135514. /**
  135515. * Callback called on success
  135516. */
  135517. successCallback?: () => void;
  135518. /**
  135519. * Defines if parallel processing can be used
  135520. */
  135521. parallelProcessing: boolean;
  135522. }
  135523. /**
  135524. * Queue used to order the simplification tasks
  135525. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135526. */
  135527. export class SimplificationQueue {
  135528. private _simplificationArray;
  135529. /**
  135530. * Gets a boolean indicating that the process is still running
  135531. */
  135532. running: boolean;
  135533. /**
  135534. * Creates a new queue
  135535. */
  135536. constructor();
  135537. /**
  135538. * Adds a new simplification task
  135539. * @param task defines a task to add
  135540. */
  135541. addTask(task: ISimplificationTask): void;
  135542. /**
  135543. * Execute next task
  135544. */
  135545. executeNext(): void;
  135546. /**
  135547. * Execute a simplification task
  135548. * @param task defines the task to run
  135549. */
  135550. runSimplification(task: ISimplificationTask): void;
  135551. private getSimplifier;
  135552. }
  135553. /**
  135554. * The implemented types of simplification
  135555. * At the moment only Quadratic Error Decimation is implemented
  135556. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135557. */
  135558. export enum SimplificationType {
  135559. /** Quadratic error decimation */
  135560. QUADRATIC = 0
  135561. }
  135562. /**
  135563. * An implementation of the Quadratic Error simplification algorithm.
  135564. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  135565. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  135566. * @author RaananW
  135567. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135568. */
  135569. export class QuadraticErrorSimplification implements ISimplifier {
  135570. private _mesh;
  135571. private triangles;
  135572. private vertices;
  135573. private references;
  135574. private _reconstructedMesh;
  135575. /** Gets or sets the number pf sync interations */
  135576. syncIterations: number;
  135577. /** Gets or sets the aggressiveness of the simplifier */
  135578. aggressiveness: number;
  135579. /** Gets or sets the number of allowed iterations for decimation */
  135580. decimationIterations: number;
  135581. /** Gets or sets the espilon to use for bounding box computation */
  135582. boundingBoxEpsilon: number;
  135583. /**
  135584. * Creates a new QuadraticErrorSimplification
  135585. * @param _mesh defines the target mesh
  135586. */
  135587. constructor(_mesh: Mesh);
  135588. /**
  135589. * Simplification of a given mesh according to the given settings.
  135590. * Since this requires computation, it is assumed that the function runs async.
  135591. * @param settings The settings of the simplification, including quality and distance
  135592. * @param successCallback A callback that will be called after the mesh was simplified.
  135593. */
  135594. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  135595. private runDecimation;
  135596. private initWithMesh;
  135597. private init;
  135598. private reconstructMesh;
  135599. private initDecimatedMesh;
  135600. private isFlipped;
  135601. private updateTriangles;
  135602. private identifyBorder;
  135603. private updateMesh;
  135604. private vertexError;
  135605. private calculateError;
  135606. }
  135607. }
  135608. declare module BABYLON {
  135609. interface Scene {
  135610. /** @hidden (Backing field) */
  135611. _simplificationQueue: SimplificationQueue;
  135612. /**
  135613. * Gets or sets the simplification queue attached to the scene
  135614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135615. */
  135616. simplificationQueue: SimplificationQueue;
  135617. }
  135618. interface Mesh {
  135619. /**
  135620. * Simplify the mesh according to the given array of settings.
  135621. * Function will return immediately and will simplify async
  135622. * @param settings a collection of simplification settings
  135623. * @param parallelProcessing should all levels calculate parallel or one after the other
  135624. * @param simplificationType the type of simplification to run
  135625. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135626. * @returns the current mesh
  135627. */
  135628. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135629. }
  135630. /**
  135631. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135632. * created in a scene
  135633. */
  135634. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135635. /**
  135636. * The component name helpfull to identify the component in the list of scene components.
  135637. */
  135638. readonly name: string;
  135639. /**
  135640. * The scene the component belongs to.
  135641. */
  135642. scene: Scene;
  135643. /**
  135644. * Creates a new instance of the component for the given scene
  135645. * @param scene Defines the scene to register the component in
  135646. */
  135647. constructor(scene: Scene);
  135648. /**
  135649. * Registers the component in a given scene
  135650. */
  135651. register(): void;
  135652. /**
  135653. * Rebuilds the elements related to this component in case of
  135654. * context lost for instance.
  135655. */
  135656. rebuild(): void;
  135657. /**
  135658. * Disposes the component and the associated ressources
  135659. */
  135660. dispose(): void;
  135661. private _beforeCameraUpdate;
  135662. }
  135663. }
  135664. declare module BABYLON {
  135665. /**
  135666. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135667. */
  135668. export interface INavigationEnginePlugin {
  135669. /**
  135670. * plugin name
  135671. */
  135672. name: string;
  135673. /**
  135674. * Creates a navigation mesh
  135675. * @param meshes array of all the geometry used to compute the navigatio mesh
  135676. * @param parameters bunch of parameters used to filter geometry
  135677. */
  135678. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135679. /**
  135680. * Create a navigation mesh debug mesh
  135681. * @param scene is where the mesh will be added
  135682. * @returns debug display mesh
  135683. */
  135684. createDebugNavMesh(scene: Scene): Mesh;
  135685. /**
  135686. * Get a navigation mesh constrained position, closest to the parameter position
  135687. * @param position world position
  135688. * @returns the closest point to position constrained by the navigation mesh
  135689. */
  135690. getClosestPoint(position: Vector3): Vector3;
  135691. /**
  135692. * Get a navigation mesh constrained position, within a particular radius
  135693. * @param position world position
  135694. * @param maxRadius the maximum distance to the constrained world position
  135695. * @returns the closest point to position constrained by the navigation mesh
  135696. */
  135697. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135698. /**
  135699. * Compute the final position from a segment made of destination-position
  135700. * @param position world position
  135701. * @param destination world position
  135702. * @returns the resulting point along the navmesh
  135703. */
  135704. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135705. /**
  135706. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135707. * @param start world position
  135708. * @param end world position
  135709. * @returns array containing world position composing the path
  135710. */
  135711. computePath(start: Vector3, end: Vector3): Vector3[];
  135712. /**
  135713. * If this plugin is supported
  135714. * @returns true if plugin is supported
  135715. */
  135716. isSupported(): boolean;
  135717. /**
  135718. * Create a new Crowd so you can add agents
  135719. * @param maxAgents the maximum agent count in the crowd
  135720. * @param maxAgentRadius the maximum radius an agent can have
  135721. * @param scene to attach the crowd to
  135722. * @returns the crowd you can add agents to
  135723. */
  135724. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135725. /**
  135726. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135727. * The queries will try to find a solution within those bounds
  135728. * default is (1,1,1)
  135729. * @param extent x,y,z value that define the extent around the queries point of reference
  135730. */
  135731. setDefaultQueryExtent(extent: Vector3): void;
  135732. /**
  135733. * Get the Bounding box extent specified by setDefaultQueryExtent
  135734. * @returns the box extent values
  135735. */
  135736. getDefaultQueryExtent(): Vector3;
  135737. /**
  135738. * Release all resources
  135739. */
  135740. dispose(): void;
  135741. }
  135742. /**
  135743. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135744. */
  135745. export interface ICrowd {
  135746. /**
  135747. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135748. * You can attach anything to that node. The node position is updated in the scene update tick.
  135749. * @param pos world position that will be constrained by the navigation mesh
  135750. * @param parameters agent parameters
  135751. * @param transform hooked to the agent that will be update by the scene
  135752. * @returns agent index
  135753. */
  135754. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135755. /**
  135756. * Returns the agent position in world space
  135757. * @param index agent index returned by addAgent
  135758. * @returns world space position
  135759. */
  135760. getAgentPosition(index: number): Vector3;
  135761. /**
  135762. * Gets the agent velocity in world space
  135763. * @param index agent index returned by addAgent
  135764. * @returns world space velocity
  135765. */
  135766. getAgentVelocity(index: number): Vector3;
  135767. /**
  135768. * remove a particular agent previously created
  135769. * @param index agent index returned by addAgent
  135770. */
  135771. removeAgent(index: number): void;
  135772. /**
  135773. * get the list of all agents attached to this crowd
  135774. * @returns list of agent indices
  135775. */
  135776. getAgents(): number[];
  135777. /**
  135778. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135779. * @param deltaTime in seconds
  135780. */
  135781. update(deltaTime: number): void;
  135782. /**
  135783. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135784. * @param index agent index returned by addAgent
  135785. * @param destination targeted world position
  135786. */
  135787. agentGoto(index: number, destination: Vector3): void;
  135788. /**
  135789. * Teleport the agent to a new position
  135790. * @param index agent index returned by addAgent
  135791. * @param destination targeted world position
  135792. */
  135793. agentTeleport(index: number, destination: Vector3): void;
  135794. /**
  135795. * Update agent parameters
  135796. * @param index agent index returned by addAgent
  135797. * @param parameters agent parameters
  135798. */
  135799. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135800. /**
  135801. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135802. * The queries will try to find a solution within those bounds
  135803. * default is (1,1,1)
  135804. * @param extent x,y,z value that define the extent around the queries point of reference
  135805. */
  135806. setDefaultQueryExtent(extent: Vector3): void;
  135807. /**
  135808. * Get the Bounding box extent specified by setDefaultQueryExtent
  135809. * @returns the box extent values
  135810. */
  135811. getDefaultQueryExtent(): Vector3;
  135812. /**
  135813. * Release all resources
  135814. */
  135815. dispose(): void;
  135816. }
  135817. /**
  135818. * Configures an agent
  135819. */
  135820. export interface IAgentParameters {
  135821. /**
  135822. * Agent radius. [Limit: >= 0]
  135823. */
  135824. radius: number;
  135825. /**
  135826. * Agent height. [Limit: > 0]
  135827. */
  135828. height: number;
  135829. /**
  135830. * Maximum allowed acceleration. [Limit: >= 0]
  135831. */
  135832. maxAcceleration: number;
  135833. /**
  135834. * Maximum allowed speed. [Limit: >= 0]
  135835. */
  135836. maxSpeed: number;
  135837. /**
  135838. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135839. */
  135840. collisionQueryRange: number;
  135841. /**
  135842. * The path visibility optimization range. [Limit: > 0]
  135843. */
  135844. pathOptimizationRange: number;
  135845. /**
  135846. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135847. */
  135848. separationWeight: number;
  135849. }
  135850. /**
  135851. * Configures the navigation mesh creation
  135852. */
  135853. export interface INavMeshParameters {
  135854. /**
  135855. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135856. */
  135857. cs: number;
  135858. /**
  135859. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135860. */
  135861. ch: number;
  135862. /**
  135863. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135864. */
  135865. walkableSlopeAngle: number;
  135866. /**
  135867. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135868. * be considered walkable. [Limit: >= 3] [Units: vx]
  135869. */
  135870. walkableHeight: number;
  135871. /**
  135872. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135873. */
  135874. walkableClimb: number;
  135875. /**
  135876. * The distance to erode/shrink the walkable area of the heightfield away from
  135877. * obstructions. [Limit: >=0] [Units: vx]
  135878. */
  135879. walkableRadius: number;
  135880. /**
  135881. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135882. */
  135883. maxEdgeLen: number;
  135884. /**
  135885. * The maximum distance a simplfied contour's border edges should deviate
  135886. * the original raw contour. [Limit: >=0] [Units: vx]
  135887. */
  135888. maxSimplificationError: number;
  135889. /**
  135890. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135891. */
  135892. minRegionArea: number;
  135893. /**
  135894. * Any regions with a span count smaller than this value will, if possible,
  135895. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135896. */
  135897. mergeRegionArea: number;
  135898. /**
  135899. * The maximum number of vertices allowed for polygons generated during the
  135900. * contour to polygon conversion process. [Limit: >= 3]
  135901. */
  135902. maxVertsPerPoly: number;
  135903. /**
  135904. * Sets the sampling distance to use when generating the detail mesh.
  135905. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135906. */
  135907. detailSampleDist: number;
  135908. /**
  135909. * The maximum distance the detail mesh surface should deviate from heightfield
  135910. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135911. */
  135912. detailSampleMaxError: number;
  135913. }
  135914. }
  135915. declare module BABYLON {
  135916. /**
  135917. * RecastJS navigation plugin
  135918. */
  135919. export class RecastJSPlugin implements INavigationEnginePlugin {
  135920. /**
  135921. * Reference to the Recast library
  135922. */
  135923. bjsRECAST: any;
  135924. /**
  135925. * plugin name
  135926. */
  135927. name: string;
  135928. /**
  135929. * the first navmesh created. We might extend this to support multiple navmeshes
  135930. */
  135931. navMesh: any;
  135932. /**
  135933. * Initializes the recastJS plugin
  135934. * @param recastInjection can be used to inject your own recast reference
  135935. */
  135936. constructor(recastInjection?: any);
  135937. /**
  135938. * Creates a navigation mesh
  135939. * @param meshes array of all the geometry used to compute the navigatio mesh
  135940. * @param parameters bunch of parameters used to filter geometry
  135941. */
  135942. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135943. /**
  135944. * Create a navigation mesh debug mesh
  135945. * @param scene is where the mesh will be added
  135946. * @returns debug display mesh
  135947. */
  135948. createDebugNavMesh(scene: Scene): Mesh;
  135949. /**
  135950. * Get a navigation mesh constrained position, closest to the parameter position
  135951. * @param position world position
  135952. * @returns the closest point to position constrained by the navigation mesh
  135953. */
  135954. getClosestPoint(position: Vector3): Vector3;
  135955. /**
  135956. * Get a navigation mesh constrained position, within a particular radius
  135957. * @param position world position
  135958. * @param maxRadius the maximum distance to the constrained world position
  135959. * @returns the closest point to position constrained by the navigation mesh
  135960. */
  135961. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135962. /**
  135963. * Compute the final position from a segment made of destination-position
  135964. * @param position world position
  135965. * @param destination world position
  135966. * @returns the resulting point along the navmesh
  135967. */
  135968. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135969. /**
  135970. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135971. * @param start world position
  135972. * @param end world position
  135973. * @returns array containing world position composing the path
  135974. */
  135975. computePath(start: Vector3, end: Vector3): Vector3[];
  135976. /**
  135977. * Create a new Crowd so you can add agents
  135978. * @param maxAgents the maximum agent count in the crowd
  135979. * @param maxAgentRadius the maximum radius an agent can have
  135980. * @param scene to attach the crowd to
  135981. * @returns the crowd you can add agents to
  135982. */
  135983. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135984. /**
  135985. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135986. * The queries will try to find a solution within those bounds
  135987. * default is (1,1,1)
  135988. * @param extent x,y,z value that define the extent around the queries point of reference
  135989. */
  135990. setDefaultQueryExtent(extent: Vector3): void;
  135991. /**
  135992. * Get the Bounding box extent specified by setDefaultQueryExtent
  135993. * @returns the box extent values
  135994. */
  135995. getDefaultQueryExtent(): Vector3;
  135996. /**
  135997. * Disposes
  135998. */
  135999. dispose(): void;
  136000. /**
  136001. * If this plugin is supported
  136002. * @returns true if plugin is supported
  136003. */
  136004. isSupported(): boolean;
  136005. }
  136006. /**
  136007. * Recast detour crowd implementation
  136008. */
  136009. export class RecastJSCrowd implements ICrowd {
  136010. /**
  136011. * Recast/detour plugin
  136012. */
  136013. bjsRECASTPlugin: RecastJSPlugin;
  136014. /**
  136015. * Link to the detour crowd
  136016. */
  136017. recastCrowd: any;
  136018. /**
  136019. * One transform per agent
  136020. */
  136021. transforms: TransformNode[];
  136022. /**
  136023. * All agents created
  136024. */
  136025. agents: number[];
  136026. /**
  136027. * Link to the scene is kept to unregister the crowd from the scene
  136028. */
  136029. private _scene;
  136030. /**
  136031. * Observer for crowd updates
  136032. */
  136033. private _onBeforeAnimationsObserver;
  136034. /**
  136035. * Constructor
  136036. * @param plugin recastJS plugin
  136037. * @param maxAgents the maximum agent count in the crowd
  136038. * @param maxAgentRadius the maximum radius an agent can have
  136039. * @param scene to attach the crowd to
  136040. * @returns the crowd you can add agents to
  136041. */
  136042. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  136043. /**
  136044. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136045. * You can attach anything to that node. The node position is updated in the scene update tick.
  136046. * @param pos world position that will be constrained by the navigation mesh
  136047. * @param parameters agent parameters
  136048. * @param transform hooked to the agent that will be update by the scene
  136049. * @returns agent index
  136050. */
  136051. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136052. /**
  136053. * Returns the agent position in world space
  136054. * @param index agent index returned by addAgent
  136055. * @returns world space position
  136056. */
  136057. getAgentPosition(index: number): Vector3;
  136058. /**
  136059. * Returns the agent velocity in world space
  136060. * @param index agent index returned by addAgent
  136061. * @returns world space velocity
  136062. */
  136063. getAgentVelocity(index: number): Vector3;
  136064. /**
  136065. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136066. * @param index agent index returned by addAgent
  136067. * @param destination targeted world position
  136068. */
  136069. agentGoto(index: number, destination: Vector3): void;
  136070. /**
  136071. * Teleport the agent to a new position
  136072. * @param index agent index returned by addAgent
  136073. * @param destination targeted world position
  136074. */
  136075. agentTeleport(index: number, destination: Vector3): void;
  136076. /**
  136077. * Update agent parameters
  136078. * @param index agent index returned by addAgent
  136079. * @param parameters agent parameters
  136080. */
  136081. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136082. /**
  136083. * remove a particular agent previously created
  136084. * @param index agent index returned by addAgent
  136085. */
  136086. removeAgent(index: number): void;
  136087. /**
  136088. * get the list of all agents attached to this crowd
  136089. * @returns list of agent indices
  136090. */
  136091. getAgents(): number[];
  136092. /**
  136093. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136094. * @param deltaTime in seconds
  136095. */
  136096. update(deltaTime: number): void;
  136097. /**
  136098. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136099. * The queries will try to find a solution within those bounds
  136100. * default is (1,1,1)
  136101. * @param extent x,y,z value that define the extent around the queries point of reference
  136102. */
  136103. setDefaultQueryExtent(extent: Vector3): void;
  136104. /**
  136105. * Get the Bounding box extent specified by setDefaultQueryExtent
  136106. * @returns the box extent values
  136107. */
  136108. getDefaultQueryExtent(): Vector3;
  136109. /**
  136110. * Release all resources
  136111. */
  136112. dispose(): void;
  136113. }
  136114. }
  136115. declare module BABYLON {
  136116. /**
  136117. * Class used to enable access to IndexedDB
  136118. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  136119. */
  136120. export class Database implements IOfflineProvider {
  136121. private _callbackManifestChecked;
  136122. private _currentSceneUrl;
  136123. private _db;
  136124. private _enableSceneOffline;
  136125. private _enableTexturesOffline;
  136126. private _manifestVersionFound;
  136127. private _mustUpdateRessources;
  136128. private _hasReachedQuota;
  136129. private _isSupported;
  136130. private _idbFactory;
  136131. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  136132. private static IsUASupportingBlobStorage;
  136133. /**
  136134. * Gets a boolean indicating if Database storate is enabled (off by default)
  136135. */
  136136. static IDBStorageEnabled: boolean;
  136137. /**
  136138. * Gets a boolean indicating if scene must be saved in the database
  136139. */
  136140. get enableSceneOffline(): boolean;
  136141. /**
  136142. * Gets a boolean indicating if textures must be saved in the database
  136143. */
  136144. get enableTexturesOffline(): boolean;
  136145. /**
  136146. * Creates a new Database
  136147. * @param urlToScene defines the url to load the scene
  136148. * @param callbackManifestChecked defines the callback to use when manifest is checked
  136149. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  136150. */
  136151. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  136152. private static _ParseURL;
  136153. private static _ReturnFullUrlLocation;
  136154. private _checkManifestFile;
  136155. /**
  136156. * Open the database and make it available
  136157. * @param successCallback defines the callback to call on success
  136158. * @param errorCallback defines the callback to call on error
  136159. */
  136160. open(successCallback: () => void, errorCallback: () => void): void;
  136161. /**
  136162. * Loads an image from the database
  136163. * @param url defines the url to load from
  136164. * @param image defines the target DOM image
  136165. */
  136166. loadImage(url: string, image: HTMLImageElement): void;
  136167. private _loadImageFromDBAsync;
  136168. private _saveImageIntoDBAsync;
  136169. private _checkVersionFromDB;
  136170. private _loadVersionFromDBAsync;
  136171. private _saveVersionIntoDBAsync;
  136172. /**
  136173. * Loads a file from database
  136174. * @param url defines the URL to load from
  136175. * @param sceneLoaded defines a callback to call on success
  136176. * @param progressCallBack defines a callback to call when progress changed
  136177. * @param errorCallback defines a callback to call on error
  136178. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  136179. */
  136180. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  136181. private _loadFileAsync;
  136182. private _saveFileAsync;
  136183. /**
  136184. * Validates if xhr data is correct
  136185. * @param xhr defines the request to validate
  136186. * @param dataType defines the expected data type
  136187. * @returns true if data is correct
  136188. */
  136189. private static _ValidateXHRData;
  136190. }
  136191. }
  136192. declare module BABYLON {
  136193. /** @hidden */
  136194. export var gpuUpdateParticlesPixelShader: {
  136195. name: string;
  136196. shader: string;
  136197. };
  136198. }
  136199. declare module BABYLON {
  136200. /** @hidden */
  136201. export var gpuUpdateParticlesVertexShader: {
  136202. name: string;
  136203. shader: string;
  136204. };
  136205. }
  136206. declare module BABYLON {
  136207. /** @hidden */
  136208. export var clipPlaneFragmentDeclaration2: {
  136209. name: string;
  136210. shader: string;
  136211. };
  136212. }
  136213. declare module BABYLON {
  136214. /** @hidden */
  136215. export var gpuRenderParticlesPixelShader: {
  136216. name: string;
  136217. shader: string;
  136218. };
  136219. }
  136220. declare module BABYLON {
  136221. /** @hidden */
  136222. export var clipPlaneVertexDeclaration2: {
  136223. name: string;
  136224. shader: string;
  136225. };
  136226. }
  136227. declare module BABYLON {
  136228. /** @hidden */
  136229. export var gpuRenderParticlesVertexShader: {
  136230. name: string;
  136231. shader: string;
  136232. };
  136233. }
  136234. declare module BABYLON {
  136235. /**
  136236. * This represents a GPU particle system in Babylon
  136237. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  136238. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  136239. */
  136240. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  136241. /**
  136242. * The layer mask we are rendering the particles through.
  136243. */
  136244. layerMask: number;
  136245. private _capacity;
  136246. private _activeCount;
  136247. private _currentActiveCount;
  136248. private _accumulatedCount;
  136249. private _renderEffect;
  136250. private _updateEffect;
  136251. private _buffer0;
  136252. private _buffer1;
  136253. private _spriteBuffer;
  136254. private _updateVAO;
  136255. private _renderVAO;
  136256. private _targetIndex;
  136257. private _sourceBuffer;
  136258. private _targetBuffer;
  136259. private _engine;
  136260. private _currentRenderId;
  136261. private _started;
  136262. private _stopped;
  136263. private _timeDelta;
  136264. private _randomTexture;
  136265. private _randomTexture2;
  136266. private _attributesStrideSize;
  136267. private _updateEffectOptions;
  136268. private _randomTextureSize;
  136269. private _actualFrame;
  136270. private readonly _rawTextureWidth;
  136271. /**
  136272. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  136273. */
  136274. static get IsSupported(): boolean;
  136275. /**
  136276. * An event triggered when the system is disposed.
  136277. */
  136278. onDisposeObservable: Observable<GPUParticleSystem>;
  136279. /**
  136280. * Gets the maximum number of particles active at the same time.
  136281. * @returns The max number of active particles.
  136282. */
  136283. getCapacity(): number;
  136284. /**
  136285. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  136286. * to override the particles.
  136287. */
  136288. forceDepthWrite: boolean;
  136289. /**
  136290. * Gets or set the number of active particles
  136291. */
  136292. get activeParticleCount(): number;
  136293. set activeParticleCount(value: number);
  136294. private _preWarmDone;
  136295. /**
  136296. * Specifies if the particles are updated in emitter local space or world space.
  136297. * This is always false for GPU particles
  136298. */
  136299. get isLocal(): boolean;
  136300. set isLocal(value: boolean);
  136301. /**
  136302. * Is this system ready to be used/rendered
  136303. * @return true if the system is ready
  136304. */
  136305. isReady(): boolean;
  136306. /**
  136307. * Gets if the system has been started. (Note: this will still be true after stop is called)
  136308. * @returns True if it has been started, otherwise false.
  136309. */
  136310. isStarted(): boolean;
  136311. /**
  136312. * Starts the particle system and begins to emit
  136313. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  136314. */
  136315. start(delay?: number): void;
  136316. /**
  136317. * Stops the particle system.
  136318. */
  136319. stop(): void;
  136320. /**
  136321. * Remove all active particles
  136322. */
  136323. reset(): void;
  136324. /**
  136325. * Returns the string "GPUParticleSystem"
  136326. * @returns a string containing the class name
  136327. */
  136328. getClassName(): string;
  136329. private _colorGradientsTexture;
  136330. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  136331. /**
  136332. * Adds a new color gradient
  136333. * @param gradient defines the gradient to use (between 0 and 1)
  136334. * @param color1 defines the color to affect to the specified gradient
  136335. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  136336. * @returns the current particle system
  136337. */
  136338. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  136339. /**
  136340. * Remove a specific color gradient
  136341. * @param gradient defines the gradient to remove
  136342. * @returns the current particle system
  136343. */
  136344. removeColorGradient(gradient: number): GPUParticleSystem;
  136345. private _angularSpeedGradientsTexture;
  136346. private _sizeGradientsTexture;
  136347. private _velocityGradientsTexture;
  136348. private _limitVelocityGradientsTexture;
  136349. private _dragGradientsTexture;
  136350. private _addFactorGradient;
  136351. /**
  136352. * Adds a new size gradient
  136353. * @param gradient defines the gradient to use (between 0 and 1)
  136354. * @param factor defines the size factor to affect to the specified gradient
  136355. * @returns the current particle system
  136356. */
  136357. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  136358. /**
  136359. * Remove a specific size gradient
  136360. * @param gradient defines the gradient to remove
  136361. * @returns the current particle system
  136362. */
  136363. removeSizeGradient(gradient: number): GPUParticleSystem;
  136364. /**
  136365. * Adds a new angular speed gradient
  136366. * @param gradient defines the gradient to use (between 0 and 1)
  136367. * @param factor defines the angular speed to affect to the specified gradient
  136368. * @returns the current particle system
  136369. */
  136370. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  136371. /**
  136372. * Remove a specific angular speed gradient
  136373. * @param gradient defines the gradient to remove
  136374. * @returns the current particle system
  136375. */
  136376. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  136377. /**
  136378. * Adds a new velocity gradient
  136379. * @param gradient defines the gradient to use (between 0 and 1)
  136380. * @param factor defines the velocity to affect to the specified gradient
  136381. * @returns the current particle system
  136382. */
  136383. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136384. /**
  136385. * Remove a specific velocity gradient
  136386. * @param gradient defines the gradient to remove
  136387. * @returns the current particle system
  136388. */
  136389. removeVelocityGradient(gradient: number): GPUParticleSystem;
  136390. /**
  136391. * Adds a new limit velocity gradient
  136392. * @param gradient defines the gradient to use (between 0 and 1)
  136393. * @param factor defines the limit velocity value to affect to the specified gradient
  136394. * @returns the current particle system
  136395. */
  136396. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136397. /**
  136398. * Remove a specific limit velocity gradient
  136399. * @param gradient defines the gradient to remove
  136400. * @returns the current particle system
  136401. */
  136402. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  136403. /**
  136404. * Adds a new drag gradient
  136405. * @param gradient defines the gradient to use (between 0 and 1)
  136406. * @param factor defines the drag value to affect to the specified gradient
  136407. * @returns the current particle system
  136408. */
  136409. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  136410. /**
  136411. * Remove a specific drag gradient
  136412. * @param gradient defines the gradient to remove
  136413. * @returns the current particle system
  136414. */
  136415. removeDragGradient(gradient: number): GPUParticleSystem;
  136416. /**
  136417. * Not supported by GPUParticleSystem
  136418. * @param gradient defines the gradient to use (between 0 and 1)
  136419. * @param factor defines the emit rate value to affect to the specified gradient
  136420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136421. * @returns the current particle system
  136422. */
  136423. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136424. /**
  136425. * Not supported by GPUParticleSystem
  136426. * @param gradient defines the gradient to remove
  136427. * @returns the current particle system
  136428. */
  136429. removeEmitRateGradient(gradient: number): IParticleSystem;
  136430. /**
  136431. * Not supported by GPUParticleSystem
  136432. * @param gradient defines the gradient to use (between 0 and 1)
  136433. * @param factor defines the start size value to affect to the specified gradient
  136434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136435. * @returns the current particle system
  136436. */
  136437. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136438. /**
  136439. * Not supported by GPUParticleSystem
  136440. * @param gradient defines the gradient to remove
  136441. * @returns the current particle system
  136442. */
  136443. removeStartSizeGradient(gradient: number): IParticleSystem;
  136444. /**
  136445. * Not supported by GPUParticleSystem
  136446. * @param gradient defines the gradient to use (between 0 and 1)
  136447. * @param min defines the color remap minimal range
  136448. * @param max defines the color remap maximal range
  136449. * @returns the current particle system
  136450. */
  136451. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136452. /**
  136453. * Not supported by GPUParticleSystem
  136454. * @param gradient defines the gradient to remove
  136455. * @returns the current particle system
  136456. */
  136457. removeColorRemapGradient(): IParticleSystem;
  136458. /**
  136459. * Not supported by GPUParticleSystem
  136460. * @param gradient defines the gradient to use (between 0 and 1)
  136461. * @param min defines the alpha remap minimal range
  136462. * @param max defines the alpha remap maximal range
  136463. * @returns the current particle system
  136464. */
  136465. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136466. /**
  136467. * Not supported by GPUParticleSystem
  136468. * @param gradient defines the gradient to remove
  136469. * @returns the current particle system
  136470. */
  136471. removeAlphaRemapGradient(): IParticleSystem;
  136472. /**
  136473. * Not supported by GPUParticleSystem
  136474. * @param gradient defines the gradient to use (between 0 and 1)
  136475. * @param color defines the color to affect to the specified gradient
  136476. * @returns the current particle system
  136477. */
  136478. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136479. /**
  136480. * Not supported by GPUParticleSystem
  136481. * @param gradient defines the gradient to remove
  136482. * @returns the current particle system
  136483. */
  136484. removeRampGradient(): IParticleSystem;
  136485. /**
  136486. * Not supported by GPUParticleSystem
  136487. * @returns the list of ramp gradients
  136488. */
  136489. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136490. /**
  136491. * Not supported by GPUParticleSystem
  136492. * Gets or sets a boolean indicating that ramp gradients must be used
  136493. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136494. */
  136495. get useRampGradients(): boolean;
  136496. set useRampGradients(value: boolean);
  136497. /**
  136498. * Not supported by GPUParticleSystem
  136499. * @param gradient defines the gradient to use (between 0 and 1)
  136500. * @param factor defines the life time factor to affect to the specified gradient
  136501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136502. * @returns the current particle system
  136503. */
  136504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136505. /**
  136506. * Not supported by GPUParticleSystem
  136507. * @param gradient defines the gradient to remove
  136508. * @returns the current particle system
  136509. */
  136510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136511. /**
  136512. * Instantiates a GPU particle system.
  136513. * 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.
  136514. * @param name The name of the particle system
  136515. * @param options The options used to create the system
  136516. * @param scene The scene the particle system belongs to
  136517. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136518. */
  136519. constructor(name: string, options: Partial<{
  136520. capacity: number;
  136521. randomTextureSize: number;
  136522. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136523. protected _reset(): void;
  136524. private _createUpdateVAO;
  136525. private _createRenderVAO;
  136526. private _initialize;
  136527. /** @hidden */
  136528. _recreateUpdateEffect(): void;
  136529. /** @hidden */
  136530. _recreateRenderEffect(): void;
  136531. /**
  136532. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136533. * @param preWarm defines if we are in the pre-warmimg phase
  136534. */
  136535. animate(preWarm?: boolean): void;
  136536. private _createFactorGradientTexture;
  136537. private _createSizeGradientTexture;
  136538. private _createAngularSpeedGradientTexture;
  136539. private _createVelocityGradientTexture;
  136540. private _createLimitVelocityGradientTexture;
  136541. private _createDragGradientTexture;
  136542. private _createColorGradientTexture;
  136543. /**
  136544. * Renders the particle system in its current state
  136545. * @param preWarm defines if the system should only update the particles but not render them
  136546. * @returns the current number of particles
  136547. */
  136548. render(preWarm?: boolean): number;
  136549. /**
  136550. * Rebuilds the particle system
  136551. */
  136552. rebuild(): void;
  136553. private _releaseBuffers;
  136554. private _releaseVAOs;
  136555. /**
  136556. * Disposes the particle system and free the associated resources
  136557. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136558. */
  136559. dispose(disposeTexture?: boolean): void;
  136560. /**
  136561. * Clones the particle system.
  136562. * @param name The name of the cloned object
  136563. * @param newEmitter The new emitter to use
  136564. * @returns the cloned particle system
  136565. */
  136566. clone(name: string, newEmitter: any): GPUParticleSystem;
  136567. /**
  136568. * Serializes the particle system to a JSON object.
  136569. * @returns the JSON object
  136570. */
  136571. serialize(): any;
  136572. /**
  136573. * Parses a JSON object to create a GPU particle system.
  136574. * @param parsedParticleSystem The JSON object to parse
  136575. * @param scene The scene to create the particle system in
  136576. * @param rootUrl The root url to use to load external dependencies like texture
  136577. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136578. * @returns the parsed GPU particle system
  136579. */
  136580. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136581. }
  136582. }
  136583. declare module BABYLON {
  136584. /**
  136585. * Represents a set of particle systems working together to create a specific effect
  136586. */
  136587. export class ParticleSystemSet implements IDisposable {
  136588. /**
  136589. * Gets or sets base Assets URL
  136590. */
  136591. static BaseAssetsUrl: string;
  136592. private _emitterCreationOptions;
  136593. private _emitterNode;
  136594. /**
  136595. * Gets the particle system list
  136596. */
  136597. systems: IParticleSystem[];
  136598. /**
  136599. * Gets the emitter node used with this set
  136600. */
  136601. get emitterNode(): Nullable<TransformNode>;
  136602. /**
  136603. * Creates a new emitter mesh as a sphere
  136604. * @param options defines the options used to create the sphere
  136605. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136606. * @param scene defines the hosting scene
  136607. */
  136608. setEmitterAsSphere(options: {
  136609. diameter: number;
  136610. segments: number;
  136611. color: Color3;
  136612. }, renderingGroupId: number, scene: Scene): void;
  136613. /**
  136614. * Starts all particle systems of the set
  136615. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136616. */
  136617. start(emitter?: AbstractMesh): void;
  136618. /**
  136619. * Release all associated resources
  136620. */
  136621. dispose(): void;
  136622. /**
  136623. * Serialize the set into a JSON compatible object
  136624. * @returns a JSON compatible representation of the set
  136625. */
  136626. serialize(): any;
  136627. /**
  136628. * Parse a new ParticleSystemSet from a serialized source
  136629. * @param data defines a JSON compatible representation of the set
  136630. * @param scene defines the hosting scene
  136631. * @param gpu defines if we want GPU particles or CPU particles
  136632. * @returns a new ParticleSystemSet
  136633. */
  136634. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136635. }
  136636. }
  136637. declare module BABYLON {
  136638. /**
  136639. * This class is made for on one-liner static method to help creating particle system set.
  136640. */
  136641. export class ParticleHelper {
  136642. /**
  136643. * Gets or sets base Assets URL
  136644. */
  136645. static BaseAssetsUrl: string;
  136646. /**
  136647. * Create a default particle system that you can tweak
  136648. * @param emitter defines the emitter to use
  136649. * @param capacity defines the system capacity (default is 500 particles)
  136650. * @param scene defines the hosting scene
  136651. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136652. * @returns the new Particle system
  136653. */
  136654. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136655. /**
  136656. * This is the main static method (one-liner) of this helper to create different particle systems
  136657. * @param type This string represents the type to the particle system to create
  136658. * @param scene The scene where the particle system should live
  136659. * @param gpu If the system will use gpu
  136660. * @returns the ParticleSystemSet created
  136661. */
  136662. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136663. /**
  136664. * Static function used to export a particle system to a ParticleSystemSet variable.
  136665. * Please note that the emitter shape is not exported
  136666. * @param systems defines the particle systems to export
  136667. * @returns the created particle system set
  136668. */
  136669. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136670. }
  136671. }
  136672. declare module BABYLON {
  136673. interface Engine {
  136674. /**
  136675. * Create an effect to use with particle systems.
  136676. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136677. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136678. * @param uniformsNames defines a list of attribute names
  136679. * @param samplers defines an array of string used to represent textures
  136680. * @param defines defines the string containing the defines to use to compile the shaders
  136681. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136682. * @param onCompiled defines a function to call when the effect creation is successful
  136683. * @param onError defines a function to call when the effect creation has failed
  136684. * @returns the new Effect
  136685. */
  136686. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136687. }
  136688. interface Mesh {
  136689. /**
  136690. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136691. * @returns an array of IParticleSystem
  136692. */
  136693. getEmittedParticleSystems(): IParticleSystem[];
  136694. /**
  136695. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136696. * @returns an array of IParticleSystem
  136697. */
  136698. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136699. }
  136700. /**
  136701. * @hidden
  136702. */
  136703. export var _IDoNeedToBeInTheBuild: number;
  136704. }
  136705. declare module BABYLON {
  136706. /** Defines the 4 color options */
  136707. export enum PointColor {
  136708. /** color value */
  136709. Color = 2,
  136710. /** uv value */
  136711. UV = 1,
  136712. /** random value */
  136713. Random = 0,
  136714. /** stated value */
  136715. Stated = 3
  136716. }
  136717. /**
  136718. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136719. * 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.
  136720. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136721. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136722. *
  136723. * Full documentation here : TO BE ENTERED
  136724. */
  136725. export class PointsCloudSystem implements IDisposable {
  136726. /**
  136727. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136728. * Example : var p = SPS.particles[i];
  136729. */
  136730. particles: CloudPoint[];
  136731. /**
  136732. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136733. */
  136734. nbParticles: number;
  136735. /**
  136736. * This a counter for your own usage. It's not set by any SPS functions.
  136737. */
  136738. counter: number;
  136739. /**
  136740. * The PCS name. This name is also given to the underlying mesh.
  136741. */
  136742. name: string;
  136743. /**
  136744. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136745. */
  136746. mesh: Mesh;
  136747. /**
  136748. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136749. * Please read :
  136750. */
  136751. vars: any;
  136752. /**
  136753. * @hidden
  136754. */
  136755. _size: number;
  136756. private _scene;
  136757. private _promises;
  136758. private _positions;
  136759. private _indices;
  136760. private _normals;
  136761. private _colors;
  136762. private _uvs;
  136763. private _indices32;
  136764. private _positions32;
  136765. private _colors32;
  136766. private _uvs32;
  136767. private _updatable;
  136768. private _isVisibilityBoxLocked;
  136769. private _alwaysVisible;
  136770. private _groups;
  136771. private _groupCounter;
  136772. private _computeParticleColor;
  136773. private _computeParticleTexture;
  136774. private _computeParticleRotation;
  136775. private _computeBoundingBox;
  136776. private _isReady;
  136777. /**
  136778. * Creates a PCS (Points Cloud System) object
  136779. * @param name (String) is the PCS name, this will be the underlying mesh name
  136780. * @param pointSize (number) is the size for each point
  136781. * @param scene (Scene) is the scene in which the PCS is added
  136782. * @param options defines the options of the PCS e.g.
  136783. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136784. */
  136785. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136786. updatable?: boolean;
  136787. });
  136788. /**
  136789. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136790. * If no points were added to the PCS, the returned mesh is just a single point.
  136791. * @returns a promise for the created mesh
  136792. */
  136793. buildMeshAsync(): Promise<Mesh>;
  136794. /**
  136795. * @hidden
  136796. */
  136797. private _buildMesh;
  136798. private _addParticle;
  136799. private _randomUnitVector;
  136800. private _getColorIndicesForCoord;
  136801. private _setPointsColorOrUV;
  136802. private _colorFromTexture;
  136803. private _calculateDensity;
  136804. /**
  136805. * Adds points to the PCS in random positions within a unit sphere
  136806. * @param nb (positive integer) the number of particles to be created from this model
  136807. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136808. * @returns the number of groups in the system
  136809. */
  136810. addPoints(nb: number, pointFunction?: any): number;
  136811. /**
  136812. * Adds points to the PCS from the surface of the model shape
  136813. * @param mesh is any Mesh object that will be used as a surface model for the points
  136814. * @param nb (positive integer) the number of particles to be created from this model
  136815. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136816. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136817. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136818. * @returns the number of groups in the system
  136819. */
  136820. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136821. /**
  136822. * Adds points to the PCS inside the model shape
  136823. * @param mesh is any Mesh object that will be used as a surface model for the points
  136824. * @param nb (positive integer) the number of particles to be created from this model
  136825. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136826. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136827. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136828. * @returns the number of groups in the system
  136829. */
  136830. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136831. /**
  136832. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136833. * This method calls `updateParticle()` for each particle of the SPS.
  136834. * For an animated SPS, it is usually called within the render loop.
  136835. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136836. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136837. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136838. * @returns the PCS.
  136839. */
  136840. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136841. /**
  136842. * Disposes the PCS.
  136843. */
  136844. dispose(): void;
  136845. /**
  136846. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136847. * doc :
  136848. * @returns the PCS.
  136849. */
  136850. refreshVisibleSize(): PointsCloudSystem;
  136851. /**
  136852. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136853. * @param size the size (float) of the visibility box
  136854. * note : this doesn't lock the PCS mesh bounding box.
  136855. * doc :
  136856. */
  136857. setVisibilityBox(size: number): void;
  136858. /**
  136859. * Gets whether the PCS is always visible or not
  136860. * doc :
  136861. */
  136862. get isAlwaysVisible(): boolean;
  136863. /**
  136864. * Sets the PCS as always visible or not
  136865. * doc :
  136866. */
  136867. set isAlwaysVisible(val: boolean);
  136868. /**
  136869. * Tells to `setParticles()` to compute the particle rotations or not
  136870. * Default value : false. The PCS is faster when it's set to false
  136871. * Note : particle rotations are only applied to parent particles
  136872. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136873. */
  136874. set computeParticleRotation(val: boolean);
  136875. /**
  136876. * Tells to `setParticles()` to compute the particle colors or not.
  136877. * Default value : true. The PCS is faster when it's set to false.
  136878. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136879. */
  136880. set computeParticleColor(val: boolean);
  136881. set computeParticleTexture(val: boolean);
  136882. /**
  136883. * Gets if `setParticles()` computes the particle colors or not.
  136884. * Default value : false. The PCS is faster when it's set to false.
  136885. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136886. */
  136887. get computeParticleColor(): boolean;
  136888. /**
  136889. * Gets if `setParticles()` computes the particle textures or not.
  136890. * Default value : false. The PCS is faster when it's set to false.
  136891. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136892. */
  136893. get computeParticleTexture(): boolean;
  136894. /**
  136895. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136896. */
  136897. set computeBoundingBox(val: boolean);
  136898. /**
  136899. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136900. */
  136901. get computeBoundingBox(): boolean;
  136902. /**
  136903. * This function does nothing. It may be overwritten to set all the particle first values.
  136904. * The PCS doesn't call this function, you may have to call it by your own.
  136905. * doc :
  136906. */
  136907. initParticles(): void;
  136908. /**
  136909. * This function does nothing. It may be overwritten to recycle a particle
  136910. * The PCS doesn't call this function, you can to call it
  136911. * doc :
  136912. * @param particle The particle to recycle
  136913. * @returns the recycled particle
  136914. */
  136915. recycleParticle(particle: CloudPoint): CloudPoint;
  136916. /**
  136917. * Updates a particle : this function should be overwritten by the user.
  136918. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136919. * doc :
  136920. * @example : just set a particle position or velocity and recycle conditions
  136921. * @param particle The particle to update
  136922. * @returns the updated particle
  136923. */
  136924. updateParticle(particle: CloudPoint): CloudPoint;
  136925. /**
  136926. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136927. * This does nothing and may be overwritten by the user.
  136928. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136929. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136930. * @param update the boolean update value actually passed to setParticles()
  136931. */
  136932. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136933. /**
  136934. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136935. * This will be passed three parameters.
  136936. * This does nothing and may be overwritten by the user.
  136937. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136938. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136939. * @param update the boolean update value actually passed to setParticles()
  136940. */
  136941. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136942. }
  136943. }
  136944. declare module BABYLON {
  136945. /**
  136946. * Represents one particle of a points cloud system.
  136947. */
  136948. export class CloudPoint {
  136949. /**
  136950. * particle global index
  136951. */
  136952. idx: number;
  136953. /**
  136954. * The color of the particle
  136955. */
  136956. color: Nullable<Color4>;
  136957. /**
  136958. * The world space position of the particle.
  136959. */
  136960. position: Vector3;
  136961. /**
  136962. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136963. */
  136964. rotation: Vector3;
  136965. /**
  136966. * The world space rotation quaternion of the particle.
  136967. */
  136968. rotationQuaternion: Nullable<Quaternion>;
  136969. /**
  136970. * The uv of the particle.
  136971. */
  136972. uv: Nullable<Vector2>;
  136973. /**
  136974. * The current speed of the particle.
  136975. */
  136976. velocity: Vector3;
  136977. /**
  136978. * The pivot point in the particle local space.
  136979. */
  136980. pivot: Vector3;
  136981. /**
  136982. * Must the particle be translated from its pivot point in its local space ?
  136983. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136984. * Default : false
  136985. */
  136986. translateFromPivot: boolean;
  136987. /**
  136988. * Index of this particle in the global "positions" array (Internal use)
  136989. * @hidden
  136990. */
  136991. _pos: number;
  136992. /**
  136993. * @hidden Index of this particle in the global "indices" array (Internal use)
  136994. */
  136995. _ind: number;
  136996. /**
  136997. * Group this particle belongs to
  136998. */
  136999. _group: PointsGroup;
  137000. /**
  137001. * Group id of this particle
  137002. */
  137003. groupId: number;
  137004. /**
  137005. * Index of the particle in its group id (Internal use)
  137006. */
  137007. idxInGroup: number;
  137008. /**
  137009. * @hidden Particle BoundingInfo object (Internal use)
  137010. */
  137011. _boundingInfo: BoundingInfo;
  137012. /**
  137013. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  137014. */
  137015. _pcs: PointsCloudSystem;
  137016. /**
  137017. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  137018. */
  137019. _stillInvisible: boolean;
  137020. /**
  137021. * @hidden Last computed particle rotation matrix
  137022. */
  137023. _rotationMatrix: number[];
  137024. /**
  137025. * Parent particle Id, if any.
  137026. * Default null.
  137027. */
  137028. parentId: Nullable<number>;
  137029. /**
  137030. * @hidden Internal global position in the PCS.
  137031. */
  137032. _globalPosition: Vector3;
  137033. /**
  137034. * Creates a Point Cloud object.
  137035. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  137036. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  137037. * @param group (PointsGroup) is the group the particle belongs to
  137038. * @param groupId (integer) is the group identifier in the PCS.
  137039. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  137040. * @param pcs defines the PCS it is associated to
  137041. */
  137042. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  137043. /**
  137044. * get point size
  137045. */
  137046. get size(): Vector3;
  137047. /**
  137048. * Set point size
  137049. */
  137050. set size(scale: Vector3);
  137051. /**
  137052. * Legacy support, changed quaternion to rotationQuaternion
  137053. */
  137054. get quaternion(): Nullable<Quaternion>;
  137055. /**
  137056. * Legacy support, changed quaternion to rotationQuaternion
  137057. */
  137058. set quaternion(q: Nullable<Quaternion>);
  137059. /**
  137060. * Returns a boolean. True if the particle intersects a mesh, else false
  137061. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  137062. * @param target is the object (point or mesh) what the intersection is computed against
  137063. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  137064. * @returns true if it intersects
  137065. */
  137066. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  137067. /**
  137068. * get the rotation matrix of the particle
  137069. * @hidden
  137070. */
  137071. getRotationMatrix(m: Matrix): void;
  137072. }
  137073. /**
  137074. * Represents a group of points in a points cloud system
  137075. * * PCS internal tool, don't use it manually.
  137076. */
  137077. export class PointsGroup {
  137078. /**
  137079. * The group id
  137080. * @hidden
  137081. */
  137082. groupID: number;
  137083. /**
  137084. * image data for group (internal use)
  137085. * @hidden
  137086. */
  137087. _groupImageData: Nullable<ArrayBufferView>;
  137088. /**
  137089. * Image Width (internal use)
  137090. * @hidden
  137091. */
  137092. _groupImgWidth: number;
  137093. /**
  137094. * Image Height (internal use)
  137095. * @hidden
  137096. */
  137097. _groupImgHeight: number;
  137098. /**
  137099. * Custom position function (internal use)
  137100. * @hidden
  137101. */
  137102. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  137103. /**
  137104. * density per facet for surface points
  137105. * @hidden
  137106. */
  137107. _groupDensity: number[];
  137108. /**
  137109. * Only when points are colored by texture carries pointer to texture list array
  137110. * @hidden
  137111. */
  137112. _textureNb: number;
  137113. /**
  137114. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  137115. * PCS internal tool, don't use it manually.
  137116. * @hidden
  137117. */
  137118. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  137119. }
  137120. }
  137121. declare module BABYLON {
  137122. interface Scene {
  137123. /** @hidden (Backing field) */
  137124. _physicsEngine: Nullable<IPhysicsEngine>;
  137125. /** @hidden */
  137126. _physicsTimeAccumulator: number;
  137127. /**
  137128. * Gets the current physics engine
  137129. * @returns a IPhysicsEngine or null if none attached
  137130. */
  137131. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  137132. /**
  137133. * Enables physics to the current scene
  137134. * @param gravity defines the scene's gravity for the physics engine
  137135. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  137136. * @return a boolean indicating if the physics engine was initialized
  137137. */
  137138. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  137139. /**
  137140. * Disables and disposes the physics engine associated with the scene
  137141. */
  137142. disablePhysicsEngine(): void;
  137143. /**
  137144. * Gets a boolean indicating if there is an active physics engine
  137145. * @returns a boolean indicating if there is an active physics engine
  137146. */
  137147. isPhysicsEnabled(): boolean;
  137148. /**
  137149. * Deletes a physics compound impostor
  137150. * @param compound defines the compound to delete
  137151. */
  137152. deleteCompoundImpostor(compound: any): void;
  137153. /**
  137154. * An event triggered when physic simulation is about to be run
  137155. */
  137156. onBeforePhysicsObservable: Observable<Scene>;
  137157. /**
  137158. * An event triggered when physic simulation has been done
  137159. */
  137160. onAfterPhysicsObservable: Observable<Scene>;
  137161. }
  137162. interface AbstractMesh {
  137163. /** @hidden */
  137164. _physicsImpostor: Nullable<PhysicsImpostor>;
  137165. /**
  137166. * Gets or sets impostor used for physic simulation
  137167. * @see http://doc.babylonjs.com/features/physics_engine
  137168. */
  137169. physicsImpostor: Nullable<PhysicsImpostor>;
  137170. /**
  137171. * Gets the current physics impostor
  137172. * @see http://doc.babylonjs.com/features/physics_engine
  137173. * @returns a physics impostor or null
  137174. */
  137175. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  137176. /** Apply a physic impulse to the mesh
  137177. * @param force defines the force to apply
  137178. * @param contactPoint defines where to apply the force
  137179. * @returns the current mesh
  137180. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  137181. */
  137182. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  137183. /**
  137184. * Creates a physic joint between two meshes
  137185. * @param otherMesh defines the other mesh to use
  137186. * @param pivot1 defines the pivot to use on this mesh
  137187. * @param pivot2 defines the pivot to use on the other mesh
  137188. * @param options defines additional options (can be plugin dependent)
  137189. * @returns the current mesh
  137190. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  137191. */
  137192. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  137193. /** @hidden */
  137194. _disposePhysicsObserver: Nullable<Observer<Node>>;
  137195. }
  137196. /**
  137197. * Defines the physics engine scene component responsible to manage a physics engine
  137198. */
  137199. export class PhysicsEngineSceneComponent implements ISceneComponent {
  137200. /**
  137201. * The component name helpful to identify the component in the list of scene components.
  137202. */
  137203. readonly name: string;
  137204. /**
  137205. * The scene the component belongs to.
  137206. */
  137207. scene: Scene;
  137208. /**
  137209. * Creates a new instance of the component for the given scene
  137210. * @param scene Defines the scene to register the component in
  137211. */
  137212. constructor(scene: Scene);
  137213. /**
  137214. * Registers the component in a given scene
  137215. */
  137216. register(): void;
  137217. /**
  137218. * Rebuilds the elements related to this component in case of
  137219. * context lost for instance.
  137220. */
  137221. rebuild(): void;
  137222. /**
  137223. * Disposes the component and the associated ressources
  137224. */
  137225. dispose(): void;
  137226. }
  137227. }
  137228. declare module BABYLON {
  137229. /**
  137230. * A helper for physics simulations
  137231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137232. */
  137233. export class PhysicsHelper {
  137234. private _scene;
  137235. private _physicsEngine;
  137236. /**
  137237. * Initializes the Physics helper
  137238. * @param scene Babylon.js scene
  137239. */
  137240. constructor(scene: Scene);
  137241. /**
  137242. * Applies a radial explosion impulse
  137243. * @param origin the origin of the explosion
  137244. * @param radiusOrEventOptions the radius or the options of radial explosion
  137245. * @param strength the explosion strength
  137246. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137247. * @returns A physics radial explosion event, or null
  137248. */
  137249. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  137250. /**
  137251. * Applies a radial explosion force
  137252. * @param origin the origin of the explosion
  137253. * @param radiusOrEventOptions the radius or the options of radial explosion
  137254. * @param strength the explosion strength
  137255. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137256. * @returns A physics radial explosion event, or null
  137257. */
  137258. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  137259. /**
  137260. * Creates a gravitational field
  137261. * @param origin the origin of the explosion
  137262. * @param radiusOrEventOptions the radius or the options of radial explosion
  137263. * @param strength the explosion strength
  137264. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137265. * @returns A physics gravitational field event, or null
  137266. */
  137267. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  137268. /**
  137269. * Creates a physics updraft event
  137270. * @param origin the origin of the updraft
  137271. * @param radiusOrEventOptions the radius or the options of the updraft
  137272. * @param strength the strength of the updraft
  137273. * @param height the height of the updraft
  137274. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  137275. * @returns A physics updraft event, or null
  137276. */
  137277. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  137278. /**
  137279. * Creates a physics vortex event
  137280. * @param origin the of the vortex
  137281. * @param radiusOrEventOptions the radius or the options of the vortex
  137282. * @param strength the strength of the vortex
  137283. * @param height the height of the vortex
  137284. * @returns a Physics vortex event, or null
  137285. * A physics vortex event or null
  137286. */
  137287. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  137288. }
  137289. /**
  137290. * Represents a physics radial explosion event
  137291. */
  137292. class PhysicsRadialExplosionEvent {
  137293. private _scene;
  137294. private _options;
  137295. private _sphere;
  137296. private _dataFetched;
  137297. /**
  137298. * Initializes a radial explosioin event
  137299. * @param _scene BabylonJS scene
  137300. * @param _options The options for the vortex event
  137301. */
  137302. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  137303. /**
  137304. * Returns the data related to the radial explosion event (sphere).
  137305. * @returns The radial explosion event data
  137306. */
  137307. getData(): PhysicsRadialExplosionEventData;
  137308. /**
  137309. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  137310. * @param impostor A physics imposter
  137311. * @param origin the origin of the explosion
  137312. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  137313. */
  137314. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  137315. /**
  137316. * Triggers affecterd impostors callbacks
  137317. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  137318. */
  137319. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  137320. /**
  137321. * Disposes the sphere.
  137322. * @param force Specifies if the sphere should be disposed by force
  137323. */
  137324. dispose(force?: boolean): void;
  137325. /*** Helpers ***/
  137326. private _prepareSphere;
  137327. private _intersectsWithSphere;
  137328. }
  137329. /**
  137330. * Represents a gravitational field event
  137331. */
  137332. class PhysicsGravitationalFieldEvent {
  137333. private _physicsHelper;
  137334. private _scene;
  137335. private _origin;
  137336. private _options;
  137337. private _tickCallback;
  137338. private _sphere;
  137339. private _dataFetched;
  137340. /**
  137341. * Initializes the physics gravitational field event
  137342. * @param _physicsHelper A physics helper
  137343. * @param _scene BabylonJS scene
  137344. * @param _origin The origin position of the gravitational field event
  137345. * @param _options The options for the vortex event
  137346. */
  137347. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  137348. /**
  137349. * Returns the data related to the gravitational field event (sphere).
  137350. * @returns A gravitational field event
  137351. */
  137352. getData(): PhysicsGravitationalFieldEventData;
  137353. /**
  137354. * Enables the gravitational field.
  137355. */
  137356. enable(): void;
  137357. /**
  137358. * Disables the gravitational field.
  137359. */
  137360. disable(): void;
  137361. /**
  137362. * Disposes the sphere.
  137363. * @param force The force to dispose from the gravitational field event
  137364. */
  137365. dispose(force?: boolean): void;
  137366. private _tick;
  137367. }
  137368. /**
  137369. * Represents a physics updraft event
  137370. */
  137371. class PhysicsUpdraftEvent {
  137372. private _scene;
  137373. private _origin;
  137374. private _options;
  137375. private _physicsEngine;
  137376. private _originTop;
  137377. private _originDirection;
  137378. private _tickCallback;
  137379. private _cylinder;
  137380. private _cylinderPosition;
  137381. private _dataFetched;
  137382. /**
  137383. * Initializes the physics updraft event
  137384. * @param _scene BabylonJS scene
  137385. * @param _origin The origin position of the updraft
  137386. * @param _options The options for the updraft event
  137387. */
  137388. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  137389. /**
  137390. * Returns the data related to the updraft event (cylinder).
  137391. * @returns A physics updraft event
  137392. */
  137393. getData(): PhysicsUpdraftEventData;
  137394. /**
  137395. * Enables the updraft.
  137396. */
  137397. enable(): void;
  137398. /**
  137399. * Disables the updraft.
  137400. */
  137401. disable(): void;
  137402. /**
  137403. * Disposes the cylinder.
  137404. * @param force Specifies if the updraft should be disposed by force
  137405. */
  137406. dispose(force?: boolean): void;
  137407. private getImpostorHitData;
  137408. private _tick;
  137409. /*** Helpers ***/
  137410. private _prepareCylinder;
  137411. private _intersectsWithCylinder;
  137412. }
  137413. /**
  137414. * Represents a physics vortex event
  137415. */
  137416. class PhysicsVortexEvent {
  137417. private _scene;
  137418. private _origin;
  137419. private _options;
  137420. private _physicsEngine;
  137421. private _originTop;
  137422. private _tickCallback;
  137423. private _cylinder;
  137424. private _cylinderPosition;
  137425. private _dataFetched;
  137426. /**
  137427. * Initializes the physics vortex event
  137428. * @param _scene The BabylonJS scene
  137429. * @param _origin The origin position of the vortex
  137430. * @param _options The options for the vortex event
  137431. */
  137432. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  137433. /**
  137434. * Returns the data related to the vortex event (cylinder).
  137435. * @returns The physics vortex event data
  137436. */
  137437. getData(): PhysicsVortexEventData;
  137438. /**
  137439. * Enables the vortex.
  137440. */
  137441. enable(): void;
  137442. /**
  137443. * Disables the cortex.
  137444. */
  137445. disable(): void;
  137446. /**
  137447. * Disposes the sphere.
  137448. * @param force
  137449. */
  137450. dispose(force?: boolean): void;
  137451. private getImpostorHitData;
  137452. private _tick;
  137453. /*** Helpers ***/
  137454. private _prepareCylinder;
  137455. private _intersectsWithCylinder;
  137456. }
  137457. /**
  137458. * Options fot the radial explosion event
  137459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137460. */
  137461. export class PhysicsRadialExplosionEventOptions {
  137462. /**
  137463. * The radius of the sphere for the radial explosion.
  137464. */
  137465. radius: number;
  137466. /**
  137467. * The strenth of the explosion.
  137468. */
  137469. strength: number;
  137470. /**
  137471. * The strenght of the force in correspondence to the distance of the affected object
  137472. */
  137473. falloff: PhysicsRadialImpulseFalloff;
  137474. /**
  137475. * Sphere options for the radial explosion.
  137476. */
  137477. sphere: {
  137478. segments: number;
  137479. diameter: number;
  137480. };
  137481. /**
  137482. * Sphere options for the radial explosion.
  137483. */
  137484. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137485. }
  137486. /**
  137487. * Options fot the updraft event
  137488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137489. */
  137490. export class PhysicsUpdraftEventOptions {
  137491. /**
  137492. * The radius of the cylinder for the vortex
  137493. */
  137494. radius: number;
  137495. /**
  137496. * The strenth of the updraft.
  137497. */
  137498. strength: number;
  137499. /**
  137500. * The height of the cylinder for the updraft.
  137501. */
  137502. height: number;
  137503. /**
  137504. * The mode for the the updraft.
  137505. */
  137506. updraftMode: PhysicsUpdraftMode;
  137507. }
  137508. /**
  137509. * Options fot the vortex event
  137510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137511. */
  137512. export class PhysicsVortexEventOptions {
  137513. /**
  137514. * The radius of the cylinder for the vortex
  137515. */
  137516. radius: number;
  137517. /**
  137518. * The strenth of the vortex.
  137519. */
  137520. strength: number;
  137521. /**
  137522. * The height of the cylinder for the vortex.
  137523. */
  137524. height: number;
  137525. /**
  137526. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137527. */
  137528. centripetalForceThreshold: number;
  137529. /**
  137530. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137531. */
  137532. centripetalForceMultiplier: number;
  137533. /**
  137534. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137535. */
  137536. centrifugalForceMultiplier: number;
  137537. /**
  137538. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137539. */
  137540. updraftForceMultiplier: number;
  137541. }
  137542. /**
  137543. * The strenght of the force in correspondence to the distance of the affected object
  137544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137545. */
  137546. export enum PhysicsRadialImpulseFalloff {
  137547. /** Defines that impulse is constant in strength across it's whole radius */
  137548. Constant = 0,
  137549. /** Defines that impulse gets weaker if it's further from the origin */
  137550. Linear = 1
  137551. }
  137552. /**
  137553. * The strength of the force in correspondence to the distance of the affected object
  137554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137555. */
  137556. export enum PhysicsUpdraftMode {
  137557. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137558. Center = 0,
  137559. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137560. Perpendicular = 1
  137561. }
  137562. /**
  137563. * Interface for a physics hit data
  137564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137565. */
  137566. export interface PhysicsHitData {
  137567. /**
  137568. * The force applied at the contact point
  137569. */
  137570. force: Vector3;
  137571. /**
  137572. * The contact point
  137573. */
  137574. contactPoint: Vector3;
  137575. /**
  137576. * The distance from the origin to the contact point
  137577. */
  137578. distanceFromOrigin: number;
  137579. }
  137580. /**
  137581. * Interface for radial explosion event data
  137582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137583. */
  137584. export interface PhysicsRadialExplosionEventData {
  137585. /**
  137586. * A sphere used for the radial explosion event
  137587. */
  137588. sphere: Mesh;
  137589. }
  137590. /**
  137591. * Interface for gravitational field event data
  137592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137593. */
  137594. export interface PhysicsGravitationalFieldEventData {
  137595. /**
  137596. * A sphere mesh used for the gravitational field event
  137597. */
  137598. sphere: Mesh;
  137599. }
  137600. /**
  137601. * Interface for updraft event data
  137602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137603. */
  137604. export interface PhysicsUpdraftEventData {
  137605. /**
  137606. * A cylinder used for the updraft event
  137607. */
  137608. cylinder: Mesh;
  137609. }
  137610. /**
  137611. * Interface for vortex event data
  137612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137613. */
  137614. export interface PhysicsVortexEventData {
  137615. /**
  137616. * A cylinder used for the vortex event
  137617. */
  137618. cylinder: Mesh;
  137619. }
  137620. /**
  137621. * Interface for an affected physics impostor
  137622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137623. */
  137624. export interface PhysicsAffectedImpostorWithData {
  137625. /**
  137626. * The impostor affected by the effect
  137627. */
  137628. impostor: PhysicsImpostor;
  137629. /**
  137630. * The data about the hit/horce from the explosion
  137631. */
  137632. hitData: PhysicsHitData;
  137633. }
  137634. }
  137635. declare module BABYLON {
  137636. /** @hidden */
  137637. export var blackAndWhitePixelShader: {
  137638. name: string;
  137639. shader: string;
  137640. };
  137641. }
  137642. declare module BABYLON {
  137643. /**
  137644. * Post process used to render in black and white
  137645. */
  137646. export class BlackAndWhitePostProcess extends PostProcess {
  137647. /**
  137648. * Linear about to convert he result to black and white (default: 1)
  137649. */
  137650. degree: number;
  137651. /**
  137652. * Creates a black and white post process
  137653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137654. * @param name The name of the effect.
  137655. * @param options The required width/height ratio to downsize to before computing the render pass.
  137656. * @param camera The camera to apply the render pass to.
  137657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137658. * @param engine The engine which the post process will be applied. (default: current engine)
  137659. * @param reusable If the post process can be reused on the same frame. (default: false)
  137660. */
  137661. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137662. }
  137663. }
  137664. declare module BABYLON {
  137665. /**
  137666. * This represents a set of one or more post processes in Babylon.
  137667. * A post process can be used to apply a shader to a texture after it is rendered.
  137668. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137669. */
  137670. export class PostProcessRenderEffect {
  137671. private _postProcesses;
  137672. private _getPostProcesses;
  137673. private _singleInstance;
  137674. private _cameras;
  137675. private _indicesForCamera;
  137676. /**
  137677. * Name of the effect
  137678. * @hidden
  137679. */
  137680. _name: string;
  137681. /**
  137682. * Instantiates a post process render effect.
  137683. * A post process can be used to apply a shader to a texture after it is rendered.
  137684. * @param engine The engine the effect is tied to
  137685. * @param name The name of the effect
  137686. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137687. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137688. */
  137689. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137690. /**
  137691. * Checks if all the post processes in the effect are supported.
  137692. */
  137693. get isSupported(): boolean;
  137694. /**
  137695. * Updates the current state of the effect
  137696. * @hidden
  137697. */
  137698. _update(): void;
  137699. /**
  137700. * Attaches the effect on cameras
  137701. * @param cameras The camera to attach to.
  137702. * @hidden
  137703. */
  137704. _attachCameras(cameras: Camera): void;
  137705. /**
  137706. * Attaches the effect on cameras
  137707. * @param cameras The camera to attach to.
  137708. * @hidden
  137709. */
  137710. _attachCameras(cameras: Camera[]): void;
  137711. /**
  137712. * Detaches the effect on cameras
  137713. * @param cameras The camera to detatch from.
  137714. * @hidden
  137715. */
  137716. _detachCameras(cameras: Camera): void;
  137717. /**
  137718. * Detatches the effect on cameras
  137719. * @param cameras The camera to detatch from.
  137720. * @hidden
  137721. */
  137722. _detachCameras(cameras: Camera[]): void;
  137723. /**
  137724. * Enables the effect on given cameras
  137725. * @param cameras The camera to enable.
  137726. * @hidden
  137727. */
  137728. _enable(cameras: Camera): void;
  137729. /**
  137730. * Enables the effect on given cameras
  137731. * @param cameras The camera to enable.
  137732. * @hidden
  137733. */
  137734. _enable(cameras: Nullable<Camera[]>): void;
  137735. /**
  137736. * Disables the effect on the given cameras
  137737. * @param cameras The camera to disable.
  137738. * @hidden
  137739. */
  137740. _disable(cameras: Camera): void;
  137741. /**
  137742. * Disables the effect on the given cameras
  137743. * @param cameras The camera to disable.
  137744. * @hidden
  137745. */
  137746. _disable(cameras: Nullable<Camera[]>): void;
  137747. /**
  137748. * Gets a list of the post processes contained in the effect.
  137749. * @param camera The camera to get the post processes on.
  137750. * @returns The list of the post processes in the effect.
  137751. */
  137752. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137753. }
  137754. }
  137755. declare module BABYLON {
  137756. /** @hidden */
  137757. export var extractHighlightsPixelShader: {
  137758. name: string;
  137759. shader: string;
  137760. };
  137761. }
  137762. declare module BABYLON {
  137763. /**
  137764. * 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.
  137765. */
  137766. export class ExtractHighlightsPostProcess extends PostProcess {
  137767. /**
  137768. * The luminance threshold, pixels below this value will be set to black.
  137769. */
  137770. threshold: number;
  137771. /** @hidden */
  137772. _exposure: number;
  137773. /**
  137774. * Post process which has the input texture to be used when performing highlight extraction
  137775. * @hidden
  137776. */
  137777. _inputPostProcess: Nullable<PostProcess>;
  137778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137779. }
  137780. }
  137781. declare module BABYLON {
  137782. /** @hidden */
  137783. export var bloomMergePixelShader: {
  137784. name: string;
  137785. shader: string;
  137786. };
  137787. }
  137788. declare module BABYLON {
  137789. /**
  137790. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137791. */
  137792. export class BloomMergePostProcess extends PostProcess {
  137793. /** Weight of the bloom to be added to the original input. */
  137794. weight: number;
  137795. /**
  137796. * Creates a new instance of @see BloomMergePostProcess
  137797. * @param name The name of the effect.
  137798. * @param originalFromInput Post process which's input will be used for the merge.
  137799. * @param blurred Blurred highlights post process which's output will be used.
  137800. * @param weight Weight of the bloom to be added to the original input.
  137801. * @param options The required width/height ratio to downsize to before computing the render pass.
  137802. * @param camera The camera to apply the render pass to.
  137803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137804. * @param engine The engine which the post process will be applied. (default: current engine)
  137805. * @param reusable If the post process can be reused on the same frame. (default: false)
  137806. * @param textureType Type of textures used when performing the post process. (default: 0)
  137807. * @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)
  137808. */
  137809. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137810. /** Weight of the bloom to be added to the original input. */
  137811. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137812. }
  137813. }
  137814. declare module BABYLON {
  137815. /**
  137816. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137817. */
  137818. export class BloomEffect extends PostProcessRenderEffect {
  137819. private bloomScale;
  137820. /**
  137821. * @hidden Internal
  137822. */
  137823. _effects: Array<PostProcess>;
  137824. /**
  137825. * @hidden Internal
  137826. */
  137827. _downscale: ExtractHighlightsPostProcess;
  137828. private _blurX;
  137829. private _blurY;
  137830. private _merge;
  137831. /**
  137832. * The luminance threshold to find bright areas of the image to bloom.
  137833. */
  137834. get threshold(): number;
  137835. set threshold(value: number);
  137836. /**
  137837. * The strength of the bloom.
  137838. */
  137839. get weight(): number;
  137840. set weight(value: number);
  137841. /**
  137842. * Specifies the size of the bloom blur kernel, relative to the final output size
  137843. */
  137844. get kernel(): number;
  137845. set kernel(value: number);
  137846. /**
  137847. * Creates a new instance of @see BloomEffect
  137848. * @param scene The scene the effect belongs to.
  137849. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137850. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137851. * @param bloomWeight The the strength of bloom.
  137852. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137853. * @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)
  137854. */
  137855. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137856. /**
  137857. * Disposes each of the internal effects for a given camera.
  137858. * @param camera The camera to dispose the effect on.
  137859. */
  137860. disposeEffects(camera: Camera): void;
  137861. /**
  137862. * @hidden Internal
  137863. */
  137864. _updateEffects(): void;
  137865. /**
  137866. * Internal
  137867. * @returns if all the contained post processes are ready.
  137868. * @hidden
  137869. */
  137870. _isReady(): boolean;
  137871. }
  137872. }
  137873. declare module BABYLON {
  137874. /** @hidden */
  137875. export var chromaticAberrationPixelShader: {
  137876. name: string;
  137877. shader: string;
  137878. };
  137879. }
  137880. declare module BABYLON {
  137881. /**
  137882. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137883. */
  137884. export class ChromaticAberrationPostProcess extends PostProcess {
  137885. /**
  137886. * The amount of seperation of rgb channels (default: 30)
  137887. */
  137888. aberrationAmount: number;
  137889. /**
  137890. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137891. */
  137892. radialIntensity: number;
  137893. /**
  137894. * 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))
  137895. */
  137896. direction: Vector2;
  137897. /**
  137898. * 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))
  137899. */
  137900. centerPosition: Vector2;
  137901. /**
  137902. * Creates a new instance ChromaticAberrationPostProcess
  137903. * @param name The name of the effect.
  137904. * @param screenWidth The width of the screen to apply the effect on.
  137905. * @param screenHeight The height of the screen to apply the effect on.
  137906. * @param options The required width/height ratio to downsize to before computing the render pass.
  137907. * @param camera The camera to apply the render pass to.
  137908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137909. * @param engine The engine which the post process will be applied. (default: current engine)
  137910. * @param reusable If the post process can be reused on the same frame. (default: false)
  137911. * @param textureType Type of textures used when performing the post process. (default: 0)
  137912. * @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)
  137913. */
  137914. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137915. }
  137916. }
  137917. declare module BABYLON {
  137918. /** @hidden */
  137919. export var circleOfConfusionPixelShader: {
  137920. name: string;
  137921. shader: string;
  137922. };
  137923. }
  137924. declare module BABYLON {
  137925. /**
  137926. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137927. */
  137928. export class CircleOfConfusionPostProcess extends PostProcess {
  137929. /**
  137930. * 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.
  137931. */
  137932. lensSize: number;
  137933. /**
  137934. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137935. */
  137936. fStop: number;
  137937. /**
  137938. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137939. */
  137940. focusDistance: number;
  137941. /**
  137942. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137943. */
  137944. focalLength: number;
  137945. private _depthTexture;
  137946. /**
  137947. * Creates a new instance CircleOfConfusionPostProcess
  137948. * @param name The name of the effect.
  137949. * @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.
  137950. * @param options The required width/height ratio to downsize to before computing the render pass.
  137951. * @param camera The camera to apply the render pass to.
  137952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137953. * @param engine The engine which the post process will be applied. (default: current engine)
  137954. * @param reusable If the post process can be reused on the same frame. (default: false)
  137955. * @param textureType Type of textures used when performing the post process. (default: 0)
  137956. * @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)
  137957. */
  137958. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137959. /**
  137960. * 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.
  137961. */
  137962. set depthTexture(value: RenderTargetTexture);
  137963. }
  137964. }
  137965. declare module BABYLON {
  137966. /** @hidden */
  137967. export var colorCorrectionPixelShader: {
  137968. name: string;
  137969. shader: string;
  137970. };
  137971. }
  137972. declare module BABYLON {
  137973. /**
  137974. *
  137975. * This post-process allows the modification of rendered colors by using
  137976. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137977. *
  137978. * The object needs to be provided an url to a texture containing the color
  137979. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137980. * Use an image editing software to tweak the LUT to match your needs.
  137981. *
  137982. * For an example of a color LUT, see here:
  137983. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137984. * For explanations on color grading, see here:
  137985. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137986. *
  137987. */
  137988. export class ColorCorrectionPostProcess extends PostProcess {
  137989. private _colorTableTexture;
  137990. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137991. }
  137992. }
  137993. declare module BABYLON {
  137994. /** @hidden */
  137995. export var convolutionPixelShader: {
  137996. name: string;
  137997. shader: string;
  137998. };
  137999. }
  138000. declare module BABYLON {
  138001. /**
  138002. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  138003. * input texture to perform effects such as edge detection or sharpening
  138004. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138005. */
  138006. export class ConvolutionPostProcess extends PostProcess {
  138007. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  138008. kernel: number[];
  138009. /**
  138010. * Creates a new instance ConvolutionPostProcess
  138011. * @param name The name of the effect.
  138012. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  138013. * @param options The required width/height ratio to downsize to before computing the render pass.
  138014. * @param camera The camera to apply the render pass to.
  138015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138016. * @param engine The engine which the post process will be applied. (default: current engine)
  138017. * @param reusable If the post process can be reused on the same frame. (default: false)
  138018. * @param textureType Type of textures used when performing the post process. (default: 0)
  138019. */
  138020. constructor(name: string,
  138021. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  138022. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138023. /**
  138024. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138025. */
  138026. static EdgeDetect0Kernel: number[];
  138027. /**
  138028. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138029. */
  138030. static EdgeDetect1Kernel: number[];
  138031. /**
  138032. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138033. */
  138034. static EdgeDetect2Kernel: number[];
  138035. /**
  138036. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138037. */
  138038. static SharpenKernel: number[];
  138039. /**
  138040. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138041. */
  138042. static EmbossKernel: number[];
  138043. /**
  138044. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138045. */
  138046. static GaussianKernel: number[];
  138047. }
  138048. }
  138049. declare module BABYLON {
  138050. /**
  138051. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  138052. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  138053. * based on samples that have a large difference in distance than the center pixel.
  138054. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  138055. */
  138056. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  138057. direction: Vector2;
  138058. /**
  138059. * Creates a new instance CircleOfConfusionPostProcess
  138060. * @param name The name of the effect.
  138061. * @param scene The scene the effect belongs to.
  138062. * @param direction The direction the blur should be applied.
  138063. * @param kernel The size of the kernel used to blur.
  138064. * @param options The required width/height ratio to downsize to before computing the render pass.
  138065. * @param camera The camera to apply the render pass to.
  138066. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  138067. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  138068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138069. * @param engine The engine which the post process will be applied. (default: current engine)
  138070. * @param reusable If the post process can be reused on the same frame. (default: false)
  138071. * @param textureType Type of textures used when performing the post process. (default: 0)
  138072. * @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)
  138073. */
  138074. 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);
  138075. }
  138076. }
  138077. declare module BABYLON {
  138078. /** @hidden */
  138079. export var depthOfFieldMergePixelShader: {
  138080. name: string;
  138081. shader: string;
  138082. };
  138083. }
  138084. declare module BABYLON {
  138085. /**
  138086. * Options to be set when merging outputs from the default pipeline.
  138087. */
  138088. export class DepthOfFieldMergePostProcessOptions {
  138089. /**
  138090. * The original image to merge on top of
  138091. */
  138092. originalFromInput: PostProcess;
  138093. /**
  138094. * Parameters to perform the merge of the depth of field effect
  138095. */
  138096. depthOfField?: {
  138097. circleOfConfusion: PostProcess;
  138098. blurSteps: Array<PostProcess>;
  138099. };
  138100. /**
  138101. * Parameters to perform the merge of bloom effect
  138102. */
  138103. bloom?: {
  138104. blurred: PostProcess;
  138105. weight: number;
  138106. };
  138107. }
  138108. /**
  138109. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  138110. */
  138111. export class DepthOfFieldMergePostProcess extends PostProcess {
  138112. private blurSteps;
  138113. /**
  138114. * Creates a new instance of DepthOfFieldMergePostProcess
  138115. * @param name The name of the effect.
  138116. * @param originalFromInput Post process which's input will be used for the merge.
  138117. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  138118. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  138119. * @param options The required width/height ratio to downsize to before computing the render pass.
  138120. * @param camera The camera to apply the render pass to.
  138121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138122. * @param engine The engine which the post process will be applied. (default: current engine)
  138123. * @param reusable If the post process can be reused on the same frame. (default: false)
  138124. * @param textureType Type of textures used when performing the post process. (default: 0)
  138125. * @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)
  138126. */
  138127. 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);
  138128. /**
  138129. * Updates the effect with the current post process compile time values and recompiles the shader.
  138130. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  138131. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  138132. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  138133. * @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
  138134. * @param onCompiled Called when the shader has been compiled.
  138135. * @param onError Called if there is an error when compiling a shader.
  138136. */
  138137. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  138138. }
  138139. }
  138140. declare module BABYLON {
  138141. /**
  138142. * Specifies the level of max blur that should be applied when using the depth of field effect
  138143. */
  138144. export enum DepthOfFieldEffectBlurLevel {
  138145. /**
  138146. * Subtle blur
  138147. */
  138148. Low = 0,
  138149. /**
  138150. * Medium blur
  138151. */
  138152. Medium = 1,
  138153. /**
  138154. * Large blur
  138155. */
  138156. High = 2
  138157. }
  138158. /**
  138159. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  138160. */
  138161. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  138162. private _circleOfConfusion;
  138163. /**
  138164. * @hidden Internal, blurs from high to low
  138165. */
  138166. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  138167. private _depthOfFieldBlurY;
  138168. private _dofMerge;
  138169. /**
  138170. * @hidden Internal post processes in depth of field effect
  138171. */
  138172. _effects: Array<PostProcess>;
  138173. /**
  138174. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  138175. */
  138176. set focalLength(value: number);
  138177. get focalLength(): number;
  138178. /**
  138179. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  138180. */
  138181. set fStop(value: number);
  138182. get fStop(): number;
  138183. /**
  138184. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  138185. */
  138186. set focusDistance(value: number);
  138187. get focusDistance(): number;
  138188. /**
  138189. * 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.
  138190. */
  138191. set lensSize(value: number);
  138192. get lensSize(): number;
  138193. /**
  138194. * Creates a new instance DepthOfFieldEffect
  138195. * @param scene The scene the effect belongs to.
  138196. * @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.
  138197. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  138198. * @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)
  138199. */
  138200. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  138201. /**
  138202. * Get the current class name of the current effet
  138203. * @returns "DepthOfFieldEffect"
  138204. */
  138205. getClassName(): string;
  138206. /**
  138207. * 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.
  138208. */
  138209. set depthTexture(value: RenderTargetTexture);
  138210. /**
  138211. * Disposes each of the internal effects for a given camera.
  138212. * @param camera The camera to dispose the effect on.
  138213. */
  138214. disposeEffects(camera: Camera): void;
  138215. /**
  138216. * @hidden Internal
  138217. */
  138218. _updateEffects(): void;
  138219. /**
  138220. * Internal
  138221. * @returns if all the contained post processes are ready.
  138222. * @hidden
  138223. */
  138224. _isReady(): boolean;
  138225. }
  138226. }
  138227. declare module BABYLON {
  138228. /** @hidden */
  138229. export var displayPassPixelShader: {
  138230. name: string;
  138231. shader: string;
  138232. };
  138233. }
  138234. declare module BABYLON {
  138235. /**
  138236. * DisplayPassPostProcess which produces an output the same as it's input
  138237. */
  138238. export class DisplayPassPostProcess extends PostProcess {
  138239. /**
  138240. * Creates the DisplayPassPostProcess
  138241. * @param name The name of the effect.
  138242. * @param options The required width/height ratio to downsize to before computing the render pass.
  138243. * @param camera The camera to apply the render pass to.
  138244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138245. * @param engine The engine which the post process will be applied. (default: current engine)
  138246. * @param reusable If the post process can be reused on the same frame. (default: false)
  138247. */
  138248. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138249. }
  138250. }
  138251. declare module BABYLON {
  138252. /** @hidden */
  138253. export var filterPixelShader: {
  138254. name: string;
  138255. shader: string;
  138256. };
  138257. }
  138258. declare module BABYLON {
  138259. /**
  138260. * Applies a kernel filter to the image
  138261. */
  138262. export class FilterPostProcess extends PostProcess {
  138263. /** The matrix to be applied to the image */
  138264. kernelMatrix: Matrix;
  138265. /**
  138266. *
  138267. * @param name The name of the effect.
  138268. * @param kernelMatrix The matrix to be applied to the image
  138269. * @param options The required width/height ratio to downsize to before computing the render pass.
  138270. * @param camera The camera to apply the render pass to.
  138271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138272. * @param engine The engine which the post process will be applied. (default: current engine)
  138273. * @param reusable If the post process can be reused on the same frame. (default: false)
  138274. */
  138275. constructor(name: string,
  138276. /** The matrix to be applied to the image */
  138277. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138278. }
  138279. }
  138280. declare module BABYLON {
  138281. /** @hidden */
  138282. export var fxaaPixelShader: {
  138283. name: string;
  138284. shader: string;
  138285. };
  138286. }
  138287. declare module BABYLON {
  138288. /** @hidden */
  138289. export var fxaaVertexShader: {
  138290. name: string;
  138291. shader: string;
  138292. };
  138293. }
  138294. declare module BABYLON {
  138295. /**
  138296. * Fxaa post process
  138297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  138298. */
  138299. export class FxaaPostProcess extends PostProcess {
  138300. /** @hidden */
  138301. texelWidth: number;
  138302. /** @hidden */
  138303. texelHeight: number;
  138304. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138305. private _getDefines;
  138306. }
  138307. }
  138308. declare module BABYLON {
  138309. /** @hidden */
  138310. export var grainPixelShader: {
  138311. name: string;
  138312. shader: string;
  138313. };
  138314. }
  138315. declare module BABYLON {
  138316. /**
  138317. * The GrainPostProcess adds noise to the image at mid luminance levels
  138318. */
  138319. export class GrainPostProcess extends PostProcess {
  138320. /**
  138321. * The intensity of the grain added (default: 30)
  138322. */
  138323. intensity: number;
  138324. /**
  138325. * If the grain should be randomized on every frame
  138326. */
  138327. animated: boolean;
  138328. /**
  138329. * Creates a new instance of @see GrainPostProcess
  138330. * @param name The name of the effect.
  138331. * @param options The required width/height ratio to downsize to before computing the render pass.
  138332. * @param camera The camera to apply the render pass to.
  138333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138334. * @param engine The engine which the post process will be applied. (default: current engine)
  138335. * @param reusable If the post process can be reused on the same frame. (default: false)
  138336. * @param textureType Type of textures used when performing the post process. (default: 0)
  138337. * @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)
  138338. */
  138339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138340. }
  138341. }
  138342. declare module BABYLON {
  138343. /** @hidden */
  138344. export var highlightsPixelShader: {
  138345. name: string;
  138346. shader: string;
  138347. };
  138348. }
  138349. declare module BABYLON {
  138350. /**
  138351. * Extracts highlights from the image
  138352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138353. */
  138354. export class HighlightsPostProcess extends PostProcess {
  138355. /**
  138356. * Extracts highlights from the image
  138357. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138358. * @param name The name of the effect.
  138359. * @param options The required width/height ratio to downsize to before computing the render pass.
  138360. * @param camera The camera to apply the render pass to.
  138361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138362. * @param engine The engine which the post process will be applied. (default: current engine)
  138363. * @param reusable If the post process can be reused on the same frame. (default: false)
  138364. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  138365. */
  138366. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138367. }
  138368. }
  138369. declare module BABYLON {
  138370. /** @hidden */
  138371. export var mrtFragmentDeclaration: {
  138372. name: string;
  138373. shader: string;
  138374. };
  138375. }
  138376. declare module BABYLON {
  138377. /** @hidden */
  138378. export var geometryPixelShader: {
  138379. name: string;
  138380. shader: string;
  138381. };
  138382. }
  138383. declare module BABYLON {
  138384. /** @hidden */
  138385. export var geometryVertexShader: {
  138386. name: string;
  138387. shader: string;
  138388. };
  138389. }
  138390. declare module BABYLON {
  138391. /** @hidden */
  138392. interface ISavedTransformationMatrix {
  138393. world: Matrix;
  138394. viewProjection: Matrix;
  138395. }
  138396. /**
  138397. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  138398. */
  138399. export class GeometryBufferRenderer {
  138400. /**
  138401. * Constant used to retrieve the position texture index in the G-Buffer textures array
  138402. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  138403. */
  138404. static readonly POSITION_TEXTURE_TYPE: number;
  138405. /**
  138406. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  138407. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  138408. */
  138409. static readonly VELOCITY_TEXTURE_TYPE: number;
  138410. /**
  138411. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  138412. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  138413. */
  138414. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  138415. /**
  138416. * Dictionary used to store the previous transformation matrices of each rendered mesh
  138417. * in order to compute objects velocities when enableVelocity is set to "true"
  138418. * @hidden
  138419. */
  138420. _previousTransformationMatrices: {
  138421. [index: number]: ISavedTransformationMatrix;
  138422. };
  138423. /**
  138424. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  138425. * in order to compute objects velocities when enableVelocity is set to "true"
  138426. * @hidden
  138427. */
  138428. _previousBonesTransformationMatrices: {
  138429. [index: number]: Float32Array;
  138430. };
  138431. /**
  138432. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  138433. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  138434. */
  138435. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  138436. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  138437. renderTransparentMeshes: boolean;
  138438. private _scene;
  138439. private _multiRenderTarget;
  138440. private _ratio;
  138441. private _enablePosition;
  138442. private _enableVelocity;
  138443. private _enableReflectivity;
  138444. private _positionIndex;
  138445. private _velocityIndex;
  138446. private _reflectivityIndex;
  138447. protected _effect: Effect;
  138448. protected _cachedDefines: string;
  138449. /**
  138450. * Set the render list (meshes to be rendered) used in the G buffer.
  138451. */
  138452. set renderList(meshes: Mesh[]);
  138453. /**
  138454. * Gets wether or not G buffer are supported by the running hardware.
  138455. * This requires draw buffer supports
  138456. */
  138457. get isSupported(): boolean;
  138458. /**
  138459. * Returns the index of the given texture type in the G-Buffer textures array
  138460. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138461. * @returns the index of the given texture type in the G-Buffer textures array
  138462. */
  138463. getTextureIndex(textureType: number): number;
  138464. /**
  138465. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138466. */
  138467. get enablePosition(): boolean;
  138468. /**
  138469. * Sets whether or not objects positions are enabled for the G buffer.
  138470. */
  138471. set enablePosition(enable: boolean);
  138472. /**
  138473. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138474. */
  138475. get enableVelocity(): boolean;
  138476. /**
  138477. * Sets wether or not objects velocities are enabled for the G buffer.
  138478. */
  138479. set enableVelocity(enable: boolean);
  138480. /**
  138481. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138482. */
  138483. get enableReflectivity(): boolean;
  138484. /**
  138485. * Sets wether or not objects roughness are enabled for the G buffer.
  138486. */
  138487. set enableReflectivity(enable: boolean);
  138488. /**
  138489. * Gets the scene associated with the buffer.
  138490. */
  138491. get scene(): Scene;
  138492. /**
  138493. * Gets the ratio used by the buffer during its creation.
  138494. * How big is the buffer related to the main canvas.
  138495. */
  138496. get ratio(): number;
  138497. /** @hidden */
  138498. static _SceneComponentInitialization: (scene: Scene) => void;
  138499. /**
  138500. * Creates a new G Buffer for the scene
  138501. * @param scene The scene the buffer belongs to
  138502. * @param ratio How big is the buffer related to the main canvas.
  138503. */
  138504. constructor(scene: Scene, ratio?: number);
  138505. /**
  138506. * Checks wether everything is ready to render a submesh to the G buffer.
  138507. * @param subMesh the submesh to check readiness for
  138508. * @param useInstances is the mesh drawn using instance or not
  138509. * @returns true if ready otherwise false
  138510. */
  138511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138512. /**
  138513. * Gets the current underlying G Buffer.
  138514. * @returns the buffer
  138515. */
  138516. getGBuffer(): MultiRenderTarget;
  138517. /**
  138518. * Gets the number of samples used to render the buffer (anti aliasing).
  138519. */
  138520. get samples(): number;
  138521. /**
  138522. * Sets the number of samples used to render the buffer (anti aliasing).
  138523. */
  138524. set samples(value: number);
  138525. /**
  138526. * Disposes the renderer and frees up associated resources.
  138527. */
  138528. dispose(): void;
  138529. protected _createRenderTargets(): void;
  138530. private _copyBonesTransformationMatrices;
  138531. }
  138532. }
  138533. declare module BABYLON {
  138534. interface Scene {
  138535. /** @hidden (Backing field) */
  138536. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138537. /**
  138538. * Gets or Sets the current geometry buffer associated to the scene.
  138539. */
  138540. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138541. /**
  138542. * Enables a GeometryBufferRender and associates it with the scene
  138543. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138544. * @returns the GeometryBufferRenderer
  138545. */
  138546. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138547. /**
  138548. * Disables the GeometryBufferRender associated with the scene
  138549. */
  138550. disableGeometryBufferRenderer(): void;
  138551. }
  138552. /**
  138553. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138554. * in several rendering techniques.
  138555. */
  138556. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138557. /**
  138558. * The component name helpful to identify the component in the list of scene components.
  138559. */
  138560. readonly name: string;
  138561. /**
  138562. * The scene the component belongs to.
  138563. */
  138564. scene: Scene;
  138565. /**
  138566. * Creates a new instance of the component for the given scene
  138567. * @param scene Defines the scene to register the component in
  138568. */
  138569. constructor(scene: Scene);
  138570. /**
  138571. * Registers the component in a given scene
  138572. */
  138573. register(): void;
  138574. /**
  138575. * Rebuilds the elements related to this component in case of
  138576. * context lost for instance.
  138577. */
  138578. rebuild(): void;
  138579. /**
  138580. * Disposes the component and the associated ressources
  138581. */
  138582. dispose(): void;
  138583. private _gatherRenderTargets;
  138584. }
  138585. }
  138586. declare module BABYLON {
  138587. /** @hidden */
  138588. export var motionBlurPixelShader: {
  138589. name: string;
  138590. shader: string;
  138591. };
  138592. }
  138593. declare module BABYLON {
  138594. /**
  138595. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138596. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138597. * As an example, all you have to do is to create the post-process:
  138598. * var mb = new BABYLON.MotionBlurPostProcess(
  138599. * 'mb', // The name of the effect.
  138600. * scene, // The scene containing the objects to blur according to their velocity.
  138601. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138602. * camera // The camera to apply the render pass to.
  138603. * );
  138604. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138605. */
  138606. export class MotionBlurPostProcess extends PostProcess {
  138607. /**
  138608. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138609. */
  138610. motionStrength: number;
  138611. /**
  138612. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138613. */
  138614. get motionBlurSamples(): number;
  138615. /**
  138616. * Sets the number of iterations to be used for motion blur quality
  138617. */
  138618. set motionBlurSamples(samples: number);
  138619. private _motionBlurSamples;
  138620. private _geometryBufferRenderer;
  138621. /**
  138622. * Creates a new instance MotionBlurPostProcess
  138623. * @param name The name of the effect.
  138624. * @param scene The scene containing the objects to blur according to their velocity.
  138625. * @param options The required width/height ratio to downsize to before computing the render pass.
  138626. * @param camera The camera to apply the render pass to.
  138627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138628. * @param engine The engine which the post process will be applied. (default: current engine)
  138629. * @param reusable If the post process can be reused on the same frame. (default: false)
  138630. * @param textureType Type of textures used when performing the post process. (default: 0)
  138631. * @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)
  138632. */
  138633. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138634. /**
  138635. * Excludes the given skinned mesh from computing bones velocities.
  138636. * 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.
  138637. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138638. */
  138639. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138640. /**
  138641. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138642. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138643. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138644. */
  138645. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138646. /**
  138647. * Disposes the post process.
  138648. * @param camera The camera to dispose the post process on.
  138649. */
  138650. dispose(camera?: Camera): void;
  138651. }
  138652. }
  138653. declare module BABYLON {
  138654. /** @hidden */
  138655. export var refractionPixelShader: {
  138656. name: string;
  138657. shader: string;
  138658. };
  138659. }
  138660. declare module BABYLON {
  138661. /**
  138662. * Post process which applies a refractin texture
  138663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138664. */
  138665. export class RefractionPostProcess extends PostProcess {
  138666. /** the base color of the refraction (used to taint the rendering) */
  138667. color: Color3;
  138668. /** simulated refraction depth */
  138669. depth: number;
  138670. /** the coefficient of the base color (0 to remove base color tainting) */
  138671. colorLevel: number;
  138672. private _refTexture;
  138673. private _ownRefractionTexture;
  138674. /**
  138675. * Gets or sets the refraction texture
  138676. * Please note that you are responsible for disposing the texture if you set it manually
  138677. */
  138678. get refractionTexture(): Texture;
  138679. set refractionTexture(value: Texture);
  138680. /**
  138681. * Initializes the RefractionPostProcess
  138682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138683. * @param name The name of the effect.
  138684. * @param refractionTextureUrl Url of the refraction texture to use
  138685. * @param color the base color of the refraction (used to taint the rendering)
  138686. * @param depth simulated refraction depth
  138687. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138688. * @param camera The camera to apply the render pass to.
  138689. * @param options The required width/height ratio to downsize to before computing the render pass.
  138690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138691. * @param engine The engine which the post process will be applied. (default: current engine)
  138692. * @param reusable If the post process can be reused on the same frame. (default: false)
  138693. */
  138694. constructor(name: string, refractionTextureUrl: string,
  138695. /** the base color of the refraction (used to taint the rendering) */
  138696. color: Color3,
  138697. /** simulated refraction depth */
  138698. depth: number,
  138699. /** the coefficient of the base color (0 to remove base color tainting) */
  138700. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138701. /**
  138702. * Disposes of the post process
  138703. * @param camera Camera to dispose post process on
  138704. */
  138705. dispose(camera: Camera): void;
  138706. }
  138707. }
  138708. declare module BABYLON {
  138709. /** @hidden */
  138710. export var sharpenPixelShader: {
  138711. name: string;
  138712. shader: string;
  138713. };
  138714. }
  138715. declare module BABYLON {
  138716. /**
  138717. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138718. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138719. */
  138720. export class SharpenPostProcess extends PostProcess {
  138721. /**
  138722. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138723. */
  138724. colorAmount: number;
  138725. /**
  138726. * How much sharpness should be applied (default: 0.3)
  138727. */
  138728. edgeAmount: number;
  138729. /**
  138730. * Creates a new instance ConvolutionPostProcess
  138731. * @param name The name of the effect.
  138732. * @param options The required width/height ratio to downsize to before computing the render pass.
  138733. * @param camera The camera to apply the render pass to.
  138734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138735. * @param engine The engine which the post process will be applied. (default: current engine)
  138736. * @param reusable If the post process can be reused on the same frame. (default: false)
  138737. * @param textureType Type of textures used when performing the post process. (default: 0)
  138738. * @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)
  138739. */
  138740. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138741. }
  138742. }
  138743. declare module BABYLON {
  138744. /**
  138745. * PostProcessRenderPipeline
  138746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138747. */
  138748. export class PostProcessRenderPipeline {
  138749. private engine;
  138750. private _renderEffects;
  138751. private _renderEffectsForIsolatedPass;
  138752. /**
  138753. * List of inspectable custom properties (used by the Inspector)
  138754. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138755. */
  138756. inspectableCustomProperties: IInspectable[];
  138757. /**
  138758. * @hidden
  138759. */
  138760. protected _cameras: Camera[];
  138761. /** @hidden */
  138762. _name: string;
  138763. /**
  138764. * Gets pipeline name
  138765. */
  138766. get name(): string;
  138767. /** Gets the list of attached cameras */
  138768. get cameras(): Camera[];
  138769. /**
  138770. * Initializes a PostProcessRenderPipeline
  138771. * @param engine engine to add the pipeline to
  138772. * @param name name of the pipeline
  138773. */
  138774. constructor(engine: Engine, name: string);
  138775. /**
  138776. * Gets the class name
  138777. * @returns "PostProcessRenderPipeline"
  138778. */
  138779. getClassName(): string;
  138780. /**
  138781. * If all the render effects in the pipeline are supported
  138782. */
  138783. get isSupported(): boolean;
  138784. /**
  138785. * Adds an effect to the pipeline
  138786. * @param renderEffect the effect to add
  138787. */
  138788. addEffect(renderEffect: PostProcessRenderEffect): void;
  138789. /** @hidden */
  138790. _rebuild(): void;
  138791. /** @hidden */
  138792. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138793. /** @hidden */
  138794. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138795. /** @hidden */
  138796. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138797. /** @hidden */
  138798. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138799. /** @hidden */
  138800. _attachCameras(cameras: Camera, unique: boolean): void;
  138801. /** @hidden */
  138802. _attachCameras(cameras: Camera[], unique: boolean): void;
  138803. /** @hidden */
  138804. _detachCameras(cameras: Camera): void;
  138805. /** @hidden */
  138806. _detachCameras(cameras: Nullable<Camera[]>): void;
  138807. /** @hidden */
  138808. _update(): void;
  138809. /** @hidden */
  138810. _reset(): void;
  138811. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138812. /**
  138813. * Disposes of the pipeline
  138814. */
  138815. dispose(): void;
  138816. }
  138817. }
  138818. declare module BABYLON {
  138819. /**
  138820. * PostProcessRenderPipelineManager class
  138821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138822. */
  138823. export class PostProcessRenderPipelineManager {
  138824. private _renderPipelines;
  138825. /**
  138826. * Initializes a PostProcessRenderPipelineManager
  138827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138828. */
  138829. constructor();
  138830. /**
  138831. * Gets the list of supported render pipelines
  138832. */
  138833. get supportedPipelines(): PostProcessRenderPipeline[];
  138834. /**
  138835. * Adds a pipeline to the manager
  138836. * @param renderPipeline The pipeline to add
  138837. */
  138838. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138839. /**
  138840. * Attaches a camera to the pipeline
  138841. * @param renderPipelineName The name of the pipeline to attach to
  138842. * @param cameras the camera to attach
  138843. * @param unique if the camera can be attached multiple times to the pipeline
  138844. */
  138845. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138846. /**
  138847. * Detaches a camera from the pipeline
  138848. * @param renderPipelineName The name of the pipeline to detach from
  138849. * @param cameras the camera to detach
  138850. */
  138851. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138852. /**
  138853. * Enables an effect by name on a pipeline
  138854. * @param renderPipelineName the name of the pipeline to enable the effect in
  138855. * @param renderEffectName the name of the effect to enable
  138856. * @param cameras the cameras that the effect should be enabled on
  138857. */
  138858. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138859. /**
  138860. * Disables an effect by name on a pipeline
  138861. * @param renderPipelineName the name of the pipeline to disable the effect in
  138862. * @param renderEffectName the name of the effect to disable
  138863. * @param cameras the cameras that the effect should be disabled on
  138864. */
  138865. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138866. /**
  138867. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138868. */
  138869. update(): void;
  138870. /** @hidden */
  138871. _rebuild(): void;
  138872. /**
  138873. * Disposes of the manager and pipelines
  138874. */
  138875. dispose(): void;
  138876. }
  138877. }
  138878. declare module BABYLON {
  138879. interface Scene {
  138880. /** @hidden (Backing field) */
  138881. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138882. /**
  138883. * Gets the postprocess render pipeline manager
  138884. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138885. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138886. */
  138887. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138888. }
  138889. /**
  138890. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138891. */
  138892. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138893. /**
  138894. * The component name helpfull to identify the component in the list of scene components.
  138895. */
  138896. readonly name: string;
  138897. /**
  138898. * The scene the component belongs to.
  138899. */
  138900. scene: Scene;
  138901. /**
  138902. * Creates a new instance of the component for the given scene
  138903. * @param scene Defines the scene to register the component in
  138904. */
  138905. constructor(scene: Scene);
  138906. /**
  138907. * Registers the component in a given scene
  138908. */
  138909. register(): void;
  138910. /**
  138911. * Rebuilds the elements related to this component in case of
  138912. * context lost for instance.
  138913. */
  138914. rebuild(): void;
  138915. /**
  138916. * Disposes the component and the associated ressources
  138917. */
  138918. dispose(): void;
  138919. private _gatherRenderTargets;
  138920. }
  138921. }
  138922. declare module BABYLON {
  138923. /**
  138924. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138925. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138926. */
  138927. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138928. private _scene;
  138929. private _camerasToBeAttached;
  138930. /**
  138931. * ID of the sharpen post process,
  138932. */
  138933. private readonly SharpenPostProcessId;
  138934. /**
  138935. * @ignore
  138936. * ID of the image processing post process;
  138937. */
  138938. readonly ImageProcessingPostProcessId: string;
  138939. /**
  138940. * @ignore
  138941. * ID of the Fast Approximate Anti-Aliasing post process;
  138942. */
  138943. readonly FxaaPostProcessId: string;
  138944. /**
  138945. * ID of the chromatic aberration post process,
  138946. */
  138947. private readonly ChromaticAberrationPostProcessId;
  138948. /**
  138949. * ID of the grain post process
  138950. */
  138951. private readonly GrainPostProcessId;
  138952. /**
  138953. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138954. */
  138955. sharpen: SharpenPostProcess;
  138956. private _sharpenEffect;
  138957. private bloom;
  138958. /**
  138959. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138960. */
  138961. depthOfField: DepthOfFieldEffect;
  138962. /**
  138963. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138964. */
  138965. fxaa: FxaaPostProcess;
  138966. /**
  138967. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138968. */
  138969. imageProcessing: ImageProcessingPostProcess;
  138970. /**
  138971. * Chromatic aberration post process which will shift rgb colors in the image
  138972. */
  138973. chromaticAberration: ChromaticAberrationPostProcess;
  138974. private _chromaticAberrationEffect;
  138975. /**
  138976. * Grain post process which add noise to the image
  138977. */
  138978. grain: GrainPostProcess;
  138979. private _grainEffect;
  138980. /**
  138981. * Glow post process which adds a glow to emissive areas of the image
  138982. */
  138983. private _glowLayer;
  138984. /**
  138985. * Animations which can be used to tweak settings over a period of time
  138986. */
  138987. animations: Animation[];
  138988. private _imageProcessingConfigurationObserver;
  138989. private _sharpenEnabled;
  138990. private _bloomEnabled;
  138991. private _depthOfFieldEnabled;
  138992. private _depthOfFieldBlurLevel;
  138993. private _fxaaEnabled;
  138994. private _imageProcessingEnabled;
  138995. private _defaultPipelineTextureType;
  138996. private _bloomScale;
  138997. private _chromaticAberrationEnabled;
  138998. private _grainEnabled;
  138999. private _buildAllowed;
  139000. /**
  139001. * Gets active scene
  139002. */
  139003. get scene(): Scene;
  139004. /**
  139005. * Enable or disable the sharpen process from the pipeline
  139006. */
  139007. set sharpenEnabled(enabled: boolean);
  139008. get sharpenEnabled(): boolean;
  139009. private _resizeObserver;
  139010. private _hardwareScaleLevel;
  139011. private _bloomKernel;
  139012. /**
  139013. * Specifies the size of the bloom blur kernel, relative to the final output size
  139014. */
  139015. get bloomKernel(): number;
  139016. set bloomKernel(value: number);
  139017. /**
  139018. * Specifies the weight of the bloom in the final rendering
  139019. */
  139020. private _bloomWeight;
  139021. /**
  139022. * Specifies the luma threshold for the area that will be blurred by the bloom
  139023. */
  139024. private _bloomThreshold;
  139025. private _hdr;
  139026. /**
  139027. * The strength of the bloom.
  139028. */
  139029. set bloomWeight(value: number);
  139030. get bloomWeight(): number;
  139031. /**
  139032. * The strength of the bloom.
  139033. */
  139034. set bloomThreshold(value: number);
  139035. get bloomThreshold(): number;
  139036. /**
  139037. * The scale of the bloom, lower value will provide better performance.
  139038. */
  139039. set bloomScale(value: number);
  139040. get bloomScale(): number;
  139041. /**
  139042. * Enable or disable the bloom from the pipeline
  139043. */
  139044. set bloomEnabled(enabled: boolean);
  139045. get bloomEnabled(): boolean;
  139046. private _rebuildBloom;
  139047. /**
  139048. * If the depth of field is enabled.
  139049. */
  139050. get depthOfFieldEnabled(): boolean;
  139051. set depthOfFieldEnabled(enabled: boolean);
  139052. /**
  139053. * Blur level of the depth of field effect. (Higher blur will effect performance)
  139054. */
  139055. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  139056. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  139057. /**
  139058. * If the anti aliasing is enabled.
  139059. */
  139060. set fxaaEnabled(enabled: boolean);
  139061. get fxaaEnabled(): boolean;
  139062. private _samples;
  139063. /**
  139064. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139065. */
  139066. set samples(sampleCount: number);
  139067. get samples(): number;
  139068. /**
  139069. * If image processing is enabled.
  139070. */
  139071. set imageProcessingEnabled(enabled: boolean);
  139072. get imageProcessingEnabled(): boolean;
  139073. /**
  139074. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  139075. */
  139076. set glowLayerEnabled(enabled: boolean);
  139077. get glowLayerEnabled(): boolean;
  139078. /**
  139079. * Gets the glow layer (or null if not defined)
  139080. */
  139081. get glowLayer(): Nullable<GlowLayer>;
  139082. /**
  139083. * Enable or disable the chromaticAberration process from the pipeline
  139084. */
  139085. set chromaticAberrationEnabled(enabled: boolean);
  139086. get chromaticAberrationEnabled(): boolean;
  139087. /**
  139088. * Enable or disable the grain process from the pipeline
  139089. */
  139090. set grainEnabled(enabled: boolean);
  139091. get grainEnabled(): boolean;
  139092. /**
  139093. * @constructor
  139094. * @param name - The rendering pipeline name (default: "")
  139095. * @param hdr - If high dynamic range textures should be used (default: true)
  139096. * @param scene - The scene linked to this pipeline (default: the last created scene)
  139097. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  139098. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  139099. */
  139100. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  139101. /**
  139102. * Get the class name
  139103. * @returns "DefaultRenderingPipeline"
  139104. */
  139105. getClassName(): string;
  139106. /**
  139107. * Force the compilation of the entire pipeline.
  139108. */
  139109. prepare(): void;
  139110. private _hasCleared;
  139111. private _prevPostProcess;
  139112. private _prevPrevPostProcess;
  139113. private _setAutoClearAndTextureSharing;
  139114. private _depthOfFieldSceneObserver;
  139115. private _buildPipeline;
  139116. private _disposePostProcesses;
  139117. /**
  139118. * Adds a camera to the pipeline
  139119. * @param camera the camera to be added
  139120. */
  139121. addCamera(camera: Camera): void;
  139122. /**
  139123. * Removes a camera from the pipeline
  139124. * @param camera the camera to remove
  139125. */
  139126. removeCamera(camera: Camera): void;
  139127. /**
  139128. * Dispose of the pipeline and stop all post processes
  139129. */
  139130. dispose(): void;
  139131. /**
  139132. * Serialize the rendering pipeline (Used when exporting)
  139133. * @returns the serialized object
  139134. */
  139135. serialize(): any;
  139136. /**
  139137. * Parse the serialized pipeline
  139138. * @param source Source pipeline.
  139139. * @param scene The scene to load the pipeline to.
  139140. * @param rootUrl The URL of the serialized pipeline.
  139141. * @returns An instantiated pipeline from the serialized object.
  139142. */
  139143. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  139144. }
  139145. }
  139146. declare module BABYLON {
  139147. /** @hidden */
  139148. export var lensHighlightsPixelShader: {
  139149. name: string;
  139150. shader: string;
  139151. };
  139152. }
  139153. declare module BABYLON {
  139154. /** @hidden */
  139155. export var depthOfFieldPixelShader: {
  139156. name: string;
  139157. shader: string;
  139158. };
  139159. }
  139160. declare module BABYLON {
  139161. /**
  139162. * BABYLON.JS Chromatic Aberration GLSL Shader
  139163. * Author: Olivier Guyot
  139164. * Separates very slightly R, G and B colors on the edges of the screen
  139165. * Inspired by Francois Tarlier & Martins Upitis
  139166. */
  139167. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  139168. /**
  139169. * @ignore
  139170. * The chromatic aberration PostProcess id in the pipeline
  139171. */
  139172. LensChromaticAberrationEffect: string;
  139173. /**
  139174. * @ignore
  139175. * The highlights enhancing PostProcess id in the pipeline
  139176. */
  139177. HighlightsEnhancingEffect: string;
  139178. /**
  139179. * @ignore
  139180. * The depth-of-field PostProcess id in the pipeline
  139181. */
  139182. LensDepthOfFieldEffect: string;
  139183. private _scene;
  139184. private _depthTexture;
  139185. private _grainTexture;
  139186. private _chromaticAberrationPostProcess;
  139187. private _highlightsPostProcess;
  139188. private _depthOfFieldPostProcess;
  139189. private _edgeBlur;
  139190. private _grainAmount;
  139191. private _chromaticAberration;
  139192. private _distortion;
  139193. private _highlightsGain;
  139194. private _highlightsThreshold;
  139195. private _dofDistance;
  139196. private _dofAperture;
  139197. private _dofDarken;
  139198. private _dofPentagon;
  139199. private _blurNoise;
  139200. /**
  139201. * @constructor
  139202. *
  139203. * Effect parameters are as follow:
  139204. * {
  139205. * chromatic_aberration: number; // from 0 to x (1 for realism)
  139206. * edge_blur: number; // from 0 to x (1 for realism)
  139207. * distortion: number; // from 0 to x (1 for realism)
  139208. * grain_amount: number; // from 0 to 1
  139209. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  139210. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  139211. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  139212. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  139213. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  139214. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  139215. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  139216. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  139217. * }
  139218. * Note: if an effect parameter is unset, effect is disabled
  139219. *
  139220. * @param name The rendering pipeline name
  139221. * @param parameters - An object containing all parameters (see above)
  139222. * @param scene The scene linked to this pipeline
  139223. * @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)
  139224. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139225. */
  139226. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  139227. /**
  139228. * Get the class name
  139229. * @returns "LensRenderingPipeline"
  139230. */
  139231. getClassName(): string;
  139232. /**
  139233. * Gets associated scene
  139234. */
  139235. get scene(): Scene;
  139236. /**
  139237. * Gets or sets the edge blur
  139238. */
  139239. get edgeBlur(): number;
  139240. set edgeBlur(value: number);
  139241. /**
  139242. * Gets or sets the grain amount
  139243. */
  139244. get grainAmount(): number;
  139245. set grainAmount(value: number);
  139246. /**
  139247. * Gets or sets the chromatic aberration amount
  139248. */
  139249. get chromaticAberration(): number;
  139250. set chromaticAberration(value: number);
  139251. /**
  139252. * Gets or sets the depth of field aperture
  139253. */
  139254. get dofAperture(): number;
  139255. set dofAperture(value: number);
  139256. /**
  139257. * Gets or sets the edge distortion
  139258. */
  139259. get edgeDistortion(): number;
  139260. set edgeDistortion(value: number);
  139261. /**
  139262. * Gets or sets the depth of field distortion
  139263. */
  139264. get dofDistortion(): number;
  139265. set dofDistortion(value: number);
  139266. /**
  139267. * Gets or sets the darken out of focus amount
  139268. */
  139269. get darkenOutOfFocus(): number;
  139270. set darkenOutOfFocus(value: number);
  139271. /**
  139272. * Gets or sets a boolean indicating if blur noise is enabled
  139273. */
  139274. get blurNoise(): boolean;
  139275. set blurNoise(value: boolean);
  139276. /**
  139277. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  139278. */
  139279. get pentagonBokeh(): boolean;
  139280. set pentagonBokeh(value: boolean);
  139281. /**
  139282. * Gets or sets the highlight grain amount
  139283. */
  139284. get highlightsGain(): number;
  139285. set highlightsGain(value: number);
  139286. /**
  139287. * Gets or sets the highlight threshold
  139288. */
  139289. get highlightsThreshold(): number;
  139290. set highlightsThreshold(value: number);
  139291. /**
  139292. * Sets the amount of blur at the edges
  139293. * @param amount blur amount
  139294. */
  139295. setEdgeBlur(amount: number): void;
  139296. /**
  139297. * Sets edge blur to 0
  139298. */
  139299. disableEdgeBlur(): void;
  139300. /**
  139301. * Sets the amout of grain
  139302. * @param amount Amount of grain
  139303. */
  139304. setGrainAmount(amount: number): void;
  139305. /**
  139306. * Set grain amount to 0
  139307. */
  139308. disableGrain(): void;
  139309. /**
  139310. * Sets the chromatic aberration amount
  139311. * @param amount amount of chromatic aberration
  139312. */
  139313. setChromaticAberration(amount: number): void;
  139314. /**
  139315. * Sets chromatic aberration amount to 0
  139316. */
  139317. disableChromaticAberration(): void;
  139318. /**
  139319. * Sets the EdgeDistortion amount
  139320. * @param amount amount of EdgeDistortion
  139321. */
  139322. setEdgeDistortion(amount: number): void;
  139323. /**
  139324. * Sets edge distortion to 0
  139325. */
  139326. disableEdgeDistortion(): void;
  139327. /**
  139328. * Sets the FocusDistance amount
  139329. * @param amount amount of FocusDistance
  139330. */
  139331. setFocusDistance(amount: number): void;
  139332. /**
  139333. * Disables depth of field
  139334. */
  139335. disableDepthOfField(): void;
  139336. /**
  139337. * Sets the Aperture amount
  139338. * @param amount amount of Aperture
  139339. */
  139340. setAperture(amount: number): void;
  139341. /**
  139342. * Sets the DarkenOutOfFocus amount
  139343. * @param amount amount of DarkenOutOfFocus
  139344. */
  139345. setDarkenOutOfFocus(amount: number): void;
  139346. private _pentagonBokehIsEnabled;
  139347. /**
  139348. * Creates a pentagon bokeh effect
  139349. */
  139350. enablePentagonBokeh(): void;
  139351. /**
  139352. * Disables the pentagon bokeh effect
  139353. */
  139354. disablePentagonBokeh(): void;
  139355. /**
  139356. * Enables noise blur
  139357. */
  139358. enableNoiseBlur(): void;
  139359. /**
  139360. * Disables noise blur
  139361. */
  139362. disableNoiseBlur(): void;
  139363. /**
  139364. * Sets the HighlightsGain amount
  139365. * @param amount amount of HighlightsGain
  139366. */
  139367. setHighlightsGain(amount: number): void;
  139368. /**
  139369. * Sets the HighlightsThreshold amount
  139370. * @param amount amount of HighlightsThreshold
  139371. */
  139372. setHighlightsThreshold(amount: number): void;
  139373. /**
  139374. * Disables highlights
  139375. */
  139376. disableHighlights(): void;
  139377. /**
  139378. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  139379. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  139380. */
  139381. dispose(disableDepthRender?: boolean): void;
  139382. private _createChromaticAberrationPostProcess;
  139383. private _createHighlightsPostProcess;
  139384. private _createDepthOfFieldPostProcess;
  139385. private _createGrainTexture;
  139386. }
  139387. }
  139388. declare module BABYLON {
  139389. /** @hidden */
  139390. export var ssao2PixelShader: {
  139391. name: string;
  139392. shader: string;
  139393. };
  139394. }
  139395. declare module BABYLON {
  139396. /** @hidden */
  139397. export var ssaoCombinePixelShader: {
  139398. name: string;
  139399. shader: string;
  139400. };
  139401. }
  139402. declare module BABYLON {
  139403. /**
  139404. * Render pipeline to produce ssao effect
  139405. */
  139406. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  139407. /**
  139408. * @ignore
  139409. * The PassPostProcess id in the pipeline that contains the original scene color
  139410. */
  139411. SSAOOriginalSceneColorEffect: string;
  139412. /**
  139413. * @ignore
  139414. * The SSAO PostProcess id in the pipeline
  139415. */
  139416. SSAORenderEffect: string;
  139417. /**
  139418. * @ignore
  139419. * The horizontal blur PostProcess id in the pipeline
  139420. */
  139421. SSAOBlurHRenderEffect: string;
  139422. /**
  139423. * @ignore
  139424. * The vertical blur PostProcess id in the pipeline
  139425. */
  139426. SSAOBlurVRenderEffect: string;
  139427. /**
  139428. * @ignore
  139429. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139430. */
  139431. SSAOCombineRenderEffect: string;
  139432. /**
  139433. * The output strength of the SSAO post-process. Default value is 1.0.
  139434. */
  139435. totalStrength: number;
  139436. /**
  139437. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  139438. */
  139439. maxZ: number;
  139440. /**
  139441. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  139442. */
  139443. minZAspect: number;
  139444. private _samples;
  139445. /**
  139446. * Number of samples used for the SSAO calculations. Default value is 8
  139447. */
  139448. set samples(n: number);
  139449. get samples(): number;
  139450. private _textureSamples;
  139451. /**
  139452. * Number of samples to use for antialiasing
  139453. */
  139454. set textureSamples(n: number);
  139455. get textureSamples(): number;
  139456. /**
  139457. * Ratio object used for SSAO ratio and blur ratio
  139458. */
  139459. private _ratio;
  139460. /**
  139461. * Dynamically generated sphere sampler.
  139462. */
  139463. private _sampleSphere;
  139464. /**
  139465. * Blur filter offsets
  139466. */
  139467. private _samplerOffsets;
  139468. private _expensiveBlur;
  139469. /**
  139470. * If bilateral blur should be used
  139471. */
  139472. set expensiveBlur(b: boolean);
  139473. get expensiveBlur(): boolean;
  139474. /**
  139475. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139476. */
  139477. radius: number;
  139478. /**
  139479. * The base color of the SSAO post-process
  139480. * The final result is "base + ssao" between [0, 1]
  139481. */
  139482. base: number;
  139483. /**
  139484. * Support test.
  139485. */
  139486. static get IsSupported(): boolean;
  139487. private _scene;
  139488. private _depthTexture;
  139489. private _normalTexture;
  139490. private _randomTexture;
  139491. private _originalColorPostProcess;
  139492. private _ssaoPostProcess;
  139493. private _blurHPostProcess;
  139494. private _blurVPostProcess;
  139495. private _ssaoCombinePostProcess;
  139496. /**
  139497. * Gets active scene
  139498. */
  139499. get scene(): Scene;
  139500. /**
  139501. * @constructor
  139502. * @param name The rendering pipeline name
  139503. * @param scene The scene linked to this pipeline
  139504. * @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 }
  139505. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139506. */
  139507. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139508. /**
  139509. * Get the class name
  139510. * @returns "SSAO2RenderingPipeline"
  139511. */
  139512. getClassName(): string;
  139513. /**
  139514. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139515. */
  139516. dispose(disableGeometryBufferRenderer?: boolean): void;
  139517. private _createBlurPostProcess;
  139518. /** @hidden */
  139519. _rebuild(): void;
  139520. private _bits;
  139521. private _radicalInverse_VdC;
  139522. private _hammersley;
  139523. private _hemisphereSample_uniform;
  139524. private _generateHemisphere;
  139525. private _createSSAOPostProcess;
  139526. private _createSSAOCombinePostProcess;
  139527. private _createRandomTexture;
  139528. /**
  139529. * Serialize the rendering pipeline (Used when exporting)
  139530. * @returns the serialized object
  139531. */
  139532. serialize(): any;
  139533. /**
  139534. * Parse the serialized pipeline
  139535. * @param source Source pipeline.
  139536. * @param scene The scene to load the pipeline to.
  139537. * @param rootUrl The URL of the serialized pipeline.
  139538. * @returns An instantiated pipeline from the serialized object.
  139539. */
  139540. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139541. }
  139542. }
  139543. declare module BABYLON {
  139544. /** @hidden */
  139545. export var ssaoPixelShader: {
  139546. name: string;
  139547. shader: string;
  139548. };
  139549. }
  139550. declare module BABYLON {
  139551. /**
  139552. * Render pipeline to produce ssao effect
  139553. */
  139554. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139555. /**
  139556. * @ignore
  139557. * The PassPostProcess id in the pipeline that contains the original scene color
  139558. */
  139559. SSAOOriginalSceneColorEffect: string;
  139560. /**
  139561. * @ignore
  139562. * The SSAO PostProcess id in the pipeline
  139563. */
  139564. SSAORenderEffect: string;
  139565. /**
  139566. * @ignore
  139567. * The horizontal blur PostProcess id in the pipeline
  139568. */
  139569. SSAOBlurHRenderEffect: string;
  139570. /**
  139571. * @ignore
  139572. * The vertical blur PostProcess id in the pipeline
  139573. */
  139574. SSAOBlurVRenderEffect: string;
  139575. /**
  139576. * @ignore
  139577. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139578. */
  139579. SSAOCombineRenderEffect: string;
  139580. /**
  139581. * The output strength of the SSAO post-process. Default value is 1.0.
  139582. */
  139583. totalStrength: number;
  139584. /**
  139585. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139586. */
  139587. radius: number;
  139588. /**
  139589. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139590. * Must not be equal to fallOff and superior to fallOff.
  139591. * Default value is 0.0075
  139592. */
  139593. area: number;
  139594. /**
  139595. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139596. * Must not be equal to area and inferior to area.
  139597. * Default value is 0.000001
  139598. */
  139599. fallOff: number;
  139600. /**
  139601. * The base color of the SSAO post-process
  139602. * The final result is "base + ssao" between [0, 1]
  139603. */
  139604. base: number;
  139605. private _scene;
  139606. private _depthTexture;
  139607. private _randomTexture;
  139608. private _originalColorPostProcess;
  139609. private _ssaoPostProcess;
  139610. private _blurHPostProcess;
  139611. private _blurVPostProcess;
  139612. private _ssaoCombinePostProcess;
  139613. private _firstUpdate;
  139614. /**
  139615. * Gets active scene
  139616. */
  139617. get scene(): Scene;
  139618. /**
  139619. * @constructor
  139620. * @param name - The rendering pipeline name
  139621. * @param scene - The scene linked to this pipeline
  139622. * @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 }
  139623. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139624. */
  139625. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139626. /**
  139627. * Get the class name
  139628. * @returns "SSAORenderingPipeline"
  139629. */
  139630. getClassName(): string;
  139631. /**
  139632. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139633. */
  139634. dispose(disableDepthRender?: boolean): void;
  139635. private _createBlurPostProcess;
  139636. /** @hidden */
  139637. _rebuild(): void;
  139638. private _createSSAOPostProcess;
  139639. private _createSSAOCombinePostProcess;
  139640. private _createRandomTexture;
  139641. }
  139642. }
  139643. declare module BABYLON {
  139644. /** @hidden */
  139645. export var screenSpaceReflectionPixelShader: {
  139646. name: string;
  139647. shader: string;
  139648. };
  139649. }
  139650. declare module BABYLON {
  139651. /**
  139652. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139653. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139654. */
  139655. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139656. /**
  139657. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139658. */
  139659. threshold: number;
  139660. /**
  139661. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139662. */
  139663. strength: number;
  139664. /**
  139665. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139666. */
  139667. reflectionSpecularFalloffExponent: number;
  139668. /**
  139669. * 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]
  139670. */
  139671. step: number;
  139672. /**
  139673. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139674. */
  139675. roughnessFactor: number;
  139676. private _geometryBufferRenderer;
  139677. private _enableSmoothReflections;
  139678. private _reflectionSamples;
  139679. private _smoothSteps;
  139680. /**
  139681. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139682. * @param name The name of the effect.
  139683. * @param scene The scene containing the objects to calculate reflections.
  139684. * @param options The required width/height ratio to downsize to before computing the render pass.
  139685. * @param camera The camera to apply the render pass to.
  139686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139687. * @param engine The engine which the post process will be applied. (default: current engine)
  139688. * @param reusable If the post process can be reused on the same frame. (default: false)
  139689. * @param textureType Type of textures used when performing the post process. (default: 0)
  139690. * @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)
  139691. */
  139692. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139693. /**
  139694. * Gets wether or not smoothing reflections is enabled.
  139695. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139696. */
  139697. get enableSmoothReflections(): boolean;
  139698. /**
  139699. * Sets wether or not smoothing reflections is enabled.
  139700. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139701. */
  139702. set enableSmoothReflections(enabled: boolean);
  139703. /**
  139704. * Gets the number of samples taken while computing reflections. More samples count is high,
  139705. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139706. */
  139707. get reflectionSamples(): number;
  139708. /**
  139709. * Sets the number of samples taken while computing reflections. More samples count is high,
  139710. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139711. */
  139712. set reflectionSamples(samples: number);
  139713. /**
  139714. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139715. * more the post-process will require GPU power and can generate a drop in FPS.
  139716. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139717. */
  139718. get smoothSteps(): number;
  139719. set smoothSteps(steps: number);
  139720. private _updateEffectDefines;
  139721. }
  139722. }
  139723. declare module BABYLON {
  139724. /** @hidden */
  139725. export var standardPixelShader: {
  139726. name: string;
  139727. shader: string;
  139728. };
  139729. }
  139730. declare module BABYLON {
  139731. /**
  139732. * Standard rendering pipeline
  139733. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139734. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139735. */
  139736. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139737. /**
  139738. * Public members
  139739. */
  139740. /**
  139741. * Post-process which contains the original scene color before the pipeline applies all the effects
  139742. */
  139743. originalPostProcess: Nullable<PostProcess>;
  139744. /**
  139745. * Post-process used to down scale an image x4
  139746. */
  139747. downSampleX4PostProcess: Nullable<PostProcess>;
  139748. /**
  139749. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139750. */
  139751. brightPassPostProcess: Nullable<PostProcess>;
  139752. /**
  139753. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139754. */
  139755. blurHPostProcesses: PostProcess[];
  139756. /**
  139757. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139758. */
  139759. blurVPostProcesses: PostProcess[];
  139760. /**
  139761. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139762. */
  139763. textureAdderPostProcess: Nullable<PostProcess>;
  139764. /**
  139765. * Post-process used to create volumetric lighting effect
  139766. */
  139767. volumetricLightPostProcess: Nullable<PostProcess>;
  139768. /**
  139769. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139770. */
  139771. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139772. /**
  139773. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139774. */
  139775. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139776. /**
  139777. * Post-process used to merge the volumetric light effect and the real scene color
  139778. */
  139779. volumetricLightMergePostProces: Nullable<PostProcess>;
  139780. /**
  139781. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139782. */
  139783. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139784. /**
  139785. * Base post-process used to calculate the average luminance of the final image for HDR
  139786. */
  139787. luminancePostProcess: Nullable<PostProcess>;
  139788. /**
  139789. * Post-processes used to create down sample post-processes in order to get
  139790. * the average luminance of the final image for HDR
  139791. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139792. */
  139793. luminanceDownSamplePostProcesses: PostProcess[];
  139794. /**
  139795. * Post-process used to create a HDR effect (light adaptation)
  139796. */
  139797. hdrPostProcess: Nullable<PostProcess>;
  139798. /**
  139799. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139800. */
  139801. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139802. /**
  139803. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139804. */
  139805. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139806. /**
  139807. * Post-process used to merge the final HDR post-process and the real scene color
  139808. */
  139809. hdrFinalPostProcess: Nullable<PostProcess>;
  139810. /**
  139811. * Post-process used to create a lens flare effect
  139812. */
  139813. lensFlarePostProcess: Nullable<PostProcess>;
  139814. /**
  139815. * Post-process that merges the result of the lens flare post-process and the real scene color
  139816. */
  139817. lensFlareComposePostProcess: Nullable<PostProcess>;
  139818. /**
  139819. * Post-process used to create a motion blur effect
  139820. */
  139821. motionBlurPostProcess: Nullable<PostProcess>;
  139822. /**
  139823. * Post-process used to create a depth of field effect
  139824. */
  139825. depthOfFieldPostProcess: Nullable<PostProcess>;
  139826. /**
  139827. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139828. */
  139829. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139830. /**
  139831. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139832. */
  139833. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139834. /**
  139835. * Represents the brightness threshold in order to configure the illuminated surfaces
  139836. */
  139837. brightThreshold: number;
  139838. /**
  139839. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139840. */
  139841. blurWidth: number;
  139842. /**
  139843. * Sets if the blur for highlighted surfaces must be only horizontal
  139844. */
  139845. horizontalBlur: boolean;
  139846. /**
  139847. * Gets the overall exposure used by the pipeline
  139848. */
  139849. get exposure(): number;
  139850. /**
  139851. * Sets the overall exposure used by the pipeline
  139852. */
  139853. set exposure(value: number);
  139854. /**
  139855. * Texture used typically to simulate "dirty" on camera lens
  139856. */
  139857. lensTexture: Nullable<Texture>;
  139858. /**
  139859. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139860. */
  139861. volumetricLightCoefficient: number;
  139862. /**
  139863. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139864. */
  139865. volumetricLightPower: number;
  139866. /**
  139867. * Used the set the blur intensity to smooth the volumetric lights
  139868. */
  139869. volumetricLightBlurScale: number;
  139870. /**
  139871. * Light (spot or directional) used to generate the volumetric lights rays
  139872. * The source light must have a shadow generate so the pipeline can get its
  139873. * depth map
  139874. */
  139875. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139876. /**
  139877. * For eye adaptation, represents the minimum luminance the eye can see
  139878. */
  139879. hdrMinimumLuminance: number;
  139880. /**
  139881. * For eye adaptation, represents the decrease luminance speed
  139882. */
  139883. hdrDecreaseRate: number;
  139884. /**
  139885. * For eye adaptation, represents the increase luminance speed
  139886. */
  139887. hdrIncreaseRate: number;
  139888. /**
  139889. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139890. */
  139891. get hdrAutoExposure(): boolean;
  139892. /**
  139893. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139894. */
  139895. set hdrAutoExposure(value: boolean);
  139896. /**
  139897. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139898. */
  139899. lensColorTexture: Nullable<Texture>;
  139900. /**
  139901. * The overall strengh for the lens flare effect
  139902. */
  139903. lensFlareStrength: number;
  139904. /**
  139905. * Dispersion coefficient for lens flare ghosts
  139906. */
  139907. lensFlareGhostDispersal: number;
  139908. /**
  139909. * Main lens flare halo width
  139910. */
  139911. lensFlareHaloWidth: number;
  139912. /**
  139913. * Based on the lens distortion effect, defines how much the lens flare result
  139914. * is distorted
  139915. */
  139916. lensFlareDistortionStrength: number;
  139917. /**
  139918. * Configures the blur intensity used for for lens flare (halo)
  139919. */
  139920. lensFlareBlurWidth: number;
  139921. /**
  139922. * Lens star texture must be used to simulate rays on the flares and is available
  139923. * in the documentation
  139924. */
  139925. lensStarTexture: Nullable<Texture>;
  139926. /**
  139927. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139928. * flare effect by taking account of the dirt texture
  139929. */
  139930. lensFlareDirtTexture: Nullable<Texture>;
  139931. /**
  139932. * Represents the focal length for the depth of field effect
  139933. */
  139934. depthOfFieldDistance: number;
  139935. /**
  139936. * Represents the blur intensity for the blurred part of the depth of field effect
  139937. */
  139938. depthOfFieldBlurWidth: number;
  139939. /**
  139940. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139941. */
  139942. get motionStrength(): number;
  139943. /**
  139944. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139945. */
  139946. set motionStrength(strength: number);
  139947. /**
  139948. * Gets wether or not the motion blur post-process is object based or screen based.
  139949. */
  139950. get objectBasedMotionBlur(): boolean;
  139951. /**
  139952. * Sets wether or not the motion blur post-process should be object based or screen based
  139953. */
  139954. set objectBasedMotionBlur(value: boolean);
  139955. /**
  139956. * List of animations for the pipeline (IAnimatable implementation)
  139957. */
  139958. animations: Animation[];
  139959. /**
  139960. * Private members
  139961. */
  139962. private _scene;
  139963. private _currentDepthOfFieldSource;
  139964. private _basePostProcess;
  139965. private _fixedExposure;
  139966. private _currentExposure;
  139967. private _hdrAutoExposure;
  139968. private _hdrCurrentLuminance;
  139969. private _motionStrength;
  139970. private _isObjectBasedMotionBlur;
  139971. private _floatTextureType;
  139972. private _camerasToBeAttached;
  139973. private _ratio;
  139974. private _bloomEnabled;
  139975. private _depthOfFieldEnabled;
  139976. private _vlsEnabled;
  139977. private _lensFlareEnabled;
  139978. private _hdrEnabled;
  139979. private _motionBlurEnabled;
  139980. private _fxaaEnabled;
  139981. private _screenSpaceReflectionsEnabled;
  139982. private _motionBlurSamples;
  139983. private _volumetricLightStepsCount;
  139984. private _samples;
  139985. /**
  139986. * @ignore
  139987. * Specifies if the bloom pipeline is enabled
  139988. */
  139989. get BloomEnabled(): boolean;
  139990. set BloomEnabled(enabled: boolean);
  139991. /**
  139992. * @ignore
  139993. * Specifies if the depth of field pipeline is enabed
  139994. */
  139995. get DepthOfFieldEnabled(): boolean;
  139996. set DepthOfFieldEnabled(enabled: boolean);
  139997. /**
  139998. * @ignore
  139999. * Specifies if the lens flare pipeline is enabed
  140000. */
  140001. get LensFlareEnabled(): boolean;
  140002. set LensFlareEnabled(enabled: boolean);
  140003. /**
  140004. * @ignore
  140005. * Specifies if the HDR pipeline is enabled
  140006. */
  140007. get HDREnabled(): boolean;
  140008. set HDREnabled(enabled: boolean);
  140009. /**
  140010. * @ignore
  140011. * Specifies if the volumetric lights scattering effect is enabled
  140012. */
  140013. get VLSEnabled(): boolean;
  140014. set VLSEnabled(enabled: boolean);
  140015. /**
  140016. * @ignore
  140017. * Specifies if the motion blur effect is enabled
  140018. */
  140019. get MotionBlurEnabled(): boolean;
  140020. set MotionBlurEnabled(enabled: boolean);
  140021. /**
  140022. * Specifies if anti-aliasing is enabled
  140023. */
  140024. get fxaaEnabled(): boolean;
  140025. set fxaaEnabled(enabled: boolean);
  140026. /**
  140027. * Specifies if screen space reflections are enabled.
  140028. */
  140029. get screenSpaceReflectionsEnabled(): boolean;
  140030. set screenSpaceReflectionsEnabled(enabled: boolean);
  140031. /**
  140032. * Specifies the number of steps used to calculate the volumetric lights
  140033. * Typically in interval [50, 200]
  140034. */
  140035. get volumetricLightStepsCount(): number;
  140036. set volumetricLightStepsCount(count: number);
  140037. /**
  140038. * Specifies the number of samples used for the motion blur effect
  140039. * Typically in interval [16, 64]
  140040. */
  140041. get motionBlurSamples(): number;
  140042. set motionBlurSamples(samples: number);
  140043. /**
  140044. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140045. */
  140046. get samples(): number;
  140047. set samples(sampleCount: number);
  140048. /**
  140049. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140050. * @constructor
  140051. * @param name The rendering pipeline name
  140052. * @param scene The scene linked to this pipeline
  140053. * @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)
  140054. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  140055. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140056. */
  140057. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  140058. private _buildPipeline;
  140059. private _createDownSampleX4PostProcess;
  140060. private _createBrightPassPostProcess;
  140061. private _createBlurPostProcesses;
  140062. private _createTextureAdderPostProcess;
  140063. private _createVolumetricLightPostProcess;
  140064. private _createLuminancePostProcesses;
  140065. private _createHdrPostProcess;
  140066. private _createLensFlarePostProcess;
  140067. private _createDepthOfFieldPostProcess;
  140068. private _createMotionBlurPostProcess;
  140069. private _getDepthTexture;
  140070. private _disposePostProcesses;
  140071. /**
  140072. * Dispose of the pipeline and stop all post processes
  140073. */
  140074. dispose(): void;
  140075. /**
  140076. * Serialize the rendering pipeline (Used when exporting)
  140077. * @returns the serialized object
  140078. */
  140079. serialize(): any;
  140080. /**
  140081. * Parse the serialized pipeline
  140082. * @param source Source pipeline.
  140083. * @param scene The scene to load the pipeline to.
  140084. * @param rootUrl The URL of the serialized pipeline.
  140085. * @returns An instantiated pipeline from the serialized object.
  140086. */
  140087. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  140088. /**
  140089. * Luminance steps
  140090. */
  140091. static LuminanceSteps: number;
  140092. }
  140093. }
  140094. declare module BABYLON {
  140095. /** @hidden */
  140096. export var tonemapPixelShader: {
  140097. name: string;
  140098. shader: string;
  140099. };
  140100. }
  140101. declare module BABYLON {
  140102. /** Defines operator used for tonemapping */
  140103. export enum TonemappingOperator {
  140104. /** Hable */
  140105. Hable = 0,
  140106. /** Reinhard */
  140107. Reinhard = 1,
  140108. /** HejiDawson */
  140109. HejiDawson = 2,
  140110. /** Photographic */
  140111. Photographic = 3
  140112. }
  140113. /**
  140114. * Defines a post process to apply tone mapping
  140115. */
  140116. export class TonemapPostProcess extends PostProcess {
  140117. private _operator;
  140118. /** Defines the required exposure adjustement */
  140119. exposureAdjustment: number;
  140120. /**
  140121. * Creates a new TonemapPostProcess
  140122. * @param name defines the name of the postprocess
  140123. * @param _operator defines the operator to use
  140124. * @param exposureAdjustment defines the required exposure adjustement
  140125. * @param camera defines the camera to use (can be null)
  140126. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  140127. * @param engine defines the hosting engine (can be ignore if camera is set)
  140128. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140129. */
  140130. constructor(name: string, _operator: TonemappingOperator,
  140131. /** Defines the required exposure adjustement */
  140132. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  140133. }
  140134. }
  140135. declare module BABYLON {
  140136. /** @hidden */
  140137. export var volumetricLightScatteringPixelShader: {
  140138. name: string;
  140139. shader: string;
  140140. };
  140141. }
  140142. declare module BABYLON {
  140143. /** @hidden */
  140144. export var volumetricLightScatteringPassVertexShader: {
  140145. name: string;
  140146. shader: string;
  140147. };
  140148. }
  140149. declare module BABYLON {
  140150. /** @hidden */
  140151. export var volumetricLightScatteringPassPixelShader: {
  140152. name: string;
  140153. shader: string;
  140154. };
  140155. }
  140156. declare module BABYLON {
  140157. /**
  140158. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  140159. */
  140160. export class VolumetricLightScatteringPostProcess extends PostProcess {
  140161. private _volumetricLightScatteringPass;
  140162. private _volumetricLightScatteringRTT;
  140163. private _viewPort;
  140164. private _screenCoordinates;
  140165. private _cachedDefines;
  140166. /**
  140167. * If not undefined, the mesh position is computed from the attached node position
  140168. */
  140169. attachedNode: {
  140170. position: Vector3;
  140171. };
  140172. /**
  140173. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  140174. */
  140175. customMeshPosition: Vector3;
  140176. /**
  140177. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  140178. */
  140179. useCustomMeshPosition: boolean;
  140180. /**
  140181. * If the post-process should inverse the light scattering direction
  140182. */
  140183. invert: boolean;
  140184. /**
  140185. * The internal mesh used by the post-process
  140186. */
  140187. mesh: Mesh;
  140188. /**
  140189. * @hidden
  140190. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  140191. */
  140192. get useDiffuseColor(): boolean;
  140193. set useDiffuseColor(useDiffuseColor: boolean);
  140194. /**
  140195. * Array containing the excluded meshes not rendered in the internal pass
  140196. */
  140197. excludedMeshes: AbstractMesh[];
  140198. /**
  140199. * Controls the overall intensity of the post-process
  140200. */
  140201. exposure: number;
  140202. /**
  140203. * Dissipates each sample's contribution in range [0, 1]
  140204. */
  140205. decay: number;
  140206. /**
  140207. * Controls the overall intensity of each sample
  140208. */
  140209. weight: number;
  140210. /**
  140211. * Controls the density of each sample
  140212. */
  140213. density: number;
  140214. /**
  140215. * @constructor
  140216. * @param name The post-process name
  140217. * @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)
  140218. * @param camera The camera that the post-process will be attached to
  140219. * @param mesh The mesh used to create the light scattering
  140220. * @param samples The post-process quality, default 100
  140221. * @param samplingModeThe post-process filtering mode
  140222. * @param engine The babylon engine
  140223. * @param reusable If the post-process is reusable
  140224. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  140225. */
  140226. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  140227. /**
  140228. * Returns the string "VolumetricLightScatteringPostProcess"
  140229. * @returns "VolumetricLightScatteringPostProcess"
  140230. */
  140231. getClassName(): string;
  140232. private _isReady;
  140233. /**
  140234. * Sets the new light position for light scattering effect
  140235. * @param position The new custom light position
  140236. */
  140237. setCustomMeshPosition(position: Vector3): void;
  140238. /**
  140239. * Returns the light position for light scattering effect
  140240. * @return Vector3 The custom light position
  140241. */
  140242. getCustomMeshPosition(): Vector3;
  140243. /**
  140244. * Disposes the internal assets and detaches the post-process from the camera
  140245. */
  140246. dispose(camera: Camera): void;
  140247. /**
  140248. * Returns the render target texture used by the post-process
  140249. * @return the render target texture used by the post-process
  140250. */
  140251. getPass(): RenderTargetTexture;
  140252. private _meshExcluded;
  140253. private _createPass;
  140254. private _updateMeshScreenCoordinates;
  140255. /**
  140256. * Creates a default mesh for the Volumeric Light Scattering post-process
  140257. * @param name The mesh name
  140258. * @param scene The scene where to create the mesh
  140259. * @return the default mesh
  140260. */
  140261. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  140262. }
  140263. }
  140264. declare module BABYLON {
  140265. interface Scene {
  140266. /** @hidden (Backing field) */
  140267. _boundingBoxRenderer: BoundingBoxRenderer;
  140268. /** @hidden (Backing field) */
  140269. _forceShowBoundingBoxes: boolean;
  140270. /**
  140271. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  140272. */
  140273. forceShowBoundingBoxes: boolean;
  140274. /**
  140275. * Gets the bounding box renderer associated with the scene
  140276. * @returns a BoundingBoxRenderer
  140277. */
  140278. getBoundingBoxRenderer(): BoundingBoxRenderer;
  140279. }
  140280. interface AbstractMesh {
  140281. /** @hidden (Backing field) */
  140282. _showBoundingBox: boolean;
  140283. /**
  140284. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  140285. */
  140286. showBoundingBox: boolean;
  140287. }
  140288. /**
  140289. * Component responsible of rendering the bounding box of the meshes in a scene.
  140290. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  140291. */
  140292. export class BoundingBoxRenderer implements ISceneComponent {
  140293. /**
  140294. * The component name helpfull to identify the component in the list of scene components.
  140295. */
  140296. readonly name: string;
  140297. /**
  140298. * The scene the component belongs to.
  140299. */
  140300. scene: Scene;
  140301. /**
  140302. * Color of the bounding box lines placed in front of an object
  140303. */
  140304. frontColor: Color3;
  140305. /**
  140306. * Color of the bounding box lines placed behind an object
  140307. */
  140308. backColor: Color3;
  140309. /**
  140310. * Defines if the renderer should show the back lines or not
  140311. */
  140312. showBackLines: boolean;
  140313. /**
  140314. * @hidden
  140315. */
  140316. renderList: SmartArray<BoundingBox>;
  140317. private _colorShader;
  140318. private _vertexBuffers;
  140319. private _indexBuffer;
  140320. private _fillIndexBuffer;
  140321. private _fillIndexData;
  140322. /**
  140323. * Instantiates a new bounding box renderer in a scene.
  140324. * @param scene the scene the renderer renders in
  140325. */
  140326. constructor(scene: Scene);
  140327. /**
  140328. * Registers the component in a given scene
  140329. */
  140330. register(): void;
  140331. private _evaluateSubMesh;
  140332. private _activeMesh;
  140333. private _prepareRessources;
  140334. private _createIndexBuffer;
  140335. /**
  140336. * Rebuilds the elements related to this component in case of
  140337. * context lost for instance.
  140338. */
  140339. rebuild(): void;
  140340. /**
  140341. * @hidden
  140342. */
  140343. reset(): void;
  140344. /**
  140345. * Render the bounding boxes of a specific rendering group
  140346. * @param renderingGroupId defines the rendering group to render
  140347. */
  140348. render(renderingGroupId: number): void;
  140349. /**
  140350. * In case of occlusion queries, we can render the occlusion bounding box through this method
  140351. * @param mesh Define the mesh to render the occlusion bounding box for
  140352. */
  140353. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  140354. /**
  140355. * Dispose and release the resources attached to this renderer.
  140356. */
  140357. dispose(): void;
  140358. }
  140359. }
  140360. declare module BABYLON {
  140361. interface Scene {
  140362. /** @hidden (Backing field) */
  140363. _depthRenderer: {
  140364. [id: string]: DepthRenderer;
  140365. };
  140366. /**
  140367. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  140368. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  140369. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140370. * @returns the created depth renderer
  140371. */
  140372. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  140373. /**
  140374. * Disables a depth renderer for a given camera
  140375. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  140376. */
  140377. disableDepthRenderer(camera?: Nullable<Camera>): void;
  140378. }
  140379. /**
  140380. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  140381. * in several rendering techniques.
  140382. */
  140383. export class DepthRendererSceneComponent implements ISceneComponent {
  140384. /**
  140385. * The component name helpfull to identify the component in the list of scene components.
  140386. */
  140387. readonly name: string;
  140388. /**
  140389. * The scene the component belongs to.
  140390. */
  140391. scene: Scene;
  140392. /**
  140393. * Creates a new instance of the component for the given scene
  140394. * @param scene Defines the scene to register the component in
  140395. */
  140396. constructor(scene: Scene);
  140397. /**
  140398. * Registers the component in a given scene
  140399. */
  140400. register(): void;
  140401. /**
  140402. * Rebuilds the elements related to this component in case of
  140403. * context lost for instance.
  140404. */
  140405. rebuild(): void;
  140406. /**
  140407. * Disposes the component and the associated ressources
  140408. */
  140409. dispose(): void;
  140410. private _gatherRenderTargets;
  140411. private _gatherActiveCameraRenderTargets;
  140412. }
  140413. }
  140414. declare module BABYLON {
  140415. /** @hidden */
  140416. export var outlinePixelShader: {
  140417. name: string;
  140418. shader: string;
  140419. };
  140420. }
  140421. declare module BABYLON {
  140422. /** @hidden */
  140423. export var outlineVertexShader: {
  140424. name: string;
  140425. shader: string;
  140426. };
  140427. }
  140428. declare module BABYLON {
  140429. interface Scene {
  140430. /** @hidden */
  140431. _outlineRenderer: OutlineRenderer;
  140432. /**
  140433. * Gets the outline renderer associated with the scene
  140434. * @returns a OutlineRenderer
  140435. */
  140436. getOutlineRenderer(): OutlineRenderer;
  140437. }
  140438. interface AbstractMesh {
  140439. /** @hidden (Backing field) */
  140440. _renderOutline: boolean;
  140441. /**
  140442. * Gets or sets a boolean indicating if the outline must be rendered as well
  140443. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  140444. */
  140445. renderOutline: boolean;
  140446. /** @hidden (Backing field) */
  140447. _renderOverlay: boolean;
  140448. /**
  140449. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140450. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140451. */
  140452. renderOverlay: boolean;
  140453. }
  140454. /**
  140455. * This class is responsible to draw bothe outline/overlay of meshes.
  140456. * It should not be used directly but through the available method on mesh.
  140457. */
  140458. export class OutlineRenderer implements ISceneComponent {
  140459. /**
  140460. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140461. */
  140462. private static _StencilReference;
  140463. /**
  140464. * The name of the component. Each component must have a unique name.
  140465. */
  140466. name: string;
  140467. /**
  140468. * The scene the component belongs to.
  140469. */
  140470. scene: Scene;
  140471. /**
  140472. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140473. */
  140474. zOffset: number;
  140475. private _engine;
  140476. private _effect;
  140477. private _cachedDefines;
  140478. private _savedDepthWrite;
  140479. /**
  140480. * Instantiates a new outline renderer. (There could be only one per scene).
  140481. * @param scene Defines the scene it belongs to
  140482. */
  140483. constructor(scene: Scene);
  140484. /**
  140485. * Register the component to one instance of a scene.
  140486. */
  140487. register(): void;
  140488. /**
  140489. * Rebuilds the elements related to this component in case of
  140490. * context lost for instance.
  140491. */
  140492. rebuild(): void;
  140493. /**
  140494. * Disposes the component and the associated ressources.
  140495. */
  140496. dispose(): void;
  140497. /**
  140498. * Renders the outline in the canvas.
  140499. * @param subMesh Defines the sumesh to render
  140500. * @param batch Defines the batch of meshes in case of instances
  140501. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140502. */
  140503. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140504. /**
  140505. * Returns whether or not the outline renderer is ready for a given submesh.
  140506. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140507. * @param subMesh Defines the submesh to check readyness for
  140508. * @param useInstances Defines wheter wee are trying to render instances or not
  140509. * @returns true if ready otherwise false
  140510. */
  140511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140512. private _beforeRenderingMesh;
  140513. private _afterRenderingMesh;
  140514. }
  140515. }
  140516. declare module BABYLON {
  140517. /**
  140518. * Defines the basic options interface of a Sprite Frame Source Size.
  140519. */
  140520. export interface ISpriteJSONSpriteSourceSize {
  140521. /**
  140522. * number of the original width of the Frame
  140523. */
  140524. w: number;
  140525. /**
  140526. * number of the original height of the Frame
  140527. */
  140528. h: number;
  140529. }
  140530. /**
  140531. * Defines the basic options interface of a Sprite Frame Data.
  140532. */
  140533. export interface ISpriteJSONSpriteFrameData {
  140534. /**
  140535. * number of the x offset of the Frame
  140536. */
  140537. x: number;
  140538. /**
  140539. * number of the y offset of the Frame
  140540. */
  140541. y: number;
  140542. /**
  140543. * number of the width of the Frame
  140544. */
  140545. w: number;
  140546. /**
  140547. * number of the height of the Frame
  140548. */
  140549. h: number;
  140550. }
  140551. /**
  140552. * Defines the basic options interface of a JSON Sprite.
  140553. */
  140554. export interface ISpriteJSONSprite {
  140555. /**
  140556. * string name of the Frame
  140557. */
  140558. filename: string;
  140559. /**
  140560. * ISpriteJSONSpriteFrame basic object of the frame data
  140561. */
  140562. frame: ISpriteJSONSpriteFrameData;
  140563. /**
  140564. * boolean to flag is the frame was rotated.
  140565. */
  140566. rotated: boolean;
  140567. /**
  140568. * boolean to flag is the frame was trimmed.
  140569. */
  140570. trimmed: boolean;
  140571. /**
  140572. * ISpriteJSONSpriteFrame basic object of the source data
  140573. */
  140574. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140575. /**
  140576. * ISpriteJSONSpriteFrame basic object of the source data
  140577. */
  140578. sourceSize: ISpriteJSONSpriteSourceSize;
  140579. }
  140580. /**
  140581. * Defines the basic options interface of a JSON atlas.
  140582. */
  140583. export interface ISpriteJSONAtlas {
  140584. /**
  140585. * Array of objects that contain the frame data.
  140586. */
  140587. frames: Array<ISpriteJSONSprite>;
  140588. /**
  140589. * object basic object containing the sprite meta data.
  140590. */
  140591. meta?: object;
  140592. }
  140593. }
  140594. declare module BABYLON {
  140595. /** @hidden */
  140596. export var spriteMapPixelShader: {
  140597. name: string;
  140598. shader: string;
  140599. };
  140600. }
  140601. declare module BABYLON {
  140602. /** @hidden */
  140603. export var spriteMapVertexShader: {
  140604. name: string;
  140605. shader: string;
  140606. };
  140607. }
  140608. declare module BABYLON {
  140609. /**
  140610. * Defines the basic options interface of a SpriteMap
  140611. */
  140612. export interface ISpriteMapOptions {
  140613. /**
  140614. * Vector2 of the number of cells in the grid.
  140615. */
  140616. stageSize?: Vector2;
  140617. /**
  140618. * Vector2 of the size of the output plane in World Units.
  140619. */
  140620. outputSize?: Vector2;
  140621. /**
  140622. * Vector3 of the position of the output plane in World Units.
  140623. */
  140624. outputPosition?: Vector3;
  140625. /**
  140626. * Vector3 of the rotation of the output plane.
  140627. */
  140628. outputRotation?: Vector3;
  140629. /**
  140630. * number of layers that the system will reserve in resources.
  140631. */
  140632. layerCount?: number;
  140633. /**
  140634. * number of max animation frames a single cell will reserve in resources.
  140635. */
  140636. maxAnimationFrames?: number;
  140637. /**
  140638. * number cell index of the base tile when the system compiles.
  140639. */
  140640. baseTile?: number;
  140641. /**
  140642. * boolean flip the sprite after its been repositioned by the framing data.
  140643. */
  140644. flipU?: boolean;
  140645. /**
  140646. * Vector3 scalar of the global RGB values of the SpriteMap.
  140647. */
  140648. colorMultiply?: Vector3;
  140649. }
  140650. /**
  140651. * Defines the IDisposable interface in order to be cleanable from resources.
  140652. */
  140653. export interface ISpriteMap extends IDisposable {
  140654. /**
  140655. * String name of the SpriteMap.
  140656. */
  140657. name: string;
  140658. /**
  140659. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140660. */
  140661. atlasJSON: ISpriteJSONAtlas;
  140662. /**
  140663. * Texture of the SpriteMap.
  140664. */
  140665. spriteSheet: Texture;
  140666. /**
  140667. * The parameters to initialize the SpriteMap with.
  140668. */
  140669. options: ISpriteMapOptions;
  140670. }
  140671. /**
  140672. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140673. */
  140674. export class SpriteMap implements ISpriteMap {
  140675. /** The Name of the spriteMap */
  140676. name: string;
  140677. /** The JSON file with the frame and meta data */
  140678. atlasJSON: ISpriteJSONAtlas;
  140679. /** The systems Sprite Sheet Texture */
  140680. spriteSheet: Texture;
  140681. /** Arguments passed with the Constructor */
  140682. options: ISpriteMapOptions;
  140683. /** Public Sprite Storage array, parsed from atlasJSON */
  140684. sprites: Array<ISpriteJSONSprite>;
  140685. /** Returns the Number of Sprites in the System */
  140686. get spriteCount(): number;
  140687. /** Returns the Position of Output Plane*/
  140688. get position(): Vector3;
  140689. /** Returns the Position of Output Plane*/
  140690. set position(v: Vector3);
  140691. /** Returns the Rotation of Output Plane*/
  140692. get rotation(): Vector3;
  140693. /** Returns the Rotation of Output Plane*/
  140694. set rotation(v: Vector3);
  140695. /** Sets the AnimationMap*/
  140696. get animationMap(): RawTexture;
  140697. /** Sets the AnimationMap*/
  140698. set animationMap(v: RawTexture);
  140699. /** Scene that the SpriteMap was created in */
  140700. private _scene;
  140701. /** Texture Buffer of Float32 that holds tile frame data*/
  140702. private _frameMap;
  140703. /** Texture Buffers of Float32 that holds tileMap data*/
  140704. private _tileMaps;
  140705. /** Texture Buffer of Float32 that holds Animation Data*/
  140706. private _animationMap;
  140707. /** Custom ShaderMaterial Central to the System*/
  140708. private _material;
  140709. /** Custom ShaderMaterial Central to the System*/
  140710. private _output;
  140711. /** Systems Time Ticker*/
  140712. private _time;
  140713. /**
  140714. * Creates a new SpriteMap
  140715. * @param name defines the SpriteMaps Name
  140716. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140717. * @param spriteSheet is the Texture that the Sprites are on.
  140718. * @param options a basic deployment configuration
  140719. * @param scene The Scene that the map is deployed on
  140720. */
  140721. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140722. /**
  140723. * Returns tileID location
  140724. * @returns Vector2 the cell position ID
  140725. */
  140726. getTileID(): Vector2;
  140727. /**
  140728. * Gets the UV location of the mouse over the SpriteMap.
  140729. * @returns Vector2 the UV position of the mouse interaction
  140730. */
  140731. getMousePosition(): Vector2;
  140732. /**
  140733. * Creates the "frame" texture Buffer
  140734. * -------------------------------------
  140735. * Structure of frames
  140736. * "filename": "Falling-Water-2.png",
  140737. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140738. * "rotated": true,
  140739. * "trimmed": true,
  140740. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140741. * "sourceSize": {"w":32,"h":32}
  140742. * @returns RawTexture of the frameMap
  140743. */
  140744. private _createFrameBuffer;
  140745. /**
  140746. * Creates the tileMap texture Buffer
  140747. * @param buffer normally and array of numbers, or a false to generate from scratch
  140748. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140749. * @returns RawTexture of the tileMap
  140750. */
  140751. private _createTileBuffer;
  140752. /**
  140753. * Modifies the data of the tileMaps
  140754. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140755. * @param pos is the iVector2 Coordinates of the Tile
  140756. * @param tile The SpriteIndex of the new Tile
  140757. */
  140758. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140759. /**
  140760. * Creates the animationMap texture Buffer
  140761. * @param buffer normally and array of numbers, or a false to generate from scratch
  140762. * @returns RawTexture of the animationMap
  140763. */
  140764. private _createTileAnimationBuffer;
  140765. /**
  140766. * Modifies the data of the animationMap
  140767. * @param cellID is the Index of the Sprite
  140768. * @param _frame is the target Animation frame
  140769. * @param toCell is the Target Index of the next frame of the animation
  140770. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140771. * @param speed is a global scalar of the time variable on the map.
  140772. */
  140773. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140774. /**
  140775. * Exports the .tilemaps file
  140776. */
  140777. saveTileMaps(): void;
  140778. /**
  140779. * Imports the .tilemaps file
  140780. * @param url of the .tilemaps file
  140781. */
  140782. loadTileMaps(url: string): void;
  140783. /**
  140784. * Release associated resources
  140785. */
  140786. dispose(): void;
  140787. }
  140788. }
  140789. declare module BABYLON {
  140790. /**
  140791. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140792. * @see http://doc.babylonjs.com/babylon101/sprites
  140793. */
  140794. export class SpritePackedManager extends SpriteManager {
  140795. /** defines the packed manager's name */
  140796. name: string;
  140797. /**
  140798. * Creates a new sprite manager from a packed sprite sheet
  140799. * @param name defines the manager's name
  140800. * @param imgUrl defines the sprite sheet url
  140801. * @param capacity defines the maximum allowed number of sprites
  140802. * @param scene defines the hosting scene
  140803. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140804. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140805. * @param samplingMode defines the smapling mode to use with spritesheet
  140806. * @param fromPacked set to true; do not alter
  140807. */
  140808. constructor(
  140809. /** defines the packed manager's name */
  140810. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140811. }
  140812. }
  140813. declare module BABYLON {
  140814. /**
  140815. * Defines the list of states available for a task inside a AssetsManager
  140816. */
  140817. export enum AssetTaskState {
  140818. /**
  140819. * Initialization
  140820. */
  140821. INIT = 0,
  140822. /**
  140823. * Running
  140824. */
  140825. RUNNING = 1,
  140826. /**
  140827. * Done
  140828. */
  140829. DONE = 2,
  140830. /**
  140831. * Error
  140832. */
  140833. ERROR = 3
  140834. }
  140835. /**
  140836. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140837. */
  140838. export abstract class AbstractAssetTask {
  140839. /**
  140840. * Task name
  140841. */ name: string;
  140842. /**
  140843. * Callback called when the task is successful
  140844. */
  140845. onSuccess: (task: any) => void;
  140846. /**
  140847. * Callback called when the task is not successful
  140848. */
  140849. onError: (task: any, message?: string, exception?: any) => void;
  140850. /**
  140851. * Creates a new AssetsManager
  140852. * @param name defines the name of the task
  140853. */
  140854. constructor(
  140855. /**
  140856. * Task name
  140857. */ name: string);
  140858. private _isCompleted;
  140859. private _taskState;
  140860. private _errorObject;
  140861. /**
  140862. * Get if the task is completed
  140863. */
  140864. get isCompleted(): boolean;
  140865. /**
  140866. * Gets the current state of the task
  140867. */
  140868. get taskState(): AssetTaskState;
  140869. /**
  140870. * Gets the current error object (if task is in error)
  140871. */
  140872. get errorObject(): {
  140873. message?: string;
  140874. exception?: any;
  140875. };
  140876. /**
  140877. * Internal only
  140878. * @hidden
  140879. */
  140880. _setErrorObject(message?: string, exception?: any): void;
  140881. /**
  140882. * Execute the current task
  140883. * @param scene defines the scene where you want your assets to be loaded
  140884. * @param onSuccess is a callback called when the task is successfully executed
  140885. * @param onError is a callback called if an error occurs
  140886. */
  140887. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140888. /**
  140889. * Execute the current task
  140890. * @param scene defines the scene where you want your assets to be loaded
  140891. * @param onSuccess is a callback called when the task is successfully executed
  140892. * @param onError is a callback called if an error occurs
  140893. */
  140894. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140895. /**
  140896. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140897. * This can be used with failed tasks that have the reason for failure fixed.
  140898. */
  140899. reset(): void;
  140900. private onErrorCallback;
  140901. private onDoneCallback;
  140902. }
  140903. /**
  140904. * Define the interface used by progress events raised during assets loading
  140905. */
  140906. export interface IAssetsProgressEvent {
  140907. /**
  140908. * Defines the number of remaining tasks to process
  140909. */
  140910. remainingCount: number;
  140911. /**
  140912. * Defines the total number of tasks
  140913. */
  140914. totalCount: number;
  140915. /**
  140916. * Defines the task that was just processed
  140917. */
  140918. task: AbstractAssetTask;
  140919. }
  140920. /**
  140921. * Class used to share progress information about assets loading
  140922. */
  140923. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140924. /**
  140925. * Defines the number of remaining tasks to process
  140926. */
  140927. remainingCount: number;
  140928. /**
  140929. * Defines the total number of tasks
  140930. */
  140931. totalCount: number;
  140932. /**
  140933. * Defines the task that was just processed
  140934. */
  140935. task: AbstractAssetTask;
  140936. /**
  140937. * Creates a AssetsProgressEvent
  140938. * @param remainingCount defines the number of remaining tasks to process
  140939. * @param totalCount defines the total number of tasks
  140940. * @param task defines the task that was just processed
  140941. */
  140942. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140943. }
  140944. /**
  140945. * Define a task used by AssetsManager to load meshes
  140946. */
  140947. export class MeshAssetTask extends AbstractAssetTask {
  140948. /**
  140949. * Defines the name of the task
  140950. */
  140951. name: string;
  140952. /**
  140953. * Defines the list of mesh's names you want to load
  140954. */
  140955. meshesNames: any;
  140956. /**
  140957. * Defines the root url to use as a base to load your meshes and associated resources
  140958. */
  140959. rootUrl: string;
  140960. /**
  140961. * Defines the filename of the scene to load from
  140962. */
  140963. sceneFilename: string;
  140964. /**
  140965. * Gets the list of loaded meshes
  140966. */
  140967. loadedMeshes: Array<AbstractMesh>;
  140968. /**
  140969. * Gets the list of loaded particle systems
  140970. */
  140971. loadedParticleSystems: Array<IParticleSystem>;
  140972. /**
  140973. * Gets the list of loaded skeletons
  140974. */
  140975. loadedSkeletons: Array<Skeleton>;
  140976. /**
  140977. * Gets the list of loaded animation groups
  140978. */
  140979. loadedAnimationGroups: Array<AnimationGroup>;
  140980. /**
  140981. * Callback called when the task is successful
  140982. */
  140983. onSuccess: (task: MeshAssetTask) => void;
  140984. /**
  140985. * Callback called when the task is successful
  140986. */
  140987. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140988. /**
  140989. * Creates a new MeshAssetTask
  140990. * @param name defines the name of the task
  140991. * @param meshesNames defines the list of mesh's names you want to load
  140992. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140993. * @param sceneFilename defines the filename of the scene to load from
  140994. */
  140995. constructor(
  140996. /**
  140997. * Defines the name of the task
  140998. */
  140999. name: string,
  141000. /**
  141001. * Defines the list of mesh's names you want to load
  141002. */
  141003. meshesNames: any,
  141004. /**
  141005. * Defines the root url to use as a base to load your meshes and associated resources
  141006. */
  141007. rootUrl: string,
  141008. /**
  141009. * Defines the filename of the scene to load from
  141010. */
  141011. sceneFilename: string);
  141012. /**
  141013. * Execute the current task
  141014. * @param scene defines the scene where you want your assets to be loaded
  141015. * @param onSuccess is a callback called when the task is successfully executed
  141016. * @param onError is a callback called if an error occurs
  141017. */
  141018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141019. }
  141020. /**
  141021. * Define a task used by AssetsManager to load text content
  141022. */
  141023. export class TextFileAssetTask extends AbstractAssetTask {
  141024. /**
  141025. * Defines the name of the task
  141026. */
  141027. name: string;
  141028. /**
  141029. * Defines the location of the file to load
  141030. */
  141031. url: string;
  141032. /**
  141033. * Gets the loaded text string
  141034. */
  141035. text: string;
  141036. /**
  141037. * Callback called when the task is successful
  141038. */
  141039. onSuccess: (task: TextFileAssetTask) => void;
  141040. /**
  141041. * Callback called when the task is successful
  141042. */
  141043. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  141044. /**
  141045. * Creates a new TextFileAssetTask object
  141046. * @param name defines the name of the task
  141047. * @param url defines the location of the file to load
  141048. */
  141049. constructor(
  141050. /**
  141051. * Defines the name of the task
  141052. */
  141053. name: string,
  141054. /**
  141055. * Defines the location of the file to load
  141056. */
  141057. url: string);
  141058. /**
  141059. * Execute the current task
  141060. * @param scene defines the scene where you want your assets to be loaded
  141061. * @param onSuccess is a callback called when the task is successfully executed
  141062. * @param onError is a callback called if an error occurs
  141063. */
  141064. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141065. }
  141066. /**
  141067. * Define a task used by AssetsManager to load binary data
  141068. */
  141069. export class BinaryFileAssetTask extends AbstractAssetTask {
  141070. /**
  141071. * Defines the name of the task
  141072. */
  141073. name: string;
  141074. /**
  141075. * Defines the location of the file to load
  141076. */
  141077. url: string;
  141078. /**
  141079. * Gets the lodaded data (as an array buffer)
  141080. */
  141081. data: ArrayBuffer;
  141082. /**
  141083. * Callback called when the task is successful
  141084. */
  141085. onSuccess: (task: BinaryFileAssetTask) => void;
  141086. /**
  141087. * Callback called when the task is successful
  141088. */
  141089. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  141090. /**
  141091. * Creates a new BinaryFileAssetTask object
  141092. * @param name defines the name of the new task
  141093. * @param url defines the location of the file to load
  141094. */
  141095. constructor(
  141096. /**
  141097. * Defines the name of the task
  141098. */
  141099. name: string,
  141100. /**
  141101. * Defines the location of the file to load
  141102. */
  141103. url: string);
  141104. /**
  141105. * Execute the current task
  141106. * @param scene defines the scene where you want your assets to be loaded
  141107. * @param onSuccess is a callback called when the task is successfully executed
  141108. * @param onError is a callback called if an error occurs
  141109. */
  141110. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141111. }
  141112. /**
  141113. * Define a task used by AssetsManager to load images
  141114. */
  141115. export class ImageAssetTask extends AbstractAssetTask {
  141116. /**
  141117. * Defines the name of the task
  141118. */
  141119. name: string;
  141120. /**
  141121. * Defines the location of the image to load
  141122. */
  141123. url: string;
  141124. /**
  141125. * Gets the loaded images
  141126. */
  141127. image: HTMLImageElement;
  141128. /**
  141129. * Callback called when the task is successful
  141130. */
  141131. onSuccess: (task: ImageAssetTask) => void;
  141132. /**
  141133. * Callback called when the task is successful
  141134. */
  141135. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  141136. /**
  141137. * Creates a new ImageAssetTask
  141138. * @param name defines the name of the task
  141139. * @param url defines the location of the image to load
  141140. */
  141141. constructor(
  141142. /**
  141143. * Defines the name of the task
  141144. */
  141145. name: string,
  141146. /**
  141147. * Defines the location of the image to load
  141148. */
  141149. url: string);
  141150. /**
  141151. * Execute the current task
  141152. * @param scene defines the scene where you want your assets to be loaded
  141153. * @param onSuccess is a callback called when the task is successfully executed
  141154. * @param onError is a callback called if an error occurs
  141155. */
  141156. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141157. }
  141158. /**
  141159. * Defines the interface used by texture loading tasks
  141160. */
  141161. export interface ITextureAssetTask<TEX extends BaseTexture> {
  141162. /**
  141163. * Gets the loaded texture
  141164. */
  141165. texture: TEX;
  141166. }
  141167. /**
  141168. * Define a task used by AssetsManager to load 2D textures
  141169. */
  141170. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  141171. /**
  141172. * Defines the name of the task
  141173. */
  141174. name: string;
  141175. /**
  141176. * Defines the location of the file to load
  141177. */
  141178. url: string;
  141179. /**
  141180. * Defines if mipmap should not be generated (default is false)
  141181. */
  141182. noMipmap?: boolean | undefined;
  141183. /**
  141184. * Defines if texture must be inverted on Y axis (default is false)
  141185. */
  141186. invertY?: boolean | undefined;
  141187. /**
  141188. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141189. */
  141190. samplingMode: number;
  141191. /**
  141192. * Gets the loaded texture
  141193. */
  141194. texture: Texture;
  141195. /**
  141196. * Callback called when the task is successful
  141197. */
  141198. onSuccess: (task: TextureAssetTask) => void;
  141199. /**
  141200. * Callback called when the task is successful
  141201. */
  141202. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  141203. /**
  141204. * Creates a new TextureAssetTask object
  141205. * @param name defines the name of the task
  141206. * @param url defines the location of the file to load
  141207. * @param noMipmap defines if mipmap should not be generated (default is false)
  141208. * @param invertY defines if texture must be inverted on Y axis (default is false)
  141209. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141210. */
  141211. constructor(
  141212. /**
  141213. * Defines the name of the task
  141214. */
  141215. name: string,
  141216. /**
  141217. * Defines the location of the file to load
  141218. */
  141219. url: string,
  141220. /**
  141221. * Defines if mipmap should not be generated (default is false)
  141222. */
  141223. noMipmap?: boolean | undefined,
  141224. /**
  141225. * Defines if texture must be inverted on Y axis (default is false)
  141226. */
  141227. invertY?: boolean | undefined,
  141228. /**
  141229. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141230. */
  141231. samplingMode?: number);
  141232. /**
  141233. * Execute the current task
  141234. * @param scene defines the scene where you want your assets to be loaded
  141235. * @param onSuccess is a callback called when the task is successfully executed
  141236. * @param onError is a callback called if an error occurs
  141237. */
  141238. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141239. }
  141240. /**
  141241. * Define a task used by AssetsManager to load cube textures
  141242. */
  141243. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  141244. /**
  141245. * Defines the name of the task
  141246. */
  141247. name: string;
  141248. /**
  141249. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141250. */
  141251. url: string;
  141252. /**
  141253. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141254. */
  141255. extensions?: string[] | undefined;
  141256. /**
  141257. * Defines if mipmaps should not be generated (default is false)
  141258. */
  141259. noMipmap?: boolean | undefined;
  141260. /**
  141261. * Defines the explicit list of files (undefined by default)
  141262. */
  141263. files?: string[] | undefined;
  141264. /**
  141265. * Gets the loaded texture
  141266. */
  141267. texture: CubeTexture;
  141268. /**
  141269. * Callback called when the task is successful
  141270. */
  141271. onSuccess: (task: CubeTextureAssetTask) => void;
  141272. /**
  141273. * Callback called when the task is successful
  141274. */
  141275. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  141276. /**
  141277. * Creates a new CubeTextureAssetTask
  141278. * @param name defines the name of the task
  141279. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141280. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141281. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141282. * @param files defines the explicit list of files (undefined by default)
  141283. */
  141284. constructor(
  141285. /**
  141286. * Defines the name of the task
  141287. */
  141288. name: string,
  141289. /**
  141290. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141291. */
  141292. url: string,
  141293. /**
  141294. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141295. */
  141296. extensions?: string[] | undefined,
  141297. /**
  141298. * Defines if mipmaps should not be generated (default is false)
  141299. */
  141300. noMipmap?: boolean | undefined,
  141301. /**
  141302. * Defines the explicit list of files (undefined by default)
  141303. */
  141304. files?: string[] | undefined);
  141305. /**
  141306. * Execute the current task
  141307. * @param scene defines the scene where you want your assets to be loaded
  141308. * @param onSuccess is a callback called when the task is successfully executed
  141309. * @param onError is a callback called if an error occurs
  141310. */
  141311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141312. }
  141313. /**
  141314. * Define a task used by AssetsManager to load HDR cube textures
  141315. */
  141316. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  141317. /**
  141318. * Defines the name of the task
  141319. */
  141320. name: string;
  141321. /**
  141322. * Defines the location of the file to load
  141323. */
  141324. url: string;
  141325. /**
  141326. * Defines the desired size (the more it increases the longer the generation will be)
  141327. */
  141328. size: number;
  141329. /**
  141330. * Defines if mipmaps should not be generated (default is false)
  141331. */
  141332. noMipmap: boolean;
  141333. /**
  141334. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141335. */
  141336. generateHarmonics: boolean;
  141337. /**
  141338. * 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)
  141339. */
  141340. gammaSpace: boolean;
  141341. /**
  141342. * Internal Use Only
  141343. */
  141344. reserved: boolean;
  141345. /**
  141346. * Gets the loaded texture
  141347. */
  141348. texture: HDRCubeTexture;
  141349. /**
  141350. * Callback called when the task is successful
  141351. */
  141352. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  141353. /**
  141354. * Callback called when the task is successful
  141355. */
  141356. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  141357. /**
  141358. * Creates a new HDRCubeTextureAssetTask object
  141359. * @param name defines the name of the task
  141360. * @param url defines the location of the file to load
  141361. * @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.
  141362. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141363. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141364. * @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)
  141365. * @param reserved Internal use only
  141366. */
  141367. constructor(
  141368. /**
  141369. * Defines the name of the task
  141370. */
  141371. name: string,
  141372. /**
  141373. * Defines the location of the file to load
  141374. */
  141375. url: string,
  141376. /**
  141377. * Defines the desired size (the more it increases the longer the generation will be)
  141378. */
  141379. size: number,
  141380. /**
  141381. * Defines if mipmaps should not be generated (default is false)
  141382. */
  141383. noMipmap?: boolean,
  141384. /**
  141385. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141386. */
  141387. generateHarmonics?: boolean,
  141388. /**
  141389. * 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)
  141390. */
  141391. gammaSpace?: boolean,
  141392. /**
  141393. * Internal Use Only
  141394. */
  141395. reserved?: boolean);
  141396. /**
  141397. * Execute the current task
  141398. * @param scene defines the scene where you want your assets to be loaded
  141399. * @param onSuccess is a callback called when the task is successfully executed
  141400. * @param onError is a callback called if an error occurs
  141401. */
  141402. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141403. }
  141404. /**
  141405. * Define a task used by AssetsManager to load Equirectangular cube textures
  141406. */
  141407. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  141408. /**
  141409. * Defines the name of the task
  141410. */
  141411. name: string;
  141412. /**
  141413. * Defines the location of the file to load
  141414. */
  141415. url: string;
  141416. /**
  141417. * Defines the desired size (the more it increases the longer the generation will be)
  141418. */
  141419. size: number;
  141420. /**
  141421. * Defines if mipmaps should not be generated (default is false)
  141422. */
  141423. noMipmap: boolean;
  141424. /**
  141425. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141426. * but the standard material would require them in Gamma space) (default is true)
  141427. */
  141428. gammaSpace: boolean;
  141429. /**
  141430. * Gets the loaded texture
  141431. */
  141432. texture: EquiRectangularCubeTexture;
  141433. /**
  141434. * Callback called when the task is successful
  141435. */
  141436. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  141437. /**
  141438. * Callback called when the task is successful
  141439. */
  141440. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  141441. /**
  141442. * Creates a new EquiRectangularCubeTextureAssetTask object
  141443. * @param name defines the name of the task
  141444. * @param url defines the location of the file to load
  141445. * @param size defines the desired size (the more it increases the longer the generation will be)
  141446. * If the size is omitted this implies you are using a preprocessed cubemap.
  141447. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141448. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141449. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141450. * (default is true)
  141451. */
  141452. constructor(
  141453. /**
  141454. * Defines the name of the task
  141455. */
  141456. name: string,
  141457. /**
  141458. * Defines the location of the file to load
  141459. */
  141460. url: string,
  141461. /**
  141462. * Defines the desired size (the more it increases the longer the generation will be)
  141463. */
  141464. size: number,
  141465. /**
  141466. * Defines if mipmaps should not be generated (default is false)
  141467. */
  141468. noMipmap?: boolean,
  141469. /**
  141470. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141471. * but the standard material would require them in Gamma space) (default is true)
  141472. */
  141473. gammaSpace?: boolean);
  141474. /**
  141475. * Execute the current task
  141476. * @param scene defines the scene where you want your assets to be loaded
  141477. * @param onSuccess is a callback called when the task is successfully executed
  141478. * @param onError is a callback called if an error occurs
  141479. */
  141480. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141481. }
  141482. /**
  141483. * This class can be used to easily import assets into a scene
  141484. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141485. */
  141486. export class AssetsManager {
  141487. private _scene;
  141488. private _isLoading;
  141489. protected _tasks: AbstractAssetTask[];
  141490. protected _waitingTasksCount: number;
  141491. protected _totalTasksCount: number;
  141492. /**
  141493. * Callback called when all tasks are processed
  141494. */
  141495. onFinish: (tasks: AbstractAssetTask[]) => void;
  141496. /**
  141497. * Callback called when a task is successful
  141498. */
  141499. onTaskSuccess: (task: AbstractAssetTask) => void;
  141500. /**
  141501. * Callback called when a task had an error
  141502. */
  141503. onTaskError: (task: AbstractAssetTask) => void;
  141504. /**
  141505. * Callback called when a task is done (whatever the result is)
  141506. */
  141507. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141508. /**
  141509. * Observable called when all tasks are processed
  141510. */
  141511. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141512. /**
  141513. * Observable called when a task had an error
  141514. */
  141515. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141516. /**
  141517. * Observable called when all tasks were executed
  141518. */
  141519. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141520. /**
  141521. * Observable called when a task is done (whatever the result is)
  141522. */
  141523. onProgressObservable: Observable<IAssetsProgressEvent>;
  141524. /**
  141525. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141527. */
  141528. useDefaultLoadingScreen: boolean;
  141529. /**
  141530. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141531. * when all assets have been downloaded.
  141532. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141533. */
  141534. autoHideLoadingUI: boolean;
  141535. /**
  141536. * Creates a new AssetsManager
  141537. * @param scene defines the scene to work on
  141538. */
  141539. constructor(scene: Scene);
  141540. /**
  141541. * Add a MeshAssetTask to the list of active tasks
  141542. * @param taskName defines the name of the new task
  141543. * @param meshesNames defines the name of meshes to load
  141544. * @param rootUrl defines the root url to use to locate files
  141545. * @param sceneFilename defines the filename of the scene file
  141546. * @returns a new MeshAssetTask object
  141547. */
  141548. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141549. /**
  141550. * Add a TextFileAssetTask to the list of active tasks
  141551. * @param taskName defines the name of the new task
  141552. * @param url defines the url of the file to load
  141553. * @returns a new TextFileAssetTask object
  141554. */
  141555. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141556. /**
  141557. * Add a BinaryFileAssetTask to the list of active tasks
  141558. * @param taskName defines the name of the new task
  141559. * @param url defines the url of the file to load
  141560. * @returns a new BinaryFileAssetTask object
  141561. */
  141562. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141563. /**
  141564. * Add a ImageAssetTask to the list of active tasks
  141565. * @param taskName defines the name of the new task
  141566. * @param url defines the url of the file to load
  141567. * @returns a new ImageAssetTask object
  141568. */
  141569. addImageTask(taskName: string, url: string): ImageAssetTask;
  141570. /**
  141571. * Add a TextureAssetTask to the list of active tasks
  141572. * @param taskName defines the name of the new task
  141573. * @param url defines the url of the file to load
  141574. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141575. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141576. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141577. * @returns a new TextureAssetTask object
  141578. */
  141579. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141580. /**
  141581. * Add a CubeTextureAssetTask to the list of active tasks
  141582. * @param taskName defines the name of the new task
  141583. * @param url defines the url of the file to load
  141584. * @param extensions defines the extension to use to load the cube map (can be null)
  141585. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141586. * @param files defines the list of files to load (can be null)
  141587. * @returns a new CubeTextureAssetTask object
  141588. */
  141589. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141590. /**
  141591. *
  141592. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141593. * @param taskName defines the name of the new task
  141594. * @param url defines the url of the file to load
  141595. * @param size defines the size you want for the cubemap (can be null)
  141596. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141597. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141598. * @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)
  141599. * @param reserved Internal use only
  141600. * @returns a new HDRCubeTextureAssetTask object
  141601. */
  141602. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141603. /**
  141604. *
  141605. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141606. * @param taskName defines the name of the new task
  141607. * @param url defines the url of the file to load
  141608. * @param size defines the size you want for the cubemap (can be null)
  141609. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141610. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141611. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141612. * @returns a new EquiRectangularCubeTextureAssetTask object
  141613. */
  141614. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141615. /**
  141616. * Remove a task from the assets manager.
  141617. * @param task the task to remove
  141618. */
  141619. removeTask(task: AbstractAssetTask): void;
  141620. private _decreaseWaitingTasksCount;
  141621. private _runTask;
  141622. /**
  141623. * Reset the AssetsManager and remove all tasks
  141624. * @return the current instance of the AssetsManager
  141625. */
  141626. reset(): AssetsManager;
  141627. /**
  141628. * Start the loading process
  141629. * @return the current instance of the AssetsManager
  141630. */
  141631. load(): AssetsManager;
  141632. /**
  141633. * Start the loading process as an async operation
  141634. * @return a promise returning the list of failed tasks
  141635. */
  141636. loadAsync(): Promise<void>;
  141637. }
  141638. }
  141639. declare module BABYLON {
  141640. /**
  141641. * Wrapper class for promise with external resolve and reject.
  141642. */
  141643. export class Deferred<T> {
  141644. /**
  141645. * The promise associated with this deferred object.
  141646. */
  141647. readonly promise: Promise<T>;
  141648. private _resolve;
  141649. private _reject;
  141650. /**
  141651. * The resolve method of the promise associated with this deferred object.
  141652. */
  141653. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141654. /**
  141655. * The reject method of the promise associated with this deferred object.
  141656. */
  141657. get reject(): (reason?: any) => void;
  141658. /**
  141659. * Constructor for this deferred object.
  141660. */
  141661. constructor();
  141662. }
  141663. }
  141664. declare module BABYLON {
  141665. /**
  141666. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141667. */
  141668. export class MeshExploder {
  141669. private _centerMesh;
  141670. private _meshes;
  141671. private _meshesOrigins;
  141672. private _toCenterVectors;
  141673. private _scaledDirection;
  141674. private _newPosition;
  141675. private _centerPosition;
  141676. /**
  141677. * Explodes meshes from a center mesh.
  141678. * @param meshes The meshes to explode.
  141679. * @param centerMesh The mesh to be center of explosion.
  141680. */
  141681. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141682. private _setCenterMesh;
  141683. /**
  141684. * Get class name
  141685. * @returns "MeshExploder"
  141686. */
  141687. getClassName(): string;
  141688. /**
  141689. * "Exploded meshes"
  141690. * @returns Array of meshes with the centerMesh at index 0.
  141691. */
  141692. getMeshes(): Array<Mesh>;
  141693. /**
  141694. * Explodes meshes giving a specific direction
  141695. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141696. */
  141697. explode(direction?: number): void;
  141698. }
  141699. }
  141700. declare module BABYLON {
  141701. /**
  141702. * Class used to help managing file picking and drag'n'drop
  141703. */
  141704. export class FilesInput {
  141705. /**
  141706. * List of files ready to be loaded
  141707. */
  141708. static get FilesToLoad(): {
  141709. [key: string]: File;
  141710. };
  141711. /**
  141712. * Callback called when a file is processed
  141713. */
  141714. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141715. private _engine;
  141716. private _currentScene;
  141717. private _sceneLoadedCallback;
  141718. private _progressCallback;
  141719. private _additionalRenderLoopLogicCallback;
  141720. private _textureLoadingCallback;
  141721. private _startingProcessingFilesCallback;
  141722. private _onReloadCallback;
  141723. private _errorCallback;
  141724. private _elementToMonitor;
  141725. private _sceneFileToLoad;
  141726. private _filesToLoad;
  141727. /**
  141728. * Creates a new FilesInput
  141729. * @param engine defines the rendering engine
  141730. * @param scene defines the hosting scene
  141731. * @param sceneLoadedCallback callback called when scene is loaded
  141732. * @param progressCallback callback called to track progress
  141733. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141734. * @param textureLoadingCallback callback called when a texture is loading
  141735. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141736. * @param onReloadCallback callback called when a reload is requested
  141737. * @param errorCallback callback call if an error occurs
  141738. */
  141739. 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);
  141740. private _dragEnterHandler;
  141741. private _dragOverHandler;
  141742. private _dropHandler;
  141743. /**
  141744. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141745. * @param elementToMonitor defines the DOM element to track
  141746. */
  141747. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141748. /**
  141749. * Release all associated resources
  141750. */
  141751. dispose(): void;
  141752. private renderFunction;
  141753. private drag;
  141754. private drop;
  141755. private _traverseFolder;
  141756. private _processFiles;
  141757. /**
  141758. * Load files from a drop event
  141759. * @param event defines the drop event to use as source
  141760. */
  141761. loadFiles(event: any): void;
  141762. private _processReload;
  141763. /**
  141764. * Reload the current scene from the loaded files
  141765. */
  141766. reload(): void;
  141767. }
  141768. }
  141769. declare module BABYLON {
  141770. /**
  141771. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141773. */
  141774. export class SceneOptimization {
  141775. /**
  141776. * Defines the priority of this optimization (0 by default which means first in the list)
  141777. */
  141778. priority: number;
  141779. /**
  141780. * Gets a string describing the action executed by the current optimization
  141781. * @returns description string
  141782. */
  141783. getDescription(): string;
  141784. /**
  141785. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141786. * @param scene defines the current scene where to apply this optimization
  141787. * @param optimizer defines the current optimizer
  141788. * @returns true if everything that can be done was applied
  141789. */
  141790. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141791. /**
  141792. * Creates the SceneOptimization object
  141793. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141794. * @param desc defines the description associated with the optimization
  141795. */
  141796. constructor(
  141797. /**
  141798. * Defines the priority of this optimization (0 by default which means first in the list)
  141799. */
  141800. priority?: number);
  141801. }
  141802. /**
  141803. * Defines an optimization used to reduce the size of render target textures
  141804. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141805. */
  141806. export class TextureOptimization extends SceneOptimization {
  141807. /**
  141808. * Defines the priority of this optimization (0 by default which means first in the list)
  141809. */
  141810. priority: number;
  141811. /**
  141812. * 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
  141813. */
  141814. maximumSize: number;
  141815. /**
  141816. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141817. */
  141818. step: number;
  141819. /**
  141820. * Gets a string describing the action executed by the current optimization
  141821. * @returns description string
  141822. */
  141823. getDescription(): string;
  141824. /**
  141825. * Creates the TextureOptimization object
  141826. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141827. * @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
  141828. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141829. */
  141830. constructor(
  141831. /**
  141832. * Defines the priority of this optimization (0 by default which means first in the list)
  141833. */
  141834. priority?: number,
  141835. /**
  141836. * 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
  141837. */
  141838. maximumSize?: number,
  141839. /**
  141840. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141841. */
  141842. step?: number);
  141843. /**
  141844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141845. * @param scene defines the current scene where to apply this optimization
  141846. * @param optimizer defines the current optimizer
  141847. * @returns true if everything that can be done was applied
  141848. */
  141849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141850. }
  141851. /**
  141852. * Defines an optimization used to increase or decrease the rendering resolution
  141853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141854. */
  141855. export class HardwareScalingOptimization extends SceneOptimization {
  141856. /**
  141857. * Defines the priority of this optimization (0 by default which means first in the list)
  141858. */
  141859. priority: number;
  141860. /**
  141861. * Defines the maximum scale to use (2 by default)
  141862. */
  141863. maximumScale: number;
  141864. /**
  141865. * Defines the step to use between two passes (0.5 by default)
  141866. */
  141867. step: number;
  141868. private _currentScale;
  141869. private _directionOffset;
  141870. /**
  141871. * Gets a string describing the action executed by the current optimization
  141872. * @return description string
  141873. */
  141874. getDescription(): string;
  141875. /**
  141876. * Creates the HardwareScalingOptimization object
  141877. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141878. * @param maximumScale defines the maximum scale to use (2 by default)
  141879. * @param step defines the step to use between two passes (0.5 by default)
  141880. */
  141881. constructor(
  141882. /**
  141883. * Defines the priority of this optimization (0 by default which means first in the list)
  141884. */
  141885. priority?: number,
  141886. /**
  141887. * Defines the maximum scale to use (2 by default)
  141888. */
  141889. maximumScale?: number,
  141890. /**
  141891. * Defines the step to use between two passes (0.5 by default)
  141892. */
  141893. step?: number);
  141894. /**
  141895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141896. * @param scene defines the current scene where to apply this optimization
  141897. * @param optimizer defines the current optimizer
  141898. * @returns true if everything that can be done was applied
  141899. */
  141900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141901. }
  141902. /**
  141903. * Defines an optimization used to remove shadows
  141904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141905. */
  141906. export class ShadowsOptimization extends SceneOptimization {
  141907. /**
  141908. * Gets a string describing the action executed by the current optimization
  141909. * @return description string
  141910. */
  141911. getDescription(): string;
  141912. /**
  141913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141914. * @param scene defines the current scene where to apply this optimization
  141915. * @param optimizer defines the current optimizer
  141916. * @returns true if everything that can be done was applied
  141917. */
  141918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141919. }
  141920. /**
  141921. * Defines an optimization used to turn post-processes off
  141922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141923. */
  141924. export class PostProcessesOptimization extends SceneOptimization {
  141925. /**
  141926. * Gets a string describing the action executed by the current optimization
  141927. * @return description string
  141928. */
  141929. getDescription(): string;
  141930. /**
  141931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141932. * @param scene defines the current scene where to apply this optimization
  141933. * @param optimizer defines the current optimizer
  141934. * @returns true if everything that can be done was applied
  141935. */
  141936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141937. }
  141938. /**
  141939. * Defines an optimization used to turn lens flares off
  141940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141941. */
  141942. export class LensFlaresOptimization extends SceneOptimization {
  141943. /**
  141944. * Gets a string describing the action executed by the current optimization
  141945. * @return description string
  141946. */
  141947. getDescription(): string;
  141948. /**
  141949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141950. * @param scene defines the current scene where to apply this optimization
  141951. * @param optimizer defines the current optimizer
  141952. * @returns true if everything that can be done was applied
  141953. */
  141954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141955. }
  141956. /**
  141957. * Defines an optimization based on user defined callback.
  141958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141959. */
  141960. export class CustomOptimization extends SceneOptimization {
  141961. /**
  141962. * Callback called to apply the custom optimization.
  141963. */
  141964. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141965. /**
  141966. * Callback called to get custom description
  141967. */
  141968. onGetDescription: () => string;
  141969. /**
  141970. * Gets a string describing the action executed by the current optimization
  141971. * @returns description string
  141972. */
  141973. getDescription(): string;
  141974. /**
  141975. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141976. * @param scene defines the current scene where to apply this optimization
  141977. * @param optimizer defines the current optimizer
  141978. * @returns true if everything that can be done was applied
  141979. */
  141980. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141981. }
  141982. /**
  141983. * Defines an optimization used to turn particles off
  141984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141985. */
  141986. export class ParticlesOptimization extends SceneOptimization {
  141987. /**
  141988. * Gets a string describing the action executed by the current optimization
  141989. * @return description string
  141990. */
  141991. getDescription(): string;
  141992. /**
  141993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141994. * @param scene defines the current scene where to apply this optimization
  141995. * @param optimizer defines the current optimizer
  141996. * @returns true if everything that can be done was applied
  141997. */
  141998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141999. }
  142000. /**
  142001. * Defines an optimization used to turn render targets off
  142002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142003. */
  142004. export class RenderTargetsOptimization extends SceneOptimization {
  142005. /**
  142006. * Gets a string describing the action executed by the current optimization
  142007. * @return description string
  142008. */
  142009. getDescription(): string;
  142010. /**
  142011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142012. * @param scene defines the current scene where to apply this optimization
  142013. * @param optimizer defines the current optimizer
  142014. * @returns true if everything that can be done was applied
  142015. */
  142016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142017. }
  142018. /**
  142019. * Defines an optimization used to merge meshes with compatible materials
  142020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142021. */
  142022. export class MergeMeshesOptimization extends SceneOptimization {
  142023. private static _UpdateSelectionTree;
  142024. /**
  142025. * Gets or sets a boolean which defines if optimization octree has to be updated
  142026. */
  142027. static get UpdateSelectionTree(): boolean;
  142028. /**
  142029. * Gets or sets a boolean which defines if optimization octree has to be updated
  142030. */
  142031. static set UpdateSelectionTree(value: boolean);
  142032. /**
  142033. * Gets a string describing the action executed by the current optimization
  142034. * @return description string
  142035. */
  142036. getDescription(): string;
  142037. private _canBeMerged;
  142038. /**
  142039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142040. * @param scene defines the current scene where to apply this optimization
  142041. * @param optimizer defines the current optimizer
  142042. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  142043. * @returns true if everything that can be done was applied
  142044. */
  142045. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  142046. }
  142047. /**
  142048. * Defines a list of options used by SceneOptimizer
  142049. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142050. */
  142051. export class SceneOptimizerOptions {
  142052. /**
  142053. * Defines the target frame rate to reach (60 by default)
  142054. */
  142055. targetFrameRate: number;
  142056. /**
  142057. * Defines the interval between two checkes (2000ms by default)
  142058. */
  142059. trackerDuration: number;
  142060. /**
  142061. * Gets the list of optimizations to apply
  142062. */
  142063. optimizations: SceneOptimization[];
  142064. /**
  142065. * Creates a new list of options used by SceneOptimizer
  142066. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  142067. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  142068. */
  142069. constructor(
  142070. /**
  142071. * Defines the target frame rate to reach (60 by default)
  142072. */
  142073. targetFrameRate?: number,
  142074. /**
  142075. * Defines the interval between two checkes (2000ms by default)
  142076. */
  142077. trackerDuration?: number);
  142078. /**
  142079. * Add a new optimization
  142080. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  142081. * @returns the current SceneOptimizerOptions
  142082. */
  142083. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  142084. /**
  142085. * Add a new custom optimization
  142086. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  142087. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  142088. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142089. * @returns the current SceneOptimizerOptions
  142090. */
  142091. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  142092. /**
  142093. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  142094. * @param targetFrameRate defines the target frame rate (60 by default)
  142095. * @returns a SceneOptimizerOptions object
  142096. */
  142097. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142098. /**
  142099. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  142100. * @param targetFrameRate defines the target frame rate (60 by default)
  142101. * @returns a SceneOptimizerOptions object
  142102. */
  142103. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142104. /**
  142105. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  142106. * @param targetFrameRate defines the target frame rate (60 by default)
  142107. * @returns a SceneOptimizerOptions object
  142108. */
  142109. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142110. }
  142111. /**
  142112. * Class used to run optimizations in order to reach a target frame rate
  142113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142114. */
  142115. export class SceneOptimizer implements IDisposable {
  142116. private _isRunning;
  142117. private _options;
  142118. private _scene;
  142119. private _currentPriorityLevel;
  142120. private _targetFrameRate;
  142121. private _trackerDuration;
  142122. private _currentFrameRate;
  142123. private _sceneDisposeObserver;
  142124. private _improvementMode;
  142125. /**
  142126. * Defines an observable called when the optimizer reaches the target frame rate
  142127. */
  142128. onSuccessObservable: Observable<SceneOptimizer>;
  142129. /**
  142130. * Defines an observable called when the optimizer enables an optimization
  142131. */
  142132. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  142133. /**
  142134. * Defines an observable called when the optimizer is not able to reach the target frame rate
  142135. */
  142136. onFailureObservable: Observable<SceneOptimizer>;
  142137. /**
  142138. * Gets a boolean indicating if the optimizer is in improvement mode
  142139. */
  142140. get isInImprovementMode(): boolean;
  142141. /**
  142142. * Gets the current priority level (0 at start)
  142143. */
  142144. get currentPriorityLevel(): number;
  142145. /**
  142146. * Gets the current frame rate checked by the SceneOptimizer
  142147. */
  142148. get currentFrameRate(): number;
  142149. /**
  142150. * Gets or sets the current target frame rate (60 by default)
  142151. */
  142152. get targetFrameRate(): number;
  142153. /**
  142154. * Gets or sets the current target frame rate (60 by default)
  142155. */
  142156. set targetFrameRate(value: number);
  142157. /**
  142158. * Gets or sets the current interval between two checks (every 2000ms by default)
  142159. */
  142160. get trackerDuration(): number;
  142161. /**
  142162. * Gets or sets the current interval between two checks (every 2000ms by default)
  142163. */
  142164. set trackerDuration(value: number);
  142165. /**
  142166. * Gets the list of active optimizations
  142167. */
  142168. get optimizations(): SceneOptimization[];
  142169. /**
  142170. * Creates a new SceneOptimizer
  142171. * @param scene defines the scene to work on
  142172. * @param options defines the options to use with the SceneOptimizer
  142173. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  142174. * @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)
  142175. */
  142176. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  142177. /**
  142178. * Stops the current optimizer
  142179. */
  142180. stop(): void;
  142181. /**
  142182. * Reset the optimizer to initial step (current priority level = 0)
  142183. */
  142184. reset(): void;
  142185. /**
  142186. * Start the optimizer. By default it will try to reach a specific framerate
  142187. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  142188. */
  142189. start(): void;
  142190. private _checkCurrentState;
  142191. /**
  142192. * Release all resources
  142193. */
  142194. dispose(): void;
  142195. /**
  142196. * Helper function to create a SceneOptimizer with one single line of code
  142197. * @param scene defines the scene to work on
  142198. * @param options defines the options to use with the SceneOptimizer
  142199. * @param onSuccess defines a callback to call on success
  142200. * @param onFailure defines a callback to call on failure
  142201. * @returns the new SceneOptimizer object
  142202. */
  142203. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  142204. }
  142205. }
  142206. declare module BABYLON {
  142207. /**
  142208. * Class used to serialize a scene into a string
  142209. */
  142210. export class SceneSerializer {
  142211. /**
  142212. * Clear cache used by a previous serialization
  142213. */
  142214. static ClearCache(): void;
  142215. /**
  142216. * Serialize a scene into a JSON compatible object
  142217. * @param scene defines the scene to serialize
  142218. * @returns a JSON compatible object
  142219. */
  142220. static Serialize(scene: Scene): any;
  142221. /**
  142222. * Serialize a mesh into a JSON compatible object
  142223. * @param toSerialize defines the mesh to serialize
  142224. * @param withParents defines if parents must be serialized as well
  142225. * @param withChildren defines if children must be serialized as well
  142226. * @returns a JSON compatible object
  142227. */
  142228. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  142229. }
  142230. }
  142231. declare module BABYLON {
  142232. /**
  142233. * Class used to host texture specific utilities
  142234. */
  142235. export class TextureTools {
  142236. /**
  142237. * Uses the GPU to create a copy texture rescaled at a given size
  142238. * @param texture Texture to copy from
  142239. * @param width defines the desired width
  142240. * @param height defines the desired height
  142241. * @param useBilinearMode defines if bilinear mode has to be used
  142242. * @return the generated texture
  142243. */
  142244. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  142245. }
  142246. }
  142247. declare module BABYLON {
  142248. /**
  142249. * This represents the different options available for the video capture.
  142250. */
  142251. export interface VideoRecorderOptions {
  142252. /** Defines the mime type of the video. */
  142253. mimeType: string;
  142254. /** Defines the FPS the video should be recorded at. */
  142255. fps: number;
  142256. /** Defines the chunk size for the recording data. */
  142257. recordChunckSize: number;
  142258. /** The audio tracks to attach to the recording. */
  142259. audioTracks?: MediaStreamTrack[];
  142260. }
  142261. /**
  142262. * This can help with recording videos from BabylonJS.
  142263. * This is based on the available WebRTC functionalities of the browser.
  142264. *
  142265. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  142266. */
  142267. export class VideoRecorder {
  142268. private static readonly _defaultOptions;
  142269. /**
  142270. * Returns whether or not the VideoRecorder is available in your browser.
  142271. * @param engine Defines the Babylon Engine.
  142272. * @returns true if supported otherwise false.
  142273. */
  142274. static IsSupported(engine: Engine): boolean;
  142275. private readonly _options;
  142276. private _canvas;
  142277. private _mediaRecorder;
  142278. private _recordedChunks;
  142279. private _fileName;
  142280. private _resolve;
  142281. private _reject;
  142282. /**
  142283. * True when a recording is already in progress.
  142284. */
  142285. get isRecording(): boolean;
  142286. /**
  142287. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  142288. * @param engine Defines the BabylonJS Engine you wish to record.
  142289. * @param options Defines options that can be used to customize the capture.
  142290. */
  142291. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  142292. /**
  142293. * Stops the current recording before the default capture timeout passed in the startRecording function.
  142294. */
  142295. stopRecording(): void;
  142296. /**
  142297. * Starts recording the canvas for a max duration specified in parameters.
  142298. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  142299. * If null no automatic download will start and you can rely on the promise to get the data back.
  142300. * @param maxDuration Defines the maximum recording time in seconds.
  142301. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  142302. * @return A promise callback at the end of the recording with the video data in Blob.
  142303. */
  142304. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  142305. /**
  142306. * Releases internal resources used during the recording.
  142307. */
  142308. dispose(): void;
  142309. private _handleDataAvailable;
  142310. private _handleError;
  142311. private _handleStop;
  142312. }
  142313. }
  142314. declare module BABYLON {
  142315. /**
  142316. * Class containing a set of static utilities functions for screenshots
  142317. */
  142318. export class ScreenshotTools {
  142319. /**
  142320. * Captures a screenshot of the current rendering
  142321. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142322. * @param engine defines the rendering engine
  142323. * @param camera defines the source camera
  142324. * @param size This parameter can be set to a single number or to an object with the
  142325. * following (optional) properties: precision, width, height. If a single number is passed,
  142326. * it will be used for both width and height. If an object is passed, the screenshot size
  142327. * will be derived from the parameters. The precision property is a multiplier allowing
  142328. * rendering at a higher or lower resolution
  142329. * @param successCallback defines the callback receives a single parameter which contains the
  142330. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142331. * src parameter of an <img> to display it
  142332. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142333. * Check your browser for supported MIME types
  142334. */
  142335. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  142336. /**
  142337. * Captures a screenshot of the current rendering
  142338. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142339. * @param engine defines the rendering engine
  142340. * @param camera defines the source camera
  142341. * @param size This parameter can be set to a single number or to an object with the
  142342. * following (optional) properties: precision, width, height. If a single number is passed,
  142343. * it will be used for both width and height. If an object is passed, the screenshot size
  142344. * will be derived from the parameters. The precision property is a multiplier allowing
  142345. * rendering at a higher or lower resolution
  142346. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142347. * Check your browser for supported MIME types
  142348. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142349. * to the src parameter of an <img> to display it
  142350. */
  142351. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  142352. /**
  142353. * Generates an image screenshot from the specified camera.
  142354. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142355. * @param engine The engine to use for rendering
  142356. * @param camera The camera to use for rendering
  142357. * @param size This parameter can be set to a single number or to an object with the
  142358. * following (optional) properties: precision, width, height. If a single number is passed,
  142359. * it will be used for both width and height. If an object is passed, the screenshot size
  142360. * will be derived from the parameters. The precision property is a multiplier allowing
  142361. * rendering at a higher or lower resolution
  142362. * @param successCallback The callback receives a single parameter which contains the
  142363. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142364. * src parameter of an <img> to display it
  142365. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142366. * Check your browser for supported MIME types
  142367. * @param samples Texture samples (default: 1)
  142368. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142369. * @param fileName A name for for the downloaded file.
  142370. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142371. */
  142372. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  142373. /**
  142374. * Generates an image screenshot from the specified camera.
  142375. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142376. * @param engine The engine to use for rendering
  142377. * @param camera The camera to use for rendering
  142378. * @param size This parameter can be set to a single number or to an object with the
  142379. * following (optional) properties: precision, width, height. If a single number is passed,
  142380. * it will be used for both width and height. If an object is passed, the screenshot size
  142381. * will be derived from the parameters. The precision property is a multiplier allowing
  142382. * rendering at a higher or lower resolution
  142383. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142384. * Check your browser for supported MIME types
  142385. * @param samples Texture samples (default: 1)
  142386. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142387. * @param fileName A name for for the downloaded file.
  142388. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142389. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142390. * to the src parameter of an <img> to display it
  142391. */
  142392. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  142393. /**
  142394. * Gets height and width for screenshot size
  142395. * @private
  142396. */
  142397. private static _getScreenshotSize;
  142398. }
  142399. }
  142400. declare module BABYLON {
  142401. /**
  142402. * Interface for a data buffer
  142403. */
  142404. export interface IDataBuffer {
  142405. /**
  142406. * Reads bytes from the data buffer.
  142407. * @param byteOffset The byte offset to read
  142408. * @param byteLength The byte length to read
  142409. * @returns A promise that resolves when the bytes are read
  142410. */
  142411. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  142412. /**
  142413. * The byte length of the buffer.
  142414. */
  142415. readonly byteLength: number;
  142416. }
  142417. /**
  142418. * Utility class for reading from a data buffer
  142419. */
  142420. export class DataReader {
  142421. /**
  142422. * The data buffer associated with this data reader.
  142423. */
  142424. readonly buffer: IDataBuffer;
  142425. /**
  142426. * The current byte offset from the beginning of the data buffer.
  142427. */
  142428. byteOffset: number;
  142429. private _dataView;
  142430. private _dataByteOffset;
  142431. /**
  142432. * Constructor
  142433. * @param buffer The buffer to read
  142434. */
  142435. constructor(buffer: IDataBuffer);
  142436. /**
  142437. * Loads the given byte length.
  142438. * @param byteLength The byte length to load
  142439. * @returns A promise that resolves when the load is complete
  142440. */
  142441. loadAsync(byteLength: number): Promise<void>;
  142442. /**
  142443. * Read a unsigned 32-bit integer from the currently loaded data range.
  142444. * @returns The 32-bit integer read
  142445. */
  142446. readUint32(): number;
  142447. /**
  142448. * Read a byte array from the currently loaded data range.
  142449. * @param byteLength The byte length to read
  142450. * @returns The byte array read
  142451. */
  142452. readUint8Array(byteLength: number): Uint8Array;
  142453. /**
  142454. * Read a string from the currently loaded data range.
  142455. * @param byteLength The byte length to read
  142456. * @returns The string read
  142457. */
  142458. readString(byteLength: number): string;
  142459. /**
  142460. * Skips the given byte length the currently loaded data range.
  142461. * @param byteLength The byte length to skip
  142462. */
  142463. skipBytes(byteLength: number): void;
  142464. }
  142465. }
  142466. declare module BABYLON {
  142467. /**
  142468. * Class for storing data to local storage if available or in-memory storage otherwise
  142469. */
  142470. export class DataStorage {
  142471. private static _Storage;
  142472. private static _GetStorage;
  142473. /**
  142474. * Reads a string from the data storage
  142475. * @param key The key to read
  142476. * @param defaultValue The value if the key doesn't exist
  142477. * @returns The string value
  142478. */
  142479. static ReadString(key: string, defaultValue: string): string;
  142480. /**
  142481. * Writes a string to the data storage
  142482. * @param key The key to write
  142483. * @param value The value to write
  142484. */
  142485. static WriteString(key: string, value: string): void;
  142486. /**
  142487. * Reads a boolean from the data storage
  142488. * @param key The key to read
  142489. * @param defaultValue The value if the key doesn't exist
  142490. * @returns The boolean value
  142491. */
  142492. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  142493. /**
  142494. * Writes a boolean to the data storage
  142495. * @param key The key to write
  142496. * @param value The value to write
  142497. */
  142498. static WriteBoolean(key: string, value: boolean): void;
  142499. /**
  142500. * Reads a number from the data storage
  142501. * @param key The key to read
  142502. * @param defaultValue The value if the key doesn't exist
  142503. * @returns The number value
  142504. */
  142505. static ReadNumber(key: string, defaultValue: number): number;
  142506. /**
  142507. * Writes a number to the data storage
  142508. * @param key The key to write
  142509. * @param value The value to write
  142510. */
  142511. static WriteNumber(key: string, value: number): void;
  142512. }
  142513. }
  142514. declare module BABYLON {
  142515. /**
  142516. * Options used for hit testing
  142517. */
  142518. export interface IWebXRHitTestOptions {
  142519. /**
  142520. * Only test when user interacted with the scene. Default - hit test every frame
  142521. */
  142522. testOnPointerDownOnly?: boolean;
  142523. /**
  142524. * The node to use to transform the local results to world coordinates
  142525. */
  142526. worldParentNode?: TransformNode;
  142527. }
  142528. /**
  142529. * Interface defining the babylon result of raycasting/hit-test
  142530. */
  142531. export interface IWebXRHitResult {
  142532. /**
  142533. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142534. */
  142535. transformationMatrix: Matrix;
  142536. /**
  142537. * The native hit test result
  142538. */
  142539. xrHitResult: XRHitResult;
  142540. }
  142541. /**
  142542. * The currently-working hit-test module.
  142543. * Hit test (or Ray-casting) is used to interact with the real world.
  142544. * For further information read here - https://github.com/immersive-web/hit-test
  142545. */
  142546. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142547. /**
  142548. * options to use when constructing this feature
  142549. */
  142550. readonly options: IWebXRHitTestOptions;
  142551. private _direction;
  142552. private _mat;
  142553. private _onSelectEnabled;
  142554. private _origin;
  142555. /**
  142556. * The module's name
  142557. */
  142558. static readonly Name: string;
  142559. /**
  142560. * The (Babylon) version of this module.
  142561. * This is an integer representing the implementation version.
  142562. * This number does not correspond to the WebXR specs version
  142563. */
  142564. static readonly Version: number;
  142565. /**
  142566. * Populated with the last native XR Hit Results
  142567. */
  142568. lastNativeXRHitResults: XRHitResult[];
  142569. /**
  142570. * Triggered when new babylon (transformed) hit test results are available
  142571. */
  142572. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142573. /**
  142574. * Creates a new instance of the (legacy version) hit test feature
  142575. * @param _xrSessionManager an instance of WebXRSessionManager
  142576. * @param options options to use when constructing this feature
  142577. */
  142578. constructor(_xrSessionManager: WebXRSessionManager,
  142579. /**
  142580. * options to use when constructing this feature
  142581. */
  142582. options?: IWebXRHitTestOptions);
  142583. /**
  142584. * execute a hit test with an XR Ray
  142585. *
  142586. * @param xrSession a native xrSession that will execute this hit test
  142587. * @param xrRay the ray (position and direction) to use for ray-casting
  142588. * @param referenceSpace native XR reference space to use for the hit-test
  142589. * @param filter filter function that will filter the results
  142590. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142591. */
  142592. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142593. /**
  142594. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142595. * @param event the (select) event to use to select with
  142596. * @param referenceSpace the reference space to use for this hit test
  142597. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142598. */
  142599. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142600. /**
  142601. * attach this feature
  142602. * Will usually be called by the features manager
  142603. *
  142604. * @returns true if successful.
  142605. */
  142606. attach(): boolean;
  142607. /**
  142608. * detach this feature.
  142609. * Will usually be called by the features manager
  142610. *
  142611. * @returns true if successful.
  142612. */
  142613. detach(): boolean;
  142614. /**
  142615. * Dispose this feature and all of the resources attached
  142616. */
  142617. dispose(): void;
  142618. protected _onXRFrame(frame: XRFrame): void;
  142619. private _onHitTestResults;
  142620. private _onSelect;
  142621. }
  142622. }
  142623. declare module BABYLON {
  142624. /**
  142625. * Options used in the plane detector module
  142626. */
  142627. export interface IWebXRPlaneDetectorOptions {
  142628. /**
  142629. * The node to use to transform the local results to world coordinates
  142630. */
  142631. worldParentNode?: TransformNode;
  142632. }
  142633. /**
  142634. * A babylon interface for a WebXR plane.
  142635. * A Plane is actually a polygon, built from N points in space
  142636. *
  142637. * Supported in chrome 79, not supported in canary 81 ATM
  142638. */
  142639. export interface IWebXRPlane {
  142640. /**
  142641. * a babylon-assigned ID for this polygon
  142642. */
  142643. id: number;
  142644. /**
  142645. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142646. */
  142647. polygonDefinition: Array<Vector3>;
  142648. /**
  142649. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142650. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142651. */
  142652. transformationMatrix: Matrix;
  142653. /**
  142654. * the native xr-plane object
  142655. */
  142656. xrPlane: XRPlane;
  142657. }
  142658. /**
  142659. * The plane detector is used to detect planes in the real world when in AR
  142660. * For more information see https://github.com/immersive-web/real-world-geometry/
  142661. */
  142662. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142663. private _options;
  142664. private _detectedPlanes;
  142665. private _enabled;
  142666. private _lastFrameDetected;
  142667. /**
  142668. * The module's name
  142669. */
  142670. static readonly Name: string;
  142671. /**
  142672. * The (Babylon) version of this module.
  142673. * This is an integer representing the implementation version.
  142674. * This number does not correspond to the WebXR specs version
  142675. */
  142676. static readonly Version: number;
  142677. /**
  142678. * Observers registered here will be executed when a new plane was added to the session
  142679. */
  142680. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142681. /**
  142682. * Observers registered here will be executed when a plane is no longer detected in the session
  142683. */
  142684. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142685. /**
  142686. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142687. * This can execute N times every frame
  142688. */
  142689. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142690. /**
  142691. * construct a new Plane Detector
  142692. * @param _xrSessionManager an instance of xr Session manager
  142693. * @param _options configuration to use when constructing this feature
  142694. */
  142695. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142696. /**
  142697. * Dispose this feature and all of the resources attached
  142698. */
  142699. dispose(): void;
  142700. protected _onXRFrame(frame: XRFrame): void;
  142701. private _init;
  142702. private _updatePlaneWithXRPlane;
  142703. /**
  142704. * avoiding using Array.find for global support.
  142705. * @param xrPlane the plane to find in the array
  142706. */
  142707. private findIndexInPlaneArray;
  142708. }
  142709. }
  142710. declare module BABYLON {
  142711. /**
  142712. * Configuration options of the anchor system
  142713. */
  142714. export interface IWebXRAnchorSystemOptions {
  142715. /**
  142716. * Should a new anchor be added every time a select event is triggered
  142717. */
  142718. addAnchorOnSelect?: boolean;
  142719. /**
  142720. * should the anchor system use plane detection.
  142721. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142722. */
  142723. usePlaneDetection?: boolean;
  142724. /**
  142725. * a node that will be used to convert local to world coordinates
  142726. */
  142727. worldParentNode?: TransformNode;
  142728. }
  142729. /**
  142730. * A babylon container for an XR Anchor
  142731. */
  142732. export interface IWebXRAnchor {
  142733. /**
  142734. * A babylon-assigned ID for this anchor
  142735. */
  142736. id: number;
  142737. /**
  142738. * Transformation matrix to apply to an object attached to this anchor
  142739. */
  142740. transformationMatrix: Matrix;
  142741. /**
  142742. * The native anchor object
  142743. */
  142744. xrAnchor: XRAnchor;
  142745. }
  142746. /**
  142747. * An implementation of the anchor system of WebXR.
  142748. * Note that the current documented implementation is not available in any browser. Future implementations
  142749. * will use the frame to create an anchor and not the session or a detected plane
  142750. * For further information see https://github.com/immersive-web/anchors/
  142751. */
  142752. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142753. private _options;
  142754. private _enabled;
  142755. private _hitTestModule;
  142756. private _lastFrameDetected;
  142757. private _onSelect;
  142758. private _planeDetector;
  142759. private _trackedAnchors;
  142760. /**
  142761. * The module's name
  142762. */
  142763. static readonly Name: string;
  142764. /**
  142765. * The (Babylon) version of this module.
  142766. * This is an integer representing the implementation version.
  142767. * This number does not correspond to the WebXR specs version
  142768. */
  142769. static readonly Version: number;
  142770. /**
  142771. * Observers registered here will be executed when a new anchor was added to the session
  142772. */
  142773. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142774. /**
  142775. * Observers registered here will be executed when an anchor was removed from the session
  142776. */
  142777. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142778. /**
  142779. * Observers registered here will be executed when an existing anchor updates
  142780. * This can execute N times every frame
  142781. */
  142782. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142783. /**
  142784. * constructs a new anchor system
  142785. * @param _xrSessionManager an instance of WebXRSessionManager
  142786. * @param _options configuration object for this feature
  142787. */
  142788. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142789. /**
  142790. * Add anchor at a specific XR point.
  142791. *
  142792. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142793. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142794. * @returns a promise the fulfills when the anchor was created
  142795. */
  142796. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142797. /**
  142798. * attach this feature
  142799. * Will usually be called by the features manager
  142800. *
  142801. * @returns true if successful.
  142802. */
  142803. attach(): boolean;
  142804. /**
  142805. * detach this feature.
  142806. * Will usually be called by the features manager
  142807. *
  142808. * @returns true if successful.
  142809. */
  142810. detach(): boolean;
  142811. /**
  142812. * Dispose this feature and all of the resources attached
  142813. */
  142814. dispose(): void;
  142815. /**
  142816. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142817. * @param hitTestModule the hit-test module to use.
  142818. */
  142819. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142820. /**
  142821. * set the plane detector to use in order to create anchors from frames
  142822. * @param planeDetector the plane-detector module to use
  142823. * @param enable enable plane-anchors. default is true
  142824. */
  142825. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142826. protected _onXRFrame(frame: XRFrame): void;
  142827. /**
  142828. * avoiding using Array.find for global support.
  142829. * @param xrAnchor the plane to find in the array
  142830. */
  142831. private _findIndexInAnchorArray;
  142832. private _updateAnchorWithXRFrame;
  142833. }
  142834. }
  142835. declare module BABYLON {
  142836. /**
  142837. * Options interface for the background remover plugin
  142838. */
  142839. export interface IWebXRBackgroundRemoverOptions {
  142840. /**
  142841. * Further background meshes to disable when entering AR
  142842. */
  142843. backgroundMeshes?: AbstractMesh[];
  142844. /**
  142845. * flags to configure the removal of the environment helper.
  142846. * If not set, the entire background will be removed. If set, flags should be set as well.
  142847. */
  142848. environmentHelperRemovalFlags?: {
  142849. /**
  142850. * Should the skybox be removed (default false)
  142851. */
  142852. skyBox?: boolean;
  142853. /**
  142854. * Should the ground be removed (default false)
  142855. */
  142856. ground?: boolean;
  142857. };
  142858. /**
  142859. * don't disable the environment helper
  142860. */
  142861. ignoreEnvironmentHelper?: boolean;
  142862. }
  142863. /**
  142864. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142865. */
  142866. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142867. /**
  142868. * read-only options to be used in this module
  142869. */
  142870. readonly options: IWebXRBackgroundRemoverOptions;
  142871. /**
  142872. * The module's name
  142873. */
  142874. static readonly Name: string;
  142875. /**
  142876. * The (Babylon) version of this module.
  142877. * This is an integer representing the implementation version.
  142878. * This number does not correspond to the WebXR specs version
  142879. */
  142880. static readonly Version: number;
  142881. /**
  142882. * registered observers will be triggered when the background state changes
  142883. */
  142884. onBackgroundStateChangedObservable: Observable<boolean>;
  142885. /**
  142886. * constructs a new background remover module
  142887. * @param _xrSessionManager the session manager for this module
  142888. * @param options read-only options to be used in this module
  142889. */
  142890. constructor(_xrSessionManager: WebXRSessionManager,
  142891. /**
  142892. * read-only options to be used in this module
  142893. */
  142894. options?: IWebXRBackgroundRemoverOptions);
  142895. /**
  142896. * attach this feature
  142897. * Will usually be called by the features manager
  142898. *
  142899. * @returns true if successful.
  142900. */
  142901. attach(): boolean;
  142902. /**
  142903. * detach this feature.
  142904. * Will usually be called by the features manager
  142905. *
  142906. * @returns true if successful.
  142907. */
  142908. detach(): boolean;
  142909. /**
  142910. * Dispose this feature and all of the resources attached
  142911. */
  142912. dispose(): void;
  142913. protected _onXRFrame(_xrFrame: XRFrame): void;
  142914. private _setBackgroundState;
  142915. }
  142916. }
  142917. declare module BABYLON {
  142918. /**
  142919. * Options for the controller physics feature
  142920. */
  142921. export class IWebXRControllerPhysicsOptions {
  142922. /**
  142923. * Should the headset get its own impostor
  142924. */
  142925. enableHeadsetImpostor?: boolean;
  142926. /**
  142927. * Optional parameters for the headset impostor
  142928. */
  142929. headsetImpostorParams?: {
  142930. /**
  142931. * The type of impostor to create. Default is sphere
  142932. */
  142933. impostorType: number;
  142934. /**
  142935. * the size of the impostor. Defaults to 10cm
  142936. */
  142937. impostorSize?: number | {
  142938. width: number;
  142939. height: number;
  142940. depth: number;
  142941. };
  142942. /**
  142943. * Friction definitions
  142944. */
  142945. friction?: number;
  142946. /**
  142947. * Restitution
  142948. */
  142949. restitution?: number;
  142950. };
  142951. /**
  142952. * The physics properties of the future impostors
  142953. */
  142954. physicsProperties?: {
  142955. /**
  142956. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142957. * Note that this requires a physics engine that supports mesh impostors!
  142958. */
  142959. useControllerMesh?: boolean;
  142960. /**
  142961. * The type of impostor to create. Default is sphere
  142962. */
  142963. impostorType?: number;
  142964. /**
  142965. * the size of the impostor. Defaults to 10cm
  142966. */
  142967. impostorSize?: number | {
  142968. width: number;
  142969. height: number;
  142970. depth: number;
  142971. };
  142972. /**
  142973. * Friction definitions
  142974. */
  142975. friction?: number;
  142976. /**
  142977. * Restitution
  142978. */
  142979. restitution?: number;
  142980. };
  142981. /**
  142982. * the xr input to use with this pointer selection
  142983. */
  142984. xrInput: WebXRInput;
  142985. }
  142986. /**
  142987. * Add physics impostor to your webxr controllers,
  142988. * including naive calculation of their linear and angular velocity
  142989. */
  142990. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142991. private readonly _options;
  142992. private _attachController;
  142993. private _controllers;
  142994. private _debugMode;
  142995. private _delta;
  142996. private _headsetImpostor?;
  142997. private _headsetMesh?;
  142998. private _lastTimestamp;
  142999. private _tmpQuaternion;
  143000. private _tmpVector;
  143001. /**
  143002. * The module's name
  143003. */
  143004. static readonly Name: string;
  143005. /**
  143006. * The (Babylon) version of this module.
  143007. * This is an integer representing the implementation version.
  143008. * This number does not correspond to the webxr specs version
  143009. */
  143010. static readonly Version: number;
  143011. /**
  143012. * Construct a new Controller Physics Feature
  143013. * @param _xrSessionManager the corresponding xr session manager
  143014. * @param _options options to create this feature with
  143015. */
  143016. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  143017. /**
  143018. * @hidden
  143019. * enable debugging - will show console outputs and the impostor mesh
  143020. */
  143021. _enablePhysicsDebug(): void;
  143022. /**
  143023. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  143024. * @param xrController the controller to add
  143025. */
  143026. addController(xrController: WebXRInputSource): void;
  143027. /**
  143028. * attach this feature
  143029. * Will usually be called by the features manager
  143030. *
  143031. * @returns true if successful.
  143032. */
  143033. attach(): boolean;
  143034. /**
  143035. * detach this feature.
  143036. * Will usually be called by the features manager
  143037. *
  143038. * @returns true if successful.
  143039. */
  143040. detach(): boolean;
  143041. /**
  143042. * Get the headset impostor, if enabled
  143043. * @returns the impostor
  143044. */
  143045. getHeadsetImpostor(): PhysicsImpostor | undefined;
  143046. /**
  143047. * Get the physics impostor of a specific controller.
  143048. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  143049. * @param controller the controller or the controller id of which to get the impostor
  143050. * @returns the impostor or null
  143051. */
  143052. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  143053. /**
  143054. * Update the physics properties provided in the constructor
  143055. * @param newProperties the new properties object
  143056. */
  143057. setPhysicsProperties(newProperties: {
  143058. impostorType?: number;
  143059. impostorSize?: number | {
  143060. width: number;
  143061. height: number;
  143062. depth: number;
  143063. };
  143064. friction?: number;
  143065. restitution?: number;
  143066. }): void;
  143067. protected _onXRFrame(_xrFrame: any): void;
  143068. private _detachController;
  143069. }
  143070. }
  143071. declare module BABYLON {
  143072. /**
  143073. * The motion controller class for all microsoft mixed reality controllers
  143074. */
  143075. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  143076. protected readonly _mapping: {
  143077. defaultButton: {
  143078. "valueNodeName": string;
  143079. "unpressedNodeName": string;
  143080. "pressedNodeName": string;
  143081. };
  143082. defaultAxis: {
  143083. "valueNodeName": string;
  143084. "minNodeName": string;
  143085. "maxNodeName": string;
  143086. };
  143087. buttons: {
  143088. "xr-standard-trigger": {
  143089. "rootNodeName": string;
  143090. "componentProperty": string;
  143091. "states": string[];
  143092. };
  143093. "xr-standard-squeeze": {
  143094. "rootNodeName": string;
  143095. "componentProperty": string;
  143096. "states": string[];
  143097. };
  143098. "xr-standard-touchpad": {
  143099. "rootNodeName": string;
  143100. "labelAnchorNodeName": string;
  143101. "touchPointNodeName": string;
  143102. };
  143103. "xr-standard-thumbstick": {
  143104. "rootNodeName": string;
  143105. "componentProperty": string;
  143106. "states": string[];
  143107. };
  143108. };
  143109. axes: {
  143110. "xr-standard-touchpad": {
  143111. "x-axis": {
  143112. "rootNodeName": string;
  143113. };
  143114. "y-axis": {
  143115. "rootNodeName": string;
  143116. };
  143117. };
  143118. "xr-standard-thumbstick": {
  143119. "x-axis": {
  143120. "rootNodeName": string;
  143121. };
  143122. "y-axis": {
  143123. "rootNodeName": string;
  143124. };
  143125. };
  143126. };
  143127. };
  143128. /**
  143129. * The base url used to load the left and right controller models
  143130. */
  143131. static MODEL_BASE_URL: string;
  143132. /**
  143133. * The name of the left controller model file
  143134. */
  143135. static MODEL_LEFT_FILENAME: string;
  143136. /**
  143137. * The name of the right controller model file
  143138. */
  143139. static MODEL_RIGHT_FILENAME: string;
  143140. profileId: string;
  143141. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  143142. protected _getFilenameAndPath(): {
  143143. filename: string;
  143144. path: string;
  143145. };
  143146. protected _getModelLoadingConstraints(): boolean;
  143147. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143148. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143149. protected _updateModel(): void;
  143150. }
  143151. }
  143152. declare module BABYLON {
  143153. /**
  143154. * The motion controller class for oculus touch (quest, rift).
  143155. * This class supports legacy mapping as well the standard xr mapping
  143156. */
  143157. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  143158. private _forceLegacyControllers;
  143159. private _modelRootNode;
  143160. /**
  143161. * The base url used to load the left and right controller models
  143162. */
  143163. static MODEL_BASE_URL: string;
  143164. /**
  143165. * The name of the left controller model file
  143166. */
  143167. static MODEL_LEFT_FILENAME: string;
  143168. /**
  143169. * The name of the right controller model file
  143170. */
  143171. static MODEL_RIGHT_FILENAME: string;
  143172. /**
  143173. * Base Url for the Quest controller model.
  143174. */
  143175. static QUEST_MODEL_BASE_URL: string;
  143176. profileId: string;
  143177. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  143178. protected _getFilenameAndPath(): {
  143179. filename: string;
  143180. path: string;
  143181. };
  143182. protected _getModelLoadingConstraints(): boolean;
  143183. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143184. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143185. protected _updateModel(): void;
  143186. /**
  143187. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  143188. * between the touch and touch 2.
  143189. */
  143190. private _isQuest;
  143191. }
  143192. }
  143193. declare module BABYLON {
  143194. /**
  143195. * The motion controller class for the standard HTC-Vive controllers
  143196. */
  143197. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  143198. private _modelRootNode;
  143199. /**
  143200. * The base url used to load the left and right controller models
  143201. */
  143202. static MODEL_BASE_URL: string;
  143203. /**
  143204. * File name for the controller model.
  143205. */
  143206. static MODEL_FILENAME: string;
  143207. profileId: string;
  143208. /**
  143209. * Create a new Vive motion controller object
  143210. * @param scene the scene to use to create this controller
  143211. * @param gamepadObject the corresponding gamepad object
  143212. * @param handness the handness of the controller
  143213. */
  143214. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  143215. protected _getFilenameAndPath(): {
  143216. filename: string;
  143217. path: string;
  143218. };
  143219. protected _getModelLoadingConstraints(): boolean;
  143220. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143221. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143222. protected _updateModel(): void;
  143223. }
  143224. }
  143225. declare module BABYLON {
  143226. /**
  143227. * A cursor which tracks a point on a path
  143228. */
  143229. export class PathCursor {
  143230. private path;
  143231. /**
  143232. * Stores path cursor callbacks for when an onchange event is triggered
  143233. */
  143234. private _onchange;
  143235. /**
  143236. * The value of the path cursor
  143237. */
  143238. value: number;
  143239. /**
  143240. * The animation array of the path cursor
  143241. */
  143242. animations: Animation[];
  143243. /**
  143244. * Initializes the path cursor
  143245. * @param path The path to track
  143246. */
  143247. constructor(path: Path2);
  143248. /**
  143249. * Gets the cursor point on the path
  143250. * @returns A point on the path cursor at the cursor location
  143251. */
  143252. getPoint(): Vector3;
  143253. /**
  143254. * Moves the cursor ahead by the step amount
  143255. * @param step The amount to move the cursor forward
  143256. * @returns This path cursor
  143257. */
  143258. moveAhead(step?: number): PathCursor;
  143259. /**
  143260. * Moves the cursor behind by the step amount
  143261. * @param step The amount to move the cursor back
  143262. * @returns This path cursor
  143263. */
  143264. moveBack(step?: number): PathCursor;
  143265. /**
  143266. * Moves the cursor by the step amount
  143267. * If the step amount is greater than one, an exception is thrown
  143268. * @param step The amount to move the cursor
  143269. * @returns This path cursor
  143270. */
  143271. move(step: number): PathCursor;
  143272. /**
  143273. * Ensures that the value is limited between zero and one
  143274. * @returns This path cursor
  143275. */
  143276. private ensureLimits;
  143277. /**
  143278. * Runs onchange callbacks on change (used by the animation engine)
  143279. * @returns This path cursor
  143280. */
  143281. private raiseOnChange;
  143282. /**
  143283. * Executes a function on change
  143284. * @param f A path cursor onchange callback
  143285. * @returns This path cursor
  143286. */
  143287. onchange(f: (cursor: PathCursor) => void): PathCursor;
  143288. }
  143289. }
  143290. declare module BABYLON {
  143291. /** @hidden */
  143292. export var blurPixelShader: {
  143293. name: string;
  143294. shader: string;
  143295. };
  143296. }
  143297. declare module BABYLON {
  143298. /** @hidden */
  143299. export var pointCloudVertexDeclaration: {
  143300. name: string;
  143301. shader: string;
  143302. };
  143303. }
  143304. // Mixins
  143305. interface Window {
  143306. mozIndexedDB: IDBFactory;
  143307. webkitIndexedDB: IDBFactory;
  143308. msIndexedDB: IDBFactory;
  143309. webkitURL: typeof URL;
  143310. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  143311. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  143312. WebGLRenderingContext: WebGLRenderingContext;
  143313. MSGesture: MSGesture;
  143314. CANNON: any;
  143315. AudioContext: AudioContext;
  143316. webkitAudioContext: AudioContext;
  143317. PointerEvent: any;
  143318. Math: Math;
  143319. Uint8Array: Uint8ArrayConstructor;
  143320. Float32Array: Float32ArrayConstructor;
  143321. mozURL: typeof URL;
  143322. msURL: typeof URL;
  143323. VRFrameData: any; // WebVR, from specs 1.1
  143324. DracoDecoderModule: any;
  143325. setImmediate(handler: (...args: any[]) => void): number;
  143326. }
  143327. interface HTMLCanvasElement {
  143328. requestPointerLock(): void;
  143329. msRequestPointerLock?(): void;
  143330. mozRequestPointerLock?(): void;
  143331. webkitRequestPointerLock?(): void;
  143332. /** Track wether a record is in progress */
  143333. isRecording: boolean;
  143334. /** Capture Stream method defined by some browsers */
  143335. captureStream(fps?: number): MediaStream;
  143336. }
  143337. interface CanvasRenderingContext2D {
  143338. msImageSmoothingEnabled: boolean;
  143339. }
  143340. interface MouseEvent {
  143341. mozMovementX: number;
  143342. mozMovementY: number;
  143343. webkitMovementX: number;
  143344. webkitMovementY: number;
  143345. msMovementX: number;
  143346. msMovementY: number;
  143347. }
  143348. interface Navigator {
  143349. mozGetVRDevices: (any: any) => any;
  143350. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143351. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143352. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143353. webkitGetGamepads(): Gamepad[];
  143354. msGetGamepads(): Gamepad[];
  143355. webkitGamepads(): Gamepad[];
  143356. }
  143357. interface HTMLVideoElement {
  143358. mozSrcObject: any;
  143359. }
  143360. interface Math {
  143361. fround(x: number): number;
  143362. imul(a: number, b: number): number;
  143363. }
  143364. interface WebGLRenderingContext {
  143365. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  143366. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  143367. vertexAttribDivisor(index: number, divisor: number): void;
  143368. createVertexArray(): any;
  143369. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  143370. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  143371. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  143372. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  143373. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  143374. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  143375. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  143376. // Queries
  143377. createQuery(): WebGLQuery;
  143378. deleteQuery(query: WebGLQuery): void;
  143379. beginQuery(target: number, query: WebGLQuery): void;
  143380. endQuery(target: number): void;
  143381. getQueryParameter(query: WebGLQuery, pname: number): any;
  143382. getQuery(target: number, pname: number): any;
  143383. MAX_SAMPLES: number;
  143384. RGBA8: number;
  143385. READ_FRAMEBUFFER: number;
  143386. DRAW_FRAMEBUFFER: number;
  143387. UNIFORM_BUFFER: number;
  143388. HALF_FLOAT_OES: number;
  143389. RGBA16F: number;
  143390. RGBA32F: number;
  143391. R32F: number;
  143392. RG32F: number;
  143393. RGB32F: number;
  143394. R16F: number;
  143395. RG16F: number;
  143396. RGB16F: number;
  143397. RED: number;
  143398. RG: number;
  143399. R8: number;
  143400. RG8: number;
  143401. UNSIGNED_INT_24_8: number;
  143402. DEPTH24_STENCIL8: number;
  143403. MIN: number;
  143404. MAX: number;
  143405. /* Multiple Render Targets */
  143406. drawBuffers(buffers: number[]): void;
  143407. readBuffer(src: number): void;
  143408. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  143409. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  143410. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  143411. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  143412. // Occlusion Query
  143413. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  143414. ANY_SAMPLES_PASSED: number;
  143415. QUERY_RESULT_AVAILABLE: number;
  143416. QUERY_RESULT: number;
  143417. }
  143418. interface WebGLProgram {
  143419. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  143420. }
  143421. interface EXT_disjoint_timer_query {
  143422. QUERY_COUNTER_BITS_EXT: number;
  143423. TIME_ELAPSED_EXT: number;
  143424. TIMESTAMP_EXT: number;
  143425. GPU_DISJOINT_EXT: number;
  143426. QUERY_RESULT_EXT: number;
  143427. QUERY_RESULT_AVAILABLE_EXT: number;
  143428. queryCounterEXT(query: WebGLQuery, target: number): void;
  143429. createQueryEXT(): WebGLQuery;
  143430. beginQueryEXT(target: number, query: WebGLQuery): void;
  143431. endQueryEXT(target: number): void;
  143432. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  143433. deleteQueryEXT(query: WebGLQuery): void;
  143434. }
  143435. interface WebGLUniformLocation {
  143436. _currentState: any;
  143437. }
  143438. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  143439. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  143440. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  143441. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143442. interface WebGLRenderingContext {
  143443. readonly RASTERIZER_DISCARD: number;
  143444. readonly DEPTH_COMPONENT24: number;
  143445. readonly TEXTURE_3D: number;
  143446. readonly TEXTURE_2D_ARRAY: number;
  143447. readonly TEXTURE_COMPARE_FUNC: number;
  143448. readonly TEXTURE_COMPARE_MODE: number;
  143449. readonly COMPARE_REF_TO_TEXTURE: number;
  143450. readonly TEXTURE_WRAP_R: number;
  143451. readonly HALF_FLOAT: number;
  143452. readonly RGB8: number;
  143453. readonly RED_INTEGER: number;
  143454. readonly RG_INTEGER: number;
  143455. readonly RGB_INTEGER: number;
  143456. readonly RGBA_INTEGER: number;
  143457. readonly R8_SNORM: number;
  143458. readonly RG8_SNORM: number;
  143459. readonly RGB8_SNORM: number;
  143460. readonly RGBA8_SNORM: number;
  143461. readonly R8I: number;
  143462. readonly RG8I: number;
  143463. readonly RGB8I: number;
  143464. readonly RGBA8I: number;
  143465. readonly R8UI: number;
  143466. readonly RG8UI: number;
  143467. readonly RGB8UI: number;
  143468. readonly RGBA8UI: number;
  143469. readonly R16I: number;
  143470. readonly RG16I: number;
  143471. readonly RGB16I: number;
  143472. readonly RGBA16I: number;
  143473. readonly R16UI: number;
  143474. readonly RG16UI: number;
  143475. readonly RGB16UI: number;
  143476. readonly RGBA16UI: number;
  143477. readonly R32I: number;
  143478. readonly RG32I: number;
  143479. readonly RGB32I: number;
  143480. readonly RGBA32I: number;
  143481. readonly R32UI: number;
  143482. readonly RG32UI: number;
  143483. readonly RGB32UI: number;
  143484. readonly RGBA32UI: number;
  143485. readonly RGB10_A2UI: number;
  143486. readonly R11F_G11F_B10F: number;
  143487. readonly RGB9_E5: number;
  143488. readonly RGB10_A2: number;
  143489. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  143490. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  143491. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  143492. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  143493. readonly DEPTH_COMPONENT32F: number;
  143494. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143495. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143496. 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;
  143497. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143498. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143499. readonly TRANSFORM_FEEDBACK: number;
  143500. readonly INTERLEAVED_ATTRIBS: number;
  143501. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143502. createTransformFeedback(): WebGLTransformFeedback;
  143503. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143504. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143505. beginTransformFeedback(primitiveMode: number): void;
  143506. endTransformFeedback(): void;
  143507. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143508. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143509. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143510. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143511. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143512. }
  143513. interface ImageBitmap {
  143514. readonly width: number;
  143515. readonly height: number;
  143516. close(): void;
  143517. }
  143518. interface WebGLQuery extends WebGLObject {
  143519. }
  143520. declare var WebGLQuery: {
  143521. prototype: WebGLQuery;
  143522. new(): WebGLQuery;
  143523. };
  143524. interface WebGLSampler extends WebGLObject {
  143525. }
  143526. declare var WebGLSampler: {
  143527. prototype: WebGLSampler;
  143528. new(): WebGLSampler;
  143529. };
  143530. interface WebGLSync extends WebGLObject {
  143531. }
  143532. declare var WebGLSync: {
  143533. prototype: WebGLSync;
  143534. new(): WebGLSync;
  143535. };
  143536. interface WebGLTransformFeedback extends WebGLObject {
  143537. }
  143538. declare var WebGLTransformFeedback: {
  143539. prototype: WebGLTransformFeedback;
  143540. new(): WebGLTransformFeedback;
  143541. };
  143542. interface WebGLVertexArrayObject extends WebGLObject {
  143543. }
  143544. declare var WebGLVertexArrayObject: {
  143545. prototype: WebGLVertexArrayObject;
  143546. new(): WebGLVertexArrayObject;
  143547. };
  143548. // Type definitions for WebVR API
  143549. // Project: https://w3c.github.io/webvr/
  143550. // Definitions by: six a <https://github.com/lostfictions>
  143551. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143552. interface VRDisplay extends EventTarget {
  143553. /**
  143554. * Dictionary of capabilities describing the VRDisplay.
  143555. */
  143556. readonly capabilities: VRDisplayCapabilities;
  143557. /**
  143558. * z-depth defining the far plane of the eye view frustum
  143559. * enables mapping of values in the render target depth
  143560. * attachment to scene coordinates. Initially set to 10000.0.
  143561. */
  143562. depthFar: number;
  143563. /**
  143564. * z-depth defining the near plane of the eye view frustum
  143565. * enables mapping of values in the render target depth
  143566. * attachment to scene coordinates. Initially set to 0.01.
  143567. */
  143568. depthNear: number;
  143569. /**
  143570. * An identifier for this distinct VRDisplay. Used as an
  143571. * association point in the Gamepad API.
  143572. */
  143573. readonly displayId: number;
  143574. /**
  143575. * A display name, a user-readable name identifying it.
  143576. */
  143577. readonly displayName: string;
  143578. readonly isConnected: boolean;
  143579. readonly isPresenting: boolean;
  143580. /**
  143581. * If this VRDisplay supports room-scale experiences, the optional
  143582. * stage attribute contains details on the room-scale parameters.
  143583. */
  143584. readonly stageParameters: VRStageParameters | null;
  143585. /**
  143586. * Passing the value returned by `requestAnimationFrame` to
  143587. * `cancelAnimationFrame` will unregister the callback.
  143588. * @param handle Define the hanle of the request to cancel
  143589. */
  143590. cancelAnimationFrame(handle: number): void;
  143591. /**
  143592. * Stops presenting to the VRDisplay.
  143593. * @returns a promise to know when it stopped
  143594. */
  143595. exitPresent(): Promise<void>;
  143596. /**
  143597. * Return the current VREyeParameters for the given eye.
  143598. * @param whichEye Define the eye we want the parameter for
  143599. * @returns the eye parameters
  143600. */
  143601. getEyeParameters(whichEye: string): VREyeParameters;
  143602. /**
  143603. * Populates the passed VRFrameData with the information required to render
  143604. * the current frame.
  143605. * @param frameData Define the data structure to populate
  143606. * @returns true if ok otherwise false
  143607. */
  143608. getFrameData(frameData: VRFrameData): boolean;
  143609. /**
  143610. * Get the layers currently being presented.
  143611. * @returns the list of VR layers
  143612. */
  143613. getLayers(): VRLayer[];
  143614. /**
  143615. * Return a VRPose containing the future predicted pose of the VRDisplay
  143616. * when the current frame will be presented. The value returned will not
  143617. * change until JavaScript has returned control to the browser.
  143618. *
  143619. * The VRPose will contain the position, orientation, velocity,
  143620. * and acceleration of each of these properties.
  143621. * @returns the pose object
  143622. */
  143623. getPose(): VRPose;
  143624. /**
  143625. * Return the current instantaneous pose of the VRDisplay, with no
  143626. * prediction applied.
  143627. * @returns the current instantaneous pose
  143628. */
  143629. getImmediatePose(): VRPose;
  143630. /**
  143631. * The callback passed to `requestAnimationFrame` will be called
  143632. * any time a new frame should be rendered. When the VRDisplay is
  143633. * presenting the callback will be called at the native refresh
  143634. * rate of the HMD. When not presenting this function acts
  143635. * identically to how window.requestAnimationFrame acts. Content should
  143636. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143637. * asynchronously from other displays and at differing refresh rates.
  143638. * @param callback Define the eaction to run next frame
  143639. * @returns the request handle it
  143640. */
  143641. requestAnimationFrame(callback: FrameRequestCallback): number;
  143642. /**
  143643. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143644. * Repeat calls while already presenting will update the VRLayers being displayed.
  143645. * @param layers Define the list of layer to present
  143646. * @returns a promise to know when the request has been fulfilled
  143647. */
  143648. requestPresent(layers: VRLayer[]): Promise<void>;
  143649. /**
  143650. * Reset the pose for this display, treating its current position and
  143651. * orientation as the "origin/zero" values. VRPose.position,
  143652. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143653. * updated when calling resetPose(). This should be called in only
  143654. * sitting-space experiences.
  143655. */
  143656. resetPose(): void;
  143657. /**
  143658. * The VRLayer provided to the VRDisplay will be captured and presented
  143659. * in the HMD. Calling this function has the same effect on the source
  143660. * canvas as any other operation that uses its source image, and canvases
  143661. * created without preserveDrawingBuffer set to true will be cleared.
  143662. * @param pose Define the pose to submit
  143663. */
  143664. submitFrame(pose?: VRPose): void;
  143665. }
  143666. declare var VRDisplay: {
  143667. prototype: VRDisplay;
  143668. new(): VRDisplay;
  143669. };
  143670. interface VRLayer {
  143671. leftBounds?: number[] | Float32Array | null;
  143672. rightBounds?: number[] | Float32Array | null;
  143673. source?: HTMLCanvasElement | null;
  143674. }
  143675. interface VRDisplayCapabilities {
  143676. readonly canPresent: boolean;
  143677. readonly hasExternalDisplay: boolean;
  143678. readonly hasOrientation: boolean;
  143679. readonly hasPosition: boolean;
  143680. readonly maxLayers: number;
  143681. }
  143682. interface VREyeParameters {
  143683. /** @deprecated */
  143684. readonly fieldOfView: VRFieldOfView;
  143685. readonly offset: Float32Array;
  143686. readonly renderHeight: number;
  143687. readonly renderWidth: number;
  143688. }
  143689. interface VRFieldOfView {
  143690. readonly downDegrees: number;
  143691. readonly leftDegrees: number;
  143692. readonly rightDegrees: number;
  143693. readonly upDegrees: number;
  143694. }
  143695. interface VRFrameData {
  143696. readonly leftProjectionMatrix: Float32Array;
  143697. readonly leftViewMatrix: Float32Array;
  143698. readonly pose: VRPose;
  143699. readonly rightProjectionMatrix: Float32Array;
  143700. readonly rightViewMatrix: Float32Array;
  143701. readonly timestamp: number;
  143702. }
  143703. interface VRPose {
  143704. readonly angularAcceleration: Float32Array | null;
  143705. readonly angularVelocity: Float32Array | null;
  143706. readonly linearAcceleration: Float32Array | null;
  143707. readonly linearVelocity: Float32Array | null;
  143708. readonly orientation: Float32Array | null;
  143709. readonly position: Float32Array | null;
  143710. readonly timestamp: number;
  143711. }
  143712. interface VRStageParameters {
  143713. sittingToStandingTransform?: Float32Array;
  143714. sizeX?: number;
  143715. sizeY?: number;
  143716. }
  143717. interface Navigator {
  143718. getVRDisplays(): Promise<VRDisplay[]>;
  143719. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143720. }
  143721. interface Window {
  143722. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143723. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143724. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143725. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143726. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143727. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143728. }
  143729. interface Gamepad {
  143730. readonly displayId: number;
  143731. }
  143732. type XRSessionMode =
  143733. | "inline"
  143734. | "immersive-vr"
  143735. | "immersive-ar";
  143736. type XRReferenceSpaceType =
  143737. | "viewer"
  143738. | "local"
  143739. | "local-floor"
  143740. | "bounded-floor"
  143741. | "unbounded";
  143742. type XREnvironmentBlendMode =
  143743. | "opaque"
  143744. | "additive"
  143745. | "alpha-blend";
  143746. type XRVisibilityState =
  143747. | "visible"
  143748. | "visible-blurred"
  143749. | "hidden";
  143750. type XRHandedness =
  143751. | "none"
  143752. | "left"
  143753. | "right";
  143754. type XRTargetRayMode =
  143755. | "gaze"
  143756. | "tracked-pointer"
  143757. | "screen";
  143758. type XREye =
  143759. | "none"
  143760. | "left"
  143761. | "right";
  143762. interface XRSpace extends EventTarget {
  143763. }
  143764. interface XRRenderState {
  143765. depthNear?: number;
  143766. depthFar?: number;
  143767. inlineVerticalFieldOfView?: number;
  143768. baseLayer?: XRWebGLLayer;
  143769. }
  143770. interface XRInputSource {
  143771. handedness: XRHandedness;
  143772. targetRayMode: XRTargetRayMode;
  143773. targetRaySpace: XRSpace;
  143774. gripSpace: XRSpace | undefined;
  143775. gamepad: Gamepad | undefined;
  143776. profiles: Array<string>;
  143777. }
  143778. interface XRSessionInit {
  143779. optionalFeatures?: XRReferenceSpaceType[];
  143780. requiredFeatures?: XRReferenceSpaceType[];
  143781. }
  143782. interface XRSession extends XRAnchorCreator {
  143783. addEventListener: Function;
  143784. removeEventListener: Function;
  143785. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143786. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143787. requestAnimationFrame: Function;
  143788. end(): Promise<void>;
  143789. renderState: XRRenderState;
  143790. inputSources: Array<XRInputSource>;
  143791. // AR hit test
  143792. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143793. updateWorldTrackingState(options: {
  143794. planeDetectionState?: { enabled: boolean; }
  143795. }): void;
  143796. }
  143797. interface XRReferenceSpace extends XRSpace {
  143798. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143799. onreset: any;
  143800. }
  143801. type XRPlaneSet = Set<XRPlane>;
  143802. type XRAnchorSet = Set<XRAnchor>;
  143803. interface XRFrame {
  143804. session: XRSession;
  143805. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143806. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143807. // Anchors
  143808. trackedAnchors?: XRAnchorSet;
  143809. // Planes
  143810. worldInformation: {
  143811. detectedPlanes?: XRPlaneSet;
  143812. };
  143813. }
  143814. interface XRViewerPose extends XRPose {
  143815. views: Array<XRView>;
  143816. }
  143817. interface XRPose {
  143818. transform: XRRigidTransform;
  143819. emulatedPosition: boolean;
  143820. }
  143821. interface XRWebGLLayerOptions {
  143822. antialias?: boolean;
  143823. depth?: boolean;
  143824. stencil?: boolean;
  143825. alpha?: boolean;
  143826. multiview?: boolean;
  143827. framebufferScaleFactor?: number;
  143828. }
  143829. declare var XRWebGLLayer: {
  143830. prototype: XRWebGLLayer;
  143831. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143832. };
  143833. interface XRWebGLLayer {
  143834. framebuffer: WebGLFramebuffer;
  143835. framebufferWidth: number;
  143836. framebufferHeight: number;
  143837. getViewport: Function;
  143838. }
  143839. declare class XRRigidTransform {
  143840. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143841. position: DOMPointReadOnly;
  143842. orientation: DOMPointReadOnly;
  143843. matrix: Float32Array;
  143844. inverse: XRRigidTransform;
  143845. }
  143846. interface XRView {
  143847. eye: XREye;
  143848. projectionMatrix: Float32Array;
  143849. transform: XRRigidTransform;
  143850. }
  143851. interface XRInputSourceChangeEvent {
  143852. session: XRSession;
  143853. removed: Array<XRInputSource>;
  143854. added: Array<XRInputSource>;
  143855. }
  143856. interface XRInputSourceEvent extends Event {
  143857. readonly frame: XRFrame;
  143858. readonly inputSource: XRInputSource;
  143859. }
  143860. // Experimental(er) features
  143861. declare class XRRay {
  143862. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143863. origin: DOMPointReadOnly;
  143864. direction: DOMPointReadOnly;
  143865. matrix: Float32Array;
  143866. }
  143867. interface XRHitResult {
  143868. hitMatrix: Float32Array;
  143869. }
  143870. interface XRAnchor {
  143871. // remove?
  143872. id?: string;
  143873. anchorSpace: XRSpace;
  143874. lastChangedTime: number;
  143875. detach(): void;
  143876. }
  143877. interface XRPlane extends XRAnchorCreator {
  143878. orientation: "Horizontal" | "Vertical";
  143879. planeSpace: XRSpace;
  143880. polygon: Array<DOMPointReadOnly>;
  143881. lastChangedTime: number;
  143882. }
  143883. interface XRAnchorCreator {
  143884. // AR Anchors
  143885. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143886. }